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

[Cleanup] Compile state updaters separately

parent a0c97b56
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ common_sources = \
boundary_writer.cc \
friction_writer.cc \
solverfactory.cc \
state.cc \
timestepping.cc \
vtk.cc
......
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "state.hh"
#include "state/ageinglawstateupdater.cc"
#include "state/sliplawstateupdater.cc"
template <class ScalarVector, class Vector>
std::shared_ptr<StateUpdater<ScalarVector, Vector>> initStateUpdater(
Config::stateModel model, ScalarVector const &alpha_initial,
Dune::BitSetVector<1> const &frictionalNodes, double L, double V0) {
switch (model) {
case Config::AgeingLaw:
return std::make_shared<AgeingLawStateUpdater<ScalarVector, Vector>>(
alpha_initial, frictionalNodes, L, V0);
case Config::SlipLaw:
return std::make_shared<SlipLawStateUpdater<ScalarVector, Vector>>(
alpha_initial, frictionalNodes, L, V0);
default:
assert(false);
}
}
#include "state_tmpl.cc"
......@@ -6,6 +6,7 @@
#include <dune/common/bitsetvector.hh>
#include "enums.hh"
#include "state/stateupdater.hh"
#include "state/ageinglawstateupdater.hh"
#include "state/sliplawstateupdater.hh"
......@@ -13,16 +14,6 @@
template <class ScalarVector, class Vector>
std::shared_ptr<StateUpdater<ScalarVector, Vector>> initStateUpdater(
Config::stateModel model, ScalarVector const &alpha_initial,
Dune::BitSetVector<1> const &frictionalNodes, double L, double V0) {
switch (model) {
case Config::AgeingLaw:
return std::make_shared<AgeingLawStateUpdater<ScalarVector, Vector>>(
alpha_initial, frictionalNodes, L, V0);
case Config::SlipLaw:
return std::make_shared<SlipLawStateUpdater<ScalarVector, Vector>>(
alpha_initial, frictionalNodes, L, V0);
default:
assert(false);
}
}
Dune::BitSetVector<1> const &frictionalNodes, double L, double V0);
#endif
#include "ageinglawstateupdater.hh"
template <class ScalarVector, class Vector>
AgeingLawStateUpdater<ScalarVector, Vector>::AgeingLawStateUpdater(
ScalarVector _alpha_initial, Dune::BitSetVector<1> const &_nodes, double _L,
double _V0)
: alpha(_alpha_initial), nodes(_nodes), L(_L), V0(_V0) {}
template <class ScalarVector, class Vector>
void AgeingLawStateUpdater<ScalarVector, Vector>::nextTimeStep() {
alpha_o = alpha;
}
template <class ScalarVector, class Vector>
void AgeingLawStateUpdater<ScalarVector, Vector>::setup(double _tau) {
tau = _tau;
}
/*
Compute [ 1-\exp(c*x) ] / x under the assumption that x is
non-negative
*/
double liftSingularity(double c, double x) {
if (x <= 0)
return -c;
else
return -std::expm1(c * x) / x;
}
template <class ScalarVector, class Vector>
void AgeingLawStateUpdater<ScalarVector, Vector>::solve(
Vector const &velocity_field) {
for (size_t i = 0; i < nodes.size(); ++i) {
if (not toBool(nodes[i]))
continue;
double const V = velocity_field[i].two_norm();
double const mtoL = -tau / L;
alpha[i] = std::log(std::exp(alpha_o[i] + V * mtoL) +
V0 * liftSingularity(mtoL, V));
}
}
template <class ScalarVector, class Vector>
void AgeingLawStateUpdater<ScalarVector, Vector>::extractAlpha(
ScalarVector &_alpha) {
_alpha = alpha;
}
......@@ -24,51 +24,4 @@ class AgeingLawStateUpdater : public StateUpdater<ScalarVector, Vector> {
double const V0;
double tau;
};
template <class ScalarVector, class Vector>
AgeingLawStateUpdater<ScalarVector, Vector>::AgeingLawStateUpdater(
ScalarVector _alpha_initial, Dune::BitSetVector<1> const &_nodes, double _L,
double _V0)
: alpha(_alpha_initial), nodes(_nodes), L(_L), V0(_V0) {}
template <class ScalarVector, class Vector>
void AgeingLawStateUpdater<ScalarVector, Vector>::nextTimeStep() {
alpha_o = alpha;
}
template <class ScalarVector, class Vector>
void AgeingLawStateUpdater<ScalarVector, Vector>::setup(double _tau) {
tau = _tau;
}
/*
Compute [ 1-\exp(c*x) ] / x under the assumption that x is
non-negative
*/
double liftSingularity(double c, double x) {
if (x <= 0)
return -c;
else
return -std::expm1(c * x) / x;
}
template <class ScalarVector, class Vector>
void AgeingLawStateUpdater<ScalarVector, Vector>::solve(
Vector const &velocity_field) {
for (size_t i = 0; i < nodes.size(); ++i) {
if (not toBool(nodes[i]))
continue;
double const V = velocity_field[i].two_norm();
double const mtoL = -tau / L;
alpha[i] = std::log(std::exp(alpha_o[i] + V * mtoL) +
V0 * liftSingularity(mtoL, V));
}
}
template <class ScalarVector, class Vector>
void AgeingLawStateUpdater<ScalarVector, Vector>::extractAlpha(
ScalarVector &_alpha) {
_alpha = alpha;
}
#endif
#include "sliplawstateupdater.hh"
template <class ScalarVector, class Vector>
SlipLawStateUpdater<ScalarVector, Vector>::SlipLawStateUpdater(
ScalarVector _alpha_initial, Dune::BitSetVector<1> const &_nodes, double _L,
double _V0)
: alpha(_alpha_initial), nodes(_nodes), L(_L), V0(_V0) {}
template <class ScalarVector, class Vector>
void SlipLawStateUpdater<ScalarVector, Vector>::nextTimeStep() {
alpha_o = alpha;
}
template <class ScalarVector, class Vector>
void SlipLawStateUpdater<ScalarVector, Vector>::setup(double _tau) {
tau = _tau;
}
template <class ScalarVector, class Vector>
void SlipLawStateUpdater<ScalarVector, Vector>::solve(
Vector const &velocity_field) {
for (size_t i = 0; i < nodes.size(); ++i) {
if (not toBool(nodes[i]))
continue;
double const V = velocity_field[i].two_norm();
double const mtVoL = -tau * V / L;
alpha[i] = (V <= 0) ? alpha_o[i] : std::expm1(mtVoL) * std::log(V / V0) +
alpha_o[i] * std::exp(mtVoL);
}
}
template <class ScalarVector, class Vector>
void SlipLawStateUpdater<ScalarVector, Vector>::extractAlpha(
ScalarVector &_alpha) {
_alpha = alpha;
}
......@@ -25,40 +25,4 @@ class SlipLawStateUpdater : public StateUpdater<ScalarVector, Vector> {
double tau;
};
template <class ScalarVector, class Vector>
SlipLawStateUpdater<ScalarVector, Vector>::SlipLawStateUpdater(
ScalarVector _alpha_initial, Dune::BitSetVector<1> const &_nodes, double _L,
double _V0)
: alpha(_alpha_initial), nodes(_nodes), L(_L), V0(_V0) {}
template <class ScalarVector, class Vector>
void SlipLawStateUpdater<ScalarVector, Vector>::nextTimeStep() {
alpha_o = alpha;
}
template <class ScalarVector, class Vector>
void SlipLawStateUpdater<ScalarVector, Vector>::setup(double _tau) {
tau = _tau;
}
template <class ScalarVector, class Vector>
void SlipLawStateUpdater<ScalarVector, Vector>::solve(
Vector const &velocity_field) {
for (size_t i = 0; i < nodes.size(); ++i) {
if (not toBool(nodes[i]))
continue;
double const V = velocity_field[i].two_norm();
double const mtVoL = -tau * V / L;
alpha[i] = (V <= 0) ? alpha_o[i] : std::expm1(mtVoL) * std::log(V / V0) +
alpha_o[i] * std::exp(mtVoL);
}
}
template <class ScalarVector, class Vector>
void SlipLawStateUpdater<ScalarVector, Vector>::extractAlpha(
ScalarVector &_alpha) {
_alpha = alpha;
}
#endif
#include "explicitvectors.hh"
template std::shared_ptr<StateUpdater<ScalarVector, Vector>> initStateUpdater<
ScalarVector, Vector>(Config::stateModel model,
ScalarVector const &alpha_initial,
Dune::BitSetVector<1> const &frictionalNodes,
double L, double V0);
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