Loading examples/transport-equation/tnl-run-transport-equation +3 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ tnl-init --test-function heaviside-of-vector-norm \ --center-0 0.5 \ --center-1 0.5 \ --center-2 0.5 \ --radius 0.1 --radius 0.2 \ --power 0.6 \ --max-norm false tnl-transport-equation --device host \ --initial-condition init.tnl \ Loading examples/transport-equation/tnl-run-transport-equation-eoc 0 → 100755 +32 −0 Original line number Diff line number Diff line #!/usr/bin/env bash tnl-grid-setup --dimensions 2 \ --origin-x 0.0 \ --origin-x 0.0 \ --proportions-x 1.0 \ --proportions-y 1.0 \ --size-x 100 \ --size-y 100 tnl-transport-equation-eoc --device host \ --initial-condition heaviside-vector-norm \ --heaviside-multiplicator 1.0 \ --vector-norm-multiplicator -1.0 \ --vector-norm-center-0 0.5 \ --vector-norm-center-1 0.5 \ --vector-norm-center-2 0.5 \ --vector-norm-radius 0.2 \ --vector-norm-power 0.6 \ --vector-norm-max-norm false \ --time-discretisation explicit \ --time-step 1.0e-5 \ --boundary-conditions-constant 0.0 \ --discrete-solver euler \ --snapshot-period 0.005 \ --final-time 0.1 \ --numerical-viscosity 1.0 \ --velocity-field-0-constant 1.0 \ --velocity-field-1-constant 1.0 \ --velocity-field-2-constant 1.0 tnl-view --mesh mesh.tnl --input-files *tnl examples/transport-equation/tnl-transport-equation-eoc.h +4 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include <TNL/Operators/Advection/LaxFridrichs.h> #include <TNL/Functions/Analytic/Constant.h> #include <TNL/Functions/Analytic/VectorNorm.h> #include <TNL/Operators/Analytic/Heaviside.h> #include <TNL/Functions/VectorField.h> #include <TNL/Meshes/Grid.h> #include "transportEquationProblemEoc.h" Loading Loading @@ -44,13 +45,10 @@ template< typename ConfigTag >class advectionConfig config.addDelimiter( "Transport equation settings:" ); config.addDelimiter( "Initial condition" ); config.addEntry< String >( "initial-condition", "Set type of initial condition.", "heaviside-vector-norm" ); config.addEntryEnum< String >( "heaviside-sphere" ); config.addEntryEnum< String >( "heaviside-vector-norm" ); Functions::Analytic::VectorNorm< 3, double >::configSetup( config, "vector-norm-" ); config.addEntry < double >( "x-center", "x-center for paraboloids.", 0.0 ); config.addEntry < double >( "y-center", "y-center for paraboloids.", 0.0 ); config.addEntry < double >( "z-center", "z-center for paraboloids.", 0.0 ); config.addEntry < double >( "coefficient", "Coefficient for paraboloids.", -1.0 ); config.addEntry < double >( "radius", "Radius for paraboloids.", 1.0 ); Operators::Analytic::Heaviside< 3, double >::configSetup( config, "heaviside-" ); Operators::Analytic::Shift< 3, double >::configSetup( config, "heaviside-" ); config.addDelimiter( "Velocity field" ); config.addEntry< String >( "velocity-field", "Type of velocity field.", "constant" ); Loading examples/transport-equation/transportEquationProblemEoc_impl.h +5 −4 Original line number Diff line number Diff line Loading @@ -71,18 +71,19 @@ setup( const MeshPointer& meshPointer, typedef typename MeshPointer::ObjectType MeshType; typedef Functions::MeshFunction< MeshType > MeshFunction; SharedPointer< MeshFunction > u( meshPointer ); if( initialCondition == "heaviside-sphere" ) if( initialCondition == "heaviside-vector-norm" ) { typedef Functions::Analytic::Paraboloid< Dimensions, RealType > ParaboloidType; typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; typedef Operators::Analytic::Heaviside< Dimensions, RealType > HeavisideType; typedef Functions::OperatorFunction< HeavisideType, ParaboloidType > InitialConditionType; typedef Functions::OperatorFunction< HeavisideType, VectorNormType > InitialConditionType; String velocityFieldType = parameters.getParameter< String >( "velocity-field" ); if( velocityFieldType == "constant" ) { typedef Operators::Analytic::Shift< Dimensions, RealType > ShiftOperatorType; typedef Functions::OperatorFunction< ShiftOperatorType, InitialConditionType > ExactSolutionType; SharedPointer< ExactSolutionType, Devices::Host > exactSolution; if( ! exactSolution->getFunction().setup( parameters, prefix ) ) if( ! exactSolution->getFunction().setup( parameters, prefix + "vector-norm-" ) || ! exactSolution->getOperator().setup( parameters, prefix + "heaviside-" ) ) return false; Containers::StaticVector< Dimensions, RealType > velocity; for( int i = 0; i < Dimensions; i++ ) Loading src/TNL/Functions/Analytic/VectorNorm.h +24 −24 Original line number Diff line number Diff line Loading @@ -37,16 +37,16 @@ class VectorNormBase : public Domain< Dimensions_, SpaceDomain > static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) { config.addEntry< double >( "center-0", "x-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( "center-1", "y-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( "center-2", "z-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( "anisotropy-0", "x-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( "anisotropy-1", "y-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( "anisotropy-2", "z-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( "power", "The p coefficient of the L-p vector norm", 2.0 ); config.addEntry< double >( "radius", "Radius of the zero-th level-set.", 0.0 ); config.addEntry< double >( "multiplicator", "Outer multiplicator of the norm - -1.0 turns the function graph upside/down.", 1.0 ); config.addEntry< bool >( "max-norm", "Turn to 'true' to get maximum norm.", false ); config.addEntry< double >( prefix + "center-0", "x-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( prefix + "center-1", "y-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( prefix + "center-2", "z-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( prefix + "anisotropy-0", "x-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( prefix + "anisotropy-1", "y-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( prefix + "anisotropy-2", "z-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( prefix + "power", "The p coefficient of the L-p vector norm", 2.0 ); config.addEntry< double >( prefix + "radius", "Radius of the zero-th level-set.", 0.0 ); config.addEntry< double >( prefix + "multiplicator", "Outer multiplicator of the norm - -1.0 turns the function graph upside/down.", 1.0 ); config.addEntry< bool >( prefix + "max-norm", "Turn to 'true' to get maximum norm.", false ); } bool setup( const Config::ParameterContainer& parameters, Loading Loading @@ -206,12 +206,12 @@ class VectorNorm< 2, Real > : public VectorNormBase< 2, Real > return ( ( TNL::abs( x ) * this->anisotropy.x() + TNL::abs( y ) * this->anisotropy.y() ) - this->radius ) * this->multiplicator; if( this->power == 2.0 ) return ( sqrt( x * x * this->anisotropy.x() + return ( std::sqrt( x * x * this->anisotropy.x() + y * y * this->anisotropy.y() ) - this->radius ) * this->multiplicator; return ( pow( pow( x, this->power ) * this->anisotropy.x() + pow( y, this->power ) * this->anisotropy.y(), 1.0 / this-> power ) - this->radius ) * this->multiplicator; return ( std::pow( std::pow( TNL::abs( x ), this->power ) * this->anisotropy.x() + std::pow( TNL::abs( y ), this->power ) * this->anisotropy.y(), 1.0 / this-> power ) - this->radius ) * this->multiplicator; } TNL_ASSERT( false, "Not implemented yet." ); TNL_ASSERT( false, std::cerr << "Not implemented yet." << std::endl ); return 0.0; } Loading Loading @@ -247,22 +247,22 @@ class VectorNorm< 3, Real > : public VectorNormBase< 3, Real > if( XDiffOrder == 0 && YDiffOrder == 0 && ZDiffOrder == 0 ) { if( this->maxNorm ) return ( TNL::max( TNL::abs( x ) * this->anisotropy.x(), TNL::abs( y ) * this->anisotropy.y(), return ( TNL::max( TNL::max( TNL::abs( x ) * this->anisotropy.x(), TNL::abs( y ) * this->anisotropy.y() ), TNL::abs( z ) * this->anisotropy.z() ) - this->radius ) * this->multiplicator; if( this->power == 1.0 ) return ( ( TNL::abs( x ) * this->anisotropy.x() + TNL::abs( y ) * this->anisotropy.y() + TNL::abs( z ) * this->anisotropy.z() ) - this->radius ) * this->multiplicator; if( this->power == 2.0 ) return ( sqrt( x * x * this->anisotropy.x() + return ( std::sqrt( x * x * this->anisotropy.x() + y * y * this->anisotropy.y() + z * z * this->anisotropy.z() ) - this->radius ) * this->multiplicator ; return ( pow( pow( x, this->power ) * this->anisotropy.x() + pow( y, this->power ) * this->anisotropy.y() + pow( z, this->power ) * this->anisotropy.z(), 1.0 / this-> power ) - this->radius ) * this->multiplicator; return ( std::pow( std::pow( TNL::abs( x ), this->power ) * this->anisotropy.x() + std::pow( TNL::abs( y ), this->power ) * this->anisotropy.y() + std::pow( TNL::abs( z ), this->power ) * this->anisotropy.z(), 1.0 / this-> power ) - this->radius ) * this->multiplicator; } TNL_ASSERT( false, "Not implemented yet." ); TNL_ASSERT( false, std::cerr << "Not implemented yet." << std::endl ); return 0.0; } Loading Loading
examples/transport-equation/tnl-run-transport-equation +3 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ tnl-init --test-function heaviside-of-vector-norm \ --center-0 0.5 \ --center-1 0.5 \ --center-2 0.5 \ --radius 0.1 --radius 0.2 \ --power 0.6 \ --max-norm false tnl-transport-equation --device host \ --initial-condition init.tnl \ Loading
examples/transport-equation/tnl-run-transport-equation-eoc 0 → 100755 +32 −0 Original line number Diff line number Diff line #!/usr/bin/env bash tnl-grid-setup --dimensions 2 \ --origin-x 0.0 \ --origin-x 0.0 \ --proportions-x 1.0 \ --proportions-y 1.0 \ --size-x 100 \ --size-y 100 tnl-transport-equation-eoc --device host \ --initial-condition heaviside-vector-norm \ --heaviside-multiplicator 1.0 \ --vector-norm-multiplicator -1.0 \ --vector-norm-center-0 0.5 \ --vector-norm-center-1 0.5 \ --vector-norm-center-2 0.5 \ --vector-norm-radius 0.2 \ --vector-norm-power 0.6 \ --vector-norm-max-norm false \ --time-discretisation explicit \ --time-step 1.0e-5 \ --boundary-conditions-constant 0.0 \ --discrete-solver euler \ --snapshot-period 0.005 \ --final-time 0.1 \ --numerical-viscosity 1.0 \ --velocity-field-0-constant 1.0 \ --velocity-field-1-constant 1.0 \ --velocity-field-2-constant 1.0 tnl-view --mesh mesh.tnl --input-files *tnl
examples/transport-equation/tnl-transport-equation-eoc.h +4 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include <TNL/Operators/Advection/LaxFridrichs.h> #include <TNL/Functions/Analytic/Constant.h> #include <TNL/Functions/Analytic/VectorNorm.h> #include <TNL/Operators/Analytic/Heaviside.h> #include <TNL/Functions/VectorField.h> #include <TNL/Meshes/Grid.h> #include "transportEquationProblemEoc.h" Loading Loading @@ -44,13 +45,10 @@ template< typename ConfigTag >class advectionConfig config.addDelimiter( "Transport equation settings:" ); config.addDelimiter( "Initial condition" ); config.addEntry< String >( "initial-condition", "Set type of initial condition.", "heaviside-vector-norm" ); config.addEntryEnum< String >( "heaviside-sphere" ); config.addEntryEnum< String >( "heaviside-vector-norm" ); Functions::Analytic::VectorNorm< 3, double >::configSetup( config, "vector-norm-" ); config.addEntry < double >( "x-center", "x-center for paraboloids.", 0.0 ); config.addEntry < double >( "y-center", "y-center for paraboloids.", 0.0 ); config.addEntry < double >( "z-center", "z-center for paraboloids.", 0.0 ); config.addEntry < double >( "coefficient", "Coefficient for paraboloids.", -1.0 ); config.addEntry < double >( "radius", "Radius for paraboloids.", 1.0 ); Operators::Analytic::Heaviside< 3, double >::configSetup( config, "heaviside-" ); Operators::Analytic::Shift< 3, double >::configSetup( config, "heaviside-" ); config.addDelimiter( "Velocity field" ); config.addEntry< String >( "velocity-field", "Type of velocity field.", "constant" ); Loading
examples/transport-equation/transportEquationProblemEoc_impl.h +5 −4 Original line number Diff line number Diff line Loading @@ -71,18 +71,19 @@ setup( const MeshPointer& meshPointer, typedef typename MeshPointer::ObjectType MeshType; typedef Functions::MeshFunction< MeshType > MeshFunction; SharedPointer< MeshFunction > u( meshPointer ); if( initialCondition == "heaviside-sphere" ) if( initialCondition == "heaviside-vector-norm" ) { typedef Functions::Analytic::Paraboloid< Dimensions, RealType > ParaboloidType; typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; typedef Operators::Analytic::Heaviside< Dimensions, RealType > HeavisideType; typedef Functions::OperatorFunction< HeavisideType, ParaboloidType > InitialConditionType; typedef Functions::OperatorFunction< HeavisideType, VectorNormType > InitialConditionType; String velocityFieldType = parameters.getParameter< String >( "velocity-field" ); if( velocityFieldType == "constant" ) { typedef Operators::Analytic::Shift< Dimensions, RealType > ShiftOperatorType; typedef Functions::OperatorFunction< ShiftOperatorType, InitialConditionType > ExactSolutionType; SharedPointer< ExactSolutionType, Devices::Host > exactSolution; if( ! exactSolution->getFunction().setup( parameters, prefix ) ) if( ! exactSolution->getFunction().setup( parameters, prefix + "vector-norm-" ) || ! exactSolution->getOperator().setup( parameters, prefix + "heaviside-" ) ) return false; Containers::StaticVector< Dimensions, RealType > velocity; for( int i = 0; i < Dimensions; i++ ) Loading
src/TNL/Functions/Analytic/VectorNorm.h +24 −24 Original line number Diff line number Diff line Loading @@ -37,16 +37,16 @@ class VectorNormBase : public Domain< Dimensions_, SpaceDomain > static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) { config.addEntry< double >( "center-0", "x-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( "center-1", "y-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( "center-2", "z-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( "anisotropy-0", "x-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( "anisotropy-1", "y-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( "anisotropy-2", "z-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( "power", "The p coefficient of the L-p vector norm", 2.0 ); config.addEntry< double >( "radius", "Radius of the zero-th level-set.", 0.0 ); config.addEntry< double >( "multiplicator", "Outer multiplicator of the norm - -1.0 turns the function graph upside/down.", 1.0 ); config.addEntry< bool >( "max-norm", "Turn to 'true' to get maximum norm.", false ); config.addEntry< double >( prefix + "center-0", "x-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( prefix + "center-1", "y-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( prefix + "center-2", "z-coordinate of the coordinates origin for the vector norm.", 0.0 ); config.addEntry< double >( prefix + "anisotropy-0", "x-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( prefix + "anisotropy-1", "y-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( prefix + "anisotropy-2", "z-coordinate of the linear anisotropy of the vector norm.", 1.0 ); config.addEntry< double >( prefix + "power", "The p coefficient of the L-p vector norm", 2.0 ); config.addEntry< double >( prefix + "radius", "Radius of the zero-th level-set.", 0.0 ); config.addEntry< double >( prefix + "multiplicator", "Outer multiplicator of the norm - -1.0 turns the function graph upside/down.", 1.0 ); config.addEntry< bool >( prefix + "max-norm", "Turn to 'true' to get maximum norm.", false ); } bool setup( const Config::ParameterContainer& parameters, Loading Loading @@ -206,12 +206,12 @@ class VectorNorm< 2, Real > : public VectorNormBase< 2, Real > return ( ( TNL::abs( x ) * this->anisotropy.x() + TNL::abs( y ) * this->anisotropy.y() ) - this->radius ) * this->multiplicator; if( this->power == 2.0 ) return ( sqrt( x * x * this->anisotropy.x() + return ( std::sqrt( x * x * this->anisotropy.x() + y * y * this->anisotropy.y() ) - this->radius ) * this->multiplicator; return ( pow( pow( x, this->power ) * this->anisotropy.x() + pow( y, this->power ) * this->anisotropy.y(), 1.0 / this-> power ) - this->radius ) * this->multiplicator; return ( std::pow( std::pow( TNL::abs( x ), this->power ) * this->anisotropy.x() + std::pow( TNL::abs( y ), this->power ) * this->anisotropy.y(), 1.0 / this-> power ) - this->radius ) * this->multiplicator; } TNL_ASSERT( false, "Not implemented yet." ); TNL_ASSERT( false, std::cerr << "Not implemented yet." << std::endl ); return 0.0; } Loading Loading @@ -247,22 +247,22 @@ class VectorNorm< 3, Real > : public VectorNormBase< 3, Real > if( XDiffOrder == 0 && YDiffOrder == 0 && ZDiffOrder == 0 ) { if( this->maxNorm ) return ( TNL::max( TNL::abs( x ) * this->anisotropy.x(), TNL::abs( y ) * this->anisotropy.y(), return ( TNL::max( TNL::max( TNL::abs( x ) * this->anisotropy.x(), TNL::abs( y ) * this->anisotropy.y() ), TNL::abs( z ) * this->anisotropy.z() ) - this->radius ) * this->multiplicator; if( this->power == 1.0 ) return ( ( TNL::abs( x ) * this->anisotropy.x() + TNL::abs( y ) * this->anisotropy.y() + TNL::abs( z ) * this->anisotropy.z() ) - this->radius ) * this->multiplicator; if( this->power == 2.0 ) return ( sqrt( x * x * this->anisotropy.x() + return ( std::sqrt( x * x * this->anisotropy.x() + y * y * this->anisotropy.y() + z * z * this->anisotropy.z() ) - this->radius ) * this->multiplicator ; return ( pow( pow( x, this->power ) * this->anisotropy.x() + pow( y, this->power ) * this->anisotropy.y() + pow( z, this->power ) * this->anisotropy.z(), 1.0 / this-> power ) - this->radius ) * this->multiplicator; return ( std::pow( std::pow( TNL::abs( x ), this->power ) * this->anisotropy.x() + std::pow( TNL::abs( y ), this->power ) * this->anisotropy.y() + std::pow( TNL::abs( z ), this->power ) * this->anisotropy.z(), 1.0 / this-> power ) - this->radius ) * this->multiplicator; } TNL_ASSERT( false, "Not implemented yet." ); TNL_ASSERT( false, std::cerr << "Not implemented yet." << std::endl ); return 0.0; } Loading