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
Commits on Source (484)
Showing
with 155 additions and 285 deletions
((c++-mode . ((c-basic-offset . 2)
(c-file-style . "gnu")
(indent-tabs-mode . nil)
(show-trailing-whitespace . nil))))
*.pyc
/aclocal.m4
/am
/autom4te.cache
/build_*
/config.guess
/config.h.in
/config.sub
/configure
/depcomp
/dependencies.m4
/install-sh
/ltmain.sh
/missing
/test-driver
Makefile.in
\ No newline at end of file
build-cmake
cmake_minimum_required(VERSION 2.8.6)
project(dune-tectonic CXX)
if(NOT (dune-common_DIR OR dune-common_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
string(REPLACE ${CMAKE_PROJECT_NAME} dune-common dune-common_DIR
${PROJECT_BINARY_DIR})
endif()
#find dune-common and set the module path
find_package(dune-common REQUIRED)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules"
${dune-common_MODULE_PATH})
#include the dune macros
include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
find_package(HDF5 COMPONENTS C REQUIRED)
add_subdirectory("src")
add_subdirectory("dune")
add_subdirectory("doc")
add_subdirectory("cmake/modules")
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
EXTRA_DIST = dune.module
SUBDIRS = src m4 dune
include $(top_srcdir)/am/top-rules
include $(top_srcdir)/am/global-rules
set(modules "DuneTectonicMacros.cmake")
install(FILES ${modules} DESTINATION ${DUNE_INSTALL_MODULEDIR})
# File for module specific CMake tests.
/* begin dune-tectonic
put the definitions for config.h specific to
your project here. Everything above will be
overwritten
*/
/* begin private */
/* Name of package */
#define PACKAGE "@DUNE_MOD_NAME@"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "@DUNE_MAINTAINER@"
/* Define to the full name of this package. */
#define PACKAGE_NAME "@DUNE_MOD_NAME@"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "@DUNE_MOD_NAME@ @DUNE_MOD_VERSION@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "@DUNE_MOD_NAME@"
/* Define to the home page for this package. */
#define PACKAGE_URL "@DUNE_MOD_URL@"
/* Define to the version of this package. */
#define PACKAGE_VERSION "@DUNE_MOD_VERSION@"
/* end private */
/* Define to the version of dune-tectonic */
#define DUNE_TECTONIC_VERSION "@DUNE_TECTONIC_VERSION@"
/* Define to the major version of dune-tectonic */
#define DUNE_TECTONIC_VERSION_MAJOR @DUNE_TECTONIC_VERSION_MAJOR@
/* Define to the minor version of dune-tectonic */
#define DUNE_TECTONIC_VERSION_MINOR @DUNE_TECTONIC_VERSION_MINOR@
/* Define to the revision of dune-tectonic */
#define DUNE_TECTONIC_VERSION_REVISION @DUNE_TECTONIC_VERSION_REVISION@
/* end dune-tectonic
Everything below here will be overwritten
*/
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
DUNE_AC_INIT # gets module version from dune.module file
AM_INIT_AUTOMAKE
AM_SILENT_RULES
AC_CONFIG_SRCDIR([src/one-body-sample.cc])
AC_CONFIG_HEADERS([config.h])
DUNE_CHECK_ALL
AC_CONFIG_FILES([
Makefile
src/Makefile
src/tests/Makefile
dune/Makefile
dune/tectonic/Makefile
m4/Makefile
dune-tectonic.pc
])
AC_OUTPUT
# finally print the summary information
DUNE_SUMMARY_ALL
add_subdirectory("doxygen")
# shortcut for creating the Doxyfile.in and Doxyfile
add_doxygen_target()
# This file contains local changes to the doxygen configuration
# please us '+=' to add file/directories to the lists
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT += @top_srcdir@/dune/
# see e.g. dune-grid for the examples of mainpage and modules
# INPUT += @srcdir@/mainpage \
# @srcdir@/modules
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
# EXCLUDE += @top_srcdir@/dune/tectonic/test
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
# EXAMPLE_PATH += @top_srcdir@/src
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
# IMAGE_PATH += @top_srcdir@/dune/tectonic/pics
......@@ -10,6 +10,6 @@ Name: @PACKAGE_NAME@
Version: @VERSION@
Description: dune-tectonic module
URL: http://dune-project.org/
Requires: dune-common dune-fufem dune-tnnmg
#Libs: -L${libdir} -ldunetectonic
Requires: dune-common dune-fufem dune-grid dune-istl dune-solvers dune-tnnmg dune-uggrid
Libs: -L${libdir}
Cflags: -I${includedir}
......@@ -2,9 +2,7 @@
# Dune module information file #
################################
#Name of the module
Module: dune-tectonic
Version: 2.1-1
Maintainer: pipping@mi.fu-berlin.de
#depending on
Depends: dune-common dune-fufem dune-tnnmg
Version: 2.5-1
Maintainer: elias.pipping@fu-berlin.de
Depends: dune-common dune-fufem dune-grid dune-istl dune-solvers dune-tnnmg dune-uggrid
add_subdirectory(tectonic)
SUBDIRS = tectonic
include $(top_srcdir)/am/global-rules
install(FILES
body.hh
frictiondata.hh
frictionpotential.hh
globalfrictiondata.hh
globalfriction.hh
globalratestatefriction.hh
gravity.hh
localfriction.hh
minimisation.hh
myblockproblem.hh
mydirectionalconvexfunction.hh
quadraticenergy.hh
tectonic.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/tectonic)
tectonicincludedir = $(includedir)/dune/tectonic
tectonicinclude_HEADERS = tectonic.hh
include $(top_srcdir)/am/global-rules
#ifndef DUNE_TECTONIC_BODY_HH
#define DUNE_TECTONIC_BODY_HH
template <int dimension> struct Body {
using ScalarFunction =
Dune::VirtualFunction<Dune::FieldVector<double, dimension>,
Dune::FieldVector<double, 1>>;
using VectorField =
Dune::VirtualFunction<Dune::FieldVector<double, dimension>,
Dune::FieldVector<double, dimension>>;
double virtual getPoissonRatio() const = 0;
double virtual getYoungModulus() const = 0;
ScalarFunction virtual const &getShearViscosityField() const = 0;
ScalarFunction virtual const &getBulkViscosityField() const = 0;
ScalarFunction virtual const &getDensityField() const = 0;
VectorField virtual const &getGravityField() const = 0;
};
#endif
#ifndef CIRCULAR_CONVEX_FUNCTION_HH
#define CIRCULAR_CONVEX_FUNCTION_HH
#include <cmath>
#include <dune/fufem/interval.hh>
namespace Dune {
template <class MatrixType, class VectorType> class CircularConvexFunction {
public:
CircularConvexFunction(MatrixType const &A, VectorType const &b,
VectorType const &x, VectorType const &dir)
: A(A),
b(b),
x(x),
dir(dir),
xnorm(x.two_norm()),
dnorm(dir.two_norm()) {}
double quadraticPart() const { return 0; }
double linearPart() const { return 0; }
void subDiff(double m, Interval<double> &D) const {
VectorType x;
cartesian(m, x);
VectorType t;
tangent(m, t);
VectorType tmp;
A.mv(x, tmp); // Ax
tmp -= b; // Ax - b
D[0] = D[1] = tmp * t; // <Ax - b,t>
}
void domain(Interval<double> &domain) const {
domain[0] = -2 * M_PI;
domain[1] = 2 * M_PI;
}
void cartesian(double m, VectorType &y) const {
y = 0;
y.axpy(std::cos(m), x);
y.axpy(std::sin(m) * xnorm / dnorm, dir);
}
private:
MatrixType const &A;
VectorType const &b;
VectorType const &x;
VectorType const &dir;
double const dnorm;
double const xnorm;
/* If x and d were normalised, we would have
cartesian(a) = cos(a) * x + sin(a) * d and
tangent(a) = -sin(a) * x + cos(a) * d.
Since we x and d are not normalised and the return of
cartesian() is fixed, we scale the tangent.
*/
void tangent(double m, VectorType &y) const {
y = 0;
y.axpy(-std::sin(m) * dnorm, x);
y.axpy(std::cos(m) * xnorm, dir);
}
};
}
#endif
#ifndef ELLIPTIC_ENERGY_HH
#define ELLIPTIC_ENERGY_HH
#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>
#include <dune/common/stdstreams.hh>
#include <dune/fufem/interval.hh>
#include "localnonlinearity.hh"
namespace Dune {
template <int dim> class EllipticEnergy {
public:
using SmallVector = FieldVector<double, dim>;
using SmallMatrix = FieldMatrix<double, dim, dim>;
using NonlinearityType = LocalNonlinearity<dim>;
EllipticEnergy(SmallMatrix const &A, SmallVector const &b,
shared_ptr<NonlinearityType const> phi, int ignore = dim)
: A(A), b(b), phi(phi), ignore(ignore) {}
std::vector<double> const &get_kinks() const { return phi->get_kinks(); }
double operator()(SmallVector const &v) const {
SmallVector y(0);
A.usmv(0.5, v, y); // 1/2 Av
y -= b; // 1/2 Av - b
return y * v + (*phi)(v); // <1/2 Av - b,v> + H(|v|)
}
void descentAtZero(SmallVector &ret) const {
SmallVector const zero(0);
// If there is a direction of descent, this is it
SmallVector d;
smoothGradient(zero, d);
d *= -1;
Interval<double> D;
phi->directionalSubDiff(zero, d, D);
double const nonlinearDecline = D[1];
double const smoothDecline = -(d * d);
double const combinedDecline = smoothDecline + nonlinearDecline;
if (combinedDecline < 0) {
ret = d;
} else {
ret = 0;
}
}
// returns false if the direction is tangential
void descentDirectionNew(SmallVector const &x, SmallVector &ret) const {
SmallVector pg;
upperGradient(x, pg);
SmallVector mg;
lowerGradient(x, mg);
double const pgx = pg * x;
double const mgx = mg * x;
if (pgx >= 0 && mgx >= 0) {
ret = pg;
ret *= -1;
} else if (pgx <= 0 && mgx <= 0) {
ret = mg;
ret *= -1;
} else {
// We know that no descent can be expected in the tangential direction
ret = SmallVector(0);
}
}
bool descentDirection(SmallVector const &x, SmallVector &ret) const {
// Check the squared norm rather than each component because
// complementaryProjection() divides by it
if (x.two_norm2() == 0.0) {
descentAtZero(ret);
return true;
}
SmallVector pg;
upperGradient(x, pg);
SmallVector mg;
lowerGradient(x, mg);
double const pgx = pg * x;
double const mgx = mg * x;
if (pgx >= 0 && mgx >= 0) {
ret = pg;
ret *= -1;
return true;
} else if (pgx <= 0 && mgx <= 0) {
ret = mg;
ret *= -1;
return true;
} else {
// Includes the case that pg points in direction x and mg
// points in direction -x. The projection will then be zero.
SmallVector d;
smoothGradient(x, d);
complementaryProjection(d, x, ret);
ret *= -1;
return false;
}
}
SmallMatrix const &A;
SmallVector const &b;
shared_ptr<NonlinearityType const> const phi;
int const ignore; // Dimension that should be ignored; goes from 0
// to dim-1; the special value dim means that no
// dimension should be ignored
private:
// Gradient of the smooth part
void smoothGradient(SmallVector const &x, SmallVector &y) const {
A.mv(x, y); // y = Av
y -= b; // y = Av - b
if (ignore != dim)
y[ignore] = 0;
}
void upperGradient(SmallVector const &x, SmallVector &y) const {
phi->upperGradient(x, y);
SmallVector z;
smoothGradient(x, z);
y += z;
if (ignore != dim)
y[ignore] = 0;
}
void lowerGradient(SmallVector const &x, SmallVector &y) const {
phi->lowerGradient(x, y);
SmallVector z;
smoothGradient(x, z);
y += z;
if (ignore != dim)
y[ignore] = 0;
}
// y = (id - P)(d) where P is the projection onto the line t*x
void complementaryProjection(SmallVector const &d, SmallVector const &x,
SmallVector &y) const {
double const dx = d * x;
double const xx = x.two_norm2();
y = d;
y.axpy(-dx / xx, x);
}
};
}
#endif