37 #ifndef __H__UG__PLUGINS__ELECTROMAGNETISM__NEDELEC_ENCODE__
38 #define __H__UG__PLUGINS__ELECTROMAGNETISM__NEDELEC_ENCODE__
54 namespace Electromagnetism{
60 template <
typename TDomain>
77 edgeVector -= aaPos [edge->
vertex(0)];
81 (*function) (func_value, aaPos [edge->
vertex(0)], time, si);
82 dofValue = func_value * edgeVector;
84 (*function) (func_value, aaPos [edge->
vertex(1)], time, si);
85 dofValue += func_value * edgeVector;
94 template <
typename TGr
idFunction>
105 typedef typename TGridFunction::domain_type domain_type;
112 std::vector<DoFIndex> ind;
114 UG_ASSERT (spFunction.valid (),
"Invalid smart pointer to the user data.");
117 for (
size_t i = 0; i < ssGrp.
size (); i++)
120 const int si = ssGrp[i];
123 if (! spGridFct->is_def_in_subset (fct, si))
125 UG_LOG (
"ComputeNedelecDoFs warning: Function " << fct <<
" undefined in subdom " << si);
130 t_edge_iterator iter = spGridFct->template begin<Edge> (si);
131 t_edge_iterator iterEnd = spGridFct->template end<Edge> (si);
132 for (; iter != iterEnd; iter++)
134 Edge * pEdge = *iter;
137 if (spGridFct->inner_dof_indices (pEdge, fct, ind) != 1)
139 " More than one DoF per edge. Not the Nedelec-type-1 element?");
142 DoFRef ((* spGridFct), ind[0])
143 = ComputeNedelecDoF<domain_type> (spFunction.get(), pEdge, aaPos, si, time);
154 template <
typename TGr
idFunction>
165 const size_t fct = spGridFct->fct_id_by_name (cmp);
168 if (fct > spGridFct->num_fct())
169 UG_THROW(
"ComputeNedelecDoFs: Component with name '" << cmp <<
"' not found.");
172 if (spGridFct->local_finite_element_id(fct).type () !=
LFEID::NEDELEC)
173 UG_THROW (
"ComputeNedelecDoFs: Illegal grid function. It should be based on the Nedelec element.");
176 SubsetGroup ssGrp (spGridFct->domain()->subset_handler ());
186 template <
typename TGr
idFunction>
198 template <
typename TGr
idFunction>
210 template <
typename TGr
idFunction>
230 template <
typename TGr
idFunction>
245 template <
typename TGr
idFunction>
248 const char* LuaFunction,
256 template <
typename TGr
idFunction>
259 const char* LuaFunction,
267 template <
typename TGr
idFunction>
270 const char* LuaFunction,
284 template <
typename TPotGr
idFunc,
typename TGr
idFunc>
296 UG_THROW (
"NedelecGradPotential: Illegal grid function. It should be based on the Nedelec element.");
299 std::vector<size_t> vVertInd (1);
300 std::vector<DoFIndex> vEdgeInd (1);
303 t_edge_iterator iterEnd = spGF->template end<Edge> ();
304 for (t_edge_iterator iter = spGF->template begin<Edge> (); iter != iterEnd; iter++)
307 Edge * pEdge = *iter;
310 for (
size_t i = 0; i < 2; i++)
313 if (spPotGF->inner_algebra_indices (pEdge->
vertex(i), vVertInd) != 1)
315 " More than one DoF per vertex for the potential.");
318 corner_val [i] = (* spPotGF) [vVertInd[0]];
322 if (spGF->inner_dof_indices (pEdge, fct, vEdgeInd) != 1)
324 " More than one DoF per edge. Not the Nedelec-Type-1 element?");
325 DoFRef ((* spGF), vEdgeInd[0])
326 -= corner_val [1] - corner_val [0];
334 template <
typename TPotGr
idFunc,
typename TGr
idFunc>
343 const size_t fct = spGF->fct_id_by_name (cmp);
346 if (fct > spGF->num_fct())
347 UG_THROW(
"NedelecGradPotential: Component with name '" << cmp <<
"' not found.");
357 template <
typename TPotGr
idFunc>
368 std::vector<size_t> vVertInd (1);
374 for (
size_t i = 0; i < ssGrp.
size (); i++)
377 const int si = ssGrp[i];
380 t_vert_iterator iter = spPotGF->template begin<Vertex> (si);
381 t_vert_iterator iterEnd = spPotGF->template end<Vertex> (si);
382 for (; iter != iterEnd; iter++)
387 if (spPotGF->inner_algebra_indices (pVertex, vVertInd) != 1)
389 " More than one DoF per vertex for the potential.");
392 (* spPotGF) [vVertInd[0]] = value;
401 template <
typename TPotGr
idFunc>
410 SubsetGroup ssGrp (spPotGF->domain()->subset_handler ());
virtual Vertex * vertex(size_t index) const
void add(const char *name)
Grid::VertexAttachmentAccessor< position_attachment_type > position_accessor_type
MathVector< dim > position_type
vector< string > TokenizeString(const char *str, const char delimiter=',')
#define UG_ASSERT(expr, msg)
void SetSubsetVertVal(SmartPtr< TPotGridFunc > spPotGF, const SubsetGroup &ssGrp, number value)
Definition: nedelec_encode.h:359
void ComputeNedelecDoFs(SmartPtr< UserData< MathVector< TGridFunction::dim >, TGridFunction::dim > > spFunction, SmartPtr< TGridFunction > spGridFct, size_t fct, const SubsetGroup &ssGrp, number time)
Definition: nedelec_encode.h:96
number ComputeNedelecDoF(UserData< MathVector< TDomain::dim >, TDomain::dim > *function, Edge *edge, const typename TDomain::position_accessor_type &aaPos, const int si, number time)
Definition: nedelec_encode.h:62
void NedelecGradPotential(SmartPtr< TPotGridFunc > spPotGF, SmartPtr< TGridFunc > spGF, size_t fct)
Definition: nedelec_encode.h:286
const number & DoFRef(const TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
geometry_traits< TElem >::const_iterator const_iterator