Plugins
Loading...
Searching...
No Matches
st_venant_wall_bnd.h
Go to the documentation of this file.
1
6#ifndef D3F_ST_VENANT_WALL_BND_H
7#define D3F_ST_VENANT_WALL_BND_H
8
9#include "common/common.h"
11
12namespace ug {
13namespace d3f {
14
23template<int dim>
24class StVenantWallBndDir : public StdDataLinker<StVenantWallBndDir<dim>, number, dim> {
27
28public:
34 : m_downStreamVec(downstreamvec) {}
35
36 virtual void operator()(number& value, const MathVector<dim>& globIP, number time, int si) const {
37 evaluate(value, globIP, time, si);
38 }
39
40 template<int refDim>
41 void operator()(number vValue[],
42 const MathVector<dim> vGlobIP[],
43 number time, int si,
44 GridObject* elem,
45 const MathVector<dim> vCornerCoords[],
46 const MathVector<refDim> vLocIP[],
47 const size_t nip,
48 LocalVector* u,
49 const MathMatrix<refDim, dim>* vJT = NULL) const
50 {
51 evaluate<refDim>(vValue, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT);
52 }
53
54 void evaluate(number& value, const MathVector<dim>& globIP, number time, int si) const {
55 UG_THROW("StVenantWallBndDir: Solution, element and local IPs required for evaluation.");
56 }
57
61 template <int refDim>
62 void evaluate(number vValue[],
63 const MathVector<dim> vGlobIP[],
64 number time, int si,
65 GridObject* elem,
66 const MathVector<dim> vCornerCoords[],
67 const MathVector<refDim> vLocIP[],
68 const size_t nip,
69 LocalVector* u,
70 const MathMatrix<refDim, dim>* vJT = NULL) const
71 {
72 if (nip < 1) return;
73
74 MathVector<dim> downStreamVec[nip];
75 MathVector<dim> elemNormal;
76
77 // Calculate the element normal (direction of the edge)
78 if (VecDistanceSq(vCornerCoords[1], vGlobIP[0]) < SMALL) {
79 elemNormal = vCornerCoords[1];
80 elemNormal -= vCornerCoords[0];
81 } else {
82 elemNormal = vCornerCoords[0];
83 elemNormal -= vCornerCoords[1];
84 }
85 VecNormalize(elemNormal, elemNormal);
86
87 // Get the downstream reference vector from user data
88 (*m_downStreamVec)(downStreamVec, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT);
89
90 // Compute the alignment (dot product)
91 for (size_t ip = 0; ip < nip; ++ip) {
92 vValue[ip] = VecDot(downStreamVec[ip], elemNormal);
93 }
94 }
95
96 template <int refDim>
97 void eval_and_deriv(number vValue[],
98 const MathVector<dim> vGlobIP[],
99 number time, int si,
100 GridObject* elem,
101 const MathVector<dim> vCornerCoords[],
102 const MathVector<refDim> vLocIP[],
103 const size_t nip,
104 LocalVector* u,
105 bool bDeriv,
106 int s,
107 std::vector<std::vector<number>> vvvDeriv[],
108 const MathMatrix<refDim, dim>* vJT = NULL) const
109 {
110 evaluate<refDim>(vValue, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT);
111 // Derivative is zero as downstream reference is typically constant or externally defined.
112 }
113
114 bool requires_grid_fct() const { return true; }
115
116private:
118};
119
120} // namespace d3f
121} // namespace ug
122
123#endif // D3F_ST_VENANT_WALL_BND_H
parameterString s
Definition Biogas.lua:2
TData & value(size_t s, size_t ip)
number time() const
const MathVector< dim > & ip(size_t s, size_t ip) const
Linker to evaluate the normal component of a downstream vector at a boundary.
Definition st_venant_wall_bnd.h:24
void evaluate(number &value, const MathVector< dim > &globIP, number time, int si) const
Definition st_venant_wall_bnd.h:54
virtual void operator()(number &value, const MathVector< dim > &globIP, number time, int si) const
Definition st_venant_wall_bnd.h:36
void eval_and_deriv(number vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< number > > vvvDeriv[], const MathMatrix< refDim, dim > *vJT=NULL) const
Definition st_venant_wall_bnd.h:97
CplUserData< MathVector< dim >, dim > TVectorData
Definition st_venant_wall_bnd.h:26
CplUserData< number, dim > TNumberData
Definition st_venant_wall_bnd.h:25
StVenantWallBndDir(SmartPtr< TVectorData > downstreamvec)
Constructor.
Definition st_venant_wall_bnd.h:33
bool requires_grid_fct() const
Definition st_venant_wall_bnd.h:114
void evaluate(number vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, const MathMatrix< refDim, dim > *vJT=NULL) const
Evaluates the dot product of the downstream vector and the boundary normal.
Definition st_venant_wall_bnd.h:62
void operator()(number vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, const MathMatrix< refDim, dim > *vJT=NULL) const
Definition st_venant_wall_bnd.h:41
SmartPtr< TVectorData > m_downStreamVec
Definition st_venant_wall_bnd.h:117
#define UG_THROW(msg)
double number
void VecNormalize(vector_t &vOut, const vector_t &v)
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
const number SMALL
TVector::value_type VecDistanceSq(const TVector &v1, const TVector &v2, const TMatrix &M)