Commit 633b910f authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

some cleanup

parent 5a874ddf
Pipeline #903 failed with stage
in 2 minutes and 2 seconds
...@@ -8,8 +8,9 @@ DEPENDENCIES=@REQUIRES@ ...@@ -8,8 +8,9 @@ DEPENDENCIES=@REQUIRES@
Name: @PACKAGE_NAME@ Name: @PACKAGE_NAME@
Version: @VERSION@ Version: @VERSION@
Description: amdis module Description: AMDiS dune-module
URL: http://www.github.com/spraetor URL: https://gitlab.math.tu-dresden.de/spraetor/dune-amdis
Requires: dune-common dune-geometry dune-localfunctions dune-istl dune-typetree dune-grid dune-functions Requires: dune-common dune-geometry dune-localfunctions dune-istl dune-typetree dune-grid dune-functions
Suggests: dune-uggrid dune-alugrid
Libs: -L${libdir} Libs: -L${libdir}
Cflags: -I${includedir} Cflags: -I${includedir}
...@@ -8,3 +8,4 @@ Version: 0.1 ...@@ -8,3 +8,4 @@ Version: 0.1
Maintainer: simon.praetorius@tu-dresden.de Maintainer: simon.praetorius@tu-dresden.de
#depending on #depending on
Depends: dune-common dune-geometry dune-localfunctions dune-istl dune-typetree dune-grid dune-functions Depends: dune-common dune-geometry dune-localfunctions dune-istl dune-typetree dune-grid dune-functions
Suggests: dune-uggrid dune-alugrid
...@@ -82,8 +82,8 @@ namespace AMDiS ...@@ -82,8 +82,8 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class RowView, class ColView> template <class RowView, class ColView>
bool Operator<MeshView>::getElementMatrix(RowView const& rowView, bool Operator<MeshView>::getElementMatrix(RowView const& rowView,
ColView const& colView, ColView const& colView,
ElementMatrix& elementMatrix, ElementMatrix& elementMatrix,
double* factor) double* factor)
{ {
AMDIS_FUNCNAME("Operator::getElementMatrix()"); AMDIS_FUNCNAME("Operator::getElementMatrix()");
...@@ -132,7 +132,7 @@ namespace AMDiS ...@@ -132,7 +132,7 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class RowView> template <class RowView>
bool Operator<MeshView>::getElementVector(RowView const& rowView, bool Operator<MeshView>::getElementVector(RowView const& rowView,
ElementVector& elementVector, ElementVector& elementVector,
double* factor) double* factor)
{ {
AMDIS_FUNCNAME("Operator::getElementVector()"); AMDIS_FUNCNAME("Operator::getElementVector()");
...@@ -175,8 +175,8 @@ namespace AMDiS ...@@ -175,8 +175,8 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class RowView, class ColView> template <class RowView, class ColView>
void Operator<MeshView>::assembleZeroOrderTerms(RowView const& rowView, void Operator<MeshView>::assembleZeroOrderTerms(RowView const& rowView,
ColView const& colView, ColView const& colView,
ElementMatrix& elementMatrix) ElementMatrix& elementMatrix)
{ {
AMDIS_FUNCNAME("Operator::assembleZeroOrderTerms(elementMatrix)"); AMDIS_FUNCNAME("Operator::assembleZeroOrderTerms(elementMatrix)");
...@@ -196,7 +196,7 @@ namespace AMDiS ...@@ -196,7 +196,7 @@ namespace AMDiS
for (size_t iq = 0; iq < quad.size(); ++iq) { for (size_t iq = 0; iq < quad.size(); ++iq) {
// Position of the current quadrature point in the reference element // Position of the current quadrature point in the reference element
const Dune::FieldVector<double,dim>& quadPos = quad[iq].position(); Dune::FieldVector<double,dim> const& quadPos = quad[iq].position();
// The multiplicative factor in the integral transformation formula // The multiplicative factor in the integral transformation formula
const double factor = geometry.integrationElement(quadPos) * quad[iq].weight(); const double factor = geometry.integrationElement(quadPos) * quad[iq].weight();
...@@ -226,7 +226,7 @@ namespace AMDiS ...@@ -226,7 +226,7 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class RowView> template <class RowView>
void Operator<MeshView>::assembleZeroOrderTerms(RowView const& rowView, void Operator<MeshView>::assembleZeroOrderTerms(RowView const& rowView,
ElementVector& elementvector) ElementVector& elementvector)
{ {
AMDIS_FUNCNAME("Operator::assembleZeroOrderTerms(elementvector)"); AMDIS_FUNCNAME("Operator::assembleZeroOrderTerms(elementvector)");
...@@ -241,9 +241,7 @@ namespace AMDiS ...@@ -241,9 +241,7 @@ namespace AMDiS
auto const& quad = Dune::QuadratureRules<double, dim>::rule(element.type(), order); auto const& quad = Dune::QuadratureRules<double, dim>::rule(element.type(), order);
for (auto* operatorTerm : zeroOrder) for (auto* operatorTerm : zeroOrder)
operatorTerm->init(element, quad); operatorTerm->init(element, quad);
for (size_t iq = 0; iq < quad.size(); ++iq) { for (size_t iq = 0; iq < quad.size(); ++iq) {
// Position of the current quadrature point in the reference element // Position of the current quadrature point in the reference element
...@@ -267,8 +265,8 @@ namespace AMDiS ...@@ -267,8 +265,8 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class RowView, class ColView> template <class RowView, class ColView>
void Operator<MeshView>::assembleFirstOrderTermsGrdPhi(RowView const& rowView, void Operator<MeshView>::assembleFirstOrderTermsGrdPhi(RowView const& rowView,
ColView const& colView, ColView const& colView,
ElementMatrix& elementMatrix) ElementMatrix& elementMatrix)
{ {
AMDIS_FUNCNAME("Operator::assembleFirstOrderTermsGrdPhi(elementMatrix)"); AMDIS_FUNCNAME("Operator::assembleFirstOrderTermsGrdPhi(elementMatrix)");
...@@ -286,8 +284,6 @@ namespace AMDiS ...@@ -286,8 +284,6 @@ namespace AMDiS
for (auto* operatorTerm : firstOrderGrdPhi) for (auto* operatorTerm : firstOrderGrdPhi)
operatorTerm->init(element, quad); operatorTerm->init(element, quad);
for (size_t iq = 0; iq < quad.size(); ++iq) { for (size_t iq = 0; iq < quad.size(); ++iq) {
// Position of the current quadrature point in the reference element // Position of the current quadrature point in the reference element
const Dune::FieldVector<double,dim>& quadPos = quad[iq].position(); const Dune::FieldVector<double,dim>& quadPos = quad[iq].position();
...@@ -327,8 +323,8 @@ namespace AMDiS ...@@ -327,8 +323,8 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class RowView, class ColView> template <class RowView, class ColView>
void Operator<MeshView>::assembleFirstOrderTermsGrdPsi(RowView const& rowView, void Operator<MeshView>::assembleFirstOrderTermsGrdPsi(RowView const& rowView,
ColView const& colView, ColView const& colView,
ElementMatrix& elementMatrix) ElementMatrix& elementMatrix)
{ {
AMDIS_FUNCNAME("Operator::assembleFirstOrderTermsGrdPsi(elementMatrix)"); AMDIS_FUNCNAME("Operator::assembleFirstOrderTermsGrdPsi(elementMatrix)");
...@@ -435,8 +431,8 @@ namespace AMDiS ...@@ -435,8 +431,8 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class RowView, class ColView> template <class RowView, class ColView>
void Operator<MeshView>::assembleSecondOrderTerms(RowView const& rowView, void Operator<MeshView>::assembleSecondOrderTerms(RowView const& rowView,
ColView const& colView, ColView const& colView,
ElementMatrix& elementMatrix) ElementMatrix& elementMatrix)
{ {
AMDIS_FUNCNAME("Operator::assembleSecondOrderTerms(elementMatrix)"); AMDIS_FUNCNAME("Operator::assembleSecondOrderTerms(elementMatrix)");
...@@ -517,7 +513,7 @@ namespace AMDiS ...@@ -517,7 +513,7 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class Term> template <class Term>
Operator<MeshView>& Operator<MeshView>::addFOTImpl(Term const& term, Operator<MeshView>& Operator<MeshView>::addFOTImpl(Term const& term,
std::size_t i, size_t i,
FirstOrderType firstOrderType) FirstOrderType firstOrderType)
{ {
using OpTerm = GenericOperatorTerm<MeshView, Term, VectorComponent>; using OpTerm = GenericOperatorTerm<MeshView, Term, VectorComponent>;
...@@ -542,7 +538,7 @@ namespace AMDiS ...@@ -542,7 +538,7 @@ namespace AMDiS
template <class MeshView> template <class MeshView>
template <class Term> template <class Term>
Operator<MeshView>& Operator<MeshView>::addSOTImpl(Term const& term, Operator<MeshView>& Operator<MeshView>::addSOTImpl(Term const& term,
std::size_t i, std::size_t j) size_t i, size_t j)
{ {
using OpTerm = GenericOperatorTerm<MeshView, Term, MatrixComponent>; using OpTerm = GenericOperatorTerm<MeshView, Term, MatrixComponent>;
secondOrder.push_back(new OpTerm(term, {i,j})); secondOrder.push_back(new OpTerm(term, {i,j}));
......
...@@ -30,8 +30,7 @@ namespace AMDiS ...@@ -30,8 +30,7 @@ namespace AMDiS
using PointList = std::vector<Dune::QuadraturePoint<double, dim>>; using PointList = std::vector<Dune::QuadraturePoint<double, dim>>;
public: public:
virtual void init(Element const& element, virtual void init(Element const& element, PointList const& points) = 0;
PointList const& points) = 0;
virtual double evalZot(size_t iq, virtual double evalZot(size_t iq,
Dune::FieldVector<double,1> const& test, Dune::FieldVector<double,1> const& test,
...@@ -58,7 +57,7 @@ namespace AMDiS ...@@ -58,7 +57,7 @@ namespace AMDiS
template <class MeshView, class Term, class Traits = tag::none> template <class MeshView, class Term, class Traits = tag::none>
class GenericOperatorTerm class GenericOperatorTerm
: public OperatorTerm<MeshView> : public OperatorTerm<MeshView>
, public OperatorEvaluation , public OperatorEvaluation // NOTE: better: use static functions
{ {
using Super = OperatorTerm<MeshView>; using Super = OperatorTerm<MeshView>;
using Element = typename Super::Element; using Element = typename Super::Element;
...@@ -73,8 +72,7 @@ namespace AMDiS ...@@ -73,8 +72,7 @@ namespace AMDiS
, traits(traits) , traits(traits)
{} {}
virtual void init(Element const& element, virtual void init(Element const& element, PointList const& points) override
PointList const& points) override
{ {
term.init(element, points); term.init(element, points);
...@@ -122,9 +120,9 @@ namespace AMDiS ...@@ -122,9 +120,9 @@ namespace AMDiS
Traits traits; Traits traits;
using value_type = std::decay_t< decltype( std::declval<Term>()[std::declval<size_t>()] ) >; using value_type = std::decay_t< decltype( std::declval<Term>()[std::declval<size_t>()] ) >;
using _cat = ValueCategory_t<value_type>; using _cat = ValueCategory_t<value_type>;
std::vector<value_type> values; std::vector<value_type> values; // NOTE: maybe caching is not necessary here, since cached already in the term
}; };
} // end namespace AMDiS } // end namespace AMDiS
...@@ -8,7 +8,7 @@ namespace AMDiS ...@@ -8,7 +8,7 @@ namespace AMDiS
{ {
// forward declarations // forward declarations
class AdaptInfo; class AdaptInfo;
/** /**
* \ingroup Problem * \ingroup Problem
* *
...@@ -21,22 +21,19 @@ namespace AMDiS ...@@ -21,22 +21,19 @@ namespace AMDiS
{ {
using Self = ProblemInstat; using Self = ProblemInstat;
using ProblemType = ProblemStat<Traits>; using ProblemType = ProblemStat<Traits>;
using SystemVectorType = typename ProblemType::SystemVectorType; using SystemVectorType = typename ProblemType::SystemVectorType;
public: public:
/// Constructs a ProblemInstat with prob as its stationary problem. /// Constructs a ProblemInstat with prob as its stationary problem.
ProblemInstat(std::string name, ProblemInstat(std::string name, ProblemType& prob)
ProblemType& prob) : ProblemInstatBase(name, nullptr)
: ProblemInstatBase(name, NULL), , problemStat(prob)
problemStat(prob)
{} {}
ProblemInstat(std::string name, ProblemInstat(std::string name, ProblemType& prob, ProblemStatBase& initialProb)
ProblemType& prob, : ProblemInstatBase(name, &initialProb)
ProblemStatBase& initialProb) , problemStat(prob)
: ProblemInstatBase(name, &initialProb),
problemStat(prob)
{} {}
/// Initialisation of the problem. /// Initialisation of the problem.
...@@ -60,10 +57,10 @@ namespace AMDiS ...@@ -60,10 +57,10 @@ namespace AMDiS
/// Returns \ref oldSolution. /// Returns \ref oldSolution.
decltype(auto) getOldSolution() { return *oldSolution; } decltype(auto) getOldSolution() { return *oldSolution; }
decltype(auto) getOldSolution() const { return *oldSolution; } decltype(auto) getOldSolution() const { return *oldSolution; }
/// Returns the I'th component of \ref oldSolution. /// Returns the I'th component of \ref oldSolution.
template <size_t I = 0> template <size_t I = 0>
decltype(auto) getOldSolution(const index_<I> _i = index_<I>()) decltype(auto) getOldSolution(const index_<I> _i = {})
{ {
return (*oldSolution)[_i]; return (*oldSolution)[_i];
} }
...@@ -76,14 +73,14 @@ namespace AMDiS ...@@ -76,14 +73,14 @@ namespace AMDiS
ProblemType& problemStat; ProblemType& problemStat;
/// Solution of the last timestep. /// Solution of the last timestep.
shared_ptr<SystemVectorType> oldSolution; std::shared_ptr<SystemVectorType> oldSolution;
}; };
#ifndef AMDIS_NO_EXTERN_PROBLEMINSTAT #ifndef AMDIS_NO_EXTERN_PROBLEMINSTAT
extern template class ProblemInstat<ProblemStatTraits<2>>; extern template class ProblemInstat<ProblemStatTraits<2>>;
#endif #endif
} // end namespace AMDiS } // end namespace AMDiS
#include "ProblemInstat.inc.hpp" #include "ProblemInstat.inc.hpp"
...@@ -7,6 +7,8 @@ namespace AMDiS ...@@ -7,6 +7,8 @@ namespace AMDiS
template <class Traits> template <class Traits>
void ProblemInstat<Traits>::transferInitialSolution(AdaptInfo& adaptInfo) void ProblemInstat<Traits>::transferInitialSolution(AdaptInfo& adaptInfo)
{ {
AMDIS_FUNCNAME("ProblemInstat::transferInitialSolution()");
test_exit(adaptInfo.getTime() == adaptInfo.getStartTime(), test_exit(adaptInfo.getTime() == adaptInfo.getStartTime(),
"after initial solution: time != start time"); "after initial solution: time != start time");
problemStat.writeFiles(adaptInfo, true); problemStat.writeFiles(adaptInfo, true);
...@@ -24,8 +26,6 @@ namespace AMDiS ...@@ -24,8 +26,6 @@ namespace AMDiS
template <class Traits> template <class Traits>
void ProblemInstat<Traits>::initialize(Flag initFlag) void ProblemInstat<Traits>::initialize(Flag initFlag)
{ {
AMDIS_FUNCNAME("ProblemInstat::initialize()");
// === create vector for old solution === // === create vector for old solution ===
if (initFlag.isSet(INIT_UH_OLD)) if (initFlag.isSet(INIT_UH_OLD))
createUhOld(); createUhOld();
...@@ -35,6 +35,8 @@ namespace AMDiS ...@@ -35,6 +35,8 @@ namespace AMDiS
template <class Traits> template <class Traits>
void ProblemInstat<Traits>::createUhOld() void ProblemInstat<Traits>::createUhOld()
{ {
AMDIS_FUNCNAME("ProblemInstat::createUhOld()");
if (oldSolution) { if (oldSolution) {
warning("oldSolution already created\n"); warning("oldSolution already created\n");
} }
...@@ -43,7 +45,7 @@ namespace AMDiS ...@@ -43,7 +45,7 @@ namespace AMDiS
// create oldSolution // create oldSolution
std::vector<std::string> componentNames(size, name + "_uOld"); std::vector<std::string> componentNames(size, name + "_uOld");
oldSolution = make_shared<SystemVectorType>(*problemStat.getFeSpaces(), componentNames); oldSolution = std::make_shared<SystemVectorType>(*problemStat.getFeSpaces(), componentNames);
} }
} }
......
...@@ -7,15 +7,16 @@ namespace AMDiS ...@@ -7,15 +7,16 @@ namespace AMDiS
{ {
// forward declarations // forward declarations
class AdaptInfo; class AdaptInfo;
/** /**
* \ingroup Problem * \ingroup Problem
* *
* \brief * \brief
* Base class for \ref ProblemInstat. * Base class for \ref ProblemInstat.
*/ */
class ProblemInstatBase : public ProblemTimeInterface, class ProblemInstatBase
public ProblemStatBase // NOTE: Why is this derived from ProblemStatBase : public ProblemTimeInterface
, public ProblemStatBase // NOTE: Why is this derived from ProblemStatBase
{ {
public: public:
/// Constructor. /// Constructor.
......
...@@ -35,7 +35,8 @@ namespace AMDiS ...@@ -35,7 +35,8 @@ namespace AMDiS
{ {
template <class Traits> template <class Traits>
class ProblemStatSeq : public ProblemStatBase class ProblemStatSeq
: public ProblemStatBase
{ {
using Self = ProblemStatSeq; using Self = ProblemStatSeq;
...@@ -98,26 +99,26 @@ namespace AMDiS ...@@ -98,26 +99,26 @@ namespace AMDiS
* MESH[0]->global refinements: nr of initial global refinements * MESH[0]->global refinements: nr of initial global refinements
**/ **/
void initialize(Flag initFlag, void initialize(Flag initFlag,
Self* adoptProblem = NULL, Self* adoptProblem = NULL,
Flag adoptFlag = INIT_NOTHING); Flag adoptFlag = INIT_NOTHING);
/// Adds an operator to \ref A. /// Adds an operator to \ref A.
/** @{ */ /** @{ */
void addMatrixOperator(OperatorType& op, void addMatrixOperator(OperatorType& op,
int i, int j, int i, int j,
double* factor = NULL, double* factor = NULL,
double* estFactor = NULL); double* estFactor = NULL);
void addMatrixOperator(shared_ptr<OperatorType> op, void addMatrixOperator(std::shared_ptr<OperatorType> op,
int i, int j, int i, int j,
double* factor = NULL, double* factor = NULL,
double* estFactor = NULL); double* estFactor = NULL);
void addMatrixOperator(std::map< std::pair<int,int>, void addMatrixOperator(std::map< std::pair<int,int>,
shared_ptr<OperatorType> > ops); std::shared_ptr<OperatorType> > ops);
void addMatrixOperator(std::map< std::pair<int,int>, void addMatrixOperator(std::map< std::pair<int,int>,
std::pair<shared_ptr<OperatorType>, bool> > ops); std::pair<std::shared_ptr<OperatorType>, bool> > ops);
/** @} */ /** @} */
...@@ -128,40 +129,39 @@ namespace AMDiS ...@@ -128,40 +129,39 @@ namespace AMDiS
double* factor = NULL, double* factor = NULL,
double* estFactor = NULL); double* estFactor = NULL);
void addVectorOperator(shared_ptr<OperatorType> op, void addVectorOperator(std::shared_ptr<OperatorType> op,
int i, int i,
double* factor = NULL, double* factor = NULL,
double* estFactor = NULL); double* estFactor = NULL);
void addVectorOperator(std::map< int, void addVectorOperator(std::map< int, std::shared_ptr<OperatorType> > ops);
shared_ptr<OperatorType> > ops); void addVectorOperator(std::map< int, std::pair<std::shared_ptr<OperatorType>, bool> > ops);
void addVectorOperator(std::map< int,
std::pair<shared_ptr<OperatorType>, bool> > ops);
/** @} */ /** @} */
/// Adds a Dirichlet boundary condition /// Adds a Dirichlet boundary condition
template <class Predicate, class Values> template <class Predicate, class Values>
void addDirichletBC(Predicate const& predicate, void addDirichletBC(Predicate const& predicate,
int row, int col, int row, int col,
Values const& values); Values const& values);
/// Implementation of \ref ProblemStatBase::solve /// Implementation of \ref ProblemStatBase::solve
virtual void solve(AdaptInfo& adaptInfo, virtual void solve(AdaptInfo& adaptInfo,
bool createMatrixData = true, bool createMatrixData = true,
bool storeMatrixData = false) override; bool storeMatrixData = false) override;
/// Implementation of \ref ProblemStatBase::buildAfterCoarse /// Implementation of \ref ProblemStatBase::buildAfterCoarse
virtual void buildAfterCoarsen(AdaptInfo& adaptInfo, virtual void buildAfterCoarsen(AdaptInfo& adaptInfo,
Flag flag, Flag flag,
bool asmMatrix = true, bool asmMatrix = true,
bool asmVector = true) override; bool asmVector = true) override;
/// Writes output files. /// Writes output files.
void writeFiles(AdaptInfo& adaptInfo, bool force = false); void writeFiles(AdaptInfo& adaptInfo, bool force = false);
public: // get-methods public: // get-methods
/// Returns nr of components \ref nComponents /// Returns nr of components \ref nComponents
...@@ -196,9 +196,9 @@ namespace AMDiS ...@@ -196,9 +196,9 @@ namespace AMDiS
/// Return the \ref linearSolver /// Return the \ref linearSolver
auto getSolver() { return linearSolver; } auto getSolver() { return linearSolver; }
void setSolver(std::shared_ptr<LinearSolverType> const& solver_) void setSolver(std::shared_ptr<LinearSolverType> const& solver)
{ {
linearSolver = solver_; linearSolver = solver;
} }
/// Return the \ref mesh /// Return the \ref mesh
...@@ -207,7 +207,7 @@ namespace AMDiS ...@@ -207,7 +207,7 @@ namespace AMDiS
void setMesh(std::shared_ptr<Mesh> const& mesh_) void setMesh(std::shared_ptr<Mesh> const& mesh_)
{ {
mesh = mesh_; mesh = mesh_;
meshView = make_shared<MeshView>(mesh->leafGridView()); meshView = std::make_shared<MeshView>(mesh->leafGridView());
createFeSpaces(); createFeSpaces();
createMatricesAndVectors(); createMatricesAndVectors();
...@@ -251,7 +251,7 @@ namespace AMDiS ...@@ -251,7 +251,7 @@ namespace AMDiS
"No mesh name specified for '", name, "->mesh'!"); "No mesh name specified for '", name, "->mesh'!");
mesh = MeshCreator<Mesh>::create(meshName); mesh = MeshCreator<Mesh>::create(meshName);
meshView =