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

[Cleanup] Make time relative

parent 55d4bade
No related branches found
No related tags found
No related merge requests found
...@@ -16,11 +16,11 @@ void assemble_neumann(GridView const &gridView, AssemblerType const &assembler, ...@@ -16,11 +16,11 @@ void assemble_neumann(GridView const &gridView, AssemblerType const &assembler,
Dune::BitSetVector<1> const &neumannNodes, Dune::BitSetVector<1> const &neumannNodes,
Dune::BlockVector<LocalVectorType> &f, Dune::BlockVector<LocalVectorType> &f,
Dune::VirtualFunction<double, double> const &neumann, Dune::VirtualFunction<double, double> const &neumann,
double time) { // constant sample function on neumann double relativeTime) { // constant sample function on
// boundary // neumann boundary
BoundaryPatch<GridView> const neumannBoundary(gridView, neumannNodes); BoundaryPatch<GridView> const neumannBoundary(gridView, neumannNodes);
LocalVectorType SampleVector(0); LocalVectorType SampleVector(0);
neumann.evaluate(time, SampleVector[0]); neumann.evaluate(relativeTime, SampleVector[0]);
ConstantFunction<LocalVectorType, LocalVectorType> const fNeumann( ConstantFunction<LocalVectorType, LocalVectorType> const fNeumann(
SampleVector); SampleVector);
NeumannBoundaryAssembler<typename GridView::Grid, LocalVectorType> NeumannBoundaryAssembler<typename GridView::Grid, LocalVectorType>
......
...@@ -16,7 +16,7 @@ void assemble_neumann(GridView const &gridView, AssemblerType const &assembler, ...@@ -16,7 +16,7 @@ void assemble_neumann(GridView const &gridView, AssemblerType const &assembler,
Dune::BitSetVector<1> const &neumannNodes, Dune::BitSetVector<1> const &neumannNodes,
Dune::BlockVector<LocalVectorType> &f, Dune::BlockVector<LocalVectorType> &f,
Dune::VirtualFunction<double, double> const &neumann, Dune::VirtualFunction<double, double> const &neumann,
double time); double relativeTime);
template <class GridView, class LocalVectorType, class AssemblerType> template <class GridView, class LocalVectorType, class AssemblerType>
Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>>
......
...@@ -27,7 +27,7 @@ template void assemble_neumann<GridView, SmallVector, AssemblerType>( ...@@ -27,7 +27,7 @@ template void assemble_neumann<GridView, SmallVector, AssemblerType>(
GridView const &gridView, AssemblerType const &assembler, GridView const &gridView, AssemblerType const &assembler,
Dune::BitSetVector<1> const &neumannNodes, Dune::BitSetVector<1> const &neumannNodes,
Dune::BlockVector<SmallVector> &f, Dune::BlockVector<SmallVector> &f,
Dune::VirtualFunction<double, double> const &neumann, double time); Dune::VirtualFunction<double, double> const &neumann, double relativeTime);
template Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> template Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>>
assemble_frictional<GridView, SmallVector, AssemblerType>( assemble_frictional<GridView, SmallVector, AssemblerType>(
......
...@@ -339,9 +339,9 @@ int main(int argc, char *argv[]) { ...@@ -339,9 +339,9 @@ int main(int argc, char *argv[]) {
frictionalNodes, *nodalIntegrals, frictionData); frictionalNodes, *nodalIntegrals, frictionData);
// Problem formulation: right-hand side // Problem formulation: right-hand side
auto const createRHS = [&](double _time, VectorType &_ell) { auto const createRHS = [&](double _relativeTime, VectorType &_ell) {
assemble_neumann(leafView, p1Assembler, neumannNodes, _ell, assemble_neumann(leafView, p1Assembler, neumannNodes, _ell,
neumannFunction, _time); neumannFunction, _relativeTime);
_ell += gravityFunctional; _ell += gravityFunctional;
}; };
VectorType ell(finestSize); VectorType ell(finestSize);
...@@ -491,16 +491,16 @@ int main(int argc, char *argv[]) { ...@@ -491,16 +491,16 @@ int main(int argc, char *argv[]) {
stateUpdater->nextTimeStep(); stateUpdater->nextTimeStep();
timeSteppingScheme->nextTimeStep(); timeSteppingScheme->nextTimeStep();
double const time = tau * run; auto const relativeTime = double(run) / double(timesteps);
createRHS(time, ell); createRHS(relativeTime, ell);
MatrixType velocityMatrix; MatrixType velocityMatrix;
VectorType velocityRHS(finestSize); VectorType velocityRHS(finestSize);
VectorType velocityIterate(finestSize); VectorType velocityIterate(finestSize);
stateUpdater->setup(tau); stateUpdater->setup(tau);
timeSteppingScheme->setup(ell, tau, time, velocityRHS, velocityIterate, timeSteppingScheme->setup(ell, tau, relativeTime, velocityRHS,
velocityMatrix); velocityIterate, velocityMatrix);
LoopSolver<VectorType> velocityProblemSolver( LoopSolver<VectorType> velocityProblemSolver(
multigridStep, maximumIterations, tolerance, &AMNorm, verbosity, multigridStep, maximumIterations, tolerance, &AMNorm, verbosity,
......
class neumannCondition: class neumannCondition:
def __call__(self, x): def __call__(self, relativeTime):
return 0 return 0
class velocityDirichletCondition: class velocityDirichletCondition:
def __call__(self, x): def __call__(self, relativeTime):
return 2e-4 return 2e-4
Functions = { Functions = {
......
...@@ -7,7 +7,7 @@ template <class VectorType, class MatrixType, class FunctionType, size_t dim> ...@@ -7,7 +7,7 @@ template <class VectorType, class MatrixType, class FunctionType, size_t dim>
class TimeSteppingScheme { class TimeSteppingScheme {
public: public:
void virtual nextTimeStep() = 0; void virtual nextTimeStep() = 0;
void virtual setup(VectorType const &ell, double _tau, double time, void virtual setup(VectorType const &ell, double _tau, double relativeTime,
VectorType &rhs, VectorType &iterate, MatrixType &AB) = 0; VectorType &rhs, VectorType &iterate, MatrixType &AB) = 0;
void virtual postProcess(VectorType const &iterate) = 0; void virtual postProcess(VectorType const &iterate) = 0;
......
...@@ -21,7 +21,7 @@ void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() { ...@@ -21,7 +21,7 @@ void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() {
template <class VectorType, class MatrixType, class FunctionType, size_t dim> template <class VectorType, class MatrixType, class FunctionType, size_t dim>
void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::setup( void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::setup(
VectorType const &ell, double _tau, double time, VectorType &rhs, VectorType const &ell, double _tau, double relativeTime, VectorType &rhs,
VectorType &iterate, MatrixType &AM) { VectorType &iterate, MatrixType &AM) {
postProcessCalled = false; postProcessCalled = false;
...@@ -77,11 +77,11 @@ void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::setup( ...@@ -77,11 +77,11 @@ void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::setup(
continue; continue;
case dim: case dim:
iterate[i] = 0; iterate[i] = 0;
dirichletFunction.evaluate(time, iterate[i][0]); dirichletFunction.evaluate(relativeTime, iterate[i][0]);
break; break;
case 1: case 1:
if (dirichletNodes[i][0]) { if (dirichletNodes[i][0]) {
dirichletFunction.evaluate(time, iterate[i][0]); dirichletFunction.evaluate(relativeTime, iterate[i][0]);
break; break;
} }
if (dirichletNodes[i][1]) { if (dirichletNodes[i][1]) {
......
...@@ -24,7 +24,7 @@ void Newmark<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() { ...@@ -24,7 +24,7 @@ void Newmark<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() {
template <class VectorType, class MatrixType, class FunctionType, size_t dim> template <class VectorType, class MatrixType, class FunctionType, size_t dim>
void Newmark<VectorType, MatrixType, FunctionType, dim>::setup( void Newmark<VectorType, MatrixType, FunctionType, dim>::setup(
VectorType const &ell, double _tau, double time, VectorType &rhs, VectorType const &ell, double _tau, double relativeTime, VectorType &rhs,
VectorType &iterate, MatrixType &AM) { VectorType &iterate, MatrixType &AM) {
postProcessCalled = false; postProcessCalled = false;
...@@ -83,11 +83,11 @@ void Newmark<VectorType, MatrixType, FunctionType, dim>::setup( ...@@ -83,11 +83,11 @@ void Newmark<VectorType, MatrixType, FunctionType, dim>::setup(
continue; continue;
case dim: case dim:
iterate[i] = 0; iterate[i] = 0;
dirichletFunction.evaluate(time, iterate[i][0]); dirichletFunction.evaluate(relativeTime, iterate[i][0]);
break; break;
case 1: case 1:
if (dirichletNodes[i][0]) { if (dirichletNodes[i][0]) {
dirichletFunction.evaluate(time, iterate[i][0]); dirichletFunction.evaluate(relativeTime, iterate[i][0]);
break; break;
} }
if (dirichletNodes[i][1]) { if (dirichletNodes[i][1]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment