DNDSR 0.2.1
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
ModelEvaluator.hpp
Go to the documentation of this file.
1#pragma once
2
3// NOTE: ModelEvaluator is a concrete advection-diffusion test physics model.
4// It does not belong in the physics-agnostic CFV module, but is kept here for
5// now because the Python bindings (CFV.ModelEvaluator) and test code depend on
6// its current location. A future refactoring phase should move it to src/Model/
7// and decouple the pybind11 registration from cfv_pybind11.cpp.
8
9#include <nlohmann/json.hpp>
10#include <utility>
11
12#include "DNDS/Defines.hpp"
15
16namespace DNDS::CFV
17{
19 {
20 real ax = 1.0;
21 real ay = 0.0;
22 real sigma = 0.0;
23
25 {
26 // clang-format off
27 DNDS_FIELD(ax, "Advection velocity x-component");
28 DNDS_FIELD(ay, "Advection velocity y-component");
29 DNDS_FIELD(sigma, "Diffusion coefficient",
31 // clang-format on
32 }
33 };
34
36 {
37 public:
38 static const int nVarsFixed = DynamicSize;
39 static const int dim = 2;
41
42 private:
44 ssp<tvfv> vfv;
45 ModelSettings settings;
46
48
49 public:
50 using TVec = Eigen::Matrix<real, dim, 1>;
51 using TMat = Eigen::Matrix<real, dim, dim>;
52 using TU = Eigen::Matrix<real, nVarsFixed, 1>;
53 using TDiffU = Eigen::Matrix<real, dim, nVarsFixed>;
55
56 ModelEvaluator(decltype(mesh) mesh_, decltype(vfv) vfv_,
57 const ModelSettings &settings_, int nVars)
58 : mesh(std::move(mesh_)), vfv(std::move(vfv_)), settings(settings_)
59 {
60 vfv->BuildUGrad(uGradBuf, nVars);
61 }
62
63 ModelSettings &get_settings() { return settings; }
64
66 {
67
68 return [this, t](const auto &u, const auto &uMean, index iCell, index iFace, int iG,
69 const Geom::tPoint &norm, const Geom::tPoint &pPhy, Geom::t_index fType)
70 {
71 static const auto Seq012 = Eigen::seq(Eigen::fix<0>, Eigen::fix<dim - 1>);
72 TU uF = u;
73 TVec normV = norm(Seq012);
75 uF, uMean,
76 iCell, iFace, iG,
77 normV, Geom::NormBuildLocalBaseV<dim>(normV),
78 pPhy,
79 t, fType, false, 1);
80 };
81 }
82
83 TU generateBoundaryValue(TU &ULxy, //! warning, possible that UL is also modified
84 const TU &ULMeanXy,
85 index iCell, index iFace, int iG,
86 const TVec &uNorm,
87 const TMat &normBase,
88 const Geom::tPoint &pPhysics,
89 real t,
90 Geom::t_index btype,
91 bool fixUL = false,
92 int geomMode = 0,
93 int linMode = 0)
94 {
95 TU ret;
96 ret.resizeLike(ULxy);
97 ret.setZero();
98 return ret;
99 }
100
102 {
103 bool direct2ndRec = false;
106 };
107
109 const EvaluateRHSOptions &options = EvaluateRHSOptions{});
110
112 tURec<nVarsFixed> &uRecNew,
114 real t,
115 bool putIntoNew = false,
116 bool recordInc = false,
117 bool uRecIsZero = false)
118 {
119 vfv->DoReconstructionIter<nVarsFixed>(uRec, uRecNew, u,
120 get_FBoundary(t),
121 putIntoNew, recordInc, uRecIsZero);
122 }
123 };
124}
pybind11-style configuration registration with macro-based field declaration and namespace-scoped tag...
#define DNDS_FIELD(name_, desc_,...)
Register a field inside a DNDS_DECLARE_CONFIG body.
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
Primary solver state container: an ArrayEigenMatrix pair with MPI-collective vector-space operations.
Definition ArrayDOF.hpp:176
Eigen::Matrix< real, dim, dim > TMat
void EvaluateRHS(tUDof< nVarsFixed > &rhs, tUDof< nVarsFixed > &u, tURec< nVarsFixed > &uRec, real t, const EvaluateRHSOptions &options=EvaluateRHSOptions{})
Eigen::Matrix< real, nVarsFixed, 1 > TU
ModelSettings & get_settings()
void DoReconstructionIter(tURec< nVarsFixed > &uRec, tURec< nVarsFixed > &uRecNew, tUDof< nVarsFixed > &u, real t, bool putIntoNew=false, bool recordInc=false, bool uRecIsZero=false)
typename tvfv::TFBoundary< nVarsFixed > Tvfv_FBoundary
ModelEvaluator(decltype(mesh) mesh_, decltype(vfv) vfv_, const ModelSettings &settings_, int nVars)
Eigen::Matrix< real, dim, nVarsFixed > TDiffU
Tvfv_FBoundary get_FBoundary(real t)
Eigen::Matrix< real, dim, 1 > TVec
TU generateBoundaryValue(TU &ULxy, const TU &ULMeanXy, index iCell, index iFace, int iG, const TVec &uNorm, const TMat &normBase, const Geom::tPoint &pPhysics, real t, Geom::t_index btype, bool fixUL=false, int geomMode=0, int linMode=0)
The VR class that provides any information needed in high-order CFV.
RangeTag range(double min)
Create a minimum-only range constraint.
int32_t t_index
Definition Geometric.hpp:6
Eigen::Vector3d tPoint
Definition Geometric.hpp:9
DNDS_CONSTANT const rowsize DynamicSize
Template parameter flag: "row width is set at runtime but uniform".
Definition Defines.hpp:282
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
Definition Defines.hpp:112
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
Definition Defines.hpp:143
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Definition Defines.hpp:110
DNDS_DECLARE_CONFIG(ModelSettings)
DistributedHex3D mesh