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

changed interface of problemStat for grid adaption

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