DNDSR 0.1.0.dev1+gcd065ad
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"
13#include "DNDS/ConfigParam.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 DNDS_FIELD(ax, "Advection velocity x-component");
27 DNDS_FIELD(ay, "Advection velocity y-component");
28 DNDS_FIELD(sigma, "Diffusion coefficient",
30 }
31 };
32
34 {
35 public:
36 static const int nVarsFixed = DynamicSize;
37 static const int dim = 2;
39
40 private:
42 ssp<tvfv> vfv;
43 ModelSettings settings;
44
46
47 public:
48 using TVec = Eigen::Matrix<real, dim, 1>;
49 using TMat = Eigen::Matrix<real, dim, dim>;
50 using TU = Eigen::Matrix<real, nVarsFixed, 1>;
51 using TDiffU = Eigen::Matrix<real, dim, nVarsFixed>;
53
54 ModelEvaluator(decltype(mesh) mesh_, decltype(vfv) vfv_,
55 const ModelSettings &settings_, int nVars)
56 : mesh(std::move(mesh_)), vfv(std::move(vfv_)), settings(settings_)
57 {
58 vfv->BuildUGrad(uGradBuf, nVars);
59 }
60
61 ModelSettings &get_settings() { return settings; }
62
64 {
65
66 return [this, t](const auto &u, const auto &uMean, index iCell, index iFace, int iG,
67 const Geom::tPoint &norm, const Geom::tPoint &pPhy, Geom::t_index fType)
68 {
69 static const auto Seq012 = Eigen::seq(Eigen::fix<0>, Eigen::fix<dim - 1>);
70 TU uF = u;
71 TVec normV = norm(Seq012);
73 uF, uMean,
74 iCell, iFace, iG,
75 normV, Geom::NormBuildLocalBaseV<dim>(normV),
76 pPhy,
77 t, fType, false, 1);
78 };
79 }
80
81 TU generateBoundaryValue(TU &ULxy, //! warning, possible that UL is also modified
82 const TU &ULMeanXy,
83 index iCell, index iFace, int iG,
84 const TVec &uNorm,
85 const TMat &normBase,
86 const Geom::tPoint &pPhysics,
87 real t,
88 Geom::t_index btype,
89 bool fixUL = false,
90 int geomMode = 0,
91 int linMode = 0)
92 {
93 TU ret;
94 ret.resizeLike(ULxy);
95 ret.setZero();
96 return ret;
97 }
98
100 {
101 bool direct2ndRec = false;
104 };
105
107 const EvaluateRHSOptions &options = EvaluateRHSOptions{});
108
110 tURec<nVarsFixed> &uRecNew,
112 real t,
113 bool putIntoNew = false,
114 bool recordInc = false,
115 bool uRecIsZero = false)
116 {
117 vfv->DoReconstructionIter<nVarsFixed>(uRec, uRecNew, u,
118 get_FBoundary(t),
119 putIntoNew, recordInc, uRecIsZero);
120 }
121 };
122}
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:172
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:277
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
Definition Defines.hpp:107
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
Definition Defines.hpp:138
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Definition Defines.hpp:105
DNDS_DECLARE_CONFIG(ModelSettings)