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

Integrate a state variable

We now re-assemble the global nonlinearity for every step
parent 58726d34
Branches
No related tags found
No related merge requests found
...@@ -25,12 +25,14 @@ class GlobalRuinaNonlinearity ...@@ -25,12 +25,14 @@ class GlobalRuinaNonlinearity
shared_ptr<BlockVector<FieldVector<double, 1>> const> a, shared_ptr<BlockVector<FieldVector<double, 1>> const> a,
shared_ptr<BlockVector<FieldVector<double, 1>> const> mu, shared_ptr<BlockVector<FieldVector<double, 1>> const> mu,
shared_ptr<BlockVector<FieldVector<double, 1>> const> eta, shared_ptr<BlockVector<FieldVector<double, 1>> const> eta,
shared_ptr<BlockVector<FieldVector<double, 1>> const> normalStress) shared_ptr<BlockVector<FieldVector<double, 1>> const> normalStress,
shared_ptr<BlockVector<FieldVector<double, 1>> const> state)
: nodalIntegrals(nodalIntegrals), : nodalIntegrals(nodalIntegrals),
a(a), a(a),
mu(mu), mu(mu),
eta(eta), eta(eta),
normalStress(normalStress), normalStress(normalStress),
state(state),
trivialNonlinearity( trivialNonlinearity(
new LocalNonlinearity<dim>(make_shared<TrivialFunction const>())), new LocalNonlinearity<dim>(make_shared<TrivialFunction const>())),
restrictions(nodalIntegrals->size()) // TODO: can we get the size from restrictions(nodalIntegrals->size()) // TODO: can we get the size from
...@@ -52,7 +54,7 @@ class GlobalRuinaNonlinearity ...@@ -52,7 +54,7 @@ class GlobalRuinaNonlinearity
auto const func = make_shared<RuinaFunction const>( auto const func = make_shared<RuinaFunction const>(
(*nodalIntegrals)[i][0], (*a)[i][0], (*mu)[i][0], (*eta)[i][0], (*nodalIntegrals)[i][0], (*a)[i][0], (*mu)[i][0], (*eta)[i][0],
(*normalStress)[i][0]); (*normalStress)[i][0], (*state)[i][0]);
restrictions[i] = make_shared<LocalNonlinearity<dim> const>(func); restrictions[i] = make_shared<LocalNonlinearity<dim> const>(func);
return restrictions[i]; return restrictions[i];
} }
...@@ -65,6 +67,7 @@ class GlobalRuinaNonlinearity ...@@ -65,6 +67,7 @@ class GlobalRuinaNonlinearity
shared_ptr<BlockVector<FieldVector<double, 1>> const> mu; shared_ptr<BlockVector<FieldVector<double, 1>> const> mu;
shared_ptr<BlockVector<FieldVector<double, 1>> const> eta; shared_ptr<BlockVector<FieldVector<double, 1>> const> eta;
shared_ptr<BlockVector<FieldVector<double, 1>> const> normalStress; shared_ptr<BlockVector<FieldVector<double, 1>> const> normalStress;
shared_ptr<BlockVector<FieldVector<double, 1>> const> state;
std::vector<shared_ptr<LocalNonlinearity<dim> const>> mutable restrictions; std::vector<shared_ptr<LocalNonlinearity<dim> const>> mutable restrictions;
}; };
......
...@@ -31,13 +31,14 @@ class NiceFunction : public VirtualFunction<double, double> { ...@@ -31,13 +31,14 @@ class NiceFunction : public VirtualFunction<double, double> {
class RuinaFunction : public NiceFunction { class RuinaFunction : public NiceFunction {
public: public:
RuinaFunction(double coefficient, double a, double mu, double eta, RuinaFunction(double coefficient, double a, double mu, double eta,
double normalStress) double normalStress, double state)
: coefficient(coefficient), : coefficient(coefficient),
a(a), a(a),
mu(mu), mu(mu),
rho(exp(-mu / a)), rho(exp(-mu / a)),
eta(eta), eta(eta),
normalStress(normalStress) {} normalStress(normalStress),
state(state) {}
/* /*
If mu and sigma_n denote the coefficient of friction and the If mu and sigma_n denote the coefficient of friction and the
...@@ -55,8 +56,8 @@ class RuinaFunction : public NiceFunction { ...@@ -55,8 +56,8 @@ class RuinaFunction : public NiceFunction {
*/ */
void virtual evaluate(double const &x, double &y) const { void virtual evaluate(double const &x, double &y) const {
double const arg = std::max(eta * x, rho); double const arg = std::max(eta * x, rho);
double const h = arg * (a * (std::log(arg) - 1) + mu); double const h = arg * (a * (std::log(arg) - 1) + mu + state);
y = 1 / eta * normalStress * h + a * rho + mu; y = 1 / eta * normalStress * h + a * rho + mu + state;
y *= coefficient; y *= coefficient;
} }
...@@ -71,7 +72,7 @@ class RuinaFunction : public NiceFunction { ...@@ -71,7 +72,7 @@ class RuinaFunction : public NiceFunction {
if (eta * s <= rho) if (eta * s <= rho)
return 0; return 0;
return coefficient * normalStress * (a * std::log(eta * s) + mu); return coefficient * normalStress * (a * std::log(eta * s) + mu + state);
} }
/* see above */ /* see above */
...@@ -79,7 +80,7 @@ class RuinaFunction : public NiceFunction { ...@@ -79,7 +80,7 @@ class RuinaFunction : public NiceFunction {
if (eta * s <= rho) if (eta * s <= rho)
return 0; return 0;
return coefficient * normalStress * (a * std::log(eta * s) + mu); return coefficient * normalStress * (a * std::log(eta * s) + mu + state);
} }
/* /*
...@@ -108,6 +109,7 @@ class RuinaFunction : public NiceFunction { ...@@ -108,6 +109,7 @@ class RuinaFunction : public NiceFunction {
double const mu; double const mu;
double const eta; double const eta;
double const normalStress; double const normalStress;
double const state;
double const rho; double const rho;
}; };
......
...@@ -144,7 +144,8 @@ Dune::shared_ptr<Dune::GlobalNonlinearity<VectorType, MatrixType> const> ...@@ -144,7 +144,8 @@ Dune::shared_ptr<Dune::GlobalNonlinearity<VectorType, MatrixType> const>
assemble_nonlinearity( assemble_nonlinearity(
int size, Dune::ParameterTree const &parset, int size, Dune::ParameterTree const &parset,
Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>>
nodalIntegrals) { nodalIntegrals,
Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> state) {
typedef Dune::BlockVector<Dune::FieldVector<double, 1>> SingletonVectorType; typedef Dune::BlockVector<Dune::FieldVector<double, 1>> SingletonVectorType;
// {{{ Assemble terms for the nonlinearity // {{{ Assemble terms for the nonlinearity
...@@ -165,7 +166,7 @@ assemble_nonlinearity( ...@@ -165,7 +166,7 @@ assemble_nonlinearity(
return Dune::make_shared< return Dune::make_shared<
Dune::GlobalRuinaNonlinearity<VectorType, MatrixType> const>( Dune::GlobalRuinaNonlinearity<VectorType, MatrixType> const>(
nodalIntegrals, a, mu, eta, normalStress); nodalIntegrals, a, mu, eta, normalStress, state);
} else if (friction_model == std::string("Laursen")) { } else if (friction_model == std::string("Laursen")) {
return Dune::make_shared<Dune::GlobalLaursenNonlinearity< return Dune::make_shared<Dune::GlobalLaursenNonlinearity<
Dune::LinearFunction, VectorType, MatrixType> const>(mu, normalStress, Dune::LinearFunction, VectorType, MatrixType> const>(mu, normalStress,
...@@ -269,8 +270,10 @@ int main(int argc, char *argv[]) { ...@@ -269,8 +270,10 @@ int main(int argc, char *argv[]) {
auto nodalIntegrals = auto nodalIntegrals =
assemble_frictional<GridType, GridView, SmallVector, P1Basis>( assemble_frictional<GridType, GridView, SmallVector, P1Basis>(
leafView, p1Basis, frictionalNodes); leafView, p1Basis, frictionalNodes);
auto myGlobalNonlinearity = assemble_nonlinearity<VectorType, OperatorType>( auto state =
grid->size(grid->maxLevel(), dim), parset, nodalIntegrals); Dune::make_shared<Dune::BlockVector<Dune::FieldVector<double, 1>>>(
grid->size(grid->maxLevel(), dim));
*state = 0.0;
// {{{ Set up TNNMG solver // {{{ Set up TNNMG solver
// linear iteration step components // linear iteration step components
...@@ -334,6 +337,10 @@ int main(int argc, char *argv[]) { ...@@ -334,6 +337,10 @@ int main(int argc, char *argv[]) {
stiffnessMatrix.mmv(u4, b4); stiffnessMatrix.mmv(u4, b4);
if (parset.get<bool>("solver.nonlineargs.use")) { if (parset.get<bool>("solver.nonlineargs.use")) {
auto myGlobalNonlinearity =
assemble_nonlinearity<VectorType, OperatorType>(
grid->size(grid->maxLevel(), dim), parset, nodalIntegrals,
state);
MyConvexProblemType myConvexProblem(stiffnessMatrix, MyConvexProblemType myConvexProblem(stiffnessMatrix,
*myGlobalNonlinearity, b1); *myGlobalNonlinearity, b1);
MyBlockProblemType myBlockProblem(parset, myConvexProblem); MyBlockProblemType myBlockProblem(parset, myConvexProblem);
...@@ -349,6 +356,10 @@ int main(int argc, char *argv[]) { ...@@ -349,6 +356,10 @@ int main(int argc, char *argv[]) {
u1 += u1_diff; u1 += u1_diff;
if (parset.get<bool>("solver.tnnmg.use")) { if (parset.get<bool>("solver.tnnmg.use")) {
auto myGlobalNonlinearity =
assemble_nonlinearity<VectorType, OperatorType>(
grid->size(grid->maxLevel(), dim), parset, nodalIntegrals,
state);
MyConvexProblemType myConvexProblem(stiffnessMatrix, MyConvexProblemType myConvexProblem(stiffnessMatrix,
*myGlobalNonlinearity, b4); *myGlobalNonlinearity, b4);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment