Skip to content
Snippets Groups Projects
Commit 3d213169 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Refactoring the invsicid flow solver.

parent 214e70d4
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ class CompressibleConservativeVariables ...@@ -38,7 +38,7 @@ class CompressibleConservativeVariables
: density( meshPointer ), : density( meshPointer ),
momentum( meshPointer ), momentum( meshPointer ),
//pressure( meshPointer ), //pressure( meshPointer ),
energy( meshPointer ) {}; energy( meshPointer ){};
void setMesh( const MeshPointer& meshPointer ) void setMesh( const MeshPointer& meshPointer )
{ {
...@@ -46,9 +46,6 @@ class CompressibleConservativeVariables ...@@ -46,9 +46,6 @@ class CompressibleConservativeVariables
this->momentum->setMesh( meshPointer ); this->momentum->setMesh( meshPointer );
//this->pressure.setMesh( meshPointer ); //this->pressure.setMesh( meshPointer );
this->energy->setMesh( meshPointer ); this->energy->setMesh( meshPointer );
this->dofs = this->density->getDofs() +
this->momentum->getDofs() +
this->energy->getDofs();
} }
template< typename Vector > template< typename Vector >
...@@ -58,18 +55,20 @@ class CompressibleConservativeVariables ...@@ -58,18 +55,20 @@ class CompressibleConservativeVariables
{ {
IndexType currentOffset( offset ); IndexType currentOffset( offset );
this->density->bind( meshPointer, data, currentOffset ); this->density->bind( meshPointer, data, currentOffset );
currentOffset += this->density->getDofs(); currentOffset += this->density->getDofs( meshPointer );
for( IndexType i = 0; i < Dimensions; i++ ) for( IndexType i = 0; i < Dimensions; i++ )
{ {
( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset );
currentOffset += ( *this->momentum )[ i ]->getDofs(); currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer );
} }
this->energy->bind( meshPointer, data, currentOffset ); this->energy->bind( meshPointer, data, currentOffset );
} }
void IndexType getDofs() const IndexType getDofs( const MeshPointer& meshPointer ) const
{ {
return this->dofs; return this->density->getDofs( meshPointer ) +
this->momentum->getDofs( meshPointer ) +
this->energy->getDofs( meshPointer );
} }
MeshFunctionPointer& getDensity() MeshFunctionPointer& getDensity()
...@@ -139,8 +138,6 @@ class CompressibleConservativeVariables ...@@ -139,8 +138,6 @@ class CompressibleConservativeVariables
protected: protected:
IndexType dofs;
MeshFunctionPointer density; MeshFunctionPointer density;
MomentumFieldPointer momentum; MomentumFieldPointer momentum;
//MeshFunctionPointer pressure; //MeshFunctionPointer pressure;
......
...@@ -27,18 +27,21 @@ class PhysicalVariablesGetter ...@@ -27,18 +27,21 @@ class PhysicalVariablesGetter
typedef typename MeshType::RealType RealType; typedef typename MeshType::RealType RealType;
typedef typename MeshType::DeviceType DeviceType; typedef typename MeshType::DeviceType DeviceType;
typedef typename MeshType::IndexType IndexType; typedef typename MeshType::IndexType IndexType;
static const int Dimensions = MeshType::getMeshDimensions();
typedef Functions::MeshFunction< MeshType > MeshFunctionType; typedef Functions::MeshFunction< MeshType > MeshFunctionType;
typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef SharedPointer< MeshFunctionType > MeshFunctionPointer;
typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType;
typedef SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; typedef SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer;
typedef Functions::VectorField< MeshType > VelocityFieldType; typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType;
typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; typedef SharedPointer< VelocityFieldType > VelocityFieldPointer;
static const int Dimensions = MeshType::getMeshDimensions();
class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain >
{ {
public: public:
typedef typename MeshType::RealType RealType;
VelocityGetter( MeshFunctionPointer density, VelocityGetter( MeshFunctionPointer density,
MeshFunctionPointer momentum ) MeshFunctionPointer momentum )
...@@ -46,26 +49,26 @@ class PhysicalVariablesGetter ...@@ -46,26 +49,26 @@ class PhysicalVariablesGetter
template< typename EntityType > template< typename EntityType >
__cuda_callable__ __cuda_callable__
const RealType& operator()( const EntityType& meshEntity, RealType operator()( const EntityType& meshEntity,
const RealType& time = 0.0 ) const const RealType& time = 0.0 ) const
{ {
return momentum.template getData< DeviceType >( meshEntity ) / return momentum.template getData< DeviceType >()( meshEntity ) /
density.template getData< DeviceType >( meshEntity ); density.template getData< DeviceType >()( meshEntity );
} }
protected: protected:
const MeshFunctionPointer density, momentum; const MeshFunctionPointer density, momentum;
}; };
void getVelocity( const ConservativeVariablesType& conservativeVariables, void getVelocity( const ConservativeVariablesPointer& conservativeVariables,
VelocityFieldPointer& velocity ) VelocityFieldPointer& velocity )
{ {
Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator;
for( int i = 0; i < Dimensions; i++ ) for( int i = 0; i < Dimensions; i++ )
{ {
SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables.getDensity(), SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(),
conservativeVariables.getMomentum()[ i ] ); ( *conservativeVariables->getMomentum() )[ i ] );
evaluator.evaluate( velocity[ i ], velocityGetter ); evaluator.evaluate( ( *velocity )[ i ], velocityGetter );
} }
} }
......
...@@ -130,9 +130,10 @@ class eulerProblem: ...@@ -130,9 +130,10 @@ class eulerProblem:
VelocityFieldPointer velocity; VelocityFieldPointer velocity;
MeshFunctionPointer pressure, energy; MeshFunctionPointer pressure, energy;
RealType gamma;
//definition //definition
Containers::Vector< RealType, DeviceType, IndexType > _uRho; /*Containers::Vector< RealType, DeviceType, IndexType > _uRho;
Containers::Vector< RealType, DeviceType, IndexType > _uRhoVelocityX; Containers::Vector< RealType, DeviceType, IndexType > _uRhoVelocityX;
Containers::Vector< RealType, DeviceType, IndexType > _uRhoVelocityY; Containers::Vector< RealType, DeviceType, IndexType > _uRhoVelocityY;
Containers::Vector< RealType, DeviceType, IndexType > _uEnergy; Containers::Vector< RealType, DeviceType, IndexType > _uEnergy;
...@@ -150,8 +151,8 @@ class eulerProblem: ...@@ -150,8 +151,8 @@ class eulerProblem:
Containers::Vector< RealType, DeviceType, IndexType > pressure; Containers::Vector< RealType, DeviceType, IndexType > pressure;
Containers::Vector< RealType, DeviceType, IndexType > velocity; Containers::Vector< RealType, DeviceType, IndexType > velocity;
Containers::Vector< RealType, DeviceType, IndexType > velocityX; Containers::Vector< RealType, DeviceType, IndexType > velocityX;
Containers::Vector< RealType, DeviceType, IndexType > velocityY; Containers::Vector< RealType, DeviceType, IndexType > velocityY;*/
double gamma;
}; };
} // namespace TNL } // namespace TNL
......
...@@ -100,7 +100,7 @@ getDofs( const MeshPointer& mesh ) const ...@@ -100,7 +100,7 @@ getDofs( const MeshPointer& mesh ) const
* Return number of DOFs (degrees of freedom) i.e. number * Return number of DOFs (degrees of freedom) i.e. number
* of unknowns to be resolved by the main solver. * of unknowns to be resolved by the main solver.
*/ */
return this->conservativeVariables->getDofs(); return this->conservativeVariables->getDofs( mesh );
} }
template< typename Mesh, template< typename Mesh,
...@@ -112,7 +112,7 @@ eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: ...@@ -112,7 +112,7 @@ eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
bindDofs( const MeshPointer& mesh, bindDofs( const MeshPointer& mesh,
DofVectorPointer& dofVector ) DofVectorPointer& dofVector )
{ {
this->conservativeVariables.bind( mesh, dofVector ); this->conservativeVariables->bind( mesh, dofVector );
} }
template< typename Mesh, template< typename Mesh,
...@@ -182,8 +182,8 @@ makeSnapshot( const RealType& time, ...@@ -182,8 +182,8 @@ makeSnapshot( const RealType& time,
this->bindDofs( mesh, dofs ); this->bindDofs( mesh, dofs );
PhysicalVariablesGetter< MeshType > physicalVariablesGetter; PhysicalVariablesGetter< MeshType > physicalVariablesGetter;
physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity );
physicalVariablesGetter.getPressure( this->conservativeVariables, this->pressure ); //physicalVariablesGetter.getPressure( this->conservativeVariables, this->pressure );
physicalVariablesGetter.getEnergy( this->conservativeVariables, this->energy ); //physicalVariablesGetter.getEnergy( this->conservativeVariables, this->energy );
FileName fileName; FileName fileName;
fileName.setExtension( "tnl" ); fileName.setExtension( "tnl" );
...@@ -220,7 +220,7 @@ getExplicitRHS( const RealType& time, ...@@ -220,7 +220,7 @@ getExplicitRHS( const RealType& time,
DofVectorPointer& _fu, DofVectorPointer& _fu,
MeshDependentDataPointer& meshDependentData ) MeshDependentDataPointer& meshDependentData )
{ {
typedef typename MeshType::Cell Cell; /*typedef typename MeshType::Cell Cell;
int count = mesh->template getEntitiesCount< Cell >()/4; int count = mesh->template getEntitiesCount< Cell >()/4;
//bind _u //bind _u
this->_uRho.bind( *_u,0,count); this->_uRho.bind( *_u,0,count);
...@@ -307,6 +307,7 @@ getExplicitRHS( const RealType& time, ...@@ -307,6 +307,7 @@ getExplicitRHS( const RealType& time,
this->rightHandSidePointer, this->rightHandSidePointer,
uEnergy, uEnergy,
fuEnergy ); fuEnergy );
*/
/* /*
BoundaryConditionsSetter< MeshFunctionType, BoundaryCondition > boundaryConditionsSetter; BoundaryConditionsSetter< MeshFunctionType, BoundaryCondition > boundaryConditionsSetter;
...@@ -364,6 +365,7 @@ postIterate( const RealType& time, ...@@ -364,6 +365,7 @@ postIterate( const RealType& time,
DofVectorPointer& dofs, DofVectorPointer& dofs,
MeshDependentDataPointer& meshDependentData ) MeshDependentDataPointer& meshDependentData )
{ {
/*
typedef typename MeshType::Cell Cell; typedef typename MeshType::Cell Cell;
int count = mesh->template getEntitiesCount< Cell >()/4; int count = mesh->template getEntitiesCount< Cell >()/4;
//bind _u //bind _u
...@@ -411,6 +413,7 @@ postIterate( const RealType& time, ...@@ -411,6 +413,7 @@ postIterate( const RealType& time,
euler2DPressure.setRho(uRho); euler2DPressure.setRho(uRho);
// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; // OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure;
// pressure = OFPressure; // pressure = OFPressure;
*/
return true; return true;
} }
......
...@@ -92,7 +92,7 @@ class MeshFunction : ...@@ -92,7 +92,7 @@ class MeshFunction :
const MeshPointer& getMeshPointer() const; const MeshPointer& getMeshPointer() const;
__cuda_callable__ IndexType getDofs() const; __cuda_callable__ IndexType getDofs( const MeshPointer& meshPointer ) const;
__cuda_callable__ const VectorType& getData() const; __cuda_callable__ const VectorType& getData() const;
......
...@@ -257,7 +257,7 @@ template< typename Mesh, ...@@ -257,7 +257,7 @@ template< typename Mesh,
__cuda_callable__ __cuda_callable__
typename MeshFunction< Mesh, MeshEntityDimensions, Real >::IndexType typename MeshFunction< Mesh, MeshEntityDimensions, Real >::IndexType
MeshFunction< Mesh, MeshEntityDimensions, Real >:: MeshFunction< Mesh, MeshEntityDimensions, Real >::
getDofs() const getDofs( const MeshPointer& meshPointer ) const
{ {
return meshPointer->template getEntitiesCount< MeshEntityDimensions >(); return meshPointer->template getEntitiesCount< MeshEntityDimensions >();
} }
......
...@@ -74,6 +74,9 @@ template< int Size, ...@@ -74,6 +74,9 @@ template< int Size,
int MeshEntityDimensions, int MeshEntityDimensions,
typename Real > typename Real >
class VectorField< Size, MeshFunction< Mesh, MeshEntityDimensions, Real > > class VectorField< Size, MeshFunction< Mesh, MeshEntityDimensions, Real > >
: public Functions::Domain< MeshFunction< Mesh, MeshEntityDimensions, Real >::getDomainDimensions(),
MeshFunction< Mesh, MeshEntityDimensions, Real >::getDomainType() >,
public Object
{ {
public: public:
...@@ -99,6 +102,33 @@ class VectorField< Size, MeshFunction< Mesh, MeshEntityDimensions, Real > > ...@@ -99,6 +102,33 @@ class VectorField< Size, MeshFunction< Mesh, MeshEntityDimensions, Real > >
this->vectorField[ i ]->setMesh( meshPointer ); this->vectorField[ i ]->setMesh( meshPointer );
}; };
static String getType()
{
return String( "Functions::VectorField< " ) +
String( Size) + ", " +
FunctionType::getType() +
" >";
}
String getTypeVirtual() const
{
return this->getType();
}
static String getSerializationType()
{
return String( "Functions::VectorField< " ) +
String( Size) + ", " +
FunctionType::getSerializationType() +
" >";
}
virtual String getSerializationTypeVirtual() const
{
return this->getSerializationType();
}
void setMesh( const MeshPointer& meshPointer ) void setMesh( const MeshPointer& meshPointer )
{ {
for( int i = 0; i < Size; i++ ) for( int i = 0; i < Size; i++ )
...@@ -118,9 +148,9 @@ class VectorField< Size, MeshFunction< Mesh, MeshEntityDimensions, Real > > ...@@ -118,9 +148,9 @@ class VectorField< Size, MeshFunction< Mesh, MeshEntityDimensions, Real > >
return true; return true;
} }
IndexType getDofs() const IndexType getDofs( const MeshPointer& meshPointer ) const
{ {
return Size * this->vectorField[ 0 ]->getDofs(); return Size * this->vectorField[ 0 ]->getDofs( meshPointer );
} }
__cuda_callable__ __cuda_callable__
...@@ -134,6 +164,42 @@ class VectorField< Size, MeshFunction< Mesh, MeshEntityDimensions, Real > > ...@@ -134,6 +164,42 @@ class VectorField< Size, MeshFunction< Mesh, MeshEntityDimensions, Real > >
{ {
return this->vectorField[ i ]; return this->vectorField[ i ];
} }
bool save( File& file ) const
{
if( ! Object::save( file ) )
return false;
for( int i = 0; i < Size; i++ )
if( ! vectorField[ i ]->save( file ) )
return false;
return true;
}
bool load( File& file )
{
if( ! Object::load( file ) )
return false;
for( int i = 0; i < Size; i++ )
if( ! vectorField[ i ]->load( file ) )
return false;
return true;
}
bool boundLoad( File& file )
{
if( ! Object::load( file ) )
return false;
for( int i = 0; i < Size; i++ )
if( ! vectorField[ i ]->boundLoad( file ) )
return false;
return true;
}
using Object::save;
using Object::load;
using Object::boundLoad;
protected: protected:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment