77 typedef typename TGridFunction::domain_type domain_type;
78 typedef typename domain_type::position_type position_type;
81 typename TGridFunction::template traits<TElem>::const_iterator iterEnd, iter;
82 iterEnd = spGridFct->template end<TElem>(si);
83 iter = spGridFct->template begin<TElem>(si);
86 if (iter == iterEnd)
return;
89 LFEID id = spGridFct->local_finite_element_id(fct);
92 for (; iter != iterEnd; ++iter)
98 std::vector<DoFIndex> ind;
99 spGridFct->inner_dof_indices(elem, fct, ind);
102 std::vector<position_type> glob_pos;
103 InnerDoFPosition<domain_type>(glob_pos, elem, *spGridFct->domain(),
id);
106 size_t ind_sz = ind.size();
107 size_t gp_sz = glob_pos.size();
109 UG_THROW(
"InterpolateOnElem: On subset " << si <<
": Number of DoFs is "
110 << ind_sz <<
", but number of DoF positions is "
111 << gp_sz <<
"." << std::endl);
114 for (
size_t i = 0; i < ind_sz && i < gp_sz; ++i)
118 position_type rel_pos=glob_pos[i];
121 (*spInterpolFunction)(val, rel_pos, time, si);
124 DoFRef(*spGridFct, ind[i]) = val;
229 for(
size_t i = 0; i < ssGrp.
size(); ++i)
232 const int si = ssGrp[i];
235 if (!spGridFct->is_def_in_subset(fct, si))
continue;
240 const int dim = ssGrp.
dim(i);
242 if (dim > TGridFunction::dim)
243 UG_THROW(
"InterpolateOnElements: Dimension of subset is " << dim <<
", but "
244 " World Dimension is " << TGridFunction::dim <<
". Cannot interpolate this.");
259 if (spGridFct->max_fct_dofs(fct,
VOLUME, si))
261 InterpolateOnElementsInner<Tetrahedron, TGridFunction>
262 (spInterpolFunction, spGridFct, fct, si, time);
263 InterpolateOnElementsInner<Hexahedron, TGridFunction>
264 (spInterpolFunction, spGridFct, fct, si, time);
265 InterpolateOnElementsInner<Prism, TGridFunction>
266 (spInterpolFunction, spGridFct, fct, si, time);
267 InterpolateOnElementsInner<Pyramid, TGridFunction>
268 (spInterpolFunction, spGridFct, fct, si, time);
269 InterpolateOnElementsInner<Octahedron, TGridFunction>
270 (spInterpolFunction, spGridFct, fct, si, time);
273 if (spGridFct->max_fct_dofs(fct,
FACE, si))
275 InterpolateOnElementsInner<Triangle, TGridFunction>
276 (spInterpolFunction, spGridFct, fct, si, time);
277 InterpolateOnElementsInner<Quadrilateral, TGridFunction>
278 (spInterpolFunction, spGridFct, fct, si, time);
279 InterpolateOnElementsInner<ConstrainingTriangle, TGridFunction>
280 (spInterpolFunction, spGridFct, fct, si, time);
281 InterpolateOnElementsInner<ConstrainingQuadrilateral, TGridFunction>
282 (spInterpolFunction, spGridFct, fct, si, time);
283 InterpolateOnElementsInner<ConstrainedTriangle, TGridFunction>
284 (spInterpolFunction, spGridFct, fct, si, time);
285 InterpolateOnElementsInner<ConstrainedQuadrilateral, TGridFunction>
286 (spInterpolFunction, spGridFct, fct, si, time);
289 if (spGridFct->max_fct_dofs(fct,
EDGE, si))
291 InterpolateOnElementsInner<RegularEdge, TGridFunction>
292 (spInterpolFunction, spGridFct, fct, si, time);
293 InterpolateOnElementsInner<ConstrainingEdge, TGridFunction>
294 (spInterpolFunction, spGridFct, fct, si, time);
295 InterpolateOnElementsInner<ConstrainedEdge, TGridFunction>
296 (spInterpolFunction, spGridFct, fct, si, time);
299 if (spGridFct->max_fct_dofs(fct,
VERTEX, si))
301 InterpolateOnElementsInner<RegularVertex, TGridFunction>
302 (spInterpolFunction, spGridFct, fct, si, time);
303 InterpolateOnElementsInner<ConstrainedVertex, TGridFunction>
304 (spInterpolFunction, spGridFct, fct, si, time);
307 default:
UG_THROW(
"InterpolateOnElements: Dimension " <<dim<<
308 " not possible for world dim "<<3<<
".");
311 UG_CATCH_THROW(
"InterpolateOnElements: Cannot interpolate on elements.");
344 if (spInterpolFunction->requires_grid_fct())
345 UG_THROW(
"Interpolate: The interpolation values depend on a grid function."
346 " This is not allowed in the current implementation. Use constant,"
347 " lua-callback or vrl-callback user data only (even within linkers).");
350 const size_t fct = spGridFct->fct_id_by_name(cmp);
353 if (fct > spGridFct->num_fct())
354 UG_THROW(
"Interpolate: Name of component '"<< cmp <<
"' not found.");
358 UG_THROW(
"This interpolation only allows Lagrange-type elements.\n"
359 "Feel free to add functionality for other types as needed.");
362 const bool bUseP1Interpolation
363 = spGridFct->local_finite_element_id(fct).order() == 1;
366 SubsetGroup ssGrp(spGridFct->domain()->subset_handler());
373 if (bUseP1Interpolation)
374 InterpolateOnDiffVertices<TGridFunction>(spInterpolFunction, spGridFct, fct, time, ssGrp, m_diff_pos);
376 InterpolateOnElementsInner<TGridFunction>(spInterpolFunction, spGridFct, fct, time, ssGrp, m_diff_pos);
406 const char* subsets,
number time)
409 if (spInterpolFunction->requires_grid_fct())
410 UG_THROW(
"Interpolate: The interpolation values depend on a grid function."
411 " This is not allowed in the current implementation. Use constant,"
412 " lua-callback or vrl-callback user data only (even within linkers).");
415 const size_t fct = spGridFct->fct_id_by_name(cmp);
418 if (fct > spGridFct->num_fct())
419 UG_THROW(
"Interpolate: Name of component '"<< cmp <<
"' not found.");
423 UG_THROW(
"This interpolation only allows Lagrange-type elements.\n"
424 "Feel free to add functionality for other types as needed.");
427 const bool bUseP1Interpolation
428 = spGridFct->local_finite_element_id(fct).order() == 1;
431 SubsetGroup ssGrp(spGridFct->domain()->subset_handler());
438 if (bUseP1Interpolation)
439 InterpolateOnVertices<TGridFunction>(spInterpolFunction, spGridFct, fct, time, ssGrp);
441 InterpolateOnElementsInner<TGridFunction>(spInterpolFunction, spGridFct, fct, time, ssGrp);
void InterpolateInnerDiff(SmartPtr< UserData< number, TGridFunction::dim > > spInterpolFunction, SmartPtr< TGridFunction > spGridFct, const char *cmp, const char *subsets, number time, const SmartPtr< CplUserData< MathVector< TGridFunction::dim >, TGridFunction::dim > > m_diff_pos)
interpolates a function on a subset
Definition interpolate_inner.h:339