Skip to content
Snippets Groups Projects
Commit d87a946c authored by Jan Schäfer's avatar Jan Schäfer
Browse files

added steger-warming flow and upwind for transport equation

parent dcf7c201
No related branches found
No related tags found
No related merge requests found
Showing
with 7510 additions and 0 deletions
#include <TNL/Functions/FunctionAdapter.h>
#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
#include <TNL/Functions/FunctionAdapter.h>
#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
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${debugExt} navierStokes.cu)
target_link_libraries (tnl-navier-stokes-sw${debugExt} tnl${debugExt}-${tnlVersion} ${CUSPARSE_LIBRARY} )
ELSE( BUILD_CUDA )
ADD_EXECUTABLE(tnl-navier-stokes-sw${debugExt} navierStokes.cpp)
target_link_libraries (tnl-navier-stokes-sw${debugExt} tnl${debugExt}-${tnlVersion} )
ENDIF( BUILD_CUDA )
INSTALL( TARGETS tnl-navier-stokes-sw${debugExt}
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 share/tnl-${tnlVersion}/examples/navier-stokes-sw )
/***************************************************************************
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 <TNL/Functions/MeshFunction.h>
#include <TNL/Functions/VectorField.h>
#include <TNL/SharedPointer.h>
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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/***************************************************************************
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 <TNL/Containers/Vector.h>
#include <TNL/Meshes/Grid.h>
#include <TNL/Functions/VectorField.h>
#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 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
/***************************************************************************
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 <TNL/Containers/Vector.h>
#include <TNL/Meshes/Grid.h>
#include <TNL/Functions/VectorField.h>
#include <TNL/SharedPointer.h>
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
/***************************************************************************
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 <TNL/Containers/Vector.h>
#include <TNL/Meshes/Grid.h>
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
/***************************************************************************
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
/***************************************************************************
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 <TNL/Containers/Vector.h>
#include <TNL/Meshes/Grid.h>
#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
/***************************************************************************
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 <TNL/Containers/Vector.h>
#include <TNL/Meshes/Grid.h>
#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
/***************************************************************************
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 <TNL/Containers/Vector.h>
#include <TNL/Meshes/Grid.h>
#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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment