From 05a6649c3835c8e125b686d6c0ab6ea17d1c0621 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Tue, 15 May 2012 14:23:42 +0200 Subject: [PATCH] Fix the first frictional node --- src/Makefile.am | 3 +-- src/one-body-sample.cc | 44 +++++++++++++++++++++++++----------------- src/write.cc | 26 ------------------------- src/write.hh | 14 -------------- src/write_tmpl.cc | 26 ------------------------- 5 files changed, 27 insertions(+), 86 deletions(-) delete mode 100644 src/write.cc delete mode 100644 src/write.hh delete mode 100644 src/write_tmpl.cc diff --git a/src/Makefile.am b/src/Makefile.am index a428d857..ba97418e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,8 +28,7 @@ one_body_sample_SOURCES = \ compute_state_ruina.cc \ mysolver.cc \ one-body-sample.cc \ - vtk.cc \ - write.cc + vtk.cc one_body_sample_CPPFLAGS = \ $(AM_CPPFLAGS) -Dsrcdir=\"$(srcdir)\" diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc index 759c0a1e..d172c1d4 100644 --- a/src/one-body-sample.cc +++ b/src/one-body-sample.cc @@ -66,7 +66,6 @@ #include "compute_state_ruina.hh" #include "mysolver.hh" #include "vtk.hh" -#include "write.hh" int const dim = 2; @@ -234,6 +233,15 @@ int main(int argc, char *argv[]) { auto const &dirichletFunction = functions.get("dirichletCondition"); auto const &neumannFunction = functions.get("neumannCondition"); + // Find a (somewhat random) frictional node + size_t first_frictional_node; + for (size_t i = 0; i < frictionalNodes.size(); ++i) { + if (frictionalNodes[i][0]) { + first_frictional_node = i; + break; + } + } + for (size_t run = 1; run <= timesteps; ++run) { double const time = h * run; if (parset.get<bool>("printProgress")) { @@ -306,25 +314,25 @@ int main(int argc, char *argv[]) { break; } - if (parset.get<bool>("writeEvolution")) - write_evolution<SingletonVectorType, VectorType>( - frictionalNodes, *s4_new, u4, neumannFunction, run, h * run, - octave_writer); - - if (parset.get<bool>("printCoefficient")) - for (size_t i = 0; i < frictionalNodes.size(); ++i) { - if (!frictionalNodes[i][0]) - continue; - - double const V = u4_diff[i].two_norm(); - double const state = (*s4_new)[i]; + // Record the state, (scaled) displacement, and Neumann + // condition at a fixed node + if (parset.get<bool>("writeEvolution")) { + double out; + neumannFunction.evaluate(time, out); + octave_writer << (*s4_new)[first_frictional_node][0] << " " + << u4[first_frictional_node][0] * 1e6 << " " << out + << std::endl; + } - coefficient_writer << mu + a *std::log(V * eta) + - b * (state - std::log(eta * L)) - << std::endl; + // Record the coefficient of friction at a fixed node + if (parset.get<bool>("printCoefficient")) { + double const V = u4_diff[first_frictional_node].two_norm(); + double const state = (*s4_new)[first_frictional_node]; - break; - } + coefficient_writer << mu + a *std::log(V * eta) + + b * (state - std::log(eta * L)) + << std::endl; + } } u4 += u4_diff; diff --git a/src/write.cc b/src/write.cc deleted file mode 100644 index 593bea26..00000000 --- a/src/write.cc +++ /dev/null @@ -1,26 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "write.hh" - -template <class SingletonVectorType, class VectorType> -void write_evolution(Dune::BitSetVector<1> const &frictionalNodes, - SingletonVectorType const &state, - VectorType const &displacement, - Dune::VirtualFunction<double, double> const &function, - int run, double time, std::ostream &octave_writer) { - // Find the first node that belongs to the frictional boundary - for (size_t i = 0; i < frictionalNodes.size(); ++i) { - if (!frictionalNodes[i][0]) - continue; - - double out; - function.evaluate(time, out); - octave_writer << state[i][0] << " " << displacement[i][0] * 1e6 << " " - << out << std::endl; - break; - } -} - -#include "write_tmpl.cc" diff --git a/src/write.hh b/src/write.hh deleted file mode 100644 index 6b0d8f92..00000000 --- a/src/write.hh +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef WRITE_HH -#define WRITE_HH - -#include <dune/common/function.hh> -#include <dune/common/bitsetvector.hh> - -template <class SingletonVectorType, class VectorType> -void write_evolution(Dune::BitSetVector<1> const &frictionalNodes, - SingletonVectorType const &state, - VectorType const &displacement, - Dune::VirtualFunction<double, double> const &function, - int run, double time, std::ostream &octave_writer); - -#endif diff --git a/src/write_tmpl.cc b/src/write_tmpl.cc deleted file mode 100644 index 5727f345..00000000 --- a/src/write_tmpl.cc +++ /dev/null @@ -1,26 +0,0 @@ -#include <dune/common/fvector.hh> -#include <dune/istl/bvector.hh> - -typedef Dune::BlockVector<Dune::FieldVector<double, 1>> SingletonVectorType; - -// {{{ 2D -typedef Dune::FieldVector<double, 2> SmallVector2; -typedef Dune::BlockVector<SmallVector2> VectorType2; - -template void write_evolution<SingletonVectorType, VectorType2>( - Dune::BitSetVector<1> const &frictionalNodes, - SingletonVectorType const &state, VectorType2 const &displacement, - Dune::VirtualFunction<double, double> const &function, int run, double time, - std::ostream &octave_writer); -// }}} - -// {{{ 3D -typedef Dune::FieldVector<double, 3> SmallVector3; -typedef Dune::BlockVector<SmallVector3> VectorType3; - -template void write_evolution<SingletonVectorType, VectorType3>( - Dune::BitSetVector<1> const &frictionalNodes, - SingletonVectorType const &state, VectorType3 const &displacement, - Dune::VirtualFunction<double, double> const &function, int run, double time, - std::ostream &octave_writer); -// }}} -- GitLab