Skip to content
Snippets Groups Projects
Commit 36a99a36 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Cleanup

Move code around, add a comment
parent 984c68fe
No related branches found
No related tags found
No related merge requests found
...@@ -256,18 +256,13 @@ ...@@ -256,18 +256,13 @@
#+name: mainBody #+name: mainBody
#+begin_src c++ #+begin_src c++
try { try {
typedef SharedPointerMap Dune::Timer timer;
<std::string, Dune::VirtualFunction<double, double> > FunctionMap;
FunctionMap functions;
initPython(functions);
Dune::ParameterTree parset; Dune::ParameterTree parset;
Dune::ParameterTreeParser::readINITree Dune::ParameterTreeParser::readINITree
(srcdir "/one-body-sample.parset", parset); (srcdir "/one-body-sample.parset", parset);
Dune::ParameterTreeParser::readOptions(argc, argv, parset); Dune::ParameterTreeParser::readOptions(argc, argv, parset);
Dune::Timer timer;
typedef Dune::FieldVector<double, dim> SmallVector; typedef Dune::FieldVector<double, dim> SmallVector;
typedef Dune::FieldMatrix<double, dim, dim> SmallMatrix; typedef Dune::FieldMatrix<double, dim, dim> SmallMatrix;
typedef Dune::BCRSMatrix<SmallMatrix> MatrixType; typedef Dune::BCRSMatrix<SmallMatrix> MatrixType;
...@@ -276,13 +271,11 @@ ...@@ -276,13 +271,11 @@
auto const E = parset.get<double>("body.E"); auto const E = parset.get<double>("body.E");
auto const nu = parset.get<double>("body.nu"); auto const nu = parset.get<double>("body.nu");
auto const solver_tolerance = parset.get<double>("solver.tolerance"); auto const mu = parset.get<double>("boundary.friction.mu");
auto const a = parset.get<double>("boundary.friction.a");
auto const refinements = parset.get<size_t>("grid.refinements"); auto const b = parset.get<double>("boundary.friction.b");
auto const V0 = parset.get<double>("boundary.friction.V0");
auto const verbose = parset.get<bool>("verbose"); auto const L = parset.get<double>("boundary.friction.L");
Solver::VerbosityMode const verbosity
= verbose ? Solver::FULL : Solver::QUIET;
// {{{ Set up grid // {{{ Set up grid
typedef Dune::ALUGrid<dim, dim, Dune::simplex, Dune::nonconforming> typedef Dune::ALUGrid<dim, dim, Dune::simplex, Dune::nonconforming>
...@@ -301,6 +294,7 @@ ...@@ -301,6 +294,7 @@
auto grid = Dune::StructuredGridFactory<GridType>::createSimplexGrid auto grid = Dune::StructuredGridFactory<GridType>::createSimplexGrid
(lowerLeft, upperRight, elements); (lowerLeft, upperRight, elements);
auto const refinements = parset.get<size_t>("grid.refinements");
grid->globalRefine(refinements); grid->globalRefine(refinements);
size_t const finestSize = grid->size(grid->maxLevel(), dim); size_t const finestSize = grid->size(grid->maxLevel(), dim);
...@@ -314,6 +308,22 @@ ...@@ -314,6 +308,22 @@
P0Basis const p0Basis(leafView); P0Basis const p0Basis(leafView);
P1Basis const p1Basis(leafView); P1Basis const p1Basis(leafView);
// Set up the boundary
size_t specialNode = finestSize;
Dune::BitSetVector<dim> ignoreNodes(finestSize, false);
Dune::BitSetVector<1> neumannNodes(finestSize, false);
Dune::BitSetVector<1> frictionalNodes(finestSize, false);
<<setupBoundary>>;
// Set up functions for time-dependent boundary conditions
typedef SharedPointerMap
<std::string, Dune::VirtualFunction<double, double> > FunctionMap;
FunctionMap functions;
initPython(functions);
auto const &dirichletFunction = functions.get("dirichletCondition");
auto const &neumannFunction = functions.get("neumannCondition");
// Set up normal stress, mass matrix, and gravity functional
double normalStress; double normalStress;
MatrixType massMatrix; MatrixType massMatrix;
VectorType gravityFunctional; VectorType gravityFunctional;
...@@ -325,18 +335,16 @@ ...@@ -325,18 +335,16 @@
<<computeNormalStress>>; <<computeNormalStress>>;
<<computeGravitationalBodyForce>>; <<computeGravitationalBodyForce>>;
} }
SingletonVectorType surfaceNormalStress(finestSize);
surfaceNormalStress = 0.0;
for (size_t i = 0; i < frictionalNodes.size(); ++i)
if (frictionalNodes[i][0])
surfaceNormalStress[i] = normalStress;
MatrixType stiffnessMatrix; MatrixType stiffnessMatrix;
<<assembleStiffnessMatrix>>; <<assembleStiffnessMatrix>>;
EnergyNorm<MatrixType, VectorType> energyNorm(stiffnessMatrix); EnergyNorm<MatrixType, VectorType> energyNorm(stiffnessMatrix);
// Set up the boundary
size_t specialNode = finestSize;
Dune::BitSetVector<dim> ignoreNodes(finestSize, false);
Dune::BitSetVector<1> neumannNodes(finestSize, false);
Dune::BitSetVector<1> frictionalNodes(finestSize, false);
<<setupBoundary>>;
auto const nodalIntegrals auto const nodalIntegrals
= assemble_frictional<GridType, GridView, SmallVector, P1Basis> = assemble_frictional<GridType, GridView, SmallVector, P1Basis>
(leafView, p1Basis, frictionalNodes); (leafView, p1Basis, frictionalNodes);
...@@ -354,35 +362,22 @@ ...@@ -354,35 +362,22 @@
SingletonVectorType alpha(alpha_initial); SingletonVectorType alpha(alpha_initial);
SingletonVectorType vonMisesStress; SingletonVectorType vonMisesStress;
SingletonVectorType surfaceNormalStress(finestSize);
surfaceNormalStress = 0.0;
for (size_t i = 0; i < frictionalNodes.size(); ++i)
if (frictionalNodes[i][0])
surfaceNormalStress[i] = normalStress;
// }}} // }}}
// Set up TNNMG solver
auto const solver_tolerance = parset.get<double>("solver.tolerance");
typedef MyConvexProblem<MatrixType, VectorType> MyConvexProblemType; typedef MyConvexProblem<MatrixType, VectorType> MyConvexProblemType;
typedef MyBlockProblem<MyConvexProblemType> MyBlockProblemType; typedef MyBlockProblem<MyConvexProblemType> MyBlockProblemType;
// Set up TNNMG solver
MySolver<dim, MatrixType, VectorType, GridType, MyBlockProblemType> MySolver<dim, MatrixType, VectorType, GridType, MyBlockProblemType>
mySolver(parset.sub("solver.tnnmg"), refinements, solver_tolerance, mySolver(parset.sub("solver.tnnmg"), refinements, solver_tolerance,
*grid, ignoreNodes); *grid, ignoreNodes);
<<createWriters>>; Solver::VerbosityMode const verbosity
= parset.get<bool>("verbose") ? Solver::FULL : Solver::QUIET;
auto const L = parset.get<double>("boundary.friction.L");
auto const a = parset.get<double>("boundary.friction.a");
auto const b = parset.get<double>("boundary.friction.b");
auto const V0 = parset.get<double>("boundary.friction.V0");
auto const mu = parset.get<double>("boundary.friction.mu");
auto const timesteps = parset.get<size_t>("timeSteps");
auto const tau = parset.get<double>("endOfTime") / timesteps;
auto const &dirichletFunction = functions.get("dirichletCondition"); <<createWriters>>;
auto const &neumannFunction = functions.get("neumannCondition");
// Set up time steppers that
auto timeSteppingScheme = initTimeStepper auto timeSteppingScheme = initTimeStepper
(parset.get<Config::scheme>("timeSteppingScheme"), dirichletFunction, (parset.get<Config::scheme>("timeSteppingScheme"), dirichletFunction,
ignoreNodes, massMatrix, stiffnessMatrix, u_initial, ud_initial, ignoreNodes, massMatrix, stiffnessMatrix, u_initial, ud_initial,
...@@ -391,6 +386,9 @@ ...@@ -391,6 +386,9 @@
(parset.get<Config::state_model>("boundary.friction.state_model"), (parset.get<Config::state_model>("boundary.friction.state_model"),
alpha_initial, frictionalNodes, L); alpha_initial, frictionalNodes, L);
auto const timesteps = parset.get<size_t>("timeSteps");
auto const tau = parset.get<double>("endOfTime") / timesteps;
auto const state_fpi_max auto const state_fpi_max
= parset.get<size_t>("solver.tnnmg.fixed_point_iterations"); = parset.get<size_t>("solver.tnnmg.fixed_point_iterations");
for (size_t run = 1; run <= timesteps; ++run) { for (size_t run = 1; run <= timesteps; ++run) {
...@@ -412,6 +410,8 @@ ...@@ -412,6 +410,8 @@
timeSteppingScheme->setup(ell, tau, time, timeSteppingScheme->setup(ell, tau, time,
problem_rhs, problem_iterate, problem_A); problem_rhs, problem_iterate, problem_A);
// Since the velocity explodes in the quasistatic case, use the
// displacement as a convergence criterion
VectorType u_saved; VectorType u_saved;
for (size_t state_fpi = 1; state_fpi <= state_fpi_max; ++state_fpi) { for (size_t state_fpi = 1; state_fpi <= state_fpi_max; ++state_fpi) {
<<setupAndSolveProblem>>; <<setupAndSolveProblem>>;
......
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