33 #ifndef __H__UG__NAVIER_STOKES__UPWIND_INTERFACE__
34 #define __H__UG__NAVIER_STOKES__UPWIND_INTERFACE__
38 #define UG_NSUPWIND_ASSERT(cond, exp) UG_ASSERT((cond), exp)
64 static const size_t maxNumSCVF = traits::maxNumSCVF + 10;
67 static const size_t maxNumSH = traits::maxNSH + 10;
162 VecScale(vDownIPVel[ip], vStdVel[ip], -1.0);
257 template <
typename TFVGeom,
typename TAssFunc>
261 template <
typename TFVGeom,
typename TAssFunc>
265 template <
typename TFVGeom>
288 template <
typename TFVGeom,
typename TAssFunc>
294 size_t id = GetUniqueFVGeomID<TFVGeom>();
297 if((
size_t)
id >= m_vComputeFunc.size())
298 m_vComputeFunc.resize(
id+1, NULL);
301 m_vComputeFunc[id] =
reinterpret_cast<ComputeFunc
>(func);
307 template <
typename TFVGeom>
314 size_t id = GetUniqueFVGeomID<TFVGeom>();
317 if(
id >= m_vComputeFunc.size() || m_vComputeFunc[
id] == NULL)
318 UG_THROW(
"No update function registered for Geometry "<<
id);
325 m_numScvf = geo.num_scvf();
326 m_numSh = geo.num_sh();
345 for(
size_t sh = 0; sh < num_sh(); ++sh)
346 for(
int d = 0; d <
dim; ++d)
347 vel[d] += upwind_shape_sh(scvf, sh) * CornerVel(d, sh);
350 if(!non_zero_shape_ip())
return vel;
353 for(
size_t scvf2 = 0; scvf2 < num_scvf(); ++scvf2)
354 VecScaleAppend(vel, upwind_shape_ip(scvf, scvf2), vStdVel[scvf2]);
360 template <
template <
class Elem,
int WorldDim>
class TFVGeom,
int dim,
typename TImpl>
378 register_func<RegularEdge>();
383 register_func<Triangle>();
384 register_func<Quadrilateral>();
389 register_func<Tetrahedron>();
390 register_func<Pyramid>();
391 register_func<Prism>();
392 register_func<Hexahedron>();
395 template <
typename TElem>
398 typedef TFVGeom<TElem, dim> TGeom;
400 typedef void (*TFunc)(
407 getImpl().template register_update_func<TGeom, TFunc>(&TImpl::template compute<TElem>);
412 TImpl&
getImpl() {
return static_cast<TImpl&
>(*this);}
function NavierStokes(fcts, subsets, discType)
Definition: upwind_interface.h:57
void(* ComputeFunc)(const FVGeometryBase *obj, const MathVector< dim > vIPVel[maxNumSCVF], number vUpShapeSh[maxNumSCVF][maxNumSH], number vUpShapeIp[maxNumSCVF][maxNumSCVF], number vConvLength[maxNumSCVF])
type of update function
Definition: upwind_interface.h:272
int m_id
id of current geometry type
Definition: upwind_interface.h:283
void register_update_func(TAssFunc func)
register a update function for a Geometry
Definition: upwind_interface.h:291
size_t m_numSh
number of current shape functions (usually in corners)
Definition: upwind_interface.h:225
number & upwind_conv_length(size_t scvf)
non-const access to Convection Length
Definition: upwind_interface.h:208
number m_vDownConvLength[maxNumSCVF]
Definition: upwind_interface.h:229
size_t num_scvf() const
returns number of sub control volume faces
Definition: upwind_interface.h:86
bool m_bNonZeroShapeIp
flag if ip shapes are non-zero
Definition: upwind_interface.h:236
number m_vvDownShapeSh[maxNumSCVF][maxNumSH]
Definition: upwind_interface.h:233
std::vector< ComputeFunc > m_vComputeFunc
Vector holding all update functions.
Definition: upwind_interface.h:280
void register_update_ip_vel_func(TAssFunc func)
register a update function for a Geometry
number & upwind_shape_ip(size_t scvf, size_t scvf2)
non-const access to upwind shapes for ip vel
Definition: upwind_interface.h:192
void compute(const FVGeometryBase *geo, const MathVector< dim > vIPVel[maxNumSCVF], number vUpShapeSh[maxNumSCVF][maxNumSH], number vUpShapeIp[maxNumSCVF][maxNumSCVF], number vConvLength[maxNumSCVF])
compute values for new geometry and corner velocities
Definition: upwind_interface.h:243
void update_downwind(const FVGeometryBase *geo, const MathVector< dim > vStdVel[])
compute values for new geometry and corner velocities
Definition: upwind_interface.h:157
void set_shape_ip_flag(bool flag)
sets the shape ip flag
Definition: upwind_interface.h:173
number downwind_shape_ip(size_t scvf, size_t scvf2) const
upwind shapes for ip vel
Definition: upwind_interface.h:135
size_t num_sh() const
returns number of shapes
Definition: upwind_interface.h:83
number m_vvUpShapeIp[maxNumSCVF][maxNumSCVF]
upwind shapes for ip vels
Definition: upwind_interface.h:239
number & downwind_shape_sh(size_t scvf, size_t sh)
non-const access to upwind shapes for corner vel
Definition: upwind_interface.h:184
INavierStokesUpwind()
constructor
Definition: upwind_interface.h:75
number downwind_conv_length(size_t scvf) const
Convection Length.
Definition: upwind_interface.h:96
number downwind_shape_sh(size_t scvf, size_t sh) const
upwind shape for corner vel
Definition: upwind_interface.h:116
static const size_t maxNumSH
max number of shape functions
Definition: upwind_interface.h:67
INavierStokesUpwind< dim > this_type
Abbreviation for own type.
Definition: upwind_interface.h:71
void update(const FVGeometryBase *geo, const MathVector< dim > vStdVel[])
compute values for new geometry and corner velocities
Definition: upwind_interface.h:143
number m_vUpConvLength[maxNumSCVF]
convection length
Definition: upwind_interface.h:228
number upwind_conv_length(size_t scvf) const
Convection Length.
Definition: upwind_interface.h:89
number m_vvUpShapeSh[maxNumSCVF][maxNumSH]
upwind shapes for corners shape functions
Definition: upwind_interface.h:232
size_t m_numScvf
number of current scvf
Definition: upwind_interface.h:222
number & downwind_shape_ip(size_t scvf, size_t scvf2)
non-const access to upwind shapes for ip vel
Definition: upwind_interface.h:200
number upwind_shape_ip(size_t scvf, size_t scvf2) const
upwind shapes for ip vel
Definition: upwind_interface.h:127
number & upwind_shape_sh(size_t scvf, size_t sh)
non-const access to upwind shapes for corner vel
Definition: upwind_interface.h:176
fv1_dim_traits< dim, dim > traits
used traits
Definition: upwind_interface.h:60
number upwind_shape_sh(size_t scvf, size_t sh) const
upwind shape for corner vel
Definition: upwind_interface.h:108
void set_geometry_type()
set the Geometry type to use for next updates
Definition: upwind_interface.h:310
MathVector< dim > upwind_vel(const size_t scvf, const LocalVector &CornerVel, const MathVector< dim > vStdVel[]) const
returns the upwind velocity
Definition: upwind_interface.h:337
static const size_t maxNumSCVF
max number of SubControlVolumeFaces
Definition: upwind_interface.h:64
void update_upwind(const FVGeometryBase *geo, const MathVector< dim > vStdVel[])
compute values for new geometry and corner velocities
Definition: upwind_interface.h:150
bool non_zero_shape_ip() const
returns if upwind shape w.r.t. ip vel is non-zero
Definition: upwind_interface.h:124
number m_vvDownShapeIp[maxNumSCVF][maxNumSCVF]
Definition: upwind_interface.h:240
number & down_upwind_conv_length(size_t scvf)
non-const access to Convection Length
Definition: upwind_interface.h:215
Definition: upwind_interface.h:362
static const size_t maxNumSCVF
Definition: upwind_interface.h:368
void register_func(Int2Type< 3 >)
Definition: upwind_interface.h:387
INavierStokesUpwind< dim > base_type
Base class.
Definition: upwind_interface.h:365
NavierStokesUpwindRegister()
constructor
Definition: upwind_interface.h:373
void register_func(Int2Type< 2 >)
Definition: upwind_interface.h:381
void register_func(Int2Type< 1 >)
Definition: upwind_interface.h:376
void register_func()
Definition: upwind_interface.h:396
static const size_t maxNumSH
Definition: upwind_interface.h:369
TImpl & getImpl()
access to implementation
Definition: upwind_interface.h:412
void VecScaleAppend(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1)
void VecScale(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
SmartPtr< INavierStokesUpwind< dim > > CreateNavierStokesUpwind(const std::string &name)
creates upwind based on a string identifier
Definition: upwind_interface.cpp:44
void VecSet(vector_t &dest, number alpha, const std::vector< size_t > vIndex)
#define UG_NSUPWIND_ASSERT(cond, exp)
Definition: upwind_interface.h:38