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

Move assembly of nonlinearity to a function

parent cc6a9aa2
No related branches found
No related tags found
No related merge requests found
...@@ -135,6 +135,46 @@ void assemble_frictional( ...@@ -135,6 +135,46 @@ void assemble_frictional(
true); // whether to resize the output vector and zero all of its entries true); // whether to resize the output vector and zero all of its entries
} }
void assemble_nonlinearity(
int size, Dune::ParameterTree const &parset,
Dune::shared_ptr<Dune::GlobalNonlinearity<dim>> &myGlobalNonlinearity,
std::vector<Dune::FieldVector<double, 1>> &nodalIntegrals) {
// {{{ Assemble terms for the nonlinearity
std::vector<double> mu;
mu.resize(size);
std::fill(mu.begin(), mu.end(), parset.get<double>("boundary.friction.mu"));
std::vector<double> normalStress;
normalStress.resize(size);
std::fill(normalStress.begin(), normalStress.end(),
parset.get<double>("boundary.friction.normalstress"));
std::string const friction_model =
parset.get<std::string>("boundary.friction.model");
if (friction_model == std::string("Ruina")) {
std::vector<double> a;
a.resize(size);
std::fill(a.begin(), a.end(),
parset.get<double>("boundary.friction.ruina.a"));
std::vector<double> eta;
eta.resize(size);
std::fill(eta.begin(), eta.end(),
parset.get<double>("boundary.friction.eta"));
auto const tmp = new Dune::GlobalRuinaNonlinearity<dim>(
nodalIntegrals, a, mu, eta, normalStress);
myGlobalNonlinearity = Dune::shared_ptr<Dune::GlobalNonlinearity<dim>>(tmp);
} else if (friction_model == std::string("Laursen")) {
auto const tmp =
new Dune::GlobalLaursenNonlinearity<dim, Dune::LinearFunction>(
mu, normalStress, nodalIntegrals);
myGlobalNonlinearity = Dune::shared_ptr<Dune::GlobalNonlinearity<dim>>(tmp);
} else {
assert(false);
}
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
try { try {
Dune::ParameterTree parset; Dune::ParameterTree parset;
...@@ -237,45 +277,9 @@ int main(int argc, char *argv[]) { ...@@ -237,45 +277,9 @@ int main(int argc, char *argv[]) {
stiffnessMatrix.mmv(u2, b2); stiffnessMatrix.mmv(u2, b2);
stiffnessMatrix.mmv(u3, b3); stiffnessMatrix.mmv(u3, b3);
// {{{ Assemble terms for the nonlinearity Dune::shared_ptr<Dune::GlobalNonlinearity<dim>> myGlobalNonlinearity;
std::vector<double> mu; assemble_nonlinearity(grid.size(grid.maxLevel(), dim), parset,
mu.resize(grid.size(grid.maxLevel(), dim)); myGlobalNonlinearity, nodalIntegrals);
std::fill(mu.begin(), mu.end(),
parset.get<double>("boundary.friction.mu"));
std::vector<double> normalStress;
normalStress.resize(grid.size(grid.maxLevel(), dim));
std::fill(normalStress.begin(), normalStress.end(),
parset.get<double>("boundary.friction.normalstress"));
typedef Dune::shared_ptr<Dune::GlobalNonlinearity<dim>>
globalNonlinearityPtr;
globalNonlinearityPtr myGlobalNonlinearity;
std::string const friction_model =
parset.get<std::string>("boundary.friction.model");
if (friction_model == std::string("Ruina")) {
std::vector<double> a;
a.resize(grid.size(grid.maxLevel(), dim));
std::fill(a.begin(), a.end(),
parset.get<double>("boundary.friction.ruina.a"));
std::vector<double> eta;
eta.resize(grid.size(grid.maxLevel(), dim));
std::fill(eta.begin(), eta.end(),
parset.get<double>("boundary.friction.eta"));
auto const tmp = new Dune::GlobalRuinaNonlinearity<dim>(
nodalIntegrals, a, mu, eta, normalStress);
myGlobalNonlinearity = globalNonlinearityPtr(tmp);
} else if (friction_model == std::string("Laursen")) {
auto const tmp =
new Dune::GlobalLaursenNonlinearity<dim, Dune::LinearFunction>(
mu, normalStress, nodalIntegrals);
myGlobalNonlinearity = globalNonlinearityPtr(tmp);
} else {
assert(false);
}
// }}} // }}}
if (parset.get<bool>("useNonlinearGS")) { if (parset.get<bool>("useNonlinearGS")) {
......
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