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

Rename get-methods

parent 2795c8e4
...@@ -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.buildAfterAdapt(adaptInfo, Flag(0)); prob.assemble(adaptInfo);
prob.solve(adaptInfo); prob.solve(adaptInfo);
prob.writeFiles(adaptInfo, true); prob.writeFiles(adaptInfo, true);
......
...@@ -38,14 +38,14 @@ int main(int argc, char** argv) ...@@ -38,14 +38,14 @@ int main(int argc, char** argv)
prob.initialize(INIT_ALL); prob.initialize(INIT_ALL);
auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0); auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
prob.addMatrixOperator(opL, _0, _0); prob.addMatrixOperator(opL, 0, 0);
auto opForce = makeOperator(tag::test{}, f, 6); auto opForce = makeOperator(tag::test{}, f, 6);
prob.addVectorOperator(opForce, _0); prob.addVectorOperator(opForce, 0);
// set boundary condition // set boundary condition
auto boundary = [](auto const& x){ return x[0] < 1.e-8 || x[1] < 1.e-8 || x[0] > 1.0-1.e-8 || x[1] > 1.0-1.e-8; }; auto boundary = [](auto const& x){ return x[0] < 1.e-8 || x[1] < 1.e-8 || x[0] > 1.0-1.e-8 || x[1] > 1.0-1.e-8; };
prob.addDirichletBC(boundary, _0, _0, g); prob.addDirichletBC(boundary, 0, 0, g);
AdaptInfo adaptInfo("adapt"); AdaptInfo adaptInfo("adapt");
...@@ -62,17 +62,17 @@ int main(int argc, char** argv) ...@@ -62,17 +62,17 @@ int main(int argc, char** argv)
widths.push_back(h); widths.push_back(h);
prob.globalBasis().update(gridView); prob.globalBasis().update(gridView);
prob.buildAfterAdapt(adaptInfo, Flag(0)); prob.assemble(adaptInfo);
prob.solve(adaptInfo); prob.solve(adaptInfo);
double errorL2 = integrate(sqr(g - prob.getSolution(_0)), gridView, 6); double errorL2 = integrate(sqr(g - prob.solution(0)), gridView, 6);
errL2.push_back(std::sqrt(errorL2)); errL2.push_back(std::sqrt(errorL2));
double errorH1 = errorL2 + integrate(unary_dot(grad_g - gradientAtQP(prob.getSolution(_0))), gridView, 6); double errorH1 = errorL2 + integrate(unary_dot(grad_g - gradientAtQP(prob.solution(0))), gridView, 6);
errH1.push_back(std::sqrt(errorH1)); errH1.push_back(std::sqrt(errorH1));
#if WRITE_FILES #if WRITE_FILES
Dune::VTKWriter<typename ElliptProblem::GridView> vtkWriter(gridView); Dune::VTKWriter<typename ElliptProblem::GridView> vtkWriter(gridView);
vtkWriter.addVertexData(prob.getSolution(_0), Dune::VTK::FieldInfo("u", Dune::VTK::FieldInfo::Type::scalar, 1)); vtkWriter.addVertexData(prob.solution(0), Dune::VTK::FieldInfo("u", Dune::VTK::FieldInfo::Type::scalar, 1));
vtkWriter.write("u_" + std::to_string(i)); vtkWriter.write("u_" + std::to_string(i));
#endif #endif
} }
......
...@@ -31,16 +31,16 @@ int main(int argc, char** argv) ...@@ -31,16 +31,16 @@ int main(int argc, char** argv)
AdaptInfo adaptInfo("adapt"); AdaptInfo adaptInfo("adapt");
auto* invTau = probInstat.getInvTau(); auto invTau = std::ref(probInstat.invTau());
auto opTimeLhs = makeOperator(tag::test_trial{}, std::ref(*invTau)); auto opTimeLhs = makeOperator(tag::test_trial{}, invTau);
prob.addMatrixOperator(opTimeLhs, 0, 0); prob.addMatrixOperator(opTimeLhs, 0, 0);
auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0); auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
prob.addMatrixOperator(opL, 0, 0); prob.addMatrixOperator(opL, 0, 0);
auto opTimeRhs = makeOperator(tag::test{}, auto opTimeRhs = makeOperator(tag::test{},
invokeAtQP([invTau](double u) { return u * (*invTau); }, prob.getSolution(0)), 2); invokeAtQP([invTau](double u) { return u * invTau.get(); }, prob.solution(0)), 2);
prob.addVectorOperator(opTimeRhs, 0); prob.addVectorOperator(opTimeRhs, 0);
auto opForce = makeOperator(tag::test{}, [](auto const& x) { return -1.0; }, 0); auto opForce = makeOperator(tag::test{}, [](auto const& x) { return -1.0; }, 0);
......
...@@ -48,12 +48,16 @@ int main(int argc, char** argv) ...@@ -48,12 +48,16 @@ int main(int argc, char** argv)
auto _v = Dune::Indices::_0; auto _v = Dune::Indices::_0;
auto _p = Dune::Indices::_1; auto _p = Dune::Indices::_1;
auto invTau = std::ref(probInstat.invTau());
// <1/tau * u, v> // <1/tau * u, v>
auto opTime = makeOperator(tag::testvec_trialvec{}, density); auto opTime = makeOperator(tag::testvec_trialvec{},
density * invTau);
prob.addMatrixOperator(opTime, _v, _v); prob.addMatrixOperator(opTime, _v, _v);
// <1/tau * u^old, v> // <1/tau * u^old, v>
auto opTimeOld = makeOperator(tag::testvec{}, density * prob.getSolution(_v)); auto opTimeOld = makeOperator(tag::testvec{},
density * invTau * prob.solution(_v));
prob.addVectorOperator(opTimeOld, _v); prob.addVectorOperator(opTimeOld, _v);
...@@ -62,17 +66,20 @@ int main(int argc, char** argv) ...@@ -62,17 +66,20 @@ int main(int argc, char** argv)
prob.addMatrixOperator(opStokes, treepath(), treepath()); prob.addMatrixOperator(opStokes, treepath(), treepath());
// <(u * nabla)u_i^old, v_i> // <(u * nabla)u_i^old, v_i>
auto opNonlin1 = makeOperator(tag::testvec_trialvec{}, density * trans(gradientAtQP(prob.getSolution(_v)))); auto opNonlin1 = makeOperator(tag::testvec_trialvec{},
density * trans(gradientAtQP(prob.solution(_v))));
prob.addMatrixOperator(opNonlin1, _v, _v); prob.addMatrixOperator(opNonlin1, _v, _v);
for (std::size_t i = 0; i < AMDIS_DOW; ++i) { for (std::size_t i = 0; i < AMDIS_DOW; ++i) {
// <(u^old * nabla)u_i, v_i> // <(u^old * nabla)u_i, v_i>
auto opNonlin2 = makeOperator(tag::test_gradtrial{}, density * prob.getSolution(_v)); auto opNonlin2 = makeOperator(tag::test_gradtrial{},
density * prob.solution(_v));
prob.addMatrixOperator(opNonlin2, treepath(_v,i), treepath(_v,i)); prob.addMatrixOperator(opNonlin2, treepath(_v,i), treepath(_v,i));
} }
// <(u^old * grad(u_i^old)), v_i> // <(u^old * grad(u_i^old)), v_i>
auto opNonlin3 = makeOperator(tag::testvec{}, trans(gradientAtQP(prob.getSolution(_v))) * prob.getSolution(_v)); auto opNonlin3 = makeOperator(tag::testvec{},
trans(gradientAtQP(prob.solution(_v))) * prob.solution(_v));
prob.addVectorOperator(opNonlin3, _v); prob.addVectorOperator(opNonlin3, _v);
// define boundary regions // define boundary regions
...@@ -98,8 +105,8 @@ int main(int argc, char** argv) ...@@ -98,8 +105,8 @@ int main(int argc, char** argv)
prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0); prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0);
// set initial conditions // set initial conditions
prob.getSolution(_v).interpolate(parabolic_y); prob.solution(_v).interpolate(parabolic_y);
prob.getSolution(_p).interpolate(0.0); prob.solution(_p).interpolate(0.0);
AdaptInstationary adapt("adapt", prob, adaptInfo, probInstat, adaptInfo); AdaptInstationary adapt("adapt", prob, adaptInfo, probInstat, adaptInfo);
adapt.adapt(); adapt.adapt();
......
...@@ -25,73 +25,73 @@ using StokesProblem = ProblemStat<StokesParam>; ...@@ -25,73 +25,73 @@ using StokesProblem = ProblemStat<StokesParam>;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
AMDiS::init(argc, argv); AMDiS::init(argc, argv);
StokesProblem prob("stokes"); StokesProblem prob("stokes");
prob.initialize(INIT_ALL); prob.initialize(INIT_ALL);
double viscosity = 1.0; double viscosity = 1.0;
Parameters::get("stokes->viscosity", viscosity); Parameters::get("stokes->viscosity", viscosity);
// tree-paths for components // tree-paths for components
auto _v = Dune::Indices::_0; auto _v = Dune::Indices::_0;
auto _p = Dune::Indices::_1; auto _p = Dune::Indices::_1;
// <viscosity*grad(u_i), grad(v_i)> // <viscosity*grad(u_i), grad(v_i)>
for (std::size_t i = 0; i < DOW; ++i) { for (std::size_t i = 0; i < DOW; ++i) {
auto opL = makeOperator(tag::gradtest_gradtrial{}, viscosity); auto opL = makeOperator(tag::gradtest_gradtrial{}, viscosity);
prob.addMatrixOperator(opL, treepath(_v,i), treepath(_v,i)); prob.addMatrixOperator(opL, treepath(_v,i), treepath(_v,i));
// <d_i(v_i), p> // <d_i(v_i), p>
auto opP = makeOperator(tag::partialtest_trial{i}, 1.0); auto opP = makeOperator(tag::partialtest_trial{i}, 1.0);
prob.addMatrixOperator(opP, treepath(_v,i), _p); prob.addMatrixOperator(opP, treepath(_v,i), _p);
// <q, d_i(u_i)> // <q, d_i(u_i)>
auto opDiv = makeOperator(tag::test_partialtrial{i}, 1.0); auto opDiv = makeOperator(tag::test_partialtrial{i}, 1.0);
prob.addMatrixOperator(opDiv, _p, treepath(_v,i)); prob.addMatrixOperator(opDiv, _p, treepath(_v,i));
} }
auto opZero = makeOperator(tag::test_trial{}, 0.0); auto opZero = makeOperator(tag::test_trial{}, 0.0);
prob.addMatrixOperator(opZero, _p, _p); prob.addMatrixOperator(opZero, _p, _p);
// define boundary regions // define boundary regions
auto left = [](auto const& x) { return x[0] < 1.e-8; }; auto left = [](auto const& x) { return x[0] < 1.e-8; };
auto not_left = [](auto const& x) { return x[0] > 1.0 - 1.e-8 || x[1] < 1.e-8 || x[1] > 1.0 - 1.e-8; }; auto not_left = [](auto const& x) { return x[0] > 1.0 - 1.e-8 || x[1] < 1.e-8 || x[1] > 1.0 - 1.e-8; };
// define boundary values // define boundary values
auto parabolic_y = [](auto const& x) -> Dune::FieldVector<double,DOW> auto parabolic_y = [](auto const& x) -> Dune::FieldVector<double,DOW>
{ {
return {0.0, x[1]*(1.0 - x[1])}; return {0.0, x[1]*(1.0 - x[1])};
}; };
auto zero = [](auto const& x) -> Dune::FieldVector<double,DOW> auto zero = [](auto const& x) -> Dune::FieldVector<double,DOW>
{ {
return {0.0, 0.0}; return {0.0, 0.0};
}; };
// set boundary conditions for velocity // set boundary conditions for velocity
prob.addDirichletBC(left, _v, _v, parabolic_y); prob.addDirichletBC(left, _v, _v, parabolic_y);
prob.addDirichletBC(not_left, _v, _v, zero); prob.addDirichletBC(not_left, _v, _v, zero);
prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0); prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0);
AdaptInfo adaptInfo("adapt"); AdaptInfo adaptInfo("adapt");
// assemble and solve system // assemble and solve system
prob.buildAfterAdapt(adaptInfo, Flag(0)); prob.assemble(adaptInfo);
#ifdef DEBUG_MTL #ifdef DEBUG_MTL
// write matrix to file // write matrix to file
mtl::io::matrix_market_ostream out("matrix_stokes0.mtx"); mtl::io::matrix_market_ostream out("matrix_stokes0.mtx");
out << prob.getSystemMatrix().matrix(); out << prob.systemMatrix().matrix();
std::cout << prob.getSystemMatrix().matrix() << '\n'; std::cout << prob.systemMatrix().matrix() << '\n';
#endif #endif
prob.solve(adaptInfo); prob.solve(adaptInfo);
// output solution // output solution
prob.writeFiles(adaptInfo); prob.writeFiles(adaptInfo);
AMDiS::finalize(); AMDiS::finalize();
return 0; return 0;
} }
...@@ -25,74 +25,74 @@ using StokesProblem = ProblemStat<StokesParam>; ...@@ -25,74 +25,74 @@ using StokesProblem = ProblemStat<StokesParam>;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
AMDiS::init(argc, argv); AMDiS::init(argc, argv);
StokesProblem prob("stokes"); StokesProblem prob("stokes");
prob.initialize(INIT_ALL); prob.initialize(INIT_ALL);
double viscosity = 1.0; double viscosity = 1.0;
Parameters::get("stokes->viscosity", viscosity); Parameters::get("stokes->viscosity", viscosity);
// tree-paths for components // tree-paths for components
auto _v = Dune::Indices::_0; auto _v = Dune::Indices::_0;
auto _p = Dune::Indices::_1; auto _p = Dune::Indices::_1;
// <viscosity*grad(u_i), grad(v_i)> // <viscosity*grad(u_i), grad(v_i)>
for (std::size_t i = 0; i < DOW; ++i) { for (std::size_t i = 0; i < DOW; ++i) {
auto opL = makeOperator(tag::gradtest_gradtrial{}, viscosity); auto opL = makeOperator(tag::gradtest_gradtrial{}, viscosity);
prob.addMatrixOperator(opL, treepath(_v,i), treepath(_v,i)); prob.addMatrixOperator(opL, treepath(_v,i), treepath(_v,i));
} }
// <d_i(v_i), p> // <d_i(v_i), p>
auto opP = makeOperator(tag::divtestvec_trial{}, 1.0); auto opP = makeOperator(tag::divtestvec_trial{}, 1.0);
prob.addMatrixOperator(opP, _v, _p); prob.addMatrixOperator(opP, _v, _p);
// <q, d_i(u_i)> // <q, d_i(u_i)>
auto opDiv = makeOperator(tag::test_divtrialvec{}, 1.0); auto opDiv = makeOperator(tag::test_divtrialvec{}, 1.0);
prob.addMatrixOperator(opDiv, _p, _v); prob.addMatrixOperator(opDiv, _p, _v);
auto opZero = makeOperator(tag::test_trial{}, 0.0); auto opZero = makeOperator(tag::test_trial{}, 0.0);
prob.addMatrixOperator(opZero, _p, _p); prob.addMatrixOperator(opZero, _p, _p);
// define boundary regions // define boundary regions
auto left = [](auto const& x) { return x[0] < 1.e-8; }; auto left = [](auto const& x) { return x[0] < 1.e-8; };
auto not_left = [](auto const& x) { return x[0] > 1.0 - 1.e-8 || x[1] < 1.e-8 || x[1] > 1.0 - 1.e-8; }; auto not_left = [](auto const& x) { return x[0] > 1.0 - 1.e-8 || x[1] < 1.e-8 || x[1] > 1.0 - 1.e-8; };
// define boundary values // define boundary values
auto parabolic_y = [](auto const& x) -> Dune::FieldVector<double,DOW> auto parabolic_y = [](auto const& x) -> Dune::FieldVector<double,DOW>
{ {
return {0.0, x[1]*(1.0 - x[1])}; return {0.0, x[1]*(1.0 - x[1])};
}; };
auto zero = [](auto const& x) -> Dune::FieldVector<double,DOW> auto zero = [](auto const& x) -> Dune::FieldVector<double,DOW>
{ {
return {0.0, 0.0}; return {0.0, 0.0};
}; };
// set boundary conditions for velocity // set boundary conditions for velocity
prob.addDirichletBC(left, _v, _v, parabolic_y); prob.addDirichletBC(left, _v, _v, parabolic_y);
prob.addDirichletBC(not_left, _v, _v, zero); prob.addDirichletBC(not_left, _v, _v, zero);
prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0); prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0);
AdaptInfo adaptInfo("adapt"); AdaptInfo adaptInfo("adapt");
// assemble and solve system // assemble and solve system
prob.buildAfterAdapt(adaptInfo, Flag(0)); prob.assemble(adaptInfo);
#ifdef DEBUG_MTL #ifdef DEBUG_MTL
// write matrix to file // write matrix to file
mtl::io::matrix_market_ostream out("matrix_stokes1.mtx"); mtl::io::matrix_market_ostream out("matrix_stokes1.mtx");
out << prob.getSystemMatrix().matrix(); out << prob.systemMatrix().matrix();
std::cout << prob.getSystemMatrix().matrix() << '\n'; std::cout << prob.systemMatrix().matrix() << '\n';
#endif #endif
prob.solve(adaptInfo); prob.solve(adaptInfo);
// output solution // output solution
prob.writeFiles(adaptInfo); prob.writeFiles(adaptInfo);
AMDiS::finalize(); AMDiS::finalize();
return 0; return 0;
} }
...@@ -62,8 +62,7 @@ int main(int argc, char** argv) ...@@ -62,8 +62,7 @@ int main(int argc, char** argv)
AdaptInfo adaptInfo("adapt"); AdaptInfo adaptInfo("adapt");
// assemble and solve system // assemble and solve system
prob.buildAfterAdapt(adaptInfo, Flag(0)); prob.assemble(adaptInfo);
prob.solve(adaptInfo); prob.solve(adaptInfo);
// output solution // output solution
......
...@@ -46,9 +46,9 @@ int main(int argc, char** argv) ...@@ -46,9 +46,9 @@ int main(int argc, char** argv)
// write matrix to file // write matrix to file
if (Parameters::get<int>("elliptMesh->global refinements").value_or(0) < 4) { if (Parameters::get<int>("elliptMesh->global refinements").value_or(0) < 4) {
mtl::io::matrix_market_ostream out("matrix.mtx"); mtl::io::matrix_market_ostream out("matrix.mtx");
out << prob.getSystemMatrix().matrix(); out << prob.systemMatrix().matrix();
std::cout << prob.getSystemMatrix().matrix() << '\n'; std::cout << prob.systemMatrix().matrix() << '\n';
} }
#endif #endif
......
...@@ -37,13 +37,13 @@ namespace AMDiS ...@@ -37,13 +37,13 @@ namespace AMDiS
virtual int adapt() = 0; virtual int adapt() = 0;
/// Returns \ref name /// Returns \ref name
std::string const& getName() const std::string const& name() const
{ {
return name_; return name_;
} }
/// Returns \ref problemIteration /// Returns \ref problemIteration
ProblemIterationInterface* getProblemIteration() const ProblemIterationInterface* problemIteration() const
{ {
return problemIteration_; return problemIteration_;
} }
...@@ -55,13 +55,13 @@ namespace AMDiS ...@@ -55,13 +55,13 @@ namespace AMDiS
} }
/// Returns \ref adaptInfo /// Returns \ref adaptInfo
AdaptInfo& getAdaptInfo() const AdaptInfo& adaptInfo() const
{ {
return adaptInfo_; return adaptInfo_;
} }
/// Returns \ref problemTime /// Returns \ref problemTime
ProblemTimeInterface* getProblemTime() const ProblemTimeInterface* problemTime() const
{ {
return problemTime_; return problemTime_;
} }
...@@ -73,7 +73,7 @@ namespace AMDiS ...@@ -73,7 +73,7 @@ namespace AMDiS
} }
/// Returns \ref initialAdaptInfo /// Returns \ref initialAdaptInfo
AdaptInfo& getInitialAdaptInfo() const AdaptInfo& initialAdaptInfo() const
{ {
return *initialAdaptInfo_; return *initialAdaptInfo_;
} }
......
...@@ -29,28 +29,28 @@ namespace AMDiS ...@@ -29,28 +29,28 @@ namespace AMDiS
: name_(name) : name_(name)
{ {
// init(); // init();
Parameters::get(name + "->start time", startTime); Parameters::get(name + "->start time", startTime_);
time = startTime; time_ = startTime_;
Parameters::get(name + "->timestep", timestep); Parameters::get(name + "->timestep", timestep_);
Parameters::get(name + "->end time", endTime); Parameters::get(name + "->end time", endTime_);
Parameters::get(name + "->max iteration", maxSpaceIteration); Parameters::get(name + "->max iteration", maxSpaceIteration_);
Parameters::get(name + "->max timestep iteration", maxTimestepIteration); Parameters::get(name + "->max timestep iteration", maxTimestepIteration_);
Parameters::get(name + "->max time iteration", maxTimeIteration); Parameters::get(name + "->max time iteration", maxTimeIteration_);
Parameters::get(name + "->min timestep", minTimestep); Parameters::get(name + "->min timestep", minTimestep_);
Parameters::get(name + "->max timestep", maxTimestep); Parameters::get(name + "->max timestep", maxTimestep_);
Parameters::get(name + "->number of timesteps", nTimesteps); Parameters::get(name + "->number of timesteps", nTimesteps_);
Parameters::get(name + "->time tolerance", globalTimeTolerance); Parameters::get(name + "->time tolerance", globalTimeTolerance_);
} }
void AdaptInfo::printTimeErrorLowInfo() const void AdaptInfo::printTimeErrorLowInfo() const
{ {
for (auto const& scalContent : scalContents) for (auto const& scalContent : scalContents_)
{ {
auto i = scalContent.first; auto i = scalContent.first;
std::cout << " Time error estimate ["<<i<<"] = " std::cout << " Time error estimate ["<<i<<"] = "
<< getTimeEstCombined(i) << "\n" << timeEstCombined(i) << "\n"
<< " Time error estimate sum ["<<i<<"] = " << " Time error estimate sum ["<<i<<"] = "
<< scalContent.second.est_t_sum << "\n" << scalContent.second.est_t_sum << "\n"
<< " Time error estimate max ["<<i<<"] = " << " Time error estimate max ["<<i<<"] = "
...@@ -64,17 +64,17 @@ namespace AMDiS ...@@ -64,17 +64,17 @@ namespace AMDiS
void AdaptInfo::reset() void AdaptInfo::reset()