Transport.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2020 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#ifndef __PASO_TRANSPORT_H__
#define __PASO_TRANSPORT_H__
#define DT_FACTOR_MAX 100000.
#include "Paso.h"
#include "Options.h"
#include "SystemMatrix.h"
#include <escript/AbstractTransportProblem.h>
namespace paso {
class TransportProblem;
typedef boost::shared_ptr<TransportProblem> TransportProblem_ptr;
typedef boost::shared_ptr<const TransportProblem> const_TransportProblem_ptr;
class TransportProblem : public escript::AbstractTransportProblem,
public boost::enable_shared_from_this<TransportProblem>
{
public:
TransportProblem();
TransportProblem(SystemMatrixPattern_ptr pattern, int blocksize,
const escript::FunctionSpace& functionspace);
~TransportProblem();
virtual void resetTransport(bool preserveSolverData) const;
void solve(double* u, double dt, double* u0, double* q, Options* options);
virtual double getSafeTimeStepSize() const;
virtual double getUnlimitedTimeStepSize() const;
void insertConstraint(const double* r, double* source) const;
void setUpConstraint(const double* q);
inline dim_t getBlockSize() const
{
return transport_matrix->row_block_size;
}
inline SystemMatrix_ptr borrowTransportMatrix() const
{
return transport_matrix;
}
inline SystemMatrix_ptr borrowMassMatrix() const
{
return mass_matrix;
}
inline double* borrowLumpedMassMatrix() const
{
return lumped_mass_matrix;
}
inline dim_t getTotalNumRows() const
{
return transport_matrix->getTotalNumRows();
}
inline Connector_ptr borrowConnector() const
{
return transport_matrix->pattern->col_connector;
}
inline index_t* borrowMainDiagonalPointer() const
{
return mass_matrix->mainBlock->borrowMainDiagonalPointer();
}
inline static int getTypeId(int solver, int preconditioner,
int package, bool symmetry,
const escript::JMPI& mpi_info)
{
return MATRIX_FORMAT_DEFAULT + MATRIX_FORMAT_BLK1;
}
SystemMatrix_ptr transport_matrix;
SystemMatrix_ptr mass_matrix;
SystemMatrix_ptr iteration_matrix;
mutable bool valid_matrices;
mutable double dt_max_R;
mutable double dt_max_T;
mutable double* constraint_mask;
double* main_diagonal_low_order_transport_matrix;
double* lumped_mass_matrix;
double* reactive_matrix;
double* main_diagonal_mass_matrix;
escript::JMPI mpi_info;
private:
virtual void setToSolution(escript::Data& out, escript::Data& u0,
escript::Data& source, double dt,
boost::python::object& options);
virtual void copyConstraint(escript::Data& source, escript::Data& q,
escript::Data& r);
};
} // namespace paso
#endif // __PASO_TRANSPORT_H__
MATRIX_FORMAT_BLK1
#define MATRIX_FORMAT_BLK1
Definition: Paso.h:64
paso::LARGE_POSITIVE_FLOAT
static const real_t LARGE_POSITIVE_FLOAT
Definition: FCT_Solver.cpp:44
escript::Data::isComplex
bool isComplex() const
True if components of this data are stored as complex.
Definition: Data.cpp:1160
PASO_ONE
#define PASO_ONE
Definition: Paso.h:68
paso::TransportProblem::TransportProblem
TransportProblem()
Default constructor - throws exception.
paso::TransportProblem::insertConstraint
void insertConstraint(const double *r, double *source) const
Definition: Transport.cpp:224
paso::TransportProblem::lumped_mass_matrix
double * lumped_mass_matrix
Definition: Transport.h:117
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:79
paso::TransportProblem::~TransportProblem
~TransportProblem()
Definition: Transport.cpp:86
PERFORMANCE_MVM
#define PERFORMANCE_MVM
Definition: performance.h:60
escript::Data::requireWrite
void requireWrite()
Ensures data is ready for write access. This means that the data will be resolved if lazy and will be...
Definition: Data.cpp:1239
paso::Performance_startMonitor
void Performance_startMonitor(Performance *pp, int monitor)
switches on a monitor
Definition: performance.cpp:178
paso::SystemMatrix
this class holds a (distributed) stiffness matrix
Definition: SystemMatrix.h:62
paso::TransportProblem::reactive_matrix
double * reactive_matrix
Definition: Transport.h:118
paso::TransportProblem::setToSolution
virtual void setToSolution(escript::Data &out, escript::Data &u0, escript::Data &source, double dt, boost::python::object &options)
sets solution out by time step dt.
Definition: Transport.cpp:95
paso::TransportProblem::borrowMainDiagonalPointer
index_t * borrowMainDiagonalPointer() const
Definition: Transport.h:90
paso::TransportProblem::getTotalNumRows
dim_t getTotalNumRows() const
Definition: Transport.h:80
paso::solve_free
void solve_free(SystemMatrix *in)
Definition: solve.cpp:143
escript::Data::getDataPointShape
const DataTypes::ShapeType & getDataPointShape() const
Return a reference to the data point shape.
Definition: Data.h:705
paso::SystemMatrix_ptr
boost::shared_ptr< SystemMatrix > SystemMatrix_ptr
Definition: SystemMatrix.h:55
paso::TransportProblem::borrowMassMatrix
SystemMatrix_ptr borrowMassMatrix() const
Definition: Transport.h:70
paso::SystemMatrixPattern_ptr
boost::shared_ptr< SystemMatrixPattern > SystemMatrixPattern_ptr
Definition: SystemMatrixPattern.h:54
paso::Solver_TFQMR
SolverResult Solver_TFQMR(SystemMatrix_ptr A, double *B, double *X, dim_t *iter, double *tolerance, Performance *pp)
Definition: TFQMR.cpp:77
paso::TransportProblem::mass_matrix
SystemMatrix_ptr mass_matrix
Definition: Transport.h:103
escript::AbstractTransportProblem
Give a short description of what AbstractTransportProblem does.
Definition: AbstractTransportProblem.h:58
escript::DataTypes::real_t_max
real_t real_t_max()
Returns the maximum finite value for the real_t type.
Definition: DataTypes.h:117
escript::Data::getDataPointSize
int getDataPointSize() const
Return the size of the data point. It is the product of the data point shape dimensions.
Definition: Data.cpp:1360
paso::InputError
@ InputError
Definition: Paso.h:74
paso::TransportProblem::constraint_mask
double * constraint_mask
Definition: Transport.h:111
escript::FunctionSpace
Definition: FunctionSpace.h:49
escript::DataTypes::DataVectorAlt::data
ElementType * data()
Definition: DataVectorAlt.h:228
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:463
Options.h
paso::TransportProblem::borrowConnector
Connector_ptr borrowConnector() const
Definition: Transport.h:85
Solver.h
paso::util::copy
void copy(dim_t N, double *out, const double *in)
out = in
Definition: PasoUtil.h:116
paso::Breakdown
@ Breakdown
Definition: Paso.h:76
Paso.h
paso::util::update
void update(dim_t n, double a, double *x, double b, const double *y)
Definition: PasoUtil.cpp:368
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
paso::TransportProblem_ptr
boost::shared_ptr< TransportProblem > TransportProblem_ptr
Definition: Transport.h:32
paso::util::l2
double l2(dim_t n, const double *x, escript::JMPI mpiinfo)
returns the global L2 norm of x
Definition: PasoUtil.cpp:530
paso::TransportProblem::borrowTransportMatrix
SystemMatrix_ptr borrowTransportMatrix() const
Definition: Transport.h:65
paso::TransportProblem::dt_max_R
double dt_max_R
safe time step size for reactive part
Definition: Transport.h:108
paso::TransportProblem::copyConstraint
virtual void copyConstraint(escript::Data &source, escript::Data &q, escript::Data &r)
copy constraint u_{,t}=r where q>0 into the problem it can be assumed that q and r are not empty and ...
Definition: Transport.cpp:130
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:93
escript::AbstractTransportProblem::getFunctionSpace
FunctionSpace getFunctionSpace() const
returns the column function space
Definition: AbstractTransportProblem.h:97
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:72
paso::TransportProblem::transport_matrix
SystemMatrix_ptr transport_matrix
Definition: Transport.h:102
escript::Data::getSampleDataRW
DataTypes::real_t * getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0)
Return the sample data for the given sample no. Please do not use this unless you NEED to access samp...
Definition: Data.h:1954
PERFORMANCE_SOLVER
#define PERFORMANCE_SOLVER
Definition: performance.h:57
PERFORMANCE_PRECONDITIONER
#define PERFORMANCE_PRECONDITIONER
Definition: performance.h:59
paso::SolverResult
SolverResult
Definition: Paso.h:57
paso::TransportProblem::setUpConstraint
void setUpConstraint(const double *q)
Definition: Transport.cpp:206
SystemMatrix.h
paso::MaxIterReached
@ MaxIterReached
Definition: Paso.h:73
paso::TransportProblem::solve
void solve(double *u, double dt, double *u0, double *q, Options *options)
Definition: Transport_solve.cpp:65
paso::Options::updateEscriptDiagnostics
void updateEscriptDiagnostics(boost::python::object &options) const
updates SolverBuddy diagnostics from this
Definition: Options.cpp:444
paso::TransportProblem::getBlockSize
dim_t getBlockSize() const
Definition: Transport.h:60
paso::util::linearCombination
void linearCombination(dim_t n, double *z, double a, const double *x, double b, const double *y)
Definition: PasoUtil.cpp:417
paso::TransportProblem
Definition: Transport.h:36
paso::TransportProblem::getTypeId
static int getTypeId(int solver, int preconditioner, int package, bool symmetry, const escript::JMPI &mpi_info)
Definition: Transport.h:95
paso::const_TransportProblem_ptr
boost::shared_ptr< const TransportProblem > const_TransportProblem_ptr
Definition: Transport.h:34
escript::Data::copyWithMask
void copyWithMask(const Data &other, const Data &mask)
Copy other Data object into this Data object where mask is positive.
Definition: Data.cpp:851
Transport.h
paso::TransportProblem::getSafeTimeStepSize
virtual double getSafeTimeStepSize() const
Definition: Transport_solve.cpp:208
paso::PasoException
PasoException exception class.
Definition: PasoException.h:47
paso::SystemMatrixType
int SystemMatrixType
Definition: SystemMatrix.h:59
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:88
paso::TransportProblem::valid_matrices
bool valid_matrices
Definition: Transport.h:106
paso::Performance_stopMonitor
void Performance_stopMonitor(Performance *pp, int monitor)
switches off a monitor
Definition: performance.cpp:197
paso::TransportProblem::borrowLumpedMassMatrix
double * borrowLumpedMassMatrix() const
Definition: Transport.h:75
paso::TransportProblem::getUnlimitedTimeStepSize
virtual double getUnlimitedTimeStepSize() const
Definition: Transport.cpp:200
Preconditioner.h
PasoUtil.h
paso::util::zeroes
void zeroes(dim_t n, double *x)
fills array x with zeroes
Definition: PasoUtil.cpp:348
paso::TransportProblem::mpi_info
escript::JMPI mpi_info
Definition: Transport.h:121
paso::TransportProblem::iteration_matrix
SystemMatrix_ptr iteration_matrix
Definition: Transport.h:104
paso::Connector_ptr
boost::shared_ptr< Connector > Connector_ptr
Definition: Coupler.h:52
paso::TransportProblem::main_diagonal_mass_matrix
double * main_diagonal_mass_matrix
Definition: Transport.h:119
paso::TransportProblem::dt_max_T
double dt_max_T
safe time step size for transport part
Definition: Transport.h:110
escript::Data::getExpandedVectorReference
DataTypes::RealVectorType & getExpandedVectorReference(DataTypes::real_t dummy=0)
Ensures that the Data is expanded and returns its underlying vector Does not check for exclusive writ...
Definition: Data.cpp:5841
paso::TransportProblem::resetTransport
virtual void resetTransport(bool preserveSolverData) const
resets the transport operator typically as they have been updated.
Definition: Transport.cpp:190
paso
Definition: BiCGStab.cpp:26
escript::Data::expand
void expand()
Whatever the current Data type make this into a DataExpanded.
Definition: Data.cpp:1180
paso::NoError
@ NoError
Definition: Paso.h:72
escript::ValueError
An exception class that signals an invalid argument value.
Definition: EsysException.h:103
paso::util::innerProduct
double innerProduct(dim_t n, const double *x, const double *y, escript::JMPI mpiinfo)
returns the inner product of global arrays x and y
Definition: PasoUtil.cpp:457
paso::Options
Definition: Options.h:78
MATRIX_FORMAT_DEFAULT
#define MATRIX_FORMAT_DEFAULT
Definition: Paso.h:62
paso::TransportProblem::main_diagonal_low_order_transport_matrix
double * main_diagonal_low_order_transport_matrix
Definition: Transport.h:113
PASO_ZERO
#define PASO_ZERO
Definition: Paso.h:69