Forked from
agnumpde / dune-tectonic
188 commits behind the upstream repository.
-
Elias Pipping authoredElias Pipping authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
frictionpotential.hh 2.17 KiB
#ifndef DUNE_TECTONIC_FRICTIONPOTENTIAL_HH
#define DUNE_TECTONIC_FRICTIONPOTENTIAL_HH
#include <algorithm>
#include <cassert>
#include <cmath>
#include <limits>
#include <dune/common/exceptions.hh>
#include <dune/common/function.hh>
#include "frictiondata.hh"
class FrictionPotentialWrapper {
public:
virtual ~FrictionPotentialWrapper() {}
double virtual differential(double s) const = 0;
double virtual second_deriv(double x) const = 0;
double virtual regularity(double s) const = 0;
double virtual coefficientOfFriction(double s) const = 0;
double virtual evaluate(double x) const {
DUNE_THROW(Dune::NotImplemented, "evaluation not implemented");
}
void virtual updateLogState(double) = 0;
};
class FrictionPotential : public FrictionPotentialWrapper {
public:
FrictionPotential(double coefficient, double _normalStress, FrictionData _fd)
: fd(_fd), weight(coefficient), normalStress(_normalStress) {}
double coefficientOfFriction(double V) const {
assert(V >= 0.0);
if (V <= Vmin)
return 0.0;
return fd.a * (std::log(V / fd.V0) + logrest);
}
double differential(double V) const {
return weight * (fd.C - normalStress * coefficientOfFriction(V));
}
double second_deriv(double V) const {
assert(V >= 0);
if (V <= Vmin)
return 0;
return weight * (-normalStress) * (fd.a / V);
}
double regularity(double V) const {
assert(V >= 0);
if (std::abs(V - Vmin) < 1e-14) // TODO
return std::numeric_limits<double>::infinity();
return std::abs(second_deriv(V));
}
void updateLogState(double logState) {
logrest = (fd.mu0 + fd.b * (logState + std::log(fd.V0 / fd.L))) / fd.a;
Vmin = fd.V0 / std::exp(logrest);
}
private:
FrictionData const fd;
double const weight;
double const normalStress;
double logrest;
double Vmin;
};
class TrivialFunction : public FrictionPotentialWrapper {
public:
double evaluate(double) const { return 0; }
double coefficientOfFriction(double s) const { return 0; }
double differential(double) const { return 0; }
double second_deriv(double) const { return 0; }
double regularity(double) const { return 0; }
void updateLogState(double) {}
};
#endif