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 220 additions and 66 deletions
#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_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_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>
......
......@@ -12,13 +12,6 @@
#include "mygeometry.hh"
double MyGeometry::verticalProjection(LocalVector const &x) {
return zenith * x;
}
double MyGeometry::horizontalProjection(LocalVector const &x) {
return orthogonalZenith * x;
}
void MyGeometry::write() {
std::fstream writer("geometry", std::fstream::out);
writer << "A = " << A << std::endl;
......
......@@ -11,24 +11,6 @@ namespace {
using LocalMatrix2D = Dune::FieldMatrix<double, 2, 2>;
using LocalVector = Dune::FieldVector<double, MY_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;
}
}
namespace reference {
......@@ -42,34 +24,31 @@ namespace reference {
double const zDistance = 0.35;
LocalVector2D const A = createVector(0, 0);
LocalVector2D const B = createVector(leftLeg, -rightLeg);
LocalVector2D const C = createVector(leftLeg, 0);
LocalVector2D const A = {0, 0};
LocalVector2D const B = {leftLeg, -rightLeg};
LocalVector2D const C = {leftLeg, 0};
LocalVector2D const Z = createVector(zDistance * s, 0);
LocalVector2D const Y =
createVector(zDistance * s, -zDistance *s / leftLeg * rightLeg);
LocalVector2D const X = createVector(Y[0] - weakLen * std::cos(leftAngle),
Y[1] + weakLen * std::sin(leftAngle));
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 U = createVector(X[0], 0);
LocalVector2D const U = {X[0], 0};
LocalVector2D const K =
createVector(B[0] - leftLeg * viscoHeight / rightLeg, B[1] + viscoHeight);
LocalVector2D const M = createVector(B[0], B[1] + viscoHeight);
LocalVector2D const K = {B[0] - leftLeg * viscoHeight / rightLeg,
B[1] + viscoHeight};
LocalVector2D const M = {B[0], B[1] + viscoHeight};
LocalVector2D const G = midPoint(A, X);
LocalVector2D const H = midPoint(X, Y);
LocalVector2D const J = midPoint(Y, B);
LocalVector2D const I = createVector(Y[0] + G[0], Y[1] + G[1]);
LocalVector2D const I = {Y[0] + G[0], Y[1] + G[1]};
LocalVector2D const zenith = createVector(0, 1);
LocalVector2D const orthogonalZenith = createVector(-1, 0);
LocalVector2D const zenith = {0, 1};
LocalMatrix2D const rotation =
createMatrix(std::cos(leftAngle), -std::sin(leftAngle),
std::sin(leftAngle), std::cos(leftAngle));
LocalMatrix2D const rotation = {{std::cos(leftAngle), -std::sin(leftAngle)},
{std::sin(leftAngle), std::cos(leftAngle)}};
}
namespace {
......@@ -102,10 +81,6 @@ LocalVector const Y = rotate(reference::Y);
LocalVector const Z = rotate(reference::Z);
LocalVector const zenith = rotate(reference::zenith);
LocalVector const orthogonalZenith = rotate(reference::orthogonalZenith);
double verticalProjection(LocalVector const &);
double horizontalProjection(LocalVector const &);
void write();
......
#ifndef SRC_SAND_WEDGE_DATA_MYGLOBALFRICTIONDATA_HH
#define SRC_SAND_WEDGE_DATA_MYGLOBALFRICTIONDATA_HH
#ifndef SRC_ONE_BODY_PROBLEM_DATA_MYGLOBALFRICTIONDATA_HH
#define SRC_ONE_BODY_PROBLEM_DATA_MYGLOBALFRICTIONDATA_HH
#include <dune/common/function.hh>
......
......@@ -2,9 +2,11 @@
#include "config.h"
#endif
#include <dune/fufem/geometry/polyhedrondistance.hh>
#include "mygrid.hh"
#include "midpoint.hh"
#include "../distances.hh"
#include "../diameter.hh"
#if MY_DIM == 3
SimplexManager::SimplexManager(unsigned int shift) : shift_(shift) {}
......@@ -199,11 +201,11 @@ void refine(Grid &grid, ConvexPolyhedron<LocalVector> const &weakPatch,
bool needRefine = true;
while (true) {
needRefine = false;
for (auto it = grid.template leafbegin<0>();
it != grid.template leafend<0>(); ++it) {
auto const geometry = it->geometry();
for (auto &&e : elements(grid.leafGridView())) {
auto const geometry = e.geometry();
auto const weakeningRegionDistance = distance(geometry, weakPatch);
auto const weakeningRegionDistance =
distance(weakPatch, geometry, 1e-6 * MyGeometry::lengthScale);
auto const admissibleDiameter =
computeAdmissibleDiameter(weakeningRegionDistance, smallestDiameter);
......@@ -211,7 +213,7 @@ void refine(Grid &grid, ConvexPolyhedron<LocalVector> const &weakPatch,
continue;
needRefine = true;
grid.mark(1, *it);
grid.mark(1, e);
}
if (!needRefine)
break;
......
#ifndef SRC_SAND_WEDGE_DATA_MYGRID_HH
#define SRC_SAND_WEDGE_DATA_MYGRID_HH
#include <boost/range/irange.hpp>
#ifndef SRC_ONE_BODY_PROBLEM_DATA_MYGRID_HH
#define SRC_ONE_BODY_PROBLEM_DATA_MYGRID_HH
#include <dune/common/fmatrix.hh>
#include <dune/grid/common/gridfactory.hh>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#include <dune/fufem/boundarypatch.hh>
#pragma clang diagnostic pop
#include <dune/tectonic/convexpolyhedron.hh>
#include <dune/fufem/geometry/convexpolyhedron.hh>
#include "mygeometry.hh"
......