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

Make multiple runs

parent 170ac694
No related branches found
No related tags found
No related merge requests found
...@@ -128,6 +128,7 @@ int main() { ...@@ -128,6 +128,7 @@ int main() {
typedef Dune::BlockVector<SmallVector> VectorType; typedef Dune::BlockVector<SmallVector> VectorType;
// FIXME: Random values // FIXME: Random values
size_t const runs = 3;
double const E = 1; double const E = 1;
double const nu = 0.3; double const nu = 0.3;
int const refinements = 5; int const refinements = 5;
...@@ -179,55 +180,60 @@ int main() { ...@@ -179,55 +180,60 @@ int main() {
u1 = 0; u1 = 0;
VectorType u2 = u1; VectorType u2 = u1;
VectorType f(grid.size(grid.maxLevel(), dim)); for (size_t run = 1; run <= runs; ++run) {
f = 0; VectorType f(grid.size(grid.maxLevel(), dim));
VectorType neumannTerm(grid.size(grid.maxLevel(), dim)); f = 0;
assemble_neumann<GridType, GridType::LeafGridView, SmallVector, P1Basis>( VectorType neumannTerm(grid.size(grid.maxLevel(), dim));
leafView, p1Basis, neumannNodes, neumannTerm); assemble_neumann<GridType, GridType::LeafGridView, SmallVector, P1Basis>(
f += neumannTerm; leafView, p1Basis, neumannNodes, neumannTerm);
f += neumannTerm;
// {{{ Assemble terms for the nonlinearity
std::vector<Dune::FieldVector<double, 1>> nodalIntegrals; // {{{ Assemble terms for the nonlinearity
assemble_frictional<GridType, GridType::LeafGridView, SmallVector, P1Basis>( std::vector<Dune::FieldVector<double, 1>> nodalIntegrals;
leafView, p1Basis, frictionalNodes, nodalIntegrals); assemble_frictional<GridType, GridType::LeafGridView, SmallVector,
P1Basis>(leafView, p1Basis, frictionalNodes,
// TODO: populate on S_F nodalIntegrals);
std::vector<double> normalStress;
normalStress.resize(grid.size(grid.maxLevel(), dim)); // TODO: populate on S_F
std::fill(normalStress.begin(), normalStress.end(), 0.0); std::vector<double> normalStress;
normalStress.resize(grid.size(grid.maxLevel(), dim));
// TODO: populate on S_F std::fill(normalStress.begin(), normalStress.end(), 0.0);
std::vector<double> coefficientOfFriction;
coefficientOfFriction.resize(grid.size(grid.maxLevel(), dim)); // TODO: populate on S_F
std::fill(coefficientOfFriction.begin(), coefficientOfFriction.end(), 0.0); std::vector<double> coefficientOfFriction;
coefficientOfFriction.resize(grid.size(grid.maxLevel(), dim));
Dune::GlobalNonlinearity<dim, Dune::LinearFunction> myGlobalNonlinearity( std::fill(coefficientOfFriction.begin(), coefficientOfFriction.end(),
coefficientOfFriction, normalStress, nodalIntegrals); 0.0);
// }}}
Dune::GlobalNonlinearity<dim, Dune::LinearFunction> myGlobalNonlinearity(
{ coefficientOfFriction, normalStress, nodalIntegrals);
MyConvexProblemType myConvexProblem(stiffnessMatrix, myGlobalNonlinearity, // }}}
f, u1);
MyBlockProblemType myBlockProblem(myConvexProblem); {
nonlinearGSStep.setProblem(u1, myBlockProblem); MyConvexProblemType myConvexProblem(stiffnessMatrix,
myGlobalNonlinearity, f, u1);
LoopSolver<VectorType> solver(&nonlinearGSStep, solver_maxIterations, MyBlockProblemType myBlockProblem(myConvexProblem);
solver_tolerance, &energyNorm, nonlinearGSStep.setProblem(u1, myBlockProblem);
Solver::FULL); // Solver::QUIET);
solver.solve(); LoopSolver<VectorType> solver(&nonlinearGSStep, solver_maxIterations,
} solver_tolerance, &energyNorm,
Solver::FULL); // Solver::QUIET);
// Use a linear solver for comparison; should return roughly the solver.solve();
// same results if phi vanishes (e.g. because the normalstress is zero) }
{
// TODO: Why does blockGSStep even provide a default constructor? // Use a linear solver for comparison; should return roughly the
BlockGSStep<OperatorType, VectorType> blockGSStep(stiffnessMatrix, u2, f); // same results if phi vanishes (e.g. because the normalstress is zero)
blockGSStep.ignoreNodes_ = &ignoreNodes; {
// TODO: Why does blockGSStep even provide a default constructor?
LoopSolver<VectorType> solver(&blockGSStep, solver_maxIterations, BlockGSStep<OperatorType, VectorType> blockGSStep(stiffnessMatrix, u2,
solver_tolerance, &energyNorm, f);
Solver::FULL); // Solver::QUIET); blockGSStep.ignoreNodes_ = &ignoreNodes;
solver.solve();
LoopSolver<VectorType> solver(&blockGSStep, solver_maxIterations,
solver_tolerance, &energyNorm,
Solver::FULL); // Solver::QUIET);
solver.solve();
}
} }
VectorType diff = u2; VectorType diff = u2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment