Skip to content
Snippets Groups Projects
Commit 92726b9c authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[projector] allow setting projection parameters

parent 365903eb
No related branches found
No related tags found
1 merge request!1636Feature/l2 norm
...@@ -55,15 +55,24 @@ namespace Dumux { ...@@ -55,15 +55,24 @@ namespace Dumux {
* into another. The convenience functions makeProjectorPair * into another. The convenience functions makeProjectorPair
* or makeProjector can be used to create such a projection. * or makeProjector can be used to create such a projection.
*/ */
template<class Scalar> template<class ScalarType>
class Projector class Projector
{ {
using BlockType = Dune::FieldMatrix<Scalar, 1, 1>; using BlockType = Dune::FieldMatrix<ScalarType, 1, 1>;
public: public:
//! Export the scalar type
using Scalar = ScalarType;
//! Export the type of the projection matrices //! Export the type of the projection matrices
using Matrix = Dune::BCRSMatrix< BlockType >; using Matrix = Dune::BCRSMatrix< BlockType >;
//! Parameters that can be passed to project()
struct Params
{
std::size_t maxIterations{100};
Scalar residualReduction{1e-13};
};
//! delete default constructor //! delete default constructor
Projector() = delete; Projector() = delete;
...@@ -83,7 +92,7 @@ public: ...@@ -83,7 +92,7 @@ public:
* \param up The projection of u into the target space * \param up The projection of u into the target space
*/ */
template< class DomainSolution, class TargetSolution> template< class DomainSolution, class TargetSolution>
void project(const DomainSolution& u, TargetSolution& up) const void project(const DomainSolution& u, TargetSolution& up, const Params& params = Params{}) const
{ {
// be picky about size of u // be picky about size of u
if ( u.size() != projMat_.M()) if ( u.size() != projMat_.M())
...@@ -95,9 +104,17 @@ public: ...@@ -95,9 +104,17 @@ public:
projMat_.mv(u, rhs); projMat_.mv(u, rhs);
SSORCGBackend solver; SSORCGBackend solver;
solver.setResidualReduction(params.residualReduction);
solver.setMaxIter(params.maxIterations);
solver.solve(massMat_, up, rhs); solver.solve(massMat_, up, rhs);
} }
/*!
* \brief Returns the default parameters.
*/
static Params defaultParams()
{ return {}; }
private: private:
Matrix massMat_; Matrix massMat_;
Matrix projMat_; Matrix projMat_;
......
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