25template <
typename TDomain,
typename TAlgebra>
32 std::vector<std::string> v_ss_names;
33 std::vector<std::string> v_fct_names;
36 for (
size_t i = 0; i < v_ss_names.size(); i++)
40 if (v_fct_names.empty ())
continue;
41 std::vector<std::string> & face_fct = m_mStoF[v_ss_names[i]];
42 for (
size_t j = 0; j < v_fct_names.size(); j++)
43 face_fct.push_back(v_fct_names[j]);
50template <
typename TDomain,
typename TAlgebra>
53 std::string fct_names,
57 std::vector<std::string> v_fct_names;
59 for (
size_t i = 0; i < v_fct_names.size (); i++)
60 m_mFtoM [v_fct_names [i]] = scaling;
66template <
typename TDomain,
typename TAlgebra>
70 std::vector<number> & v_scaling
73 typedef fct_name_scaling_map_type::const_iterator scaling_iter_type;
76 v_scaling.resize (fct_pattern->
num_fct ());
77 for (
size_t i = 0; i < v_scaling.size (); i++)
81 for (scaling_iter_type iter = m_mFtoM.begin (); iter != m_mFtoM.end (); ++iter)
83 const char * fct_name = iter->first.c_str ();
84 number fct_scale = iter->second;
86 for (
size_t i = 0; i < v_scaling.size (); i++)
87 if (strcmp (fct_name, fct_pattern->
name (i)) == 0)
88 v_scaling [i] = fct_scale;
95template <
typename TDomain,
typename TAlgebra>
107 if (m_spVolStabData.invalid())
108 UG_THROW (
"OutFlowBC: No volume stabilization specified!");
110 typedef bc_data_map_type::iterator t_face_iter;
112 std::vector<DoFIndex> multInd;
114 FunctionGroup fctGrp (base_type::m_spApproxSpace->function_pattern ());
117 std::vector<number> vScaling;
118 names_to_ids_in_scaling (base_type::m_spApproxSpace->function_pattern().
get (), vScaling);
121 for (t_face_iter face = m_mStoF.begin(); face != m_mStoF.end(); ++face)
124 ssGrp.
add (face->first);
127 fctGrp.
add (face->second);
130 for (
size_t i = 0; i < ssGrp.
size (); i++)
140 number flux = s_a0 * flux_parts[0] + flux_parts[1];
143 for(
size_t j = 0; j < fctGrp.
size (); j++)
145 size_t fct = fctGrp [j];
148 if (dd->inner_dof_indices (vrt, fct, multInd) != 1)
149 UG_THROW (
"OutFlowBC: More than one DoF per vertex. Not the Lagrange element?");
152 DoFRef (J, multInd[0], multInd[0]) += flux * vScaling[fct];
162template <
typename TDomain,
typename TAlgebra>
171 const std::vector<number> * vScaleMass,
172 const std::vector<number> * vScaleStiff
175 if (vScaleMass == NULL || vScaleStiff == NULL)
176 UG_THROW (
"OutFlowBC: This BC can be used for instationary problems only!");
177 if (m_spVolStabData.invalid())
178 UG_THROW (
"OutFlowBC: No volume stabilization specified!");
180 typedef bc_data_map_type::iterator t_face_iter;
182 std::vector<DoFIndex> multInd;
184 FunctionGroup fctGrp (base_type::m_spApproxSpace->function_pattern ());
187 std::vector<number> vScaling;
188 names_to_ids_in_scaling (base_type::m_spApproxSpace->function_pattern().
get (), vScaling);
191 for (t_face_iter face = m_mStoF.begin(); face != m_mStoF.end(); ++face)
194 ssGrp.
add (face->first);
197 fctGrp.
add (face->second);
200 for (
size_t i = 0; i < ssGrp.
size (); i++)
210 number flux = (* vScaleStiff)[0] * flux_part[0] + (* vScaleMass)[0] * flux_part[1];
213 for(
size_t j = 0; j < fctGrp.
size (); j++)
215 size_t fct = fctGrp [j];
218 if (dd->inner_dof_indices (vrt, fct, multInd) != 1)
219 UG_THROW (
"OutFlowBC: More than one DoF per vertex. Not the Lagrange element?");
222 DoFRef (d, multInd[0]) += flux * vScaling[fct] *
DoFRef (u, multInd[0]);
234template <
typename TDomain,
typename TAlgebra>
237 std::string ss_names,
238 std::string fct_names,
243 std::vector<std::string> v_ss_names;
244 std::vector<std::string> v_fct_names;
247 for (
size_t i = 0; i < v_ss_names.size(); i++)
251 if (v_fct_names.empty ())
continue;
252 std::map<std::string, t_inDirichlet> & face_fct = m_mStoF[v_ss_names[i]];
253 for (
size_t j = 0; j < v_fct_names.size(); j++)
265template <
typename TDomain,
typename TAlgebra>
268 std::string fct_names,
272 std::vector<std::string> v_fct_names;
274 for (
size_t i = 0; i < v_fct_names.size (); i++)
275 m_mFtoM [v_fct_names [i]] = scaling;
281template <
typename TDomain,
typename TAlgebra>
285 std::vector<number> & v_scaling
288 typedef fct_name_scaling_map_type::const_iterator scaling_iter_type;
291 v_scaling.resize (fct_pattern->
num_fct ());
292 for (
size_t i = 0; i < v_scaling.size (); i++)
296 for (scaling_iter_type iter = m_mFtoM.begin (); iter != m_mFtoM.end (); ++iter)
298 const char * fct_name = iter->first.c_str ();
299 number fct_scale = iter->second;
301 for (
size_t i = 0; i < v_scaling.size (); i++)
302 if (strcmp (fct_name, fct_pattern->
name (i)) == 0)
303 v_scaling [i] = fct_scale;
310template <
typename TDomain,
typename TAlgebra>
322 if (m_spVolStabData.invalid())
323 UG_THROW (
"InOutFlowBC: No volume stabilization specified!");
325 typedef typename bc_data_map_type::iterator t_face_iter;
326 typedef typename std::map<std::string, t_inDirichlet>::iterator t_func_iter;
328 std::vector<DoFIndex> multInd;
330 FunctionGroup fctGrp (base_type::m_spApproxSpace->function_pattern ());
333 std::vector<number> vScaling;
334 names_to_ids_in_scaling (base_type::m_spApproxSpace->function_pattern().
get (), vScaling);
337 for (t_face_iter face = m_mStoF.begin(); face != m_mStoF.end(); ++face)
340 ssGrp.
add (face->first);
343 t_func_iter func_end = face->second.end();
344 for (t_func_iter func_iter = face->second.begin(); func_iter != func_end; ++func_iter)
345 fctGrp.
add (func_iter->first);
348 for (
size_t i = 0; i < ssGrp.
size (); i++)
358 number flux = s_a0 * flux_parts[0] + flux_parts[1];
361 for(
size_t j = 0; j < fctGrp.
size (); j++)
363 size_t fct = fctGrp [j];
366 if (dd->inner_dof_indices (vrt, fct, multInd) != 1)
367 UG_THROW (
"InOutFlowBC: More than one DoF per vertex. Not the Lagrange element?");
372 DoFRef (J, multInd[0], multInd[0]) += flux * vScaling[fct];
374 m_spVolStabData->set_flag (vrt,
true);
381 m_spVolStabData->set_flag (vrt,
false);
392template <
typename TDomain,
typename TAlgebra>
401 const std::vector<number> * vScaleMass,
402 const std::vector<number> * vScaleStiff
405 if (vScaleMass == NULL || vScaleStiff == NULL)
406 UG_THROW (
"InOutFlowBC: This BC can be used for instationary problems only!");
407 if (m_spVolStabData.invalid())
408 UG_THROW (
"InOutFlowBC: No volume stabilization specified!");
410 typedef typename bc_data_map_type::iterator t_face_iter;
411 typedef typename std::map<std::string, t_inDirichlet>::iterator t_func_iter;
413 std::vector<DoFIndex> multInd;
415 FunctionGroup fctGrp (base_type::m_spApproxSpace->function_pattern ());
418 std::vector<number> vScaling;
419 names_to_ids_in_scaling (base_type::m_spApproxSpace->function_pattern().
get (), vScaling);
422 for (t_face_iter face = m_mStoF.begin(); face != m_mStoF.end(); ++face)
425 ssGrp.
add (face->first);
428 t_func_iter func_end = face->second.end();
429 for (t_func_iter func_iter = face->second.begin(); func_iter != func_end; ++func_iter)
430 fctGrp.
add (func_iter->first);
433 for (
size_t i = 0; i < ssGrp.
size (); i++)
443 number flux = (* vScaleStiff)[0] * flux_part[0] + (* vScaleMass)[0] * flux_part[1];
446 for(
size_t j = 0; j < fctGrp.
size (); j++)
448 size_t fct = fctGrp [j];
451 if (dd->inner_dof_indices (vrt, fct, multInd) != 1)
452 UG_THROW (
"InOutFlowBC: More than one DoF per vertex. Not the Lagrange element?");
457 DoFRef (d, multInd[0]) += flux * vScaling[fct] *
DoFRef (u, multInd[0]);
459 m_spVolStabData->set_flag (vrt,
true);
464 DoFRef (d, multInd[0]) = 0;
466 m_spVolStabData->set_flag (vrt,
false);
475template <
typename TDomain,
typename TAlgebra>
484 if (m_spVolStabData.invalid())
485 UG_THROW (
"InOutFlowBC: No volume stabilization specified!");
487 typedef typename bc_data_map_type::iterator t_face_iter;
488 typedef typename std::map<std::string, t_inDirichlet>::iterator t_func_iter;
490 std::vector<DoFIndex> multInd;
493 typename domain_type::position_accessor_type aaPos = base_type::m_spApproxSpace->domain()->position_accessor();
496 for (t_face_iter face = m_mStoF.begin(); face != m_mStoF.end(); ++face)
499 ssGrp.
add (face->first);
502 for (
size_t i = 0; i < ssGrp.
size (); i++)
511 if (m_spVolStabData->flag (vrt))
continue;
514 t_func_iter func_end = face->second.end();
515 for (t_func_iter func_iter = face->second.begin(); func_iter != func_end; ++func_iter)
518 size_t fct_id = fctPattern->fct_id_by_name (func_iter->first.c_str ());
521 if (dd->inner_dof_indices (vrt, fct_id, multInd) != 1)
522 UG_THROW (
"InOutFlowBC: More than one DoF per vertex. Not the Lagrange element?");
526 if (inflow_data.
func.valid ())
527 (* inflow_data.
func) (inflow_data.
val, aaPos[vrt], time, si);
530 DoFRef (u, multInd[0]) = inflow_data.
val;
void add(const char *name)
const char * name(size_t fct) const
void add(const char *name)
void adjust_jacobian(matrix_type &J, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0, ConstSmartPtr< VectorTimeSeries< vector_type > > vSol=SPNULL, const number s_a0=1.0)
sets a unity row at the inflow vertices and apply the volume stabilization otherwise
Definition inout_bnd_impl.h:312
void names_to_ids_in_scaling(const FunctionPattern *fct_pattern, std::vector< number > &v_scaling) const
transform the scaling specification from the names to the id's
Definition inout_bnd_impl.h:283
void adjust_defect(vector_type &d, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0, ConstSmartPtr< VectorTimeSeries< vector_type > > vSol=SPNULL, const std::vector< number > *vScaleMass=NULL, const std::vector< number > *vScaleStiff=NULL)
sets a zero value in the defect at the inflow vertices and apply the volume stabilization otherwise
Definition inout_bnd_impl.h:394
void adjust_solution(vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0)
sets the dirichlet value in the solution at the inflow vertices
Definition inout_bnd_impl.h:477
void add_spec(std::string ss_names, std::string fct_names, number val, SmartPtr< UserData< number, dim > > func)
adds a boundary condition data specification
Definition inout_bnd_impl.h:236
void scale(std::string fct_names, number scaling)
sets scaling for a given functions
Definition inout_bnd_impl.h:267
algebra_type::vector_type vector_type
type of algebra vector
Definition inout_bnd.h:235
algebra_type::matrix_type matrix_type
type of algebra matrix
Definition inout_bnd.h:232
void names_to_ids_in_scaling(const FunctionPattern *fct_pattern, std::vector< number > &v_scaling) const
transform the scaling specification from the names to the id's
Definition inout_bnd_impl.h:68
void scale(std::string fct_names, number scaling)
sets scaling for a given functions
Definition inout_bnd_impl.h:52
void adjust_jacobian(matrix_type &J, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0, ConstSmartPtr< VectorTimeSeries< vector_type > > vSol=SPNULL, const number s_a0=1.0)
apply the volume stabilization to the Jacobian
Definition inout_bnd_impl.h:97
algebra_type::matrix_type matrix_type
type of algebra matrix
Definition inout_bnd.h:69
algebra_type::vector_type vector_type
type of algebra vector
Definition inout_bnd.h:72
void adjust_defect(vector_type &d, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0, ConstSmartPtr< VectorTimeSeries< vector_type > > vSol=SPNULL, const std::vector< number > *vScaleMass=NULL, const std::vector< number > *vScaleStiff=NULL)
apply the volume stabilization to the defect
Definition inout_bnd_impl.h:164
void add(std::string ss_names, std::string fct_names)
adds a combination of subsets and functions to the condition
Definition inout_bnd_impl.h:27
SmartPtr< TSubsetHandler > subset_handler()
UG_API std::vector< std::string > TokenizeTrimString(const std::string &str, const char delimiter=',')
const number & DoFRef(const TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
void SetDirichletRow(TMatrix &mat, const DoFIndex &ind)
auxiliary class for the Dirichlet values
Definition inout_bnd.h:243
number val
constant value (if specified)
Definition inout_bnd.h:244
SmartPtr< UserData< number, dim > > func
value as a function (if not SPNULL)
Definition inout_bnd.h:245