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

Fixing use of MatrixRow in matrxi assembler.

parent b3bf74e8
No related branches found
No related tags found
No related merge requests found
......@@ -76,7 +76,7 @@ template< typename MeshReal,
typename MeshIndex,
typename Real,
typename Index >
template< typename Vector, typename MatrixRow >
template< typename Vector, typename Matrix >
__cuda_callable__
void
tnlLinearDiffusion< tnlGrid< 1, MeshReal, Device, MeshIndex >, Real, Index >::
......@@ -87,8 +87,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
Vector& u,
Vector& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
const RealType lambdaX = tau * mesh.getHxSquareInverse();
//printf( "tau = %f lambda = %f dx_sqr = %f dx = %f, \n", tau, lambdaX, mesh.getHxSquareInverse(), mesh.getHx() );
matrixRow.setElement( 0, mesh.template getCellNextToCell< -1 >( index ), - lambdaX );
......@@ -156,7 +157,7 @@ template< typename MeshReal,
typename MeshIndex,
typename Real,
typename Index >
template< typename Vector, typename MatrixRow >
template< typename Vector, typename Matrix >
__cuda_callable__
void
tnlLinearDiffusion< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >::
......@@ -167,8 +168,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
Vector& u,
Vector& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
const RealType lambdaX = tau * mesh.getHxSquareInverse();
const RealType lambdaY = tau * mesh.getHySquareInverse();
matrixRow.setElement( 0, mesh.template getCellNextToCell< 0, -1 >( index ), -lambdaY );
......@@ -240,7 +242,7 @@ template< typename MeshReal,
typename MeshIndex,
typename Real,
typename Index >
template< typename Vector, typename MatrixRow >
template< typename Vector, typename Matrix >
__cuda_callable__
void
tnlLinearDiffusion< tnlGrid< 3, MeshReal, Device, MeshIndex >, Real, Index >::
......@@ -251,8 +253,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
Vector& u,
Vector& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
const RealType lambdaX = tau * mesh.getHxSquareInverse();
const RealType lambdaY = tau * mesh.getHySquareInverse();
const RealType lambdaZ = tau * mesh.getHzSquareInverse();
......
......@@ -135,7 +135,7 @@ template< int Dimensions,
typename Function,
typename Real,
typename Index >
template< typename MatrixRow >
template< typename Matrix >
__cuda_callable__
void
tnlAnalyticDirichletBoundaryConditions< tnlGrid< Dimensions, MeshReal, Device, MeshIndex >, Function, Real, Index >::
......@@ -145,8 +145,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
DofVectorType& u,
DofVectorType& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
matrixRow.setElement( 0, index, 1.0 );
b[ index ] = function.getValue( mesh.template getCellCenter< VertexType >( coordinates ), time );
}
......
......@@ -112,7 +112,7 @@ template< typename MeshReal,
typename Function,
typename Real,
typename Index >
template< typename MatrixRow >
template< typename Matrix >
__cuda_callable__
void
tnlAnalyticNeumannBoundaryConditions< tnlGrid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index >::
......@@ -122,8 +122,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
DofVectorType& u,
DofVectorType& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
const Real functionValue = this->function.getValue( mesh.template getCellCenter< VertexType >( coordinates ), time );
if( coordinates.x() == 0 )
{
......@@ -205,7 +206,7 @@ template< typename MeshReal,
typename Function,
typename Real,
typename Index >
template< typename MatrixRow >
template< typename Matrix >
__cuda_callable__
void
tnlAnalyticNeumannBoundaryConditions< tnlGrid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index >::
......@@ -215,8 +216,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
DofVectorType& u,
DofVectorType& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
const Real functionValue = this->function.getValue( mesh.template getCellCenter< VertexType >( coordinates ), time );
if( coordinates.x() == 0 )
{
......@@ -320,7 +322,7 @@ template< typename MeshReal,
typename Function,
typename Real,
typename Index >
template< typename MatrixRow >
template< typename Matrix >
__cuda_callable__
void
tnlAnalyticNeumannBoundaryConditions< tnlGrid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index >::
......@@ -330,8 +332,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
DofVectorType& u,
DofVectorType& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
const Real functionValue = this->function.getValue( mesh.template getCellCenter< VertexType >( coordinates ), time );
if( coordinates.x() == 0 )
{
......
......@@ -128,7 +128,7 @@ template< int Dimensions,
typename Vector,
typename Real,
typename Index >
template< typename MatrixRow >
template< typename Matrix >
__cuda_callable__
void
tnlDirichletBoundaryConditions< tnlGrid< Dimensions, MeshReal, Device, MeshIndex >, Vector, Real, Index >::
......@@ -138,8 +138,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
DofVectorType& u,
DofVectorType& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
matrixRow.setElement( 0, index, 1.0 );
b[ index ] = this->vector[ index ];
}
......
......@@ -89,7 +89,7 @@ template< typename MeshReal,
typename Vector,
typename Real,
typename Index >
template< typename MatrixRow >
template< typename Matrix >
__cuda_callable__
void
tnlNeumannBoundaryConditions< tnlGrid< 1, MeshReal, Device, MeshIndex >, Vector, Real, Index >::
......@@ -99,8 +99,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
DofVectorType& u,
DofVectorType& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
if( coordinates.x() == 0 )
{
matrixRow.setElement( 0, index, 1.0 );
......@@ -179,7 +180,7 @@ template< typename MeshReal,
typename Vector,
typename Real,
typename Index >
template< typename MatrixRow >
template< typename Matrix >
__cuda_callable__
void
tnlNeumannBoundaryConditions< tnlGrid< 2, MeshReal, Device, MeshIndex >, Vector, Real, Index >::
......@@ -189,8 +190,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
DofVectorType& u,
DofVectorType& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
if( coordinates.x() == 0 )
{
matrixRow.setElement( 0, index, 1.0 );
......@@ -291,7 +293,7 @@ template< typename MeshReal,
typename Vector,
typename Real,
typename Index >
template< typename MatrixRow >
template< typename Matrix >
__cuda_callable__
void
tnlNeumannBoundaryConditions< tnlGrid< 3, MeshReal, Device, MeshIndex >, Vector, Real, Index >::
......@@ -301,8 +303,9 @@ updateLinearSystem( const RealType& time,
const CoordinatesType& coordinates,
DofVectorType& u,
DofVectorType& b,
MatrixRow& matrixRow ) const
Matrix& matrix ) const
{
typename Matrix::MatrixRow matrixRow = matrix.getRow( index );
if( coordinates.x() == 0 )
{
matrixRow.setElement( 0, index, 1.0 );
......
......@@ -118,13 +118,12 @@ class tnlLinearSystemAssembler
TraverserUserData& userData,
const IndexType index )
{
typename MatrixType::MatrixRow matrixRow = userData.matrix->getRow( index );
userData.boundaryConditions->updateLinearSystem( *userData.time + *userData.tau,
mesh,
index,
*userData.u,
*userData.b,
matrixRow );
*userData.matrix );
}
};
......@@ -148,14 +147,13 @@ class tnlLinearSystemAssembler
index,
*userData.time );*/
typename MatrixType::MatrixRow matrixRow = userData.matrix->getRow( index );
userData.differentialOperator->updateLinearSystem( *userData.time,
*userData.tau,
mesh,
index,
*userData.u,
*userData.b,
matrixRow );
*userData.matrix );
//userData.matrix->addElement( index, index, 1.0, 1.0 );
const RealType& rhs = FunctionAdapter::getValue( mesh,
*userData.rightHandSide,
......@@ -239,15 +237,14 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
const CoordinatesType& coordinates )
{
//printf( "index = %d \n", index );
( *userData.b )[ index ] = 0.0;
typename MatrixType::MatrixRow matrixRow = userData.matrix->getRow( index );
( *userData.b )[ index ] = 0.0;
userData.boundaryConditions->updateLinearSystem( *userData.time + *userData.tau,
mesh,
index,
coordinates,
*userData.u,
*userData.b,
matrixRow );
*userData.matrix );
}
#ifdef HAVE_CUDA
......@@ -261,14 +258,13 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
//printf( "index = %d \n", index );
// printf("Matrix assembler: Index = %d \n", index );
( *userData.b )[ index ] = 0.0;
typename MatrixType::MatrixRow matrixRow = userData.matrix->getRow( index );
userData.boundaryConditions->updateLinearSystem( *userData.time,
mesh,
index,
coordinates,
*userData.u,
*userData.b,
matrixRow );
*userData.matrix );
//printf( "BC: index = %d, b = %f \n", index, ( *userData.b )[ index ] );
}
......@@ -301,7 +297,6 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
coordinates,
*userData.time );*/
typename MatrixType::MatrixRow matrixRow = userData.matrix->getRow( index );
userData.differentialOperator->updateLinearSystem( *userData.time,
*userData.tau,
mesh,
......@@ -309,7 +304,7 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
coordinates,
*userData.u,
*userData.b,
matrixRow );
*userData.matrix );
/*if( *userData.timeDiscretisationCoefficient != 0.0 )
userData.matrix->addElementFast( index,
index,
......@@ -348,7 +343,6 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
coordinates,
*userData.time );*/
typename MatrixType::MatrixRow matrixRow = userData.matrix->getRow( index );
userData.differentialOperator->updateLinearSystem( *userData.time,
*userData.tau,
mesh,
......@@ -356,7 +350,7 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
coordinates,
*userData.u,
*userData.b,
matrixRow );
*userData.matrix );
/*if( *userData.timeDiscretisationCoefficient != 0.0 )
userData.matrix->addElementFast( index,
index,
......
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