GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/navierstokes/mass/problem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 5 7 71.4%
Functions: 25 52 48.1%
Branches: 10 21 47.6%

Line Branch Exec Source
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 //
7 /*!
8 * \file
9 * \ingroup NavierStokesModel
10 * \copydoc Dumux::NavierStokesMassProblem
11 */
12 #ifndef DUMUX_NAVIERSTOKES_MASS_PROBLEM_HH
13 #define DUMUX_NAVIERSTOKES_MASS_PROBLEM_HH
14
15 #include <dune/common/exceptions.hh>
16 #include <dune/common/typetraits.hh>
17 #include <dumux/common/numeqvector.hh>
18 #include <dumux/common/properties.hh>
19 #include <dumux/common/fvproblemwithspatialparams.hh>
20 #include <dumux/discretization/method.hh>
21
22 namespace Dumux {
23
24 // default implementation
25 template<class TypeTag, class DiscretizationMethod>
26 class NavierStokesMassProblemImpl : public FVProblemWithSpatialParams<TypeTag>
27 {
28 using ParentType = FVProblemWithSpatialParams<TypeTag>;
29 using Implementation = GetPropType<TypeTag, Properties::Problem>;
30
31 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
32 using GridView = typename GridGeometry::GridView;
33 using FVElementGeometry = typename GridGeometry::LocalView;
34 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
35 using Element = typename GridView::template Codim<0>::Entity;
36 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
37 using VelocityVector = GlobalPosition;
38 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
39 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
40 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
41
42 static constexpr bool isCoupled_ = !std::is_empty_v<CouplingManager>;
43
44 public:
45
46 //! These types are used in place of the typical NumEqVector type.
47 //! In the momentum problem, there is a discrepancy between
48 //! the assembly NumEqVector type, and the type used in the residual.
49 //! These aliases are used in both problems to differentiate.
50 using InitialValues = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
51 using Sources = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
52 using DirichletValues = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
53 using BoundaryFluxes = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
54
55 //! Export the boundary types.
56 using BoundaryTypes = Dumux::BoundaryTypes<ModelTraits::numEq()>;
57
58 //! this problem is used for the mass balance model
59 static constexpr bool isMomentumProblem() { return false; }
60
61 /*!
62 * \brief The constructor
63 * \param gridGeometry The finite volume grid geometry
64 * \param couplingManager The coupling manager (couples mass and momentum equations)
65 * \param paramGroup The parameter group in which to look for runtime parameters first (default is "")
66 */
67 66 NavierStokesMassProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
68 std::shared_ptr<CouplingManager> couplingManager,
69 const std::string& paramGroup = "")
70 : ParentType(gridGeometry, paramGroup)
71
2/6
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
132 , couplingManager_(couplingManager)
72 66 {}
73
74 /*!
75 * \brief The constructor for usage without a coupling manager
76 * \param gridGeometry The finite volume grid geometry
77 * \param paramGroup The parameter group in which to look for runtime parameters first (default is "")
78 */
79 NavierStokesMassProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
80 const std::string& paramGroup = "")
81 : NavierStokesMassProblemImpl(gridGeometry, {}, paramGroup)
82 {}
83
84 /*!
85 * \brief Returns the normal velocity at a given sub control volume face.
86 */
87 VelocityVector faceVelocity(const Element& element,
88 const FVElementGeometry& fvGeometry,
89 const SubControlVolumeFace& scvf) const
90 {
91 if constexpr (isCoupled_)
92
0/7
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
305628750 return couplingManager_->faceVelocity(element, scvf);
93 else
94 return asImp_().velocityAtPos(scvf.ipGlobal());
95 }
96
97 /*!
98 * \brief Returns the velocity at the element center.
99 */
100 VelocityVector elementVelocity(const FVElementGeometry& fvGeometry) const
101 {
102 if constexpr (isCoupled_)
103 return couplingManager_->elementVelocity(fvGeometry);
104 else
105 return asImp_().velocityAtPos(fvGeometry.element().geometry().center());
106 }
107
108 /*!
109 * \brief Returns the velocity at a given position.
110 */
111 VelocityVector velocityAtPos(const GlobalPosition&) const
112 {
113 DUNE_THROW(Dune::NotImplemented, "velocityAtPos not implemented");
114 }
115
116 const CouplingManager& couplingManager() const
117 {
118 if constexpr (isCoupled_)
119
8/8
✓ Branch 0 taken 1420 times.
✓ Branch 1 taken 9300 times.
✓ Branch 2 taken 1420 times.
✓ Branch 3 taken 9300 times.
✓ Branch 4 taken 2050 times.
✓ Branch 5 taken 1750 times.
✓ Branch 6 taken 2050 times.
✓ Branch 7 taken 1750 times.
34390 return *couplingManager_;
120 else
121 DUNE_THROW(Dune::InvalidStateException,
122 "Accessing coupling manager of an uncoupled problem is not possible."
123 );
124 }
125
126 private:
127 //! Returns the implementation of the problem (i.e. static polymorphism)
128 Implementation &asImp_()
129 { return *static_cast<Implementation *>(this); }
130
131 //! \copydoc asImp_()
132 const Implementation &asImp_() const
133 { return *static_cast<const Implementation *>(this); }
134
135 std::shared_ptr<CouplingManager> couplingManager_;
136 };
137
138 /*!
139 * \ingroup NavierStokesModel
140 * \brief Navier-Stokes mass problem class
141 *
142 * Inherit from this problem to implement Navier-Stokes mass problems
143 */
144 template<class TypeTag>
145 using NavierStokesMassProblem = NavierStokesMassProblemImpl<
146 TypeTag, typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod
147 >;
148
149 } // end namespace Dumux
150
151 #endif
152