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

Adding timeDiscretisationCoefficient for stationary problems to the

matrix assembler.
parent 5ed29452
No related branches found
No related tags found
No related merge requests found
......@@ -46,8 +46,11 @@ class tnlLinearSystemAssemblerTraversalUserData
Matrix *matrix;
const Real* timeDiscretisationCoefficient;
tnlLinearSystemAssemblerTraversalUserData( const Real& time,
const Real& tau,
const Real& timeDiscretisationCoefficient,
const DifferentialOperator& differentialOperator,
const BoundaryConditions& boundaryConditions,
const RightHandSide& rightHandSide,
......@@ -56,6 +59,7 @@ class tnlLinearSystemAssemblerTraversalUserData
DofVector& b )
: time( &time ),
tau( &tau ),
timeDiscretisationCoefficient( &timeDiscretisationCoefficient ),
differentialOperator( &differentialOperator ),
boundaryConditions( &boundaryConditions ),
rightHandSide( &rightHandSide ),
......@@ -120,10 +124,6 @@ class tnlLinearSystemAssembler
*userData.u,
*userData.b,
matrixRow );
/*userData.matrix->setRowFast( index,
userData.columns->getData(),
userData.values->getData(),
rowLength );*/
}
};
......@@ -155,13 +155,8 @@ class tnlLinearSystemAssembler
*userData.u,
*userData.b,
matrixRow );
/*userData.matrix->setRowFast( index,
userData.columns->getData(),
userData.values->getData(),
rowLength );*/
userData.matrix->addElement( index, index, 1.0, 1.0 );
}
};
};
......@@ -195,6 +190,9 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
RightHandSide,
MatrixType > TraversalUserData;
tnlLinearSystemAssembler()
: timeDiscretisationCoefficient( 1.0 ){}
template< int EntityDimensions >
void assembly( const RealType& time,
const RealType& tau,
......@@ -206,6 +204,14 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
MatrixType& matrix,
DofVector& b ) const;
/****
* TODO: Fix this. Somehow.
*/
void setTimeDiscretisationCoefficient( const Real& c )
{
this->timeDiscretisationCoefficient = c;
}
class TraversalBoundaryEntitiesProcessor
{
public:
......@@ -281,7 +287,11 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
*userData.u,
*userData.b,
matrixRow );
userData.matrix->addElementFast( index, index, 1.0, 1.0 );
if( *userData.timeDiscretisationCoefficient != 0.0 )
userData.matrix->addElementFast( index,
index,
*userData.timeDiscretisationCoefficient,
1.0 );
}
#ifdef HAVE_CUDA
......@@ -310,9 +320,18 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
*userData.u,
*userData.b,
matrixRow );
userData.matrix->addElementFast( index, index, 1.0, 1.0 );
if( *userData.timeDiscretisationCoefficient != 0.0 )
userData.matrix->addElementFast( index,
index,
*userData.timeDiscretisationCoefficient,
1.0 );
}
};
protected:
Real timeDiscretisationCoefficient;
};
#include <solvers/pde/tnlLinearSystemAssembler_impl.h>
......
......@@ -123,7 +123,15 @@ assembly( const RealType& time,
if( ( tnlDeviceEnum ) DeviceType::DeviceType == tnlHostDevice )
{
TraversalUserData userData( time, tau, differentialOperator, boundaryConditions, rightHandSide, u, matrix, b );
TraversalUserData userData( time,
tau,
this->timeDiscretisationCoefficient,
differentialOperator,
boundaryConditions,
rightHandSide,
u,
matrix,
b );
tnlTraverser< MeshType, EntityDimensions > meshTraversal;
meshTraversal.template processBoundaryEntities< TraversalUserData,
TraversalBoundaryEntitiesProcessor >
......@@ -138,13 +146,23 @@ assembly( const RealType& time,
{
RealType* kernelTime = tnlCuda::passToDevice( time );
RealType* kernelTau = tnlCuda::passToDevice( tau );
RealType timeDiscretisationCoefficient = this->timeDiscretisationCoefficient; // retyping between different floating point types, TODO check it
RealType* kernelTimeDiscretisationCoefficient = tnlCuda::passToDevice( timeDiscretisationCoefficient );
DifferentialOperator* kernelDifferentialOperator = tnlCuda::passToDevice( differentialOperator );
BoundaryConditions* kernelBoundaryConditions = tnlCuda::passToDevice( boundaryConditions );
RightHandSide* kernelRightHandSide = tnlCuda::passToDevice( rightHandSide );
DofVector* kernelU = tnlCuda::passToDevice( u );
DofVector* kernelB = tnlCuda::passToDevice( b );
MatrixType* kernelMatrix = tnlCuda::passToDevice( matrix );
TraversalUserData userData( *kernelTime, *kernelTau, *kernelDifferentialOperator, *kernelBoundaryConditions, *kernelRightHandSide, *kernelU, *kernelMatrix, *kernelB );
TraversalUserData userData( *kernelTime,
*kernelTau,
*kernelTimeDiscretisationCoefficient,
*kernelDifferentialOperator,
*kernelBoundaryConditions,
*kernelRightHandSide,
*kernelU,
*kernelMatrix,
*kernelB );
checkCudaDevice;
tnlTraverser< MeshType, EntityDimensions > meshTraversal;
meshTraversal.template processBoundaryEntities< TraversalUserData,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment