Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • podlesny/dune-tectonic
  • agnumpde/dune-tectonic
2 results
Show changes
Showing
with 420 additions and 15 deletions
#include "../explicitvectors.hh"
#include "../explicitgrid.hh"
#include "../program_state.hh"
using MyProgramState = ProgramState<Vector, ScalarVector>;
using P1Basis = P1NodalBasis<GridView, double>;
using MyFunction = BasisGridFunction<P1Basis, Vector>;
template class GridEvaluator<LocalVector, GridView>;
template Dune::Matrix<typename MyFunction::RangeType>
GridEvaluator<LocalVector, GridView>::evaluate(MyFunction const &f) const;
template class PatchInfoWriter<MyProgramState, P1Basis, GridView>;
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "restart-io.hh"
template <class ProgramState>
RestartIO<ProgramState>::RestartIO(HDF5::Grouplike &group, size_t vertexCount)
: displacementWriter_(group, "displacement", vertexCount,
Vector::block_type::dimension),
velocityWriter_(group, "velocity", vertexCount,
Vector::block_type::dimension),
accelerationWriter_(group, "acceleration", vertexCount,
Vector::block_type::dimension),
stateWriter_(group, "state", vertexCount),
weightedNormalStressWriter_(group, "weightedNormalStress", vertexCount),
relativeTimeWriter_(group, "relativeTime"),
relativeTimeIncrementWriter_(group, "relativeTimeIncrement") {}
template <class ProgramState>
void RestartIO<ProgramState>::write(ProgramState const &programState) {
addEntry(displacementWriter_, programState.timeStep, programState.u);
addEntry(velocityWriter_, programState.timeStep, programState.v);
addEntry(accelerationWriter_, programState.timeStep, programState.a);
addEntry(stateWriter_, programState.timeStep, programState.alpha);
addEntry(weightedNormalStressWriter_, programState.timeStep,
programState.weightedNormalStress);
addEntry(relativeTimeWriter_, programState.timeStep,
programState.relativeTime);
addEntry(relativeTimeIncrementWriter_, programState.timeStep,
programState.relativeTau);
}
template <class ProgramState>
void RestartIO<ProgramState>::read(size_t timeStep,
ProgramState &programState) {
programState.timeStep = timeStep;
readEntry(displacementWriter_, timeStep, programState.u);
readEntry(velocityWriter_, timeStep, programState.v);
readEntry(accelerationWriter_, timeStep, programState.a);
readEntry(stateWriter_, timeStep, programState.alpha);
readEntry(weightedNormalStressWriter_, timeStep,
programState.weightedNormalStress);
readEntry(relativeTimeWriter_, timeStep, programState.relativeTime);
readEntry(relativeTimeIncrementWriter_, timeStep, programState.relativeTau);
}
#include "restart-io_tmpl.cc"
#ifndef SRC_HDF_RESTART_HDF_HH
#define SRC_HDF_RESTART_HDF_HH
#include <dune/fufem/hdf5/file.hh>
#include <dune/fufem/hdf5/sequenceio.hh>
template <class ProgramState> class RestartIO {
using ScalarVector = typename ProgramState::ScalarVector;
using Vector = typename ProgramState::Vector;
public:
RestartIO(HDF5::Grouplike &group, size_t vertexCount);
void write(ProgramState const &programState);
void read(size_t timeStep, ProgramState &programState);
private:
HDF5::SequenceIO<2> displacementWriter_;
HDF5::SequenceIO<2> velocityWriter_;
HDF5::SequenceIO<2> accelerationWriter_;
HDF5::SequenceIO<1> stateWriter_;
HDF5::SequenceIO<1> weightedNormalStressWriter_;
HDF5::SequenceIO<0> relativeTimeWriter_;
HDF5::SequenceIO<0> relativeTimeIncrementWriter_;
};
#endif
#include "../explicitvectors.hh"
#include "../program_state.hh"
using MyProgramState = ProgramState<Vector, ScalarVector>;
template class RestartIO<MyProgramState>;
#ifndef SRC_HDF5_RESTRICT_HH
#define SRC_HDF5_RESTRICT_HH
#include <cassert>
#include <dune/common/bitsetvector.hh>
#include "../tobool.hh"
template <class Vector, class Patch>
Vector restrictToSurface(Vector const &v1, Patch const &patch) {
auto const &vertices = *patch.getVertices();
assert(vertices.size() == v1.size());
Vector ret(vertices.count());
auto target = ret.begin();
for (size_t i = 0; i < v1.size(); ++i)
if (toBool(vertices[i]))
*(target++) = v1[i];
assert(target == ret.end());
return ret;
}
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "restrict.hh"
#include "surface-writer.hh"
template <class ProgramState, class GridView>
SurfaceWriter<ProgramState, GridView>::SurfaceWriter(
HDF5::Grouplike &file, Vector const &vertexCoordinates, Patch const &surface)
: group_(file, "surface"),
surface_(surface),
surfaceDisplacementWriter_(group_, "displacement", surface.numVertices(),
Vector::block_type::dimension),
surfaceVelocityWriter_(group_, "velocity", surface.numVertices(),
Vector::block_type::dimension) {
auto const surfaceCoordinates = restrictToSurface(vertexCoordinates, surface);
HDF5::SingletonWriter<2> surfaceCoordinateWriter(group_, "coordinates",
surfaceCoordinates.size(),
Vector::block_type::dimension);
setEntry(surfaceCoordinateWriter, surfaceCoordinates);
}
template <class ProgramState, class GridView>
void SurfaceWriter<ProgramState, GridView>::write(
ProgramState const &programState) {
auto const surfaceDisplacements = restrictToSurface(programState.u, surface_);
addEntry(surfaceDisplacementWriter_, programState.timeStep,
surfaceDisplacements);
auto const surfaceVelocities = restrictToSurface(programState.v, surface_);
addEntry(surfaceVelocityWriter_, programState.timeStep, surfaceVelocities);
}
#include "surface-writer_tmpl.cc"
#ifndef SRC_HDF_SURFACE_WRITER_HH
#define SRC_HDF_SURFACE_WRITER_HH
#include <dune/fufem/boundarypatch.hh>
#include <dune/fufem/hdf5/sequenceio.hh>
#include <dune/fufem/hdf5/singletonwriter.hh>
template <class ProgramState, class GridView> class SurfaceWriter {
using Vector = typename ProgramState::Vector;
using Patch = BoundaryPatch<GridView>;
public:
SurfaceWriter(HDF5::Grouplike &file, Vector const &vertexCoordinates,
Patch const &surface);
void write(ProgramState const &programState);
private:
HDF5::Group group_;
Patch const &surface_;
HDF5::SequenceIO<2> surfaceDisplacementWriter_;
HDF5::SequenceIO<2> surfaceVelocityWriter_;
};
#endif
#include "../explicitvectors.hh"
#include "../explicitgrid.hh"
#include "../program_state.hh"
using MyProgramState = ProgramState<Vector, ScalarVector>;
template class SurfaceWriter<MyProgramState, GridView>;
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "time-writer.hh"
template <class ProgramState>
TimeWriter<ProgramState>::TimeWriter(HDF5::Grouplike &file)
: file_(file),
relativeTimeWriter_(file_, "relativeTime"),
relativeTimeIncrementWriter_(file_, "relativeTimeIncrement") {}
template <class ProgramState>
void TimeWriter<ProgramState>::write(ProgramState const &programState) {
addEntry(relativeTimeWriter_, programState.timeStep,
programState.relativeTime);
addEntry(relativeTimeIncrementWriter_, programState.timeStep,
programState.relativeTau);
}
#include "time-writer_tmpl.cc"
#ifndef SRC_HDF_TIME_WRITER_HH
#define SRC_HDF_TIME_WRITER_HH
#include <dune/fufem/hdf5/file.hh>
#include <dune/fufem/hdf5/sequenceio.hh>
template <class ProgramState> class TimeWriter {
public:
TimeWriter(HDF5::Grouplike &file);
void write(ProgramState const &programState);
private:
HDF5::Grouplike &file_;
HDF5::SequenceIO<0> relativeTimeWriter_;
HDF5::SequenceIO<0> relativeTimeIncrementWriter_;
};
#endif
#include "../explicitvectors.hh"
#include "../program_state.hh"
using MyProgramState = ProgramState<Vector, ScalarVector>;
template class TimeWriter<MyProgramState>;
#ifndef SRC_MATRICES_HH
#define SRC_MATRICES_HH
template <class Matrix> struct Matrices {
Matrix elasticity;
Matrix damping;
Matrix mass;
};
#endif
# -*- mode:conf -*-
[boundary.friction]
smallestDiameter= 2e-3 # [m]
[timeSteps]
refinementTolerance = 1e-5
[u0.solver]
tolerance = 1e-8
[a0.solver]
tolerance = 1e-8
[v.solver]
tolerance = 1e-8
[v.fpi]
tolerance = 1e-5
[solver.tnnmg.linear]
tolerance = 1e-10
# -*- mode:conf -*-
[boundary.friction]
smallestDiameter= 2e-2 # [m]
[boundary.friction.weakening]
patchType = Trapezoidal
[timeSteps]
refinementTolerance = 1e-5
[u0.solver]
tolerance = 1e-6
[a0.solver]
tolerance = 1e-6
[v.solver]
tolerance = 1e-6
[v.fpi]
tolerance = 1e-5
[solver.tnnmg.linear]
tolerance = 1e-10
#ifndef SRC_ONE_BODY_PROBLEM_DATA_BC_HH
#define SRC_ONE_BODY_PROBLEM_DATA_BC_HH
class VelocityDirichletCondition
: public Dune::VirtualFunction<double, double> {
void evaluate(double const &relativeTime, double &y) const {
// Assumed to vanish at time zero
double const finalVelocity = -5e-5;
y = (relativeTime <= 0.1)
? finalVelocity * (1.0 - std::cos(relativeTime * M_PI / 0.1)) / 2.0
: finalVelocity;
}
};
class NeumannCondition : public Dune::VirtualFunction<double, double> {
void evaluate(double const &relativeTime, double &y) const { y = 0.0; }
};
#endif
#ifndef SRC_MIDPOINT_HH
#define SRC_MIDPOINT_HH
#include <dune/solvers/common/arithmetic.hh>
template <class Vector> Vector midPoint(Vector const &x, Vector const &y) {
Vector ret(0);
Arithmetic::addProduct(ret, 0.5, x);
Arithmetic::addProduct(ret, 0.5, y);
return ret;
}
#endif
#ifndef SRC_SAND_WEDGE_DATA_MYBODY_HH
#define SRC_SAND_WEDGE_DATA_MYBODY_HH
#ifndef SRC_ONE_BODY_PROBLEM_DATA_MYBODY_HH
#define SRC_ONE_BODY_PROBLEM_DATA_MYBODY_HH
#include <dune/common/fvector.hh>
......@@ -8,8 +8,8 @@
#include <dune/tectonic/body.hh>
#include <dune/tectonic/gravity.hh>
#include "twopiece.hh"
#include "mygeometry.hh"
#include "segmented-function.hh"
template <int dimension> class MyBody : public Body<dimension> {
using typename Body<dimension>::ScalarFunction;
......@@ -47,9 +47,9 @@ template <int dimension> class MyBody : public Body<dimension> {
private:
double const poissonRatio_;
double const youngModulus_;
TwoPieceFunction const shearViscosityField_;
TwoPieceFunction const bulkViscosityField_;
TwoPieceFunction const densityField_;
SegmentedFunction const shearViscosityField_;
SegmentedFunction const bulkViscosityField_;
SegmentedFunction const densityField_;
Gravity<dimension> const gravityField_;
};
#endif
......@@ -4,14 +4,13 @@
#include <fstream>
#include "mygeometry.hh"
#ifdef HAVE_CAIROMM
#include <cairomm/context.h>
#include <cairomm/fontface.h>
#include <cairomm/surface.h>
#endif
double MyGeometry::verticalProjection(LocalVector const &x) {
return zenith * x;
}
double MyGeometry::horizontalProjection(LocalVector const &x) {
return rotatedZenith * x;
}
#include "mygeometry.hh"
void MyGeometry::write() {
std::fstream writer("geometry", std::fstream::out);
......@@ -126,8 +125,7 @@ void MyGeometry::render() {
// labels
{
auto const label = [&](LocalVector2D const &v,
std::string l) { // TODO: implicit?
auto const label = [&](LocalVector2D const &v, std::string l) {
moveTo(v);
cr->rel_move_to(0.005, -0.02);
cr->show_text(l);
......
......@@ -3,96 +3,68 @@
#include <dune/common/fvector.hh>
#include <dune/fufem/arithmetic.hh>
#ifdef HAVE_CAIROMM
#include <cairomm/context.h>
#include <cairomm/fontface.h>
#include <cairomm/surface.h>
#endif
#include "midpoint.hh"
namespace MyGeometry {
namespace {
using LocalVector2D = Dune::FieldVector<double, 2>;
using LocalMatrix2D = Dune::FieldMatrix<double, 2, 2>;
using LocalVector = Dune::FieldVector<double, DIM>;
// kludge because fieldvectors have no initialiser_list constructor, see
// https://dune-project.org/flyspray/index.php?do=details&task_id=1166
LocalVector2D createVector(double x, double y) {
LocalVector2D ret{ 0 };
ret[0] = x;
ret[1] = y;
return ret;
}
LocalMatrix2D createMatrix(double a11, double a12, double a21, double a22) {
LocalMatrix2D ret{ 0 };
ret[0][0] = a11;
ret[0][1] = a12;
ret[1][0] = a21;
ret[1][1] = a22;
return ret;
}
LocalVector2D convexCombination(LocalVector2D const &x,
LocalVector2D const &y) {
LocalVector2D ret{ 0 };
Arithmetic::addProduct(ret, 0.5, x);
Arithmetic::addProduct(ret, 0.5, y);
return ret;
}
using LocalVector = Dune::FieldVector<double, MY_DIM>;
}
namespace reference {
double const rightLeg = 0.27;
double const leftLeg = 1.00;
double const s = 1.0; // scaling factor
double const rightLeg = 0.27 * s;
double const leftLeg = 1.00 * s;
double const leftAngle = atan(rightLeg / leftLeg);
double const viscoHeight = 0.06; // Height of the viscous bottom layer
double const weakLen = 0.20; // Length of the weak zone
double const viscoHeight = 0.06 * s; // Height of the viscous bottom layer
double const weakLen = 0.20 * s; // Length of the weak zone
LocalVector2D const A = createVector(0, 0);
LocalVector2D const B = createVector(leftLeg, -rightLeg);
LocalVector2D const C = createVector(leftLeg, 0);
double const zDistance = 0.35;
LocalVector2D const Z = createVector(0.35, 0);
LocalVector2D const Y = createVector(0.35, -0.35 / leftLeg * rightLeg);
LocalVector2D const X = createVector(Y[0] - weakLen * std::cos(leftAngle),
Y[1] + weakLen * std::sin(leftAngle));
LocalVector2D const A = {0, 0};
LocalVector2D const B = {leftLeg, -rightLeg};
LocalVector2D const C = {leftLeg, 0};
LocalVector2D const U = createVector(X[0], 0);
LocalVector2D const Z = {zDistance * s, 0};
LocalVector2D const Y = {zDistance * s, -zDistance *s / leftLeg *rightLeg};
LocalVector2D const X = {Y[0] - weakLen * std::cos(leftAngle),
Y[1] + weakLen *std::sin(leftAngle)};
LocalVector2D const K =
createVector(B[0] - leftLeg * viscoHeight / rightLeg, B[1] + viscoHeight);
LocalVector2D const M = createVector(B[0], B[1] + viscoHeight);
LocalVector2D const U = {X[0], 0};
LocalVector2D const G = convexCombination(A, X);
LocalVector2D const H = convexCombination(X, Y);
LocalVector2D const J = convexCombination(Y, B);
LocalVector2D const K = {B[0] - leftLeg * viscoHeight / rightLeg,
B[1] + viscoHeight};
LocalVector2D const M = {B[0], B[1] + viscoHeight};
LocalVector2D const I = createVector(Y[0] + G[0], Y[1] + G[1]);
LocalVector2D const G = midPoint(A, X);
LocalVector2D const H = midPoint(X, Y);
LocalVector2D const J = midPoint(Y, B);
LocalVector2D const zenith = createVector(0, 1);
LocalVector2D const rotatedZenith = createVector(-1, 0);
LocalVector2D const I = {Y[0] + G[0], Y[1] + G[1]};
LocalMatrix2D const rotation =
createMatrix(std::cos(leftAngle), -std::sin(leftAngle),
std::sin(leftAngle), std::cos(leftAngle));
LocalVector2D const zenith = {0, 1};
LocalMatrix2D const rotation = {{std::cos(leftAngle), -std::sin(leftAngle)},
{std::sin(leftAngle), std::cos(leftAngle)}};
}
namespace {
LocalVector rotate(LocalVector2D const &x) {
LocalVector2D ret2D;
reference::rotation.mv(x, ret2D);
LocalVector ret{ 0 };
LocalVector ret(0);
ret[0] = ret2D[0];
ret[1] = ret2D[1];
return ret;
}
}
double const depth = 0.10;
double const lengthScale = reference::s;
double const depth = 0.60 * lengthScale;
LocalVector const A = rotate(reference::A);
LocalVector const B = rotate(reference::B);
......@@ -109,11 +81,6 @@ LocalVector const Y = rotate(reference::Y);
LocalVector const Z = rotate(reference::Z);
LocalVector const zenith = rotate(reference::zenith);
LocalVector const rotatedZenith =
rotate(reference::rotatedZenith); // FIXME: misnomer
double verticalProjection(LocalVector const &);
double horizontalProjection(LocalVector const &);
void write();
......