Skip to content
Snippets Groups Projects
Commit 78246216 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Optimized smart pointers in MatrixSetter

parent 5ce9ef29
No related branches found
No related tags found
No related merge requests found
......@@ -21,24 +21,20 @@ class MatrixSetterTraversalUserData
public:
typedef typename CompressedRowsLengthsVector::DeviceType DeviceType;
typedef SharedPointer< DifferentialOperator, DeviceType > DifferentialOperatorPointer;
typedef SharedPointer< BoundaryConditions, DeviceType > BoundaryConditionsPointer;
typedef SharedPointer< CompressedRowsLengthsVector, DeviceType > CompressedRowsLengthsVectorPointer;
const DifferentialOperator* differentialOperator;
const DifferentialOperatorPointer differentialOperatorPointer;
const BoundaryConditions* boundaryConditions;
const BoundaryConditionsPointer boundaryConditionsPointer;
CompressedRowsLengthsVector* rowLengths;
CompressedRowsLengthsVectorPointer rowLengthsPointer;
MatrixSetterTraversalUserData( const DifferentialOperatorPointer& differentialOperatorPointer,
const BoundaryConditionsPointer& boundaryConditionsPointer,
CompressedRowsLengthsVectorPointer& rowLengthsPointer )
: differentialOperatorPointer( differentialOperatorPointer ),
boundaryConditionsPointer( boundaryConditionsPointer ),
rowLengthsPointer( rowLengthsPointer )
{};
MatrixSetterTraversalUserData( const DifferentialOperator* differentialOperator,
const BoundaryConditions* boundaryConditions,
CompressedRowsLengthsVector* rowLengths )
: differentialOperator( differentialOperator ),
boundaryConditions( boundaryConditions ),
rowLengths( rowLengths )
{}
};
......@@ -54,17 +50,17 @@ class MatrixSetter
typedef typename MeshType::DeviceType DeviceType;
typedef typename CompressedRowsLengthsVector::RealType IndexType;
typedef MatrixSetterTraversalUserData< DifferentialOperator,
BoundaryConditions,
CompressedRowsLengthsVector > TraversalUserData;
BoundaryConditions,
CompressedRowsLengthsVector > TraversalUserData;
typedef SharedPointer< DifferentialOperator, DeviceType > DifferentialOperatorPointer;
typedef SharedPointer< BoundaryConditions, DeviceType > BoundaryConditionsPointer;
typedef SharedPointer< CompressedRowsLengthsVector, DeviceType > CompressedRowsLengthsVectorPointer;
template< typename EntityType >
void getCompressedRowsLengths( const MeshPointer& meshPointer,
DifferentialOperatorPointer& differentialOperatorPointer,
BoundaryConditionsPointer& boundaryConditionsPointer,
CompressedRowsLengthsVectorPointer& rowLengthsPointer ) const;
const DifferentialOperatorPointer& differentialOperatorPointer,
const BoundaryConditionsPointer& boundaryConditionsPointer,
CompressedRowsLengthsVectorPointer& rowLengthsPointer ) const;
class TraversalBoundaryEntitiesProcessor
{
......@@ -76,8 +72,8 @@ class MatrixSetter
TraversalUserData& userData,
const EntityType& entity )
{
userData.rowLengthsPointer.template modifyData< DeviceType >()[ entity.getIndex() ] =
userData.boundaryConditionsPointer.template getData< DeviceType >().getLinearSystemRowLength( mesh, entity.getIndex(), entity );
( *userData.rowLengths )[ entity.getIndex() ] =
userData.boundaryConditions->getLinearSystemRowLength( mesh, entity.getIndex(), entity );
}
};
......@@ -92,8 +88,8 @@ class MatrixSetter
TraversalUserData& userData,
const EntityType& entity )
{
userData.rowLengthsPointer.template modifyData< DeviceType >()[ entity.getIndex() ] =
userData.differentialOperatorPointer.template getData< DeviceType >().getLinearSystemRowLength( mesh, entity.getIndex(), entity );
( *userData.rowLengths )[ entity.getIndex() ] =
userData.differentialOperator->getLinearSystemRowLength( mesh, entity.getIndex(), entity );
}
};
......
......@@ -23,12 +23,14 @@ template< typename Mesh,
void
MatrixSetter< Mesh, DifferentialOperator, BoundaryConditions, CompressedRowsLengthsVector >::
getCompressedRowsLengths( const MeshPointer& meshPointer,
DifferentialOperatorPointer& differentialOperatorPointer,
BoundaryConditionsPointer& boundaryConditionsPointer,
const DifferentialOperatorPointer& differentialOperatorPointer,
const BoundaryConditionsPointer& boundaryConditionsPointer,
CompressedRowsLengthsVectorPointer& rowLengthsPointer ) const
{
{
TraversalUserData userData( differentialOperatorPointer, boundaryConditionsPointer, rowLengthsPointer );
TraversalUserData userData( &differentialOperatorPointer.template getData< DeviceType >(),
&boundaryConditionsPointer.template getData< DeviceType >(),
&rowLengthsPointer.template modifyData< DeviceType >() );
Meshes::Traverser< MeshType, EntityType > meshTraversal;
meshTraversal.template processBoundaryEntities< TraversalUserData,
TraversalBoundaryEntitiesProcessor >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment