Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
......@@ -8,33 +8,35 @@
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
class {problemBaseName}Problem:
public TNL::Problems::PDEProblem< Mesh,
typename DifferentialOperator::RealType,
typename Mesh::DeviceType,
typename DifferentialOperator::IndexType >
Communicator,
typename DifferentialOperator::RealType,
typename Mesh::DeviceType,
typename Mesh::IndexType >
{{
public:
typedef typename DifferentialOperator::RealType RealType;
typedef typename Mesh::DeviceType DeviceType;
typedef typename DifferentialOperator::IndexType IndexType;
typedef TNL::Functions::MeshFunction< Mesh > MeshFunctionType;
typedef TNL::Problems::PDEProblem< Mesh, RealType, DeviceType, IndexType > BaseType;
typedef TNL::SharedPointer< DifferentialOperator > DifferentialOperatorPointer;
typedef TNL::SharedPointer< BoundaryCondition > BoundaryConditionPointer;
typedef TNL::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer;
typedef typename Mesh::IndexType IndexType;
typedef TNL::Functions::MeshFunction< Mesh, Mesh::getMeshDimension(), RealType > MeshFunctionType;
typedef TNL::Problems::PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType;
typedef TNL::Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer;
typedef TNL::Pointers::SharedPointer< DifferentialOperator > DifferentialOperatorPointer;
typedef TNL::Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer;
typedef TNL::Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer;
using typename BaseType::MeshType;
using typename BaseType::MeshPointer;
using typename BaseType::DofVectorType;
using typename BaseType::DofVectorPointer;
using typename BaseType::MeshDependentDataType;
using typename BaseType::MeshDependentDataPointer;
using CommunicatorType = Communicator;
static TNL::String getTypeStatic();
......@@ -43,51 +45,42 @@ class {problemBaseName}Problem:
void writeProlog( TNL::Logger& logger,
const TNL::Config::ParameterContainer& parameters ) const;
bool setup( const MeshPointer& meshPointer,
const TNL::Config::ParameterContainer& parameters,
bool setup( const TNL::Config::ParameterContainer& parameters,
const TNL::String& prefix );
bool setInitialCondition( const TNL::Config::ParameterContainer& parameters,
const MeshPointer& mesh,
DofVectorPointer& dofs,
MeshDependentDataPointer& meshDependentData );
DofVectorPointer& dofs );
template< typename MatrixPointer >
bool setupLinearSystem( const MeshPointer& mesh,
MatrixPointer& matrixPointer );
bool setupLinearSystem( MatrixPointer& matrixPointer );
bool makeSnapshot( const RealType& time,
const IndexType& step,
const MeshPointer& mesh,
DofVectorPointer& dofs,
MeshDependentDataPointer& meshDependentData );
DofVectorPointer& dofs );
IndexType getDofs( const MeshPointer& mesh ) const;
IndexType getDofs() const;
void bindDofs( const MeshPointer& mesh,
DofVectorPointer& dofs );
void bindDofs( DofVectorPointer& dofs );
void getExplicitUpdate( const RealType& time,
const RealType& tau,
const MeshPointer& mesh,
DofVectorPointer& _u,
DofVectorPointer& _fu,
MeshDependentDataPointer& meshDependentData );
DofVectorPointer& _fu );
template< typename MatrixPointer >
void assemblyLinearSystem( const RealType& time,
const RealType& tau,
const MeshPointer& mesh,
DofVectorPointer& dofs,
MatrixPointer& matrixPointer,
DofVectorPointer& rightHandSide,
MeshDependentDataPointer& meshDependentData );
DofVectorPointer& rightHandSide );
protected:
DifferentialOperatorPointer differentialOperator;
BoundaryConditionPointer boundaryCondition;
RightHandSidePointer rightHandSide;
TNL::Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, DifferentialOperator, BoundaryCondition, RightHandSide > explicitUpdater;
......
......@@ -8,33 +8,36 @@
#include <TNL/Solvers/PDE/BackwardTimeDiscretisation.h>
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
TNL::String
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
getTypeStatic()
{{
return TNL::String( "{problemBaseName}Problem< " ) + Mesh :: getTypeStatic() + " >";
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
TNL::String
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
getPrologHeader() const
{{
return TNL::String( "{problemName}" );
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
void
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
writeProlog( TNL::Logger& logger, const TNL::Config::ParameterContainer& parameters ) const
{{
/****
......@@ -44,60 +47,60 @@ writeProlog( TNL::Logger& logger, const TNL::Config::ParameterContainer& paramet
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
bool
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
setup( const MeshPointer& meshPointer,
const TNL::Config::ParameterContainer& parameters,
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
setup( const TNL::Config::ParameterContainer& parameters,
const TNL::String& prefix )
{{
if( ! this->boundaryCondition->setup( meshPointer, parameters, "boundary-conditions-" ) ||
if( ! this->boundaryCondition->setup( this->getMesh(), parameters, "boundary-conditions-" ) ||
! this->rightHandSide->setup( parameters, "right-hand-side-" ) )
return false;
return true;
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
typename {problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::IndexType
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
getDofs( const MeshPointer& mesh ) const
typename {problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::IndexType
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
getDofs() const
{{
/****
* Return number of DOFs (degrees of freedom) i.e. number
* of unknowns to be resolved by the main solver.
*/
return mesh->template getEntitiesCount< typename MeshType::Cell >();
return this->getMesh()->template getEntitiesCount< typename MeshType::Cell >();
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
void
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
bindDofs( const MeshPointer& mesh,
DofVectorPointer& dofVector )
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
bindDofs( DofVectorPointer& dofVector )
{{
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
bool
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
setInitialCondition( const TNL::Config::ParameterContainer& parameters,
const MeshPointer& mesh,
DofVectorPointer& dofs,
MeshDependentDataPointer& meshDependentData )
DofVectorPointer& dofs )
{{
const TNL::String& initialConditionFile = parameters.getParameter< TNL::String >( "initial-condition" );
TNL::Functions::MeshFunction< Mesh > u( mesh, dofs );
MeshFunctionType u( this->getMesh(), dofs );
if( ! u.boundLoad( initialConditionFile ) )
{{
std::cerr << "I am not able to load the initial condition from the file " << initialConditionFile << "." << std::endl;
......@@ -107,45 +110,42 @@ setInitialCondition( const TNL::Config::ParameterContainer& parameters,
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
template< typename MatrixPointer >
bool
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
setupLinearSystem( const MeshPointer& meshPointer,
MatrixPointer& matrixPointer )
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
setupLinearSystem( MatrixPointer& matrixPointer )
{{
const IndexType dofs = this->getDofs( meshPointer );
const IndexType dofs = this->getDofs();
typedef typename MatrixPointer::ObjectType::CompressedRowLengthsVector CompressedRowLengthsVectorType;
TNL::SharedPointer< CompressedRowLengthsVectorType > rowLengthsPointer;
if( ! rowLengthsPointer->setSize( dofs ) )
return false;
TNL::Pointers::SharedPointer< CompressedRowLengthsVectorType > rowLengthsPointer;
rowLengthsPointer->setSize( dofs );
TNL::Matrices::MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter;
matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( meshPointer,
matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( this->getMesh(),
differentialOperator,
boundaryCondition,
rowLengthsPointer );
matrixPointer->setDimensions( dofs, dofs );
if( ! matrixPointer->setCompressedRowLengths( *rowLengthsPointer ) )
return false;
matrixPointer->setCompressedRowLengths( *rowLengthsPointer );
return true;
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
bool
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
makeSnapshot( const RealType& time,
const IndexType& step,
const MeshPointer& mesh,
DofVectorPointer& dofs,
MeshDependentDataPointer& meshDependentData )
DofVectorPointer& dofs )
{{
std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl;
this->bindDofs( mesh, dofs );
this->bindDofs( dofs );
TNL::FileName fileName;
fileName.setFileNameBase( "u-" );
fileName.setExtension( "tnl" );
......@@ -156,17 +156,16 @@ makeSnapshot( const RealType& time,
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
void
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
getExplicitUpdate( const RealType& time,
const RealType& tau,
const MeshPointer& mesh,
DofVectorPointer& _u,
DofVectorPointer& _fu,
MeshDependentDataPointer& meshDependentData )
DofVectorPointer& _fu )
{{
/****
* If you use an explicit solver like EulerSolver or MersonSolver, you
......@@ -177,28 +176,27 @@ getExplicitUpdate( const RealType& time,
* You may use supporting mesh dependent data if you need.
*/
TNL::SharedPointer< MeshFunctionType > uPointer( mesh, _u );
TNL::SharedPointer< MeshFunctionType > fuPointer( mesh, _fu );
this->explicitUpdater.setDifferentialOperator( this->differentialOperator ),
this->explicitUpdater.setBoundaryConditions( this->boundaryCondition ),
this->explicitUpdater.setRightHandSide( this->rightHandSide ),
this->explicitUpdater.template update< typename Mesh::Cell >( time, tau, mesh, uPointer, fuPointer );
TNL::Pointers::SharedPointer< MeshFunctionType > uPointer( this->getMesh(), _u );
TNL::Pointers::SharedPointer< MeshFunctionType > fuPointer( this->getMesh(), _fu );
this->explicitUpdater.setDifferentialOperator( this->differentialOperator );
this->explicitUpdater.setBoundaryConditions( this->boundaryCondition );
this->explicitUpdater.setRightHandSide( this->rightHandSide );
this->explicitUpdater.template update< typename Mesh::Cell, CommunicatorType >( time, tau, this->getMesh(), uPointer, fuPointer );
}}
template< typename Mesh,
typename Communicator,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator >
template< typename MatrixPointer >
void
{problemBaseName}Problem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::
{problemBaseName}Problem< Mesh, Communicator, BoundaryCondition, RightHandSide, DifferentialOperator >::
assemblyLinearSystem( const RealType& time,
const RealType& tau,
const MeshPointer& mesh,
DofVectorPointer& _u,
MatrixPointer& matrixPointer,
DofVectorPointer& b,
MeshDependentDataPointer& meshDependentData )
DofVectorPointer& b )
{{
/****
* If you implement a (semi-)implicit solver, this method is supposed
......@@ -206,14 +204,14 @@ assemblyLinearSystem( const RealType& time,
* You may use supporting mesh dependent data if you need.
*/
TNL::SharedPointer< TNL::Functions::MeshFunction< Mesh > > uPointer( mesh, _u );
MeshFunctionPointer uPointer( this->getMesh(), _u );
this->systemAssembler.setDifferentialOperator( this->differentialOperator );
this->systemAssembler.setBoundaryConditions( this->boundaryCondition );
this->systemAssembler.setRightHandSide( this->rightHandSide );
this->systemAssembler.template assembly< typename Mesh::Cell, typename MatrixPointer::ObjectType >(
time,
tau,
mesh,
this->getMesh(),
uPointer,
matrixPointer,
b );
......
......@@ -4,7 +4,7 @@
template< typename Mesh, typename Real >
class {problemBaseName}Rhs
: public TNL::Functions::Domain< Mesh::meshDimension, TNL::Functions::MeshDomain >
: public TNL::Functions::Domain< Mesh::getMeshDimension(), TNL::Functions::MeshDomain >
{{
public:
......
#!/usr/bin/env python
class timeSerie:
def __init__( self, index, label ):
self.index = index
self.label = label
inputFile = ""
outputFile = ""
verbose = "false"
timeSeries = []
i = 0
while i < len( arguments ):
if arguments[ i ] == "--input-file":
refinement = arguments[ i + 1 ]
i = i + 2
continue
if arguments[ i ] == "--output-file":
output_file_name = arguments[ i + 1 ]
i = i + 2
continue
if arguments[ i ] == "--time-serie":
index = arguments[ i + 1 ]
label = arguments[ i + 2 ]
timeSeries.append( timeSerie( index, label ) )
i = i + 3
continue
if arguments[ i ] == "--verbose":
verbose = float( arguments[ i + 1 ] )
i = i +2
continue
input_files. append( arguments[ i ] )
i = i + 1