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

Determine schemes outside of main()

parent 9d49146e
No related branches found
No related tags found
No related merge requests found
......@@ -133,6 +133,49 @@ void setup_boundary(GridView const &gridView,
}
}
template <class VectorType, class MatrixType, class FunctionType, int dim>
Dune::shared_ptr<TimeSteppingScheme<VectorType, MatrixType, FunctionType, dim>>
initTimeStepper(Config::scheme scheme, FunctionType const &dirichletFunction,
Dune::BitSetVector<dim> const &ignoreNodes,
MatrixType const &massMatrix, MatrixType const &stiffnessMatrix,
VectorType const &u_initial, VectorType const &ud_initial,
VectorType const &udd_initial) {
switch (scheme) {
case Config::ImplicitTwoStep:
return Dune::make_shared<
ImplicitTwoStep<VectorType, MatrixType, FunctionType, dim>>(
stiffnessMatrix, u_initial, ud_initial, ignoreNodes,
dirichletFunction);
case Config::ImplicitEuler:
return Dune::make_shared<
ImplicitEuler<VectorType, MatrixType, FunctionType, dim>>(
stiffnessMatrix, u_initial, ud_initial, ignoreNodes,
dirichletFunction);
case Config::Newmark:
return Dune::make_shared<
Newmark<VectorType, MatrixType, FunctionType, dim>>(
stiffnessMatrix, massMatrix, u_initial, ud_initial, udd_initial,
ignoreNodes, dirichletFunction);
}
}
template <class SingletonVectorType, class VectorType>
Dune::shared_ptr<StateUpdater<SingletonVectorType, VectorType>>
initStateUpdater(Config::state_model model,
SingletonVectorType const &alpha_initial,
Dune::BitSetVector<1> const &frictionalNodes, double L) {
switch (model) {
case Config::Dieterich:
return Dune::make_shared<
DieterichStateUpdater<SingletonVectorType, VectorType>>(
alpha_initial, frictionalNodes, L);
case Config::Ruina:
return Dune::make_shared<
RuinaStateUpdater<SingletonVectorType, VectorType>>(
alpha_initial, frictionalNodes, L);
}
}
int main(int argc, char *argv[]) {
try {
typedef SharedPointerMap<std::string, Dune::VirtualFunction<double, double>>
......@@ -329,47 +372,13 @@ int main(int argc, char *argv[]) {
first_frictional_node < frictionalNodes.size())
++first_frictional_node;
Dune::shared_ptr<TimeSteppingScheme<
VectorType, MatrixType, Dune::VirtualFunction<double, double>, dim>>
timeSteppingScheme;
switch (parset.get<Config::scheme>("timeSteppingScheme")) {
case Config::ImplicitTwoStep:
timeSteppingScheme = Dune::make_shared<
ImplicitTwoStep<VectorType, MatrixType,
Dune::VirtualFunction<double, double>, dim>>(
stiffnessMatrix, u_initial, ud_initial, ignoreNodes,
dirichletFunction);
break;
case Config::ImplicitEuler:
timeSteppingScheme = Dune::make_shared<
ImplicitEuler<VectorType, MatrixType,
Dune::VirtualFunction<double, double>, dim>>(
stiffnessMatrix, u_initial, ud_initial, ignoreNodes,
dirichletFunction);
break;
case Config::Newmark:
timeSteppingScheme = Dune::make_shared<
Newmark<VectorType, MatrixType,
Dune::VirtualFunction<double, double>, dim>>(
stiffnessMatrix, massMatrix, u_initial, ud_initial, udd_initial,
ignoreNodes, dirichletFunction);
break;
}
Dune::shared_ptr<StateUpdater<SingletonVectorType, VectorType>>
stateUpdater;
switch (parset.get<Config::state_model>("boundary.friction.state.model")) {
case Config::Dieterich:
stateUpdater = Dune::make_shared<
DieterichStateUpdater<SingletonVectorType, VectorType>>(
alpha_initial, frictionalNodes, L);
break;
case Config::Ruina:
stateUpdater = Dune::make_shared<
RuinaStateUpdater<SingletonVectorType, VectorType>>(
alpha_initial, frictionalNodes, L);
break;
}
auto timeSteppingScheme =
initTimeStepper(parset.get<Config::scheme>("timeSteppingScheme"),
dirichletFunction, ignoreNodes, massMatrix,
stiffnessMatrix, u_initial, ud_initial, udd_initial);
auto stateUpdater = initStateUpdater<SingletonVectorType, VectorType>(
parset.get<Config::state_model>("boundary.friction.state.model"),
alpha_initial, frictionalNodes, L);
auto const state_fpi_max =
parset.get<size_t>("solver.tnnmg.fixed_point_iterations");
......
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