43 namespace Electromagnetism{
48 template <
typename TDomain,
typename TAlgebra>
55 typedef std::vector<std::string> t_f_vec;
57 std::vector<std::string> subsets;
61 std::string s_f_name (f_name);
65 " Only single functions function allowed in the specification of"
66 " Dirichlet values, but the following functions given:"
70 for (
size_t i = 0; i < subsets.size (); i++)
73 if (m_mDirichletSS.find (subsets [i]) == m_mDirichletSS.end ())
74 m_mDirichletSS [subsets [i]] = m_vDirichletFunc;
76 std::vector<std::string> & imp_funcs = m_mDirichletSS [subsets [i]];
77 if (n_func == 0)
continue;
78 t_f_vec::iterator f_entry = std::find (imp_funcs.begin (), imp_funcs.end (), s_f_name);
79 if (f_entry == imp_funcs.end ())
80 UG_THROW (
"NedelecDirichletBC: Wrong speficifation of the Dirichlet BC for subset "
81 << subsets [i] <<
": func " << f_name <<
82 " not present in the object or is specified twice for the subsets.");
83 imp_funcs.erase (f_entry);
90 template <
typename TDomain,
typename TAlgebra>
96 add_subset (
"", subsets);
102 template <
typename TDomain,
typename TAlgebra>
106 const char*
function,
110 add_subset (
function, subsets);
111 m_vConstBCData.push_back (
TConstBC (value,
function, subsets));
117 template <
typename TDomain,
typename TAlgebra>
120 std::vector<number> vValue,
121 const char*
function,
125 if (vValue.size () != (
size_t)
dim)
127 "Wrong dimensionality of a Dirichlet BC. Specify " <<
dim <<
" values.");
129 for (
size_t i = 0; i < (size_t)
dim; i++) value[i] = vValue[i];
130 add (value,
function, subsets);
136 template <
typename TDomain,
typename TAlgebra>
140 const char*
function,
144 add_subset (
function, subsets);
145 m_vUserDataBCData.push_back (
TUserDataBC (func,
function, subsets));
152 template <
typename TDomain,
typename TAlgebra>
156 const char*
function,
161 UG_THROW (
"NedelecDirichletBC: Illegal BC specification."
162 " A " <<
dim <<
"d vector-valued function should be specified");
165 add (sp_userData,
function, subsets);
172 template <
typename TDomain,
typename TAlgebra>
178 typedef std::map<std::string, std::vector<std::string> > t_ss_map;
181 t_ss_map::const_iterator iterEnd = m_mDirichletSS.end ();
182 for (t_ss_map::const_iterator iter = m_mDirichletSS.begin (); iter != iterEnd; ++iter)
183 dirichlet_ssgrp.
add (iter->first);
190 template <
typename TDomain,
typename TAlgebra>
198 if (functionGroup.
size () != 1)
200 " Only single functions function allowed in the specification of"
201 " Dirichlet values, but the following functions given:"
208 for(
size_t si = 0; si < subsetGroup.
size (); ++si)
211 const int subsetIndex = subsetGroup[si];
212 const size_t fct = functionGroup[0];
215 if (subsetIndex < 0 || subsetIndex >= pSH->num_subsets ())
217 " Invalid Subset Index " << subsetIndex <<
". (Valid is"
218 " 0, .. , " << pSH->num_subsets() <<
").");
221 if (fct >= base_type::m_spApproxSpace->function_pattern()->num_fct ())
223 " Function " << fct <<
" does not exist in pattern.");
226 if (!base_type::m_spApproxSpace->function_pattern()->is_def_in_subset (fct, subsetIndex))
228 " Function " << fct <<
" not defined on subset " << subsetIndex);
236 template <
typename TDomain,
typename TAlgebra>
237 template <
typename TUserData>
240 std::map<
int, std::vector<TUserData *> > & mvUserDataBndSegment,
241 std::vector<TUserData> & vUserData
245 mvUserDataBndSegment.clear ();
248 for (
size_t i = 0; i < vUserData.size (); ++i)
255 vUserData[i].ssGrp = base_type::m_spApproxSpace->subset_grp_by_name (vUserData[i].ssName.c_str());
257 UG_CATCH_THROW(
" Subsets '" << vUserData[i].ssName <<
"' not all contained in ApproximationSpace.");
261 fctGrp = base_type::m_spApproxSpace->fct_grp_by_name (vUserData[i].fctName.c_str());
263 UG_CATCH_THROW (
" Functions '" << vUserData[i].fctName <<
"' not all contained in ApproximationSpace.");
266 check_functions_and_subsets (fctGrp, vUserData[i].ssGrp);
269 vUserData[i].fct = fctGrp[0];
272 for (
size_t si = 0; si < vUserData[i].ssGrp.size (); ++si)
273 mvUserDataBndSegment[vUserData[i].ssGrp[si]].push_back (&vUserData[i]);
280 template <
typename TDomain,
typename TAlgebra>
283 typedef std::map<std::string, std::vector<std::string> > t_ss_map;
286 t_ss_map::const_iterator iterEnd = m_mDirichletSS.end ();
287 for (t_ss_map::const_iterator iter = m_mDirichletSS.begin (); iter != iterEnd; ++iter)
288 if (iter->second.size () != 0)
294 ssGrp = base_type::m_spApproxSpace->subset_grp_by_name (iter->first.c_str ());
296 UG_CATCH_THROW(
" Subsets '" << iter->first <<
"' not all contained in ApproximationSpace.");
299 for (
size_t i = 0; i < ssGrp.
size (); i++)
303 f_grp.
add (iter->second);
311 template <
typename TDomain,
typename TAlgebra>
323 std::vector<DoFIndex> multInd;
325 FunctionGroup fctGrp (base_type::m_spApproxSpace->function_pattern (), m_vDirichletFunc);
331 for (
size_t i = 0; i < ssGrp.
size (); i++)
339 for(
size_t fct_i = 0; fct_i < fctGrp.
size (); fct_i++)
342 if (dd->inner_dof_indices (*iter, fctGrp [fct_i], multInd) != 1)
344 "More than one DoF per edge. Not the Nedelec-type-1 element?");
355 template <
typename TDomain,
typename TAlgebra>
364 const std::vector<number> * vScaleMass,
365 const std::vector<number> * vScaleStiff
368 std::vector<DoFIndex> multInd;
370 FunctionGroup fctGrp (base_type::m_spApproxSpace->function_pattern (), m_vDirichletFunc);
376 for (
size_t i = 0; i < ssGrp.
size (); i++)
384 for(
size_t fct_i = 0; fct_i < fctGrp.
size (); fct_i++)
387 if (dd->inner_dof_indices (*iter, fctGrp [fct_i], multInd) != 1)
389 "More than one DoF per edge. Not the Nedelec-type-1 element?");
392 DoFRef (d, multInd[0]) = 0.0;
400 template <
typename TDomain,
typename TAlgebra>
401 template <
typename TUserData>
404 const std::vector<TUserData *> & vUserData,
411 std::vector<DoFIndex> multInd;
417 for(
size_t i = 0; i < vUserData.size (); ++i)
419 Edge * pEdge = *iter;
421 if (dd->inner_dof_indices (pEdge, vUserData[i]->fct, multInd) != 1)
423 "More than one DoF per edge. Not the Nedelec-type-1 element?");
426 DoFRef (u, multInd[0]) = (* vUserData[i]) (pEdge, si,
m_aaPos, time);
434 template <
typename TDomain,
typename TAlgebra>
442 typedef std::map<int, FunctionGroup> t_ss_map;
444 std::vector<DoFIndex> multInd;
447 t_ss_map::const_iterator ssIterEnd = m_mZeroBC.end ();
448 for (t_ss_map::const_iterator ssIter = m_mZeroBC.begin (); ssIter != ssIterEnd; ++ssIter)
451 int si = ssIter->first;
457 Edge * pEdge = *iter;
460 for(
size_t i = 0; i < fctGrp.
size (); ++i)
463 if (dd->inner_dof_indices (pEdge, fctGrp[i], multInd) != 1)
465 "More than one DoF per edge. Not the Nedelec-type-1 element?");
468 DoFRef (u, multInd[0]) = 0;
477 template <
typename TDomain,
typename TAlgebra>
490 typename std::map<int, std::vector<TConstBC*> >::const_iterator iter;
491 for (iter = m_mConstBC.begin (); iter != m_mConstBC.end (); ++iter)
492 adjust_solution<TConstBC> ((*iter).second, (*iter).first, u, dd, time);
495 typename std::map<int, std::vector<TUserDataBC*> >::const_iterator iter;
496 for (iter = m_mUserDataBC.begin (); iter != m_mUserDataBC.end (); ++iter)
497 adjust_solution<TUserDataBC> ((*iter).second, (*iter).first, u, dd, time);
500 adjust_solution_implicit (u, dd, time);
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 for all dirichlet indices
Definition: nedelec_dirichlet_impl.h:313
void add_subset(const char *f_name, const char *ss_names)
inserts a subset to the list of the Dirichlet subsets
Definition: nedelec_dirichlet_impl.h:50
void extract_data()
Definition: nedelec_dirichlet.h:294
void adjust_solution(const std::vector< TUserData * > &vUserData, int si, vector_type &u, ConstSmartPtr< DoFDistribution > dd, number time)
Sets the specified Dirichlet values in the solution.
Definition: nedelec_dirichlet_impl.h:403
void add(MathVector< dim > &value, const char *function, const char *subsets)
adds a constant Dirichlet value on a subset
Definition: nedelec_dirichlet_impl.h:104
void adjust_solution_implicit(vector_type &u, ConstSmartPtr< DoFDistribution > dd, number time)
Sets the zero Dirichlet values for the implicitly specified BC.
Definition: nedelec_dirichlet_impl.h:436
void extract_implicit()
Composes the list of the implicit BC.
Definition: nedelec_dirichlet_impl.h:281
void check_functions_and_subsets(FunctionGroup &functionGroup, SubsetGroup &subsetGroup)
Verifies whether the string input represents legal data.
Definition: nedelec_dirichlet_impl.h:192
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 for all dirichlet indices
Definition: nedelec_dirichlet_impl.h:357
void add_0(const char *subsets)
adds a zero Dirichlet value on a subset
Definition: nedelec_dirichlet_impl.h:92
DoFDistribution::traits< Edge >::const_iterator t_edge_iterator
iterator over edges
Definition: nedelec_dirichlet.h:114
virtual void get_dirichlet_subsets(SubsetGroup &dirichlet_ssgrp) const
composes an array of subset indices of the Dirichlet boundary
Definition: nedelec_dirichlet_impl.h:174
void add(const char *name)
void set_function_pattern(ConstSmartPtr< FunctionPattern > spFuncPattern)
algebra_type::vector_type vector_type
algebra_type::matrix_type matrix_type
void add(const char *name)
SmartPtr< TSubsetHandler > subset_handler()
position_accessor_type m_aaPos
vector< string > TokenizeString(const char *str, const char delimiter=',')
#define UG_CATCH_THROW(msg)
const number & DoFRef(const TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
void SetDirichletRow(TMatrix &mat, const DoFIndex &ind)
structure for the Dirichlet BC that is constant over a patch
Definition: nedelec_dirichlet.h:165
Structure for the Dirichlet BC that are given by a function.
Definition: nedelec_dirichlet.h:207