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

Make RuinaFunction convex(!)

parent 2324ce75
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,9 @@ class NiceFunction { ...@@ -27,7 +27,9 @@ class NiceFunction {
// Whether H(|.|) is smooth at zero // Whether H(|.|) is smooth at zero
bool virtual smoothesNorm() const { return false; } bool virtual smoothesNorm() const { return false; }
void virtual evaluate(double const &x, double &y) const = 0; void virtual evaluate(double const &x, double &y) const {
DUNE_THROW(NotImplemented, "evaluation not implemented");
}
}; };
class RuinaFunction : public NiceFunction { class RuinaFunction : public NiceFunction {
...@@ -35,30 +37,20 @@ class RuinaFunction : public NiceFunction { ...@@ -35,30 +37,20 @@ class RuinaFunction : public NiceFunction {
RuinaFunction(double coefficient, double a, double mu, double eta, RuinaFunction(double coefficient, double a, double mu, double eta,
double normalStress, double b, double state, double L, double h) double normalStress, double b, double state, double L, double h)
: a(a), : a(a),
mu(mu),
eta(eta),
h(h), h(h),
coefficientProduct(coefficient * normalStress), coefficientProduct(coefficient * normalStress),
c(mu + (a - b) * std::log(eta) - b * std::log(L)), K(b *
K(b * state) // state is assumed to be logarithmic (state - std::log(eta * L))), // state is assumed to be logarithmic
{} rho(std::exp(-(mu + K) / a)) {}
void virtual evaluate(double const &x, double &y) const {
double const arg = x / h;
if (arg == 0) { // TODO: Make this controllable
y = 0;
return;
}
double const expstar = arg * std::log(arg) - arg;
y = a * expstar + (c + K) * arg;
y *= coefficientProduct * h;
}
double virtual leftDifferential(double x) const { double virtual leftDifferential(double x) const {
double const arg = x / h; double const arg = x / h * eta;
if (arg < 1e-14) // TODO: Make this controllable if (arg <= rho)
return 0; return 0;
double const ret = (a * std::log(arg) + c + K); double const ret = a * std::log(arg) + mu + K;
return coefficientProduct * ret; return coefficientProduct * ret;
} }
...@@ -66,26 +58,31 @@ class RuinaFunction : public NiceFunction { ...@@ -66,26 +58,31 @@ class RuinaFunction : public NiceFunction {
return leftDifferential(s); return leftDifferential(s);
} }
double virtual second_deriv(double s) const { double virtual second_deriv(double x) const {
if (s < 1e-14) // TODO: Make this controllable double const arg = x / h * eta;
if (arg <= rho)
return 0; return 0;
return coefficientProduct * a / s; return coefficientProduct * a / x;
} }
double virtual regularity(double s) const { double virtual regularity(double x) const {
if (s == 0) double const arg = x / h * eta;
// TODO: Make this controllable
if (arg < 1e-14 || std::abs(arg - rho) < 1e-14)
return std::numeric_limits<double>::infinity(); return std::numeric_limits<double>::infinity();
return std::abs(second_deriv(s)); return std::abs(second_deriv(x));
} }
private: private:
double const a; double const a;
double const mu;
double const eta;
double const h; double const h;
double const coefficientProduct; double const coefficientProduct;
double const c;
double const K; double const K;
double const rho;
}; };
class LinearFunction : public NiceFunction { class LinearFunction : public NiceFunction {
......
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