47template<
typename TDomain>
52 const char * functions,
56 m_spUpwind (upwind), m_source (0), m_diffusion (0),
61 UG_THROW (
"Wrong number of functions: The ElemDisc 'FV1_Convection'"
62 " needs exactly 1 symbolic function.");
78template<
typename TDomain>
81 const std::vector<LFEID> & vLfeID,
88 " The discretization does not support hanging nodes.\n");
91 if (vLfeID.size () != 1)
92 UG_THROW (
"FV1_Convection: Only one component is supported.");
96 UG_THROW (
"FV1_Convection: This discretization works with the piecewise linear shape functions only.");
104template<
typename TDomain>
105template<
typename TElem>
113 static const int refDim = TElem::dim;
119 if(m_spUpwind.invalid ())
120 UG_THROW(
"FV1_Convection: Upwind has not been set.");
124 const size_t numSCVFip = geo.num_scvf_ips();
125 m_imVelocity.template set_local_ips<refDim> (vSCVFip, numSCVFip,
false);
128 m_spUpwind->template set_geometry_type<TFVGeom> (geo);
132template<
typename TDomain>
133template<
typename TElem>
139template<
typename TDomain>
140template<
typename TElem>
156 UG_CATCH_THROW(
"FV1_Convection: Cannot update the Finite Volume Geometry.");
160 const size_t numSCVFip = geo.num_scvf_ips();
161 m_imVelocity.set_global_ips (vSCVFip, numSCVFip);
165template<
typename TDomain>
166template<
typename TElem>
180 if (m_imVelocity.data_given())
183 if(! m_spUpwind->update (&geo, m_imVelocity.values (), NULL,
false))
184 UG_THROW(
"ERROR in 'FV1_Convection: Cannot compute convection shapes.\n");
185 const size_t numConvShapes = m_spUpwind->num_sh();
188 for(
size_t ip = 0; ip < geo.num_scvf(); ++ip)
191 const typename TFVGeom::SCVF& scvf = geo.scvf (ip);
193 for(
size_t sh = 0; sh < numConvShapes; ++sh)
195 const number D_conv_flux = (* m_spUpwind) (ip, sh);
198 J(_U_, scvf.from(), _U_, sh) += D_conv_flux;
199 J(_U_, scvf.to(), _U_, sh) -= D_conv_flux;
202 J(_U_, scvf.from(), _U_, scvf.from()) -= D_conv_flux;
203 J(_U_, scvf.to(), _U_, scvf.to() ) += D_conv_flux;
212 for(
size_t ip = 0; ip < geo.num_scvf(); ++ip)
215 const typename TFVGeom::SCVF& scvf = geo.scvf (ip);
218 for(
size_t sh = 0; sh < scvf.num_sh(); ++sh)
221 normal[dim-1] /= m_alpha;
223 const number D_diff_flux = m_diffusion *
VecDot(scvf.global_grad(sh), normal);
224 J(_U_, scvf.from(), _U_, sh) -= D_diff_flux;
225 J(_U_, scvf.to() , _U_, sh) += D_diff_flux;
232template<
typename TDomain>
233template<
typename TElem>
247 if (m_imVelocity.data_given())
250 if(! m_spUpwind->update (&geo, m_imVelocity.values (), NULL,
false))
251 UG_THROW(
"ERROR in 'FV1_Convection: Cannot compute convection shapes.\n");
252 const size_t numConvShapes = m_spUpwind->num_sh();
255 for(
size_t ip = 0; ip < geo.num_scvf(); ++ip)
258 const typename TFVGeom::SCVF& scvf = geo.scvf (ip);
262 for(
size_t sh = 0; sh < numConvShapes; ++sh)
263 conv_flux += u (_U_, sh) * (* m_spUpwind) (ip, sh);
264 d(_U_, scvf.from()) += conv_flux;
265 d(_U_, scvf.to() ) -= conv_flux;
268 for(
size_t sh = 0; sh < numConvShapes; ++sh)
270 d(_U_, scvf.from()) -= u (_U_, scvf.from()) * (* m_spUpwind) (ip, sh);
271 d(_U_, scvf.to() ) += u (_U_, scvf.to() ) * (* m_spUpwind) (ip, sh);
280 for(
size_t ip = 0; ip < geo.num_scvf(); ++ip)
283 const typename TFVGeom::SCVF& scvf = geo.scvf (ip);
290 for(
size_t sh = 0; sh < scvf.num_sh(); ++sh)
295 normal[dim-1] /= m_alpha;
297 const number diff_flux = m_diffusion *
VecDot(grad, normal);
300 d(_U_, scvf.from()) -= diff_flux;
301 d(_U_, scvf.to() ) += diff_flux;
307template<
typename TDomain>
308template<
typename TElem>
322 for(
size_t ip = 0; ip < geo.num_scv(); ++ip)
325 const typename TFVGeom::SCV& scv = geo.scv (ip);
328 const int co = scv.node_id();
331 J(_U_, co, _U_, co) += scv.volume ();
336template<
typename TDomain>
337template<
typename TElem>
351 for(
size_t ip = 0; ip < geo.num_scv(); ++ip)
354 const typename TFVGeom::SCV& scv = geo.scv (ip);
357 const int co = scv.node_id();
360 d(_U_, co) += u (_U_, co) * scv.volume ();
365template<
typename TDomain>
366template<
typename TElem>
379 for(
size_t ip = 0; ip < geo.num_scv(); ++ip)
382 const typename TFVGeom::SCV& scv = geo.scv (ip);
385 const int co = scv.node_id();
388 b(_U_, co) += m_source * scv.volume ();
397template<
typename TDomain>
408template<
typename TDomain>
409template<
typename TElem>
414 this->clear_add_fct(
id);
416 this->set_prep_elem_loop_fct(
id, & this_type::template prepare_element_loop<TElem>);
417 this->set_prep_elem_fct (
id, & this_type::template prepare_element<TElem>);
418 this->set_fsh_elem_loop_fct (
id, & this_type::template finish_element_loop<TElem>);
419 this->set_add_jac_A_elem_fct(
id, & this_type::template ass_JA_elem<TElem>);
420 this->set_add_jac_M_elem_fct(
id, & this_type::template ass_JM_elem<TElem>);
421 this->set_add_def_A_elem_fct(
id, & this_type::template ass_dA_elem<TElem>);
422 this->set_add_def_M_elem_fct(
id, & this_type::template ass_dM_elem<TElem>);
423 this->set_add_rhs_elem_fct (
id, & this_type::template ass_rhs_elem<TElem>);
426 m_exGrad->template set_fct<this_type,refDim>(
id,
this, &this_type::template ex_grad<TElem>);
432template<
typename TDomain>
433template <
typename TElem>
484 UG_ASSERT(vLocIP == geo.scvf_local_ips(),
"Huhh: Think twice!");
486 if(vLocIP == geo.scvf_local_ips())
489 for(
size_t ip = 0; ip < geo.num_scvf(); ++ip)
492 const typename TFVGeom::SCVF& scvf = geo.scvf(ip);
497 for(
size_t sh = 0; sh < scvf.num_sh(); ++sh)
498 VecScaleAppend(grad, m_diffusion*u(_U_, sh), scvf.global_grad(sh));
500 grad[dim-1] /= m_alpha;
void register_import(IDataImport< dim > &Imp)
virtual void prepare_setting(const std::vector< LFEID > &vLfeID, bool bNonRegular)
check type of the grid and the trial space
Definition fv1_conv_impl.h:80
base_type::position_type position_type
position type
Definition fv1_conv.h:89
void ex_grad(MathVector< dim > vValue[], const MathVector< dim > vGlobIP[], number time, int si, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< dim > vLocIP[], const size_t nip, bool bDeriv, std::vector< std::vector< MathVector< dim > > > vvvDeriv[])
computes the gradient of the concentration
Definition fv1_conv_impl.h:435
void finish_element_loop()
finalizes the loop over the elements: clear the source
Definition fv1_conv_impl.h:134
void ass_dM_elem(LocalVector &d, const LocalVector &u, GridObject *elem, const position_type vCornerCoords[])
computes the mass part of the defect of a time-dependent problem
Definition fv1_conv_impl.h:339
void register_loc_discr_func()
registers the local assembler functions for a given element
Definition fv1_conv_impl.h:410
void prepare_element(const LocalVector &u, GridObject *elem, ReferenceObjectID roid, const position_type vCornerCoords[])
prepares a given element for assembling: computes the discretization of the rot-rot operator
Definition fv1_conv_impl.h:142
void ass_rhs_elem(LocalVector &d, GridObject *elem, const position_type vCornerCoords[])
assembles the right-hand side
Definition fv1_conv_impl.h:368
void ass_JM_elem(LocalMatrix &J, const LocalVector &u, GridObject *elem, const position_type vCornerCoords[])
computes the mass matrix of a time-dependent problem
Definition fv1_conv_impl.h:310
void prepare_element_loop(ReferenceObjectID roid, int si)
prepares the loop over the elements: checks whether the parameters are set, ...
Definition fv1_conv_impl.h:107
DataImport< MathVector< dim >, dim > m_imVelocity
data import for the velocity field (if used)
Definition fv1_conv.h:229
FV1_Convection(SmartPtr< IConvectionShapes< dim > > upwind, const char *functions, const char *subsets)
constructor
Definition fv1_conv_impl.h:50
void ass_dA_elem(LocalVector &d, const LocalVector &u, GridObject *elem, const position_type vCornerCoords[])
assembles the local defect
Definition fv1_conv_impl.h:235
void register_all_loc_discr_funcs()
registers the local assembler functions for all the elements and dimensions
Definition fv1_conv_impl.h:398
void ass_JA_elem(LocalMatrix &J, const LocalVector &u, GridObject *elem, const position_type vCornerCoords[])
assembles the local stiffness matrix
Definition fv1_conv_impl.h:168
SmartPtr< TSubsetHandler > subset_handler()
#define UG_ASSERT(expr, msg)
#define UG_CATCH_THROW(msg)
void VecScaleAppend(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1)
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
void VecSet(vector_t &dest, number alpha, const std::vector< size_t > vIndex)
Definition fv1_conv.h:215