version 3.8
staggered/elementsolution.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_STAGGERED_ELEMENT_SOLUTION_HH
13#define DUMUX_STAGGERED_ELEMENT_SOLUTION_HH
14
15#include <type_traits>
16#include <dune/istl/bvector.hh>
18
19namespace Dumux {
20
28template<class PrimaryVariables, class CellCenterPrimaryVariables>
29PrimaryVariables makePriVarsFromCellCenterPriVars(const CellCenterPrimaryVariables& cellCenterPriVars)
30{
31 static_assert(int(PrimaryVariables::dimension) > int(CellCenterPrimaryVariables::dimension),
32 "PrimaryVariables' size must be greater than the one of CellCenterPrimaryVariables");
33
34 PrimaryVariables priVars(0.0);
35 constexpr auto offset = PrimaryVariables::dimension - CellCenterPrimaryVariables::dimension;
36 for (std::size_t i = 0; i < cellCenterPriVars.size(); ++i)
37 priVars[i + offset] = cellCenterPriVars[i];
38 return priVars;
39}
40
41template<class PrimaryVariables>
42using StaggeredElementSolution = Dune::BlockVector<PrimaryVariables>;
43
49template<class FVElementGeometry, class PrimaryVariables>
50auto elementSolution(PrimaryVariables&& priVars)
51-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::staggered,
53{
54 return StaggeredElementSolution<PrimaryVariables>({std::move(priVars)});
55}
56
64template<class PrimaryVariables, class CellCenterPrimaryVariables>
66{
67 return StaggeredElementSolution<PrimaryVariables>({makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars)});
68}
69
70} // end namespace Dumux
71
72#endif
StaggeredElementSolution< PrimaryVariables > makeElementSolutionFromCellCenterPrivars(const CellCenterPrimaryVariables &cellCenterPriVars)
Helper function to create an elementSolution from cell center primary variables.
Definition: staggered/elementsolution.hh:65
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::cctpfa||GridGeometry::discMethod==DiscretizationMethods::ccmpfa, CCElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for cell-centered schemes.
Definition: cellcentered/elementsolution.hh:101
PrimaryVariables makePriVarsFromCellCenterPriVars(const CellCenterPrimaryVariables &cellCenterPriVars)
Helper function to create a PrimaryVariables object from CellCenterPrimaryVariables.
Definition: staggered/elementsolution.hh:29
The available discretization methods in Dumux.
constexpr Staggered staggered
Definition: method.hh:149
Definition: adapt.hh:17
Dune::BlockVector< PrimaryVariables > StaggeredElementSolution
Definition: staggered/elementsolution.hh:42