Commit 69292946 authored by Praetorius, Simon's avatar Praetorius, Simon

changed interface of problemStat for grid adaption

parent 280450a6
Pipeline #1253 passed with stage
in 19 minutes and 29 seconds
......@@ -35,7 +35,7 @@ int main(int argc, char** argv)
prob.addDirichletBC(predicate, 0, 0, dbcValues);
AdaptInfo adaptInfo("adapt");
prob.buildAfterCoarsen(adaptInfo, Flag(0));
prob.buildAfterAdapt(adaptInfo, Flag(0));
prob.solve(adaptInfo);
prob.writeFiles(adaptInfo, true);
......
......@@ -61,7 +61,7 @@ int main(int argc, char** argv)
h = std::max(h, e.geometry().volume());
widths.push_back(h);
prob.buildAfterCoarsen(adaptInfo, Flag(0));
prob.buildAfterAdapt(adaptInfo, Flag(0));
prob.solve(adaptInfo);
double errorL2 = integrate(sqr(g - prob.getSolution(_0)), gridView, 6);
......
......@@ -78,7 +78,7 @@ int main(int argc, char** argv)
AdaptInfo adaptInfo("adapt");
// assemble and solve system
prob.buildAfterCoarsen(adaptInfo, Flag(0));
prob.buildAfterAdapt(adaptInfo, Flag(0));
#ifdef DEBUG_MTL
// write matrix to file
......
......@@ -79,7 +79,7 @@ int main(int argc, char** argv)
AdaptInfo adaptInfo("adapt");
// assemble and solve system
prob.buildAfterCoarsen(adaptInfo, Flag(0));
prob.buildAfterAdapt(adaptInfo, Flag(0));
#ifdef DEBUG_MTL
// write matrix to file
......
......@@ -62,7 +62,7 @@ int main(int argc, char** argv)
AdaptInfo adaptInfo("adapt");
// assemble and solve system
prob.buildAfterCoarsen(adaptInfo, Flag(0));
prob.buildAfterAdapt(adaptInfo, Flag(0));
prob.solve(adaptInfo);
......
......@@ -40,7 +40,7 @@ int main(int argc, char** argv)
auto dbcValues = [](auto const& x){ return 0.0; }; // set value
prob.addDirichletBC(predicate, 1, 1, dbcValues);
prob.buildAfterCoarsen(adaptInfo, Flag(0));
prob.buildAfterAdapt(adaptInfo, Flag(0));
#ifdef DEBUG_MTL
// write matrix to file
......
......@@ -43,14 +43,8 @@ namespace AMDiS
/// Implementation of \ref ProblemStatBase::estimate().
virtual void estimate(AdaptInfo&) override { /* by default, do nothing */ }
/// Implementation of \ref ProblemStatBase::buildBeforeRefine().
virtual void buildBeforeRefine(AdaptInfo&, Flag) override { /* by default, do nothing */ }
/// Implementation of \ref ProblemStatBase::buildBeforeCoarsen().
virtual void buildBeforeCoarsen(AdaptInfo&, Flag) override { /* by default, do nothing */ }
/// Implementation of \ref ProblemStatBase::buildAfterCoarsen().
virtual void buildAfterCoarsen(AdaptInfo&, Flag, bool, bool) override { /* by default, do nothing */ }
/// Implementation of \ref ProblemStatBase::buildAfterAdapt().
virtual void buildAfterAdapt(AdaptInfo&, Flag, bool, bool) override { /* by default, do nothing */ }
/// Implementation of \ref ProblemStatBase::markElements().
virtual Flag markElements(AdaptInfo&) override
......@@ -59,13 +53,7 @@ namespace AMDiS
}
/// Implementation of \ref ProblemStatBase::refineMesh().
virtual Flag refineMesh(AdaptInfo&) override
{
return 0;
}
/// Implementation of \ref ProblemStatBase::coarsenMesh().
virtual Flag coarsenMesh(AdaptInfo&) override
virtual Flag adaptGrid(AdaptInfo&) override
{
return 0;
}
......
......@@ -147,10 +147,10 @@ namespace AMDiS
bool storeMatrixData = false) override;
/// Implementation of \ref ProblemStatBase::buildAfterCoarse
virtual void buildAfterCoarsen(AdaptInfo& adaptInfo,
Flag flag,
bool asmMatrix = true,
bool asmVector = true) override;
virtual void buildAfterAdapt(AdaptInfo& adaptInfo,
Flag flag,
bool asmMatrix = true,
bool asmVector = true) override;
/// Writes output files.
void writeFiles(AdaptInfo& adaptInfo, bool force = false);
......@@ -319,20 +319,11 @@ namespace AMDiS
return StandardProblemIteration::oneIteration(adaptInfo, toDo);
}
/// Implementation of \ref ProblemStatBase::buildBeforeRefine.
virtual void buildBeforeRefine(AdaptInfo&, Flag) override { /* Does nothing. */ }
/// Implementation of \ref ProblemStatBase::buildBeforeCoarsen.
virtual void buildBeforeCoarsen(AdaptInfo&, Flag) override { /* Does nothing. */ }
/// Implementation of \ref ProblemStatBase::estimate.
virtual void estimate(AdaptInfo& adaptInfo) override { /* Does nothing. */ }
/// Implementation of \ref ProblemStatBase::refineMesh.
virtual Flag refineMesh(AdaptInfo& adaptInfo) override { return 0; }
/// Implementation of \ref ProblemStatBase::coarsenMesh.
virtual Flag coarsenMesh(AdaptInfo& adaptInfo) override { return 0; }
virtual Flag adaptGrid(AdaptInfo& adaptInfo) override;
/// Implementation of \ref ProblemStatBase::markElements.
virtual Flag markElements(AdaptInfo& adaptInfo) override;
......
......@@ -13,7 +13,6 @@
#include <amdis/LocalAssembler.hpp>
#include <amdis/GridFunctionOperator.hpp>
#include <amdis/common/Loops.hpp>
// #include <amdis/Estimator.hpp>
namespace AMDiS {
......@@ -324,18 +323,32 @@ Flag ProblemStat<Traits>::markElements(AdaptInfo& adaptInfo)
}
template <class Traits>
Flag ProblemStat<Traits>::
adaptGrid(AdaptInfo& adaptInfo)
{
Dune::Timer t;
grid_->preAdapt();
grid_->adapt();
globalBasis_->update(gridView());
grid_->postAdapt();
msg("Grid adaption needed {} seconds", t.elapsed());
return 0;
}
template <class Traits>
void ProblemStat<Traits>::
buildAfterCoarsen(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool asmVector)
buildAfterAdapt(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool asmVector)
{
Dune::Timer t;
Assembler<Traits> assembler(*globalBasis_, matrixOperators_, rhsOperators_, constraints_);
auto gv = grid_->leafGridView();
globalBasis_->update(gv);
assembler.assemble(*systemMatrix_, *solution_, *rhs_, asmMatrix, asmVector);
msg("buildAfterCoarsen needed {} seconds", t.elapsed());
msg("buildAfterAdapt needed {} seconds", t.elapsed());
}
......
......@@ -64,25 +64,16 @@ namespace AMDiS
/// Marks mesh elements for refinement and coarsening.
virtual Flag markElements(AdaptInfo& adaptInfo) = 0;
/// Assembling of system matrices and vectors before refinement.
virtual void buildBeforeRefine(AdaptInfo& adaptInfo, Flag flag) = 0;
/// Assembling of system matrices and vectors before coarsening.
virtual void buildBeforeCoarsen(AdaptInfo& adaptInfo, Flag flag) = 0;
/** \brief
* Assembling of system matrices and vectors after coarsening.
* By the last two parameters, assembling can be restricted to either
* matrices or vectors only.
*/
virtual void buildAfterCoarsen(AdaptInfo& adaptInfo, Flag flag,
virtual void buildAfterAdapt(AdaptInfo& adaptInfo, Flag flag,
bool assembleMatrix, bool assembleVector) = 0;
/// Refinement of the mesh.
virtual Flag refineMesh(AdaptInfo& adaptInfo) = 0;
/// Coarsening of the mesh.
virtual Flag coarsenMesh(AdaptInfo& adaptInfo) = 0;
/// Refinement/coarsening of the grid.
virtual Flag adaptGrid(AdaptInfo& adaptInfo) = 0;
/** \brief
* Solves the assembled system. The result is an approximative solution.
......
......@@ -66,25 +66,14 @@ namespace AMDiS
else
markFlag = 3;
if (toDo.isSet(BUILD))
problem_.buildBeforeRefine(adaptInfo, markFlag);
// refine
if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_REFINED))
flag = problem_.refineMesh(adaptInfo);
if (toDo.isSet(BUILD))
problem_.buildBeforeCoarsen(adaptInfo, markFlag);
// coarsen
if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_COARSENED))
flag |= problem_.coarsenMesh(adaptInfo);
if (toDo.isSet(ADAPT) && (markFlag.isSet(MESH_REFINED) || markFlag.isSet(MESH_COARSENED)))
flag |= problem_.adaptGrid(adaptInfo);
if (toDo.isSet(BUILD))
problem_.buildAfterCoarsen(adaptInfo, markFlag, true, true);
problem_.buildAfterAdapt(adaptInfo, markFlag, true, true);
if (toDo.isSet(BUILD_RHS))
problem_.buildAfterCoarsen(adaptInfo, markFlag, false, true);
problem_.buildAfterAdapt(adaptInfo, markFlag, false, true);
return flag;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment