version 3.11-dev
freeflow/navierstokes/momentum/problem.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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_NAVIERSTOKES_MOMENTUM_PROBLEM_HH
13#define DUMUX_NAVIERSTOKES_MOMENTUM_PROBLEM_HH
14
15#include <dune/common/exceptions.hh>
16#include <dune/common/fvector.hh>
17#include <dune/common/typetraits.hh>
23
24namespace Dumux {
25
26template<class TypeTag, class DiscretizationMethod>
28
29template<class TypeTag>
30class NavierStokesMomentumProblemImpl<TypeTag, DiscretizationMethods::FCStaggered>
31: public FVProblemWithSpatialParams<TypeTag>
32{
34 using Implementation = GetPropType<TypeTag, Properties::Problem>;
35
37 using GridView = typename GridGeometry::GridView;
38 using Element = typename GridView::template Codim<0>::Entity;
39
41 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
42 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
44
45 using FVElementGeometry = typename GridGeometry::LocalView;
46 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
47 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
49
50 enum {
51 dim = GridView::dimension,
52 dimWorld = GridView::dimensionworld
53 };
54
55 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
56 using VelocityVector = Dune::FieldVector<Scalar, dimWorld>;
57 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
60
61 static constexpr bool isCoupled_ = !std::is_empty_v<CouplingManager>;
62
63
64public:
68 using InitialValues = Dune::FieldVector<Scalar, dimWorld>;
69 using Sources = Dune::FieldVector<Scalar, dimWorld>;
70 using DirichletValues = Dune::FieldVector<Scalar, dimWorld>;
71 using BoundaryFluxes = Dune::FieldVector<Scalar, dimWorld>;
72
73 using MomentumFluxType = Dune::FieldVector<Scalar, dimWorld>;
74
77
79 static constexpr bool isMomentumProblem() { return true; }
80
87 NavierStokesMomentumProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
88 std::shared_ptr<CouplingManager> couplingManager,
89 const std::string& paramGroup = "")
90 : ParentType(gridGeometry, paramGroup)
91 , gravity_(0.0)
92 , couplingManager_(couplingManager)
93 {
94 if (getParamFromGroup<bool>(paramGroup, "Problem.EnableGravity"))
95 gravity_[dim-1] = -9.81;
96
97 enableInertiaTerms_ = getParamFromGroup<bool>(paramGroup, "Problem.EnableInertiaTerms");
98 }
99
105 NavierStokesMomentumProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
106 const std::string& paramGroup = "")
107 : NavierStokesMomentumProblemImpl(gridGeometry, {}, paramGroup)
108 {}
109
128 Sources source(const Element& element,
129 const FVElementGeometry& fvGeometry,
130 const ElementVolumeVariables& elemVolVars,
131 const SubControlVolume& scv) const
132 {
133 // forward to solution independent, fully-implicit specific interface
134 return asImp_().sourceAtPos(scv.dofPosition());
135 }
136
150 Sources sourceAtPos(const GlobalPosition& globalPos) const
151 {
154 return Sources(0.0);
155 }
156
163 Sources scvPointSources(const Element& element,
164 const FVElementGeometry& fvGeometry,
165 const ElementVolumeVariables& elemVolVars,
166 const SubControlVolume& scv) const
167 {
168 if (!this->pointSourceMap().empty())
169 DUNE_THROW(Dune::NotImplemented, "scvPointSources not implemented");
170
171 return Sources(0.0);
172 }
173
181 auto boundaryTypes(const Element& element,
182 const SubControlVolumeFace& scvf) const
183 {
184 // Forward it to the method which only takes the global coordinate.
185 // We evaluate the boundary type at the center of the sub control volume face
186 // in order to avoid ambiguities at domain corners.
187 return asImp_().boundaryTypesAtPos(scvf.center());
188 }
189
198 DirichletValues dirichlet(const Element& element, const SubControlVolumeFace& scvf) const
199 {
200 return asImp_().dirichletAtPos(scvf.ipGlobal());
201 }
202
212 template<class ElementFluxVariablesCache>
213 BoundaryFluxes neumann(const Element& element,
214 const FVElementGeometry& fvGeometry,
215 const ElementVolumeVariables& elemVolVars,
216 const ElementFluxVariablesCache& elemFluxVarsCache,
217 const SubControlVolumeFace& scvf) const
218 { return asImp_().neumannAtPos(scvf.ipGlobal()); }
219
223 BoundaryFluxes neumannAtPos(const GlobalPosition& globalPos) const
224 { return BoundaryFluxes(0.0); }
225
232 const GravityVector& gravity() const
233 { return gravity_; }
234
239 { return enableInertiaTerms_; }
240
245 Scalar pressure(const Element& element,
246 const FVElementGeometry& fvGeometry,
247 const SubControlVolumeFace& scvf) const
248 {
249 if constexpr (isCoupled_)
250 return couplingManager_->pressure(element, fvGeometry, scvf);
251 else
252 return asImp_().pressureAtPos(scvf.ipGlobal());
253 }
254
258 Scalar pressureAtPos(const GlobalPosition&) const
259 {
260 DUNE_THROW(Dune::NotImplemented, "pressureAtPos not implemented");
261 }
262
269 Scalar referencePressure(const Element& element,
270 const FVElementGeometry& fvGeometry,
271 const SubControlVolumeFace& scvf) const
272 { return 0.0; }
273
278 Scalar density(const Element& element,
279 const FVElementGeometry& fvGeometry,
280 const SubControlVolumeFace& scvf) const
281 {
282 if constexpr (isCoupled_)
283 return couplingManager_->density(element, fvGeometry, scvf);
284 else
285 return asImp_().densityAtPos(scvf.ipGlobal());
286 }
287
292 Scalar density(const Element& element,
293 const SubControlVolume& scv,
294 const bool isPreviousTimeStep = false) const
295 {
296 if constexpr (isCoupled_)
297 return couplingManager_->density(element, scv, isPreviousTimeStep);
298 else
299 return asImp_().densityAtPos(scv.dofPosition());
300 }
301
302 auto insideAndOutsideDensity(const Element& element,
303 const FVElementGeometry& fvGeometry,
304 const SubControlVolumeFace& scvf,
305 const bool isPreviousTimeStep = false) const
306 {
307 if constexpr (isCoupled_)
308 return couplingManager_->insideAndOutsideDensity(element, fvGeometry, scvf, isPreviousTimeStep);
309 else
310 {
311 const auto rho = asImp_().densityAtPos(scvf.ipGlobal());
312 return std::make_pair(rho, rho);
313 }
314 }
315
319 Scalar densityAtPos(const GlobalPosition&) const
320 {
321 DUNE_THROW(Dune::NotImplemented, "densityAtPos not implemented");
322 }
323
328 Scalar effectiveViscosity(const Element& element,
329 const FVElementGeometry& fvGeometry,
330 const SubControlVolumeFace& scvf) const
331 {
332 if constexpr (isCoupled_)
333 return couplingManager_->effectiveViscosity(element, fvGeometry, scvf);
334 else
335 return asImp_().effectiveViscosityAtPos(scvf.ipGlobal());
336 }
337
342 Scalar effectiveViscosity(const Element& element,
343 const FVElementGeometry& fvGeometry,
344 const SubControlVolume& scv) const
345 {
346 if constexpr (isCoupled_)
347 return couplingManager_->effectiveViscosity(element, fvGeometry, scv);
348 else
349 return asImp_().effectiveViscosityAtPos(scv.dofPosition());
350 }
351
355 Scalar effectiveViscosityAtPos(const GlobalPosition&) const
356 {
357 DUNE_THROW(Dune::NotImplemented, "effectiveViscosityAtPos not implemented");
358 }
359
364 template<class SolutionVector>
365 void applyInitialSolution(SolutionVector& sol) const
366 {
367 sol.resize(this->gridGeometry().numDofs());
368 std::vector<bool> dofHandled(this->gridGeometry().numDofs(), false);
369 auto fvGeometry = localView(this->gridGeometry());
370 for (const auto& element : elements(this->gridGeometry().gridView()))
371 {
372 fvGeometry.bindElement(element);
373 for (const auto& scv : scvs(fvGeometry))
374 {
375 const auto dofIdx = scv.dofIndex();
376 if (!dofHandled[dofIdx])
377 {
378 dofHandled[dofIdx] = true;
379 sol[dofIdx] = asImp_().initial(scv)[scv.dofAxis()];
380 }
381 }
382 }
383 }
384
388 InitialValues initial(const SubControlVolume& scv) const
389 {
390 return asImp_().initialAtPos(scv.dofPosition());
391 }
392
394 Scalar pseudo3DWallFriction(const Element& element,
395 const FVElementGeometry& fvGeometry,
396 const ElementVolumeVariables& elemVolVars,
397 const SubControlVolume& scv,
398 const Scalar height,
399 const Scalar factor = 8.0) const
400 {
401 const Scalar velocity = elemVolVars[scv].velocity();
402 const auto scvf = scvfs(fvGeometry, scv).begin();
403 const Scalar viscosity = effectiveViscosity(element, fvGeometry, *scvf);
404 return pseudo3DWallFriction(velocity, viscosity, height, factor);
405 }
406
420 Scalar pseudo3DWallFriction(const Scalar velocity,
421 const Scalar viscosity,
422 const Scalar height,
423 const Scalar factor = 8.0) const
424 {
425 static_assert(dim == 2, "Pseudo 3D wall friction may only be used in 2D");
426 return -factor * velocity * viscosity / (height*height);
427 }
428
434 bool onSlipBoundary(const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvf) const
435 { return asImp_().onSlipBoundaryAtPos(scvf.center()); }
436
441 bool onSlipBoundaryAtPos(const GlobalPosition& pos) const
442 { return false; }
443
444 const CouplingManager& couplingManager() const
445 {
446 if constexpr (isCoupled_)
447 return *couplingManager_;
448 else
449 DUNE_THROW(Dune::InvalidStateException,
450 "Accessing coupling manager of an uncoupled problem is not possible."
451 );
452 }
453
454private:
456 Implementation& asImp_()
457 { return *static_cast<Implementation *>(this); }
458
460 const Implementation& asImp_() const
461 { return *static_cast<const Implementation *>(this); }
462
463 GravityVector gravity_;
464 bool enableInertiaTerms_;
465 std::shared_ptr<CouplingManager> couplingManager_;
466};
467
471template<class TypeTag, class DM>
472class NavierStokesMomentumProblemImpl<TypeTag, DiscretizationMethods::CVFE<DM>>
473: public FVProblemWithSpatialParams<TypeTag>
474{
476 using Implementation = GetPropType<TypeTag, Properties::Problem>;
477
479 using GridView = typename GridGeometry::GridView;
480 using Element = typename GridView::template Codim<0>::Entity;
481
483 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
484 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
486
487 using FVElementGeometry = typename GridGeometry::LocalView;
488 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
489 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
491
492 static constexpr int dim = GridView::dimension;
493 static constexpr int dimWorld = GridView::dimensionworld;
494
495 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
496 using VelocityVector = Dune::FieldVector<Scalar, dimWorld>;
497 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
500
501public:
505 using InitialValues = Dune::FieldVector<Scalar, dimWorld>;
506 using Sources = Dune::FieldVector<Scalar, dimWorld>;
507 using DirichletValues = Dune::FieldVector<Scalar, dimWorld>;
508 using BoundaryFluxes = Dune::FieldVector<Scalar, dimWorld>;
509
512
514 static constexpr bool isMomentumProblem() { return true; }
515
522 NavierStokesMomentumProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
523 std::shared_ptr<CouplingManager> couplingManager,
524 const std::string& paramGroup = "")
525 : ParentType(gridGeometry, paramGroup)
526 , gravity_(0.0)
527 , couplingManager_(couplingManager)
528 {
529 if (getParamFromGroup<bool>(paramGroup, "Problem.EnableGravity"))
530 gravity_[dim-1] = -9.81;
531
532 enableInertiaTerms_ = getParamFromGroup<bool>(paramGroup, "Problem.EnableInertiaTerms");
533 }
534
540 NavierStokesMomentumProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
541 const std::string& paramGroup = "")
542 : NavierStokesMomentumProblemImpl(gridGeometry, {}, paramGroup)
543 {}
544
563 template<class ElementVolumeVariables>
564 Sources source(const Element &element,
565 const FVElementGeometry& fvGeometry,
566 const ElementVolumeVariables& elemVolVars,
567 const SubControlVolume &scv) const
568 {
569 // forward to solution independent, fully-implicit specific interface
570 return asImp_().sourceAtPos(scv.center());
571 }
572
585 Sources sourceAtPos(const GlobalPosition &globalPos) const
586 {
589 return Sources(0.0);
590 }
591
599 BoundaryTypes boundaryTypes(const Element& element,
600 const SubControlVolume& scv) const
601 {
602 // forward it to the method which only takes the global coordinate
603 return asImp_().boundaryTypesAtPos(scv.dofPosition());
604 }
605
613 BoundaryTypes boundaryTypes(const Element& element,
614 const SubControlVolumeFace& scvf) const
615 {
616 DUNE_THROW(Dune::InvalidStateException, "boundaryTypes(..., scvf) called for a CVFE method.");
617 }
618
626 DirichletValues dirichlet(const Element& element, const SubControlVolume& scv) const
627 {
628 // forward it to the method which only takes the global coordinate
629 return asImp_().dirichletAtPos(scv.dofPosition());
630 }
631
639 DirichletValues dirichlet(const Element& element, const SubControlVolumeFace& scvf) const
640 {
641 // forward it to the method which only takes the global coordinate
642 DUNE_THROW(Dune::InvalidStateException, "dirichlet(scvf) called for CVFE method.");
643 }
644
651 const GravityVector& gravity() const
652 { return gravity_; }
653
658 { return enableInertiaTerms_; }
659
666 Scalar referencePressure() const
667 { return 0.0; }
668
673 Scalar pressure(const Element& element,
674 const FVElementGeometry& fvGeometry,
675 const SubControlVolumeFace& scvf) const
676 {
677 if constexpr (std::is_empty_v<CouplingManager>)
678 return asImp_().pressureAtPos(scvf.ipGlobal());
679 else
680 return couplingManager_->pressure(element, fvGeometry, scvf);
681 }
682
687 Scalar pressure(const Element& element,
688 const FVElementGeometry& fvGeometry,
689 const SubControlVolume& scv,
690 const bool isPreviousTimeStep = false) const
691 {
692 if constexpr (std::is_empty_v<CouplingManager>)
693 return asImp_().pressureAtPos(scv.dofPosition());
694 else
695 return couplingManager_->pressure(element, fvGeometry, scv, isPreviousTimeStep);
696 }
697
702 template<class IpData>
703 Scalar pressure(const Element& element,
704 const FVElementGeometry& fvGeometry,
705 const IpData& ipData,
706 const bool isPreviousTimeStep = false) const
707 {
708 if constexpr (std::is_empty_v<CouplingManager>)
709 return asImp_().pressureAtPos(ipData.global());
710 else
711 return couplingManager_->pressure(element, fvGeometry, ipData, isPreviousTimeStep);
712 }
713
717 Scalar pressureAtPos(const GlobalPosition&) const
718 {
719 DUNE_THROW(Dune::NotImplemented, "pressureAtPos not implemented");
720 }
721
726 Scalar density(const Element& element,
727 const FVElementGeometry& fvGeometry,
728 const SubControlVolumeFace& scvf) const
729 {
730 if constexpr (std::is_empty_v<CouplingManager>)
731 return asImp_().densityAtPos(scvf.ipGlobal());
732 else
733 return couplingManager_->density(element, fvGeometry, scvf);
734 }
735
740 Scalar density(const Element& element,
741 const FVElementGeometry& fvGeometry,
742 const SubControlVolume& scv,
743 const bool isPreviousTimeStep = false) const
744 {
745 if constexpr (std::is_empty_v<CouplingManager>)
746 return asImp_().densityAtPos(scv.dofPosition());
747 else
748 return couplingManager_->density(element, fvGeometry, scv, isPreviousTimeStep);
749 }
750
755 template<class IpData>
756 Scalar density(const Element& element,
757 const FVElementGeometry& fvGeometry,
758 const IpData& ipData,
759 const bool isPreviousTimeStep = false) const
760 {
761 if constexpr (std::is_empty_v<CouplingManager>)
762 return asImp_().densityAtPos(ipData.global());
763 else
764 return couplingManager_->density(element, fvGeometry, ipData, isPreviousTimeStep);
765 }
766
770 Scalar densityAtPos(const GlobalPosition&) const
771 {
772 DUNE_THROW(Dune::NotImplemented, "densityAtPos not implemented");
773 }
774
779 Scalar effectiveViscosity(const Element& element,
780 const FVElementGeometry& fvGeometry,
781 const SubControlVolumeFace& scvf) const
782 {
783 if constexpr (std::is_empty_v<CouplingManager>)
784 return asImp_().effectiveViscosityAtPos(scvf.ipGlobal());
785 else
786 return couplingManager_->effectiveViscosity(element, fvGeometry, scvf);
787 }
788
793 Scalar effectiveViscosity(const Element& element,
794 const FVElementGeometry& fvGeometry,
795 const SubControlVolume& scv,
796 const bool isPreviousTimeStep = false) const
797 {
798 if constexpr (std::is_empty_v<CouplingManager>)
799 return asImp_().effectiveViscosityAtPos(scv.dofPosition());
800 else
801 return couplingManager_->effectiveViscosity(element, fvGeometry, scv, isPreviousTimeStep);
802 }
803
808 template<class IpData>
809 Scalar effectiveViscosity(const Element& element,
810 const FVElementGeometry& fvGeometry,
811 const IpData& ipData,
812 const bool isPreviousTimeStep = false) const
813 {
814 if constexpr (std::is_empty_v<CouplingManager>)
815 return asImp_().effectiveViscosityAtPos(ipData.global());
816 else
817 return couplingManager_->effectiveViscosity(element, fvGeometry, ipData, isPreviousTimeStep);
818 }
819
823 Scalar effectiveViscosityAtPos(const GlobalPosition&) const
824 {
825 DUNE_THROW(Dune::NotImplemented, "effectiveViscosityAtPos not implemented");
826 }
827
832 template<class SolutionVector>
833 void applyInitialSolution(SolutionVector& sol) const
834 {
835 static_assert(GridGeometry::discMethod == DiscretizationMethods::CVFE<DM>{});
836 sol.resize(this->gridGeometry().numDofs());
837 std::vector<bool> dofHandled(this->gridGeometry().numDofs(), false);
838 auto fvGeometry = localView(this->gridGeometry());
839 for (const auto& element : elements(this->gridGeometry().gridView()))
840 {
841 fvGeometry.bindElement(element);
842 for (const auto& scv : scvs(fvGeometry))
843 {
844 const auto dofIdx = scv.dofIndex();
845 if (!dofHandled[dofIdx])
846 {
847 dofHandled[dofIdx] = true;
848 sol[dofIdx] = asImp_().initial(scv);
849 }
850 }
851 }
852 }
853
857 InitialValues initial(const SubControlVolume& scv) const
858 {
859 static_assert(GridGeometry::discMethod == DiscretizationMethods::CVFE<DM>{});
860 return asImp_().initialAtPos(scv.dofPosition());
861 }
862
863private:
865 Implementation &asImp_()
866 { return *static_cast<Implementation *>(this); }
867
869 const Implementation &asImp_() const
870 { return *static_cast<const Implementation *>(this); }
871
872 GravityVector gravity_;
873 bool enableInertiaTerms_;
874 std::shared_ptr<CouplingManager> couplingManager_ = {};
875};
876
877
881template<class TypeTag>
883: public FVProblemWithSpatialParams<TypeTag>
884{
886 using Implementation = GetPropType<TypeTag, Properties::Problem>;
887
889 using GridView = typename GridGeometry::GridView;
890 using Element = typename GridView::template Codim<0>::Entity;
891
893 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
894 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
896
897 using FVElementGeometry = typename GridGeometry::LocalView;
898 using GlobalPosition = typename FVElementGeometry::SubControlVolumeFace::GlobalPosition;
899 using LocalPosition = typename Element::Geometry::LocalCoordinate;
900
901 static constexpr int dim = GridView::dimension;
902 static constexpr int dimWorld = GridView::dimensionworld;
903
904 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
907
908public:
909 using InitialValues = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
910 using Sources = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
911 using DirichletValues = Dune::FieldVector<Scalar, dimWorld>;
912 using BoundaryFluxes = Dune::FieldVector<Scalar, ModelTraits::numEq()>;
913
916
918 static constexpr bool isMomentumProblem() { return true; }
919
926 CVFENavierStokesMomentumProblem(std::shared_ptr<const GridGeometry> gridGeometry,
927 std::shared_ptr<CouplingManager> couplingManager,
928 const std::string& paramGroup = "")
930 , gravity_(0.0)
931 , couplingManager_(couplingManager)
932 {
933 if (getParamFromGroup<bool>(paramGroup, "Problem.EnableGravity"))
934 gravity_[dim-1] = -9.81;
935
936 enableInertiaTerms_ = getParamFromGroup<bool>(paramGroup, "Problem.EnableInertiaTerms");
937 }
938
944 CVFENavierStokesMomentumProblem(std::shared_ptr<const GridGeometry> gridGeometry,
945 const std::string& paramGroup = "")
947 {}
948
964 template<class ElementVariables, class IpData>
965 Sources source(const FVElementGeometry& fvGeometry,
966 const ElementVariables& elemVars,
967 const IpData& ipData) const
968 {
969 return asImp_().sourceAtPos(ipData.global());
970 }
971
984 Sources sourceAtPos(const GlobalPosition &globalPos) const
985 {
988 return Sources(0.0);
989 }
990
998 template<class Intersection>
999 BoundaryTypes boundaryTypes(const FVElementGeometry& fvGeometry,
1000 const Intersection& intersection) const
1001 {
1002 // forward it to the method which only takes the global coordinate
1003 return asImp_().boundaryTypesAtPos(intersection.geometry().center());
1004 }
1005
1013 template<class FaceIpData>
1014 DirichletValues dirichlet(const FVElementGeometry& fvGeometry,
1015 const FaceIpData& faceIpData) const
1016 {
1017 // forward it to the method which only takes the global coordinate
1018 return asImp_().dirichletAtPos(faceIpData.global());
1019 }
1020
1029 template<class ElementVariables, class ElementFluxVariablesCache, class FaceIpData>
1030 BoundaryFluxes boundaryFlux(const FVElementGeometry& fvGeometry,
1031 const ElementVariables& elemVars,
1032 const ElementFluxVariablesCache& elemFluxVarsCache,
1033 const FaceIpData& faceIpData) const
1034 {
1035 return asImp_().boundaryFluxAtPos(faceIpData.global());
1036 }
1037
1041 BoundaryFluxes boundaryFluxAtPos(const GlobalPosition& globalPos) const
1042 { return BoundaryFluxes(0.0); }
1043
1050 const GravityVector& gravity() const
1051 { return gravity_; }
1052
1057 { return enableInertiaTerms_; }
1058
1065 Scalar referencePressure() const
1066 { return 0.0; }
1067
1072 template<class IpData>
1073 Scalar pressure(const Element& element,
1074 const FVElementGeometry& fvGeometry,
1075 const IpData& ipData,
1076 const bool isPreviousTimeStep = false) const
1077 {
1078 if constexpr (std::is_empty_v<CouplingManager>)
1079 return asImp_().pressureAtPos(ipData.global());
1080 else
1081 return couplingManager_->pressure(element, fvGeometry, ipData, isPreviousTimeStep);
1082 }
1083
1087 Scalar pressureAtPos(const GlobalPosition&) const
1088 {
1089 DUNE_THROW(Dune::NotImplemented, "pressureAtPos not implemented");
1090 }
1091
1096 template<class IpData>
1097 Scalar density(const Element& element,
1098 const FVElementGeometry& fvGeometry,
1099 const IpData& ipData,
1100 const bool isPreviousTimeStep = false) const
1101 {
1102 if constexpr (std::is_empty_v<CouplingManager>)
1103 return asImp_().densityAtPos(ipData.global());
1104 else
1105 return couplingManager_->density(element, fvGeometry, ipData, isPreviousTimeStep);
1106 }
1107
1111 Scalar densityAtPos(const GlobalPosition&) const
1112 {
1113 DUNE_THROW(Dune::NotImplemented, "densityAtPos not implemented");
1114 }
1115
1116
1121 template<class IpData>
1122 Scalar effectiveViscosity(const Element& element,
1123 const FVElementGeometry& fvGeometry,
1124 const IpData& ipData,
1125 const bool isPreviousTimeStep = false) const
1126 {
1127 if constexpr (std::is_empty_v<CouplingManager>)
1128 return asImp_().effectiveViscosityAtPos(ipData.global());
1129 else
1130 return couplingManager_->effectiveViscosity(element, fvGeometry, ipData, isPreviousTimeStep);
1131 }
1132
1136 Scalar effectiveViscosityAtPos(const GlobalPosition&) const
1137 {
1138 DUNE_THROW(Dune::NotImplemented, "effectiveViscosityAtPos not implemented");
1139 }
1140
1145 template<class SolutionVector>
1146 void applyInitialSolution(SolutionVector& sol) const
1147 {
1148 sol.resize(this->gridGeometry().numDofs());
1149 std::vector<bool> dofHandled(this->gridGeometry().numDofs(), false);
1150 auto fvGeometry = localView(this->gridGeometry());
1151 for (const auto& element : elements(this->gridGeometry().gridView()))
1152 {
1153 fvGeometry.bindElement(element);
1154 for (const auto& localDof : localDofs(fvGeometry))
1155 {
1156 const auto dofIdx = localDof.dofIndex();
1157 if (!dofHandled[dofIdx])
1158 {
1159 dofHandled[dofIdx] = true;
1160 sol[dofIdx] = asImp_().initial(fvGeometry, ipData(fvGeometry, localDof));
1161 }
1162 }
1163 }
1164 }
1165
1169 template<class IpData>
1170 InitialValues initial(const FVElementGeometry& fvGeometry, const IpData& ipData) const
1171 {
1172 return asImp_().initialAtPos(ipData.global());
1173 }
1174
1175private:
1177 Implementation &asImp_()
1178 { return *static_cast<Implementation *>(this); }
1179
1181 const Implementation &asImp_() const
1182 { return *static_cast<const Implementation *>(this); }
1183
1184 GravityVector gravity_;
1185 bool enableInertiaTerms_;
1186 std::shared_ptr<CouplingManager> couplingManager_ = {};
1187};
1188
1195template<class TypeTag>
1198>;
1199
1200} // end namespace Dumux
1201
1202#endif
Class to specify the type of a boundary.
Definition: common/boundarytypes.hh:26
Navier-Stokes default problem implementation for CVFE discretizations.
Definition: freeflow/navierstokes/momentum/problem.hh:884
Scalar densityAtPos(const GlobalPosition &) const
Returns the density at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:1111
BoundaryFluxes boundaryFluxAtPos(const GlobalPosition &globalPos) const
Returns the boundary flux at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:1041
CVFENavierStokesMomentumProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager, const std::string &paramGroup="")
The constructor.
Definition: freeflow/navierstokes/momentum/problem.hh:926
Dune::FieldVector< Scalar, ModelTraits::numEq()> BoundaryFluxes
Definition: freeflow/navierstokes/momentum/problem.hh:912
bool enableInertiaTerms() const
Returns whether inertia terms should be considered.
Definition: freeflow/navierstokes/momentum/problem.hh:1056
Scalar effectiveViscosity(const Element &element, const FVElementGeometry &fvGeometry, const IpData &ipData, const bool isPreviousTimeStep=false) const
Returns the effective dynamic viscosity at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:1122
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: freeflow/navierstokes/momentum/problem.hh:1146
DirichletValues dirichlet(const FVElementGeometry &fvGeometry, const FaceIpData &faceIpData) const
Evaluate the boundary conditions for a Dirichlet control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:1014
BoundaryTypes boundaryTypes(const FVElementGeometry &fvGeometry, const Intersection &intersection) const
Specifies which kind of boundary condition should be used for which equation on a given boundary face...
Definition: freeflow/navierstokes/momentum/problem.hh:999
Scalar pressureAtPos(const GlobalPosition &) const
Returns the pressure at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:1087
Scalar referencePressure() const
Returns a reference pressure This pressure is subtracted from the actual pressure for the momentum ba...
Definition: freeflow/navierstokes/momentum/problem.hh:1065
InitialValues initial(const FVElementGeometry &fvGeometry, const IpData &ipData) const
Evaluate the initial value at an interpolation point.
Definition: freeflow/navierstokes/momentum/problem.hh:1170
Sources sourceAtPos(const GlobalPosition &globalPos) const
Evaluate the source term for all phases at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:984
Scalar pressure(const Element &element, const FVElementGeometry &fvGeometry, const IpData &ipData, const bool isPreviousTimeStep=false) const
Returns the pressure at given interpolation point data.
Definition: freeflow/navierstokes/momentum/problem.hh:1073
CVFENavierStokesMomentumProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor for usage without a coupling manager.
Definition: freeflow/navierstokes/momentum/problem.hh:944
Sources source(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const IpData &ipData) const
Evaluate the source term at a given interpolation point, related to the residual of a local dof.
Definition: freeflow/navierstokes/momentum/problem.hh:965
Scalar density(const Element &element, const FVElementGeometry &fvGeometry, const IpData &ipData, const bool isPreviousTimeStep=false) const
Returns the density at given interpolation point data.
Definition: freeflow/navierstokes/momentum/problem.hh:1097
Dune::FieldVector< Scalar, ModelTraits::numEq()> InitialValues
Definition: freeflow/navierstokes/momentum/problem.hh:909
Dune::FieldVector< Scalar, ModelTraits::numEq()> Sources
Definition: freeflow/navierstokes/momentum/problem.hh:910
BoundaryFluxes boundaryFlux(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const ElementFluxVariablesCache &elemFluxVarsCache, const FaceIpData &faceIpData) const
Evaluates the boundary flux related to a localDof at a given interpolation point.
Definition: freeflow/navierstokes/momentum/problem.hh:1030
static constexpr bool isMomentumProblem()
This problem is used for the momentum balance model.
Definition: freeflow/navierstokes/momentum/problem.hh:918
const GravityVector & gravity() const
A default, i.e. if the user's does not overload any boundaryFlux method.
Definition: freeflow/navierstokes/momentum/problem.hh:1050
Scalar effectiveViscosityAtPos(const GlobalPosition &) const
Returns the effective dynamic viscosity at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:1136
Dune::FieldVector< Scalar, dimWorld > DirichletValues
Definition: freeflow/navierstokes/momentum/problem.hh:911
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:43
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:524
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:520
Base class for all finite-volume problems using spatial parameters.
Definition: fvproblemwithspatialparams.hh:29
Class to specify the type of a boundary condition for the Navier-Stokes model.
Definition: freeflow/navierstokes/momentum/boundarytypes.hh:25
Scalar effectiveViscosity(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns the effective dynamic viscosity at a given sub control volume face.
Definition: freeflow/navierstokes/momentum/problem.hh:779
Scalar density(const Element &element, const FVElementGeometry &fvGeometry, const IpData &ipData, const bool isPreviousTimeStep=false) const
Returns the density at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:756
Dune::FieldVector< Scalar, dimWorld > Sources
Definition: freeflow/navierstokes/momentum/problem.hh:506
NavierStokesMomentumProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager, const std::string &paramGroup="")
The constructor.
Definition: freeflow/navierstokes/momentum/problem.hh:522
Scalar pressure(const Element &element, const FVElementGeometry &fvGeometry, const IpData &ipData, const bool isPreviousTimeStep=false) const
Returns the pressure at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:703
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: freeflow/navierstokes/momentum/problem.hh:833
Scalar pressureAtPos(const GlobalPosition &) const
Returns the pressure at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:717
Scalar effectiveViscosity(const Element &element, const FVElementGeometry &fvGeometry, const IpData &ipData, const bool isPreviousTimeStep=false) const
Returns the effective dynamic viscosity at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:809
Scalar pressure(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolume &scv, const bool isPreviousTimeStep=false) const
Returns the pressure at a given sub control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:687
static constexpr bool isMomentumProblem()
This problem is used for the momentum balance model.
Definition: freeflow/navierstokes/momentum/problem.hh:514
Scalar densityAtPos(const GlobalPosition &) const
Returns the density at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:770
InitialValues initial(const SubControlVolume &scv) const
Evaluate the initial value at an sub control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:857
Sources sourceAtPos(const GlobalPosition &globalPos) const
Evaluate the source term for all phases at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:585
Sources source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: freeflow/navierstokes/momentum/problem.hh:564
Scalar effectiveViscosityAtPos(const GlobalPosition &) const
Returns the effective dynamic viscosity at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:823
Dune::FieldVector< Scalar, dimWorld > InitialValues
Definition: freeflow/navierstokes/momentum/problem.hh:505
BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: freeflow/navierstokes/momentum/problem.hh:613
const GravityVector & gravity() const
Returns the acceleration due to gravity.
Definition: freeflow/navierstokes/momentum/problem.hh:651
Scalar density(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns the density at a given sub control volume face.
Definition: freeflow/navierstokes/momentum/problem.hh:726
Dune::FieldVector< Scalar, dimWorld > DirichletValues
Definition: freeflow/navierstokes/momentum/problem.hh:507
DirichletValues dirichlet(const Element &element, const SubControlVolume &scv) const
Evaluate the boundary conditions for a Dirichlet control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:626
bool enableInertiaTerms() const
Returns whether inertia terms should be considered.
Definition: freeflow/navierstokes/momentum/problem.hh:657
NavierStokesMomentumProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor for usage without a coupling manager.
Definition: freeflow/navierstokes/momentum/problem.hh:540
BoundaryTypes boundaryTypes(const Element &element, const SubControlVolume &scv) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: freeflow/navierstokes/momentum/problem.hh:599
Scalar density(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolume &scv, const bool isPreviousTimeStep=false) const
Returns the density at a given sub control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:740
Dune::FieldVector< Scalar, dimWorld > BoundaryFluxes
Definition: freeflow/navierstokes/momentum/problem.hh:508
Scalar referencePressure() const
Returns a reference pressure This pressure is subtracted from the actual pressure for the momentum ba...
Definition: freeflow/navierstokes/momentum/problem.hh:666
Scalar effectiveViscosity(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolume &scv, const bool isPreviousTimeStep=false) const
Returns the effective dynamic viscosity at a given sub control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:793
Scalar pressure(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns the pressure at a given sub control volume face.
Definition: freeflow/navierstokes/momentum/problem.hh:673
DirichletValues dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a Dirichlet control volume face.
Definition: freeflow/navierstokes/momentum/problem.hh:639
Sources source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: freeflow/navierstokes/momentum/problem.hh:128
NavierStokesMomentumProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor for usage without a coupling manager.
Definition: freeflow/navierstokes/momentum/problem.hh:105
Scalar pressure(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns the pressure at a given sub control volume face.
Definition: freeflow/navierstokes/momentum/problem.hh:245
auto boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: freeflow/navierstokes/momentum/problem.hh:181
Scalar pseudo3DWallFriction(const Scalar velocity, const Scalar viscosity, const Scalar height, const Scalar factor=8.0) const
An additional drag term can be included as source term for the momentum balance to mimic 3D flow beha...
Definition: freeflow/navierstokes/momentum/problem.hh:420
Scalar effectiveViscosity(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns the effective dynamic viscosity at a given sub control volume face.
Definition: freeflow/navierstokes/momentum/problem.hh:328
bool enableInertiaTerms() const
Returns whether inertia terms should be considered.
Definition: freeflow/navierstokes/momentum/problem.hh:238
NavierStokesMomentumProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager, const std::string &paramGroup="")
The constructor.
Definition: freeflow/navierstokes/momentum/problem.hh:87
Scalar pseudo3DWallFriction(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv, const Scalar height, const Scalar factor=8.0) const
Convenience function for staggered grid implementation.
Definition: freeflow/navierstokes/momentum/problem.hh:394
auto insideAndOutsideDensity(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf, const bool isPreviousTimeStep=false) const
Definition: freeflow/navierstokes/momentum/problem.hh:302
Scalar effectiveViscosityAtPos(const GlobalPosition &) const
Returns the effective dynamic viscosity at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:355
const CouplingManager & couplingManager() const
Definition: freeflow/navierstokes/momentum/problem.hh:444
Dune::FieldVector< Scalar, dimWorld > MomentumFluxType
Definition: freeflow/navierstokes/momentum/problem.hh:73
static constexpr bool isMomentumProblem()
This problem is used for the momentum balance model.
Definition: freeflow/navierstokes/momentum/problem.hh:79
Scalar referencePressure(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns a reference pressure at a given sub control volume face. This pressure is subtracted from the...
Definition: freeflow/navierstokes/momentum/problem.hh:269
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: freeflow/navierstokes/momentum/problem.hh:365
Scalar density(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns the density at a given sub control volume face.
Definition: freeflow/navierstokes/momentum/problem.hh:278
const GravityVector & gravity() const
A default, i.e. if the user's does not overload any neumann method.
Definition: freeflow/navierstokes/momentum/problem.hh:232
bool onSlipBoundary(const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf) const
Returns true if the scvf is located on a boundary with a slip condition.
Definition: freeflow/navierstokes/momentum/problem.hh:434
Dune::FieldVector< Scalar, dimWorld > InitialValues
Definition: freeflow/navierstokes/momentum/problem.hh:68
Scalar density(const Element &element, const SubControlVolume &scv, const bool isPreviousTimeStep=false) const
Returns the density at a given sub control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:292
BoundaryFluxes neumannAtPos(const GlobalPosition &globalPos) const
Returns the neumann flux at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:223
InitialValues initial(const SubControlVolume &scv) const
Evaluate the initial value at a sub control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:388
Sources scvPointSources(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Adds contribution of point sources for a specific sub control volume to the values....
Definition: freeflow/navierstokes/momentum/problem.hh:163
Scalar effectiveViscosity(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolume &scv) const
Returns the effective dynamic viscosity at a given sub control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:342
Scalar densityAtPos(const GlobalPosition &) const
Returns the density at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:319
Dune::FieldVector< Scalar, dimWorld > BoundaryFluxes
Definition: freeflow/navierstokes/momentum/problem.hh:71
DirichletValues dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet control volume face.
Definition: freeflow/navierstokes/momentum/problem.hh:198
Dune::FieldVector< Scalar, dimWorld > DirichletValues
Definition: freeflow/navierstokes/momentum/problem.hh:70
Dune::FieldVector< Scalar, dimWorld > Sources
Definition: freeflow/navierstokes/momentum/problem.hh:69
BoundaryFluxes neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann control volume.
Definition: freeflow/navierstokes/momentum/problem.hh:213
bool onSlipBoundaryAtPos(const GlobalPosition &pos) const
Returns true if the scvf is located on a boundary with a slip condition.
Definition: freeflow/navierstokes/momentum/problem.hh:441
Scalar pressureAtPos(const GlobalPosition &) const
Returns the pressure at a given position.
Definition: freeflow/navierstokes/momentum/problem.hh:258
Sources sourceAtPos(const GlobalPosition &globalPos) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: freeflow/navierstokes/momentum/problem.hh:150
Definition: freeflow/navierstokes/momentum/problem.hh:27
Defines all properties used in Dumux.
Base class for all finite volume problems that are parameterized.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
The available discretization methods in Dumux.
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:62
Definition: adapt.hh:17
std::ranges::range auto scvs(const FVElementGeometry &fvGeometry, const LocalDof &localDof)
Definition: localdof.hh:79
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition: localdof.hh:50
A helper to deduce a vector with the same size as numbers of equations.
Definition: method.hh:46