Loading examples/advection/tnlRiemann1DBoundaryConditions.h 0 → 100644 +139 −0 Original line number Diff line number Diff line /*** 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_ #include <operators/tnlOperator.h> #include <functions/tnlConstantFunction.h> #include <functions/tnlFunctionAdapter.h> template< typename Mesh, typename Function = tnlConstantFunction< Mesh::getMeshDimensions(), typename Mesh::RealType >, int MeshEntitiesDimensions = Mesh::getMeshDimensions(), typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class tnlRiemann1DBoundaryConditions : public tnlOperator< Mesh, MeshBoundaryDomain, MeshEntitiesDimensions, MeshEntitiesDimensions, Real, Index > { public: typedef Mesh MeshType; typedef Function FunctionType; typedef Real RealType; typedef typename MeshType::DeviceType DeviceType; typedef Index IndexType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef typename MeshType::VertexType VertexType; static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } static void configSetup( tnlConfigDescription& config, const tnlString& prefix = "" ) { Function::configSetup( config, prefix ); } bool setup( const tnlParameterContainer& parameters, const tnlString& prefix = "" ) { return this->function.setup( 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 ] = tnlFunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); } protected: Function function; //static_assert( Device::DeviceType == Function::Device::DeviceType ); }; template< typename Mesh, typename Function > ostream& operator << ( ostream& str, const tnlRiemann1DBoundaryConditions< Mesh, Function >& bc ) { str << "Riemann1D boundary conditions: vector = " << bc.getVector(); return str; } #endif /* TNLRiemann1DBOUNDARYCONDITIONS_H_ */ examples/advection/tnlRiemann2DBoundaryConditions.h 0 → 100644 +149 −0 Original line number Diff line number Diff line /*** 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_ #include <operators/tnlOperator.h> #include <functions/tnlConstantFunction.h> #include <functions/tnlFunctionAdapter.h> template< typename Mesh, typename Function = tnlConstantFunction< Mesh::getMeshDimensions(), typename Mesh::RealType >, int MeshEntitiesDimensions = Mesh::getMeshDimensions(), typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class tnlRiemann2DBoundaryConditions : public tnlOperator< Mesh, MeshBoundaryDomain, MeshEntitiesDimensions, MeshEntitiesDimensions, Real, Index > { public: typedef Mesh MeshType; typedef Function FunctionType; typedef Real RealType; typedef typename MeshType::DeviceType DeviceType; typedef Index IndexType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef typename MeshType::VertexType VertexType; static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } static void configSetup( tnlConfigDescription& config, const tnlString& prefix = "" ) { Function::configSetup( config, prefix ); } bool setup( const tnlParameterContainer& parameters, const tnlString& prefix = "" ) { return this->function.setup( parameters, prefix ); } void setFunction( const Function& function ) { this->function = function; } void setX0( const RealType& x0 ) { this->x0 = x0; } 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 = 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 ] = tnlFunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); } protected: Function function; RealType x0 = 0.3; //static_assert( Device::DeviceType == Function::Device::DeviceType ); }; template< typename Mesh, typename Function > ostream& operator << ( ostream& str, const tnlRiemann2DBoundaryConditions< Mesh, Function >& bc ) { str << "Riemann2D boundary conditions: vector = " << bc.getVector(); return str; } #endif /* TNLRiemann2DBOUNDARYCONDITIONS_H_ */ examples/inviscid-flow/2d/tnl-run-euler-2d 0 → 100644 +33 −0 Original line number Diff line number Diff line #!/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 Loading
examples/advection/tnlRiemann1DBoundaryConditions.h 0 → 100644 +139 −0 Original line number Diff line number Diff line /*** 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_ #include <operators/tnlOperator.h> #include <functions/tnlConstantFunction.h> #include <functions/tnlFunctionAdapter.h> template< typename Mesh, typename Function = tnlConstantFunction< Mesh::getMeshDimensions(), typename Mesh::RealType >, int MeshEntitiesDimensions = Mesh::getMeshDimensions(), typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class tnlRiemann1DBoundaryConditions : public tnlOperator< Mesh, MeshBoundaryDomain, MeshEntitiesDimensions, MeshEntitiesDimensions, Real, Index > { public: typedef Mesh MeshType; typedef Function FunctionType; typedef Real RealType; typedef typename MeshType::DeviceType DeviceType; typedef Index IndexType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef typename MeshType::VertexType VertexType; static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } static void configSetup( tnlConfigDescription& config, const tnlString& prefix = "" ) { Function::configSetup( config, prefix ); } bool setup( const tnlParameterContainer& parameters, const tnlString& prefix = "" ) { return this->function.setup( 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 ] = tnlFunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); } protected: Function function; //static_assert( Device::DeviceType == Function::Device::DeviceType ); }; template< typename Mesh, typename Function > ostream& operator << ( ostream& str, const tnlRiemann1DBoundaryConditions< Mesh, Function >& bc ) { str << "Riemann1D boundary conditions: vector = " << bc.getVector(); return str; } #endif /* TNLRiemann1DBOUNDARYCONDITIONS_H_ */
examples/advection/tnlRiemann2DBoundaryConditions.h 0 → 100644 +149 −0 Original line number Diff line number Diff line /*** 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_ #include <operators/tnlOperator.h> #include <functions/tnlConstantFunction.h> #include <functions/tnlFunctionAdapter.h> template< typename Mesh, typename Function = tnlConstantFunction< Mesh::getMeshDimensions(), typename Mesh::RealType >, int MeshEntitiesDimensions = Mesh::getMeshDimensions(), typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class tnlRiemann2DBoundaryConditions : public tnlOperator< Mesh, MeshBoundaryDomain, MeshEntitiesDimensions, MeshEntitiesDimensions, Real, Index > { public: typedef Mesh MeshType; typedef Function FunctionType; typedef Real RealType; typedef typename MeshType::DeviceType DeviceType; typedef Index IndexType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef typename MeshType::VertexType VertexType; static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } static void configSetup( tnlConfigDescription& config, const tnlString& prefix = "" ) { Function::configSetup( config, prefix ); } bool setup( const tnlParameterContainer& parameters, const tnlString& prefix = "" ) { return this->function.setup( parameters, prefix ); } void setFunction( const Function& function ) { this->function = function; } void setX0( const RealType& x0 ) { this->x0 = x0; } 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 = 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 ] = tnlFunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); } protected: Function function; RealType x0 = 0.3; //static_assert( Device::DeviceType == Function::Device::DeviceType ); }; template< typename Mesh, typename Function > ostream& operator << ( ostream& str, const tnlRiemann2DBoundaryConditions< Mesh, Function >& bc ) { str << "Riemann2D boundary conditions: vector = " << bc.getVector(); return str; } #endif /* TNLRiemann2DBOUNDARYCONDITIONS_H_ */
examples/inviscid-flow/2d/tnl-run-euler-2d 0 → 100644 +33 −0 Original line number Diff line number Diff line #!/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