12#ifndef DUMUX_ASSEMBLY_INITIAL_SOLUTION_HH
13#define DUMUX_ASSEMBLY_INITIAL_SOLUTION_HH
26template<
class SolutionVector,
class Problem>
29 const auto& gg = problem.gridGeometry();
30 using GridGeometry = std::decay_t<
decltype(gg)>;
35 constexpr int dim = GridGeometry::GridView::dimension;
36 const auto numDofs = gg.vertexMapper().size();
37 const auto numVert = gg.gridView().size(dim);
42 if (numDofs != numVert)
44 std::vector<bool> dofVisited(numDofs,
false);
45 for (
const auto& element : elements(gg.gridView()))
47 for (
int i = 0; i < element.subEntities(dim); ++i)
49 const auto dofIdxGlobal = gg.vertexMapper().subIndex(element, i, dim);
51 if (!dofVisited[dofIdxGlobal])
53 sol[dofIdxGlobal] = problem.initial(element.template subEntity<dim>(i));
54 dofVisited[dofIdxGlobal] =
true;
63 for (
const auto& vertex : vertices(gg.gridView()))
64 sol[gg.vertexMapper().index(vertex)] = problem.initial(vertex);
71 problem.applyInitialSolution(sol);
77 sol.resize(gg.numDofs());
78 for (
const auto& element : elements(gg.gridView()))
79 sol[gg.elementMapper().index(element)] = problem.initial(element);
87template<
class SolutionVector,
class Problem>
void assembleInitialSolution(SolutionVector &sol, const Problem &problem)
Set a solution vector to the initial solution provided by the problem.
Definition: initialsolution.hh:27
SolutionVector makeInitialSolution(const Problem &problem)
Create a solution vector filled with the initial solution provided by the problem.
Definition: initialsolution.hh:88
The available discretization methods in Dumux.
constexpr Box box
Definition: method.hh:147
constexpr Staggered staggered
Definition: method.hh:149