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

[Cleanup] Move boundary info writing to a class

Also print information for time 0
parent 68841bcd
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ bin_PROGRAMS = \
SOURCES = \
assemblers.cc \
friction_writer.cc \
state/compute_state_dieterich_euler.cc \
state/compute_state_ruina.cc \
solverfactory.cc \
......
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "friction_writer.hh"
double computeCOF(FrictionData const &fd, double V, double log_state) {
double const mu = fd.mu0 + fd.a * std::log(V / fd.V0) +
fd.b * (log_state + std::log(fd.V0 / fd.L));
return (mu > 0) ? mu : 0;
}
template <class BitVectorType>
FrictionWriter<BitVectorType>::FrictionWriter(
FrictionData const &_fd, BitVectorType const &_boundaryNodes)
: coefficientWriter("coefficients", std::fstream::out),
displacementWriter("displacements", std::fstream::out),
stateWriter("states", std::fstream::out),
velocityWriter("velocities", std::fstream::out),
fd(_fd),
boundaryNodes(_boundaryNodes) {}
template <class BitVectorType>
FrictionWriter<BitVectorType>::~FrictionWriter() {
stateWriter.close();
displacementWriter.close();
velocityWriter.close();
coefficientWriter.close();
}
template <class BitVectorType>
template <class SingletonVectorType, class VectorType>
void FrictionWriter<BitVectorType>::writeInfo(SingletonVectorType const &alpha,
VectorType const &u,
VectorType const &v) {
for (size_t i = 0; i < boundaryNodes.size(); ++i) {
if (!boundaryNodes[i][0])
continue;
coefficientWriter << computeCOF(fd, v[i].two_norm(), alpha[i]) << " ";
displacementWriter << u[i][0] << " ";
stateWriter << alpha[i][0] << " ";
velocityWriter << v[i][0] << " ";
}
stateWriter << std::endl;
displacementWriter << std::endl;
velocityWriter << std::endl;
coefficientWriter << std::endl;
}
#include "friction_writer_tmpl.cc"
//#include <iostream>
#include <fstream>
#include <dune/tectonic/frictiondata.hh>
template <class BitVectorType> class FrictionWriter {
public:
FrictionWriter(FrictionData const &_fd, BitVectorType const &_boundaryNodes);
~FrictionWriter();
template <class SingletonVectorType, class VectorType>
void writeInfo(SingletonVectorType const &alpha, VectorType const &u,
VectorType const &v);
private:
std::fstream coefficientWriter;
std::fstream displacementWriter;
std::fstream stateWriter;
std::fstream velocityWriter;
FrictionData const &fd;
BitVectorType const &boundaryNodes;
};
#include <dune/common/bitsetvector.hh>
#include <dune/istl/bvector.hh>
using BitVectorType = Dune::BitSetVector<1>;
using SingletonVectorType = Dune::BlockVector<Dune::FieldVector<double, 1>>;
using VectorType2 = Dune::BlockVector<Dune::FieldVector<double, 2>>;
using VectorType3 = Dune::BlockVector<Dune::FieldVector<double, 3>>;
template class FrictionWriter<BitVectorType>;
template void FrictionWriter<BitVectorType>::writeInfo(
SingletonVectorType const &alpha, VectorType2 const &u,
VectorType2 const &v);
template void FrictionWriter<BitVectorType>::writeInfo(
SingletonVectorType const &alpha, VectorType3 const &u,
VectorType3 const &v);
......@@ -82,6 +82,7 @@
#include <dune/tectonic/globalnonlinearity.hh>
#include "assemblers.hh"
#include "friction_writer.hh"
#include "solverfactory.hh"
#include "vtk.hh"
......@@ -152,12 +153,6 @@ void initPython() {
Python::run("sys.path.append('" srcdir "')");
}
double computeCOF(FrictionData const &fd, double V, double log_state) {
double const mu = fd.mu0 + fd.a * std::log(V / fd.V0) +
fd.b * (log_state + std::log(fd.V0 / fd.L));
return (mu > 0) ? mu : 0;
}
int main(int argc, char *argv[]) {
try {
Dune::Timer timer;
......@@ -442,6 +437,8 @@ int main(int argc, char *argv[]) {
initialAccelerationProblemSolver.solve();
}
// }}}
FrictionWriter<Dune::BitSetVector<1>> writer(frictionData, frictionalNodes);
writer.writeInfo(alpha_initial, u_initial, v_initial);
// Set up TNNMG solver
using NonlinearFactoryType = SolverFactory<
......@@ -460,11 +457,7 @@ int main(int argc, char *argv[]) {
coordinateWriter << coordinates[i] << std::endl;
coordinateWriter.close();
}
std::fstream stateWriter("states", std::fstream::out),
displacementWriter("displacements", std::fstream::out),
velocityWriter("velocities", std::fstream::out),
coefficientWriter("coefficients", std::fstream::out),
iterationWriter("iterations", std::fstream::out),
std::fstream iterationWriter("iterations", std::fstream::out),
relaxationWriter("relaxation", std::fstream::out);
auto timeSteppingScheme =
......@@ -579,19 +572,7 @@ int main(int argc, char *argv[]) {
if (printProgress)
std::cerr << std::endl;
for (size_t i = 0; i < frictionalNodes.size(); ++i)
if (frictionalNodes[i][0]) {
stateWriter << alpha[i][0] << " ";
displacementWriter << u[i][0] << " ";
velocityWriter << v[i][0] << " ";
coefficientWriter << computeCOF(frictionData, v[i].two_norm(),
alpha[i]) << " ";
}
stateWriter << std::endl;
displacementWriter << std::endl;
velocityWriter << std::endl;
coefficientWriter << std::endl;
writer.writeInfo(alpha, u, v);
iterationWriter << std::endl;
relaxationWriter << std::endl;
......@@ -612,10 +593,6 @@ int main(int argc, char *argv[]) {
std::cerr << std::endl << "Making " << timesteps << " time steps took "
<< timer.elapsed() << "s" << std::endl;
stateWriter.close();
displacementWriter.close();
velocityWriter.close();
coefficientWriter.close();
iterationWriter.close();
relaxationWriter.close();
......
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