33 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__BINGHAM_VISCOSITY_LINKER__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__BINGHAM_VISCOSITY_LINKER__
61 :
public StdDataLinker< BinghamViscosityLinker<dim>, number, dim>
83 UG_LOG(
"BinghamViscosityLinker::evaluate single called");
89 (*m_spDensity)(density, globIP,
time, si);
90 (*m_spViscosity)(viscosity, globIP,
time, si);
91 (*m_spYieldStress)(yieldStress, globIP,
time, si);
92 (*m_spVelocityGrad)(velocityGrad, globIP,
time, si);
97 for(
int d1 = 0; d1 <
dim; ++d1)
99 for(
int d2 = 0; d2 <
dim; ++d2)
101 innerSum += pow(velocityGrad(d1,d2) + velocityGrad(d2,d1),2);
106 value = viscosity + yieldStress/sqrt(0.5+(1.0/(pow(2,
dim))*innerSum));
111 template <
int refDim>
122 UG_LOG(
"BinghamViscosityLinker::evaluate called");
123 std::vector<number> vDensity(nip);
124 std::vector<number> vViscosity(nip);
125 std::vector<number> vYieldStress(nip);
126 std::vector<MathMatrix<dim,dim> > vVelocityGrad(nip);
128 (*m_spDensity)(&vDensity[0], vGlobIP,
time, si,
129 elem, vCornerCoords, vLocIP, nip, u, vJT);
130 (*m_spViscosity)(&vViscosity[0], vGlobIP,
time, si,
131 elem, vCornerCoords, vLocIP, nip, u, vJT);
132 (*m_spYieldStress)(&vYieldStress[0], vGlobIP,
time, si,
133 elem, vCornerCoords, vLocIP, nip, u, vJT);
134 (*m_spVelocityGrad)(&vVelocityGrad[0], vGlobIP,
time, si,
135 elem, vCornerCoords, vLocIP, nip, u, vJT);
137 for(
size_t ip = 0;
ip < nip; ++
ip)
142 for(
int d1 = 0; d1 <
dim; ++d1)
144 for(
int d2 = 0; d2 <
dim; ++d2)
146 mu += pow(vVelocityGrad[
ip](d1,d2) + vVelocityGrad[
ip](d2,d1),2);
151 mu = vViscosity[
ip] + vYieldStress[
ip]/sqrt(0.5+(1.0/(pow(2,
dim))*
mu));
152 vValue[
ip] =
mu * 1./vDensity[
ip];
156 template <
int refDim>
167 std::vector<std::vector<number> > vvvDeriv[],
171 UG_LOG(
"BinghamViscosityLinker::eval_and_deriv called");
178 for(
size_t ip = 0;
ip < nip; ++
ip)
183 for(
int d1 = 0; d1 <
dim; ++d1)
185 for(
int d2 = 0; d2 <
dim; ++d2)
187 mu += pow(vVelocityGrad[
ip](d1,d2) + vVelocityGrad[
ip](d2,d1),2);
192 mu = vViscosity[
ip] + vYieldStress[
ip]/sqrt(0.5+(1.0/(pow(2,
dim))*
mu));
193 vValue[
ip] =
mu * 1./vDensity[
ip];
203 this->set_zero(vvvDeriv, nip);
208 for(
size_t ip = 0;
ip < nip; ++
ip)
210 for(
size_t fct = 0; fct <
m_spDDensity->num_fct(); ++fct)
219 for(
size_t sh = 0; sh < this->num_sh(commonFct); ++sh)
221 vvvDeriv[
ip][commonFct][sh] -= vDDensity[sh] / vDensity[
ip] * vValue[
ip];
230 for(
size_t ip = 0;
ip < nip; ++
ip)
241 for(
size_t sh = 0; sh < this->num_sh(commonFct); ++sh)
243 vvvDeriv[
ip][commonFct][sh] += vDViscosity[sh] / vDensity[
ip];
252 for(
size_t ip = 0;
ip < nip; ++
ip)
255 number rInvariant = vValue[
ip] - (vViscosity[
ip] / vDensity[
ip]);
266 for(
size_t sh = 0; sh < this->num_sh(commonFct); ++sh)
268 vvvDeriv[
ip][commonFct][sh] += vDYieldStress[sh] * rInvariant;
275 UG_LOG(
"Derivatives of velocity gradient missing");
305 m_spDDensity = data.template cast_dynamic<DependentUserData<number, dim> >();
318 m_spDViscosity = data.template cast_dynamic<DependentUserData<number, dim> >();
331 m_spDYieldStress = data.template cast_dynamic<DependentUserData<number, dim> >();
349 }
catch (std::exception& e) {
350 UG_LOG(
"Error: " << e.what());
location name
Definition: checkpoint_util.lua:128
Definition: smart_pointer.h:108
Linker for the Bingham viscosity.
Definition: bingham_viscosity_linker.h:62
void set_density(SmartPtr< CplUserData< number, dim > > data)
set density import
Definition: bingham_viscosity_linker.h:302
void set_viscosity(SmartPtr< CplUserData< number, dim > > data)
set viscosity import
Definition: bingham_viscosity_linker.h:315
static const size_t _ETA_
import for viscosity
Definition: bingham_viscosity_linker.h:363
SmartPtr< DependentUserData< MathMatrix< dim, dim >, dim > > m_spDVelocityGrad
Definition: bingham_viscosity_linker.h:373
SmartPtr< DependentUserData< number, dim > > m_spDDensity
Definition: bingham_viscosity_linker.h:361
BinghamViscosityLinker()
Definition: bingham_viscosity_linker.h:68
StdDataLinker< BinghamViscosityLinker< dim >, number, dim > base_type
Definition: bingham_viscosity_linker.h:64
void set_viscosity(number val)
Definition: bingham_viscosity_linker.h:322
void set_velocity_gradient(SmartPtr< CplUserData< MathMatrix< dim, dim >, dim > > data)
set velocity gradient import
Definition: bingham_viscosity_linker.h:341
static const size_t _DV_
import for velocity gradient
Definition: bingham_viscosity_linker.h:371
void evaluate(number &value, const MathVector< dim > &globIP, number time, int si) const
Definition: bingham_viscosity_linker.h:79
SmartPtr< CplUserData< number, dim > > m_spDensity
Definition: bingham_viscosity_linker.h:360
SmartPtr< DependentUserData< number, dim > > m_spDViscosity
Definition: bingham_viscosity_linker.h:365
SmartPtr< DependentUserData< number, dim > > m_spDYieldStress
Definition: bingham_viscosity_linker.h:369
SmartPtr< CplUserData< MathMatrix< dim, dim >, dim > > m_spVelocityGrad
Definition: bingham_viscosity_linker.h:372
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
Definition: bingham_viscosity_linker.h:112
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: bingham_viscosity_linker.h:157
void set_yield_stress(number val)
Definition: bingham_viscosity_linker.h:335
SmartPtr< CplUserData< number, dim > > m_spViscosity
Definition: bingham_viscosity_linker.h:364
SmartPtr< CplUserData< number, dim > > m_spYieldStress
Definition: bingham_viscosity_linker.h:368
static const size_t _TAU_
import for yield stress
Definition: bingham_viscosity_linker.h:367
static const size_t _RHO_
import for density
Definition: bingham_viscosity_linker.h:359
void set_yield_stress(SmartPtr< CplUserData< number, dim > > data)
set density import
Definition: bingham_viscosity_linker.h:328
void set_density(number val)
Definition: bingham_viscosity_linker.h:309
constant scalar user data
Definition: const_user_data.h:153
Type based UserData.
Definition: user_data.h:501
const TData & value(size_t s, size_t ip) const
returns the value at ip
Definition: user_data.h:512
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
const MathVector< dim > & ip(size_t s, size_t ip) const
returns global ip
Definition: user_data.h:401
number time() const
get the current evaluation time
Definition: user_data.h:285
Definition: local_algebra.h:198
combines several UserDatas to a new UserData of a specified type
Definition: linker.h:54
void set_num_input(size_t num)
sets the number of inputs
Definition: linker.h:107
size_t input_common_fct(size_t i, size_t fct) const
returns the number in the common FctGrp for a fct of an input
Definition: linker.h:153
virtual void set_input(size_t i, SmartPtr< ICplUserData< dim > > input, SmartPtr< UserDataInfo > info)
sets an input
Definition: linker.h:114
virtual bool zero_derivative() const
returns if derivative is zero
Definition: linker_impl.h:179
#define UG_LOG(msg)
Definition: log.h:367
double number
Definition: types.h:124
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition: smart_pointer.h:836