33 #ifndef UG__LIB_DISC__FUNCTION_SPACES__INTERPOLATE_INNER_H
34 #define UG__LIB_DISC__FUNCTION_SPACES__INTERPOLATE_INNER_H
67 template <
typename TElem,
typename TGr
idFunction>
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;
139 template <
typename TElem,
typename TGr
idFunction>
149 typedef typename TGridFunction::domain_type domain_type;
150 typedef typename domain_type::position_type position_type;
202 InterpolateOnElementsInner<TElem,TGridFunction>(spInterpolFunction, spGridFct, fct, si,time, *diff_pos);
218 template <
typename TGr
idFunction>
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);
243 UG_THROW(
"InterpolateOnElements: Dimension of subset is " <<
dim <<
", but "
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.");
338 template <
typename TGr
idFunction>
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);
403 template <
typename TGr
idFunction>
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);
451 template <
typename TGr
idFunction>
456 template <
typename TGr
idFunction>
461 template <
typename TGr
idFunction>
470 template <
typename TGr
idFunction>
473 const char* subsets,
number time)
480 template <
typename TGr
idFunction>
485 template <
typename TGr
idFunction>
490 template <
typename TGr
idFunction>
500 template <
typename TGr
idFunction>
503 const char* subsets,
number time)
510 template <
typename TGr
idFunction>
515 template <
typename TGr
idFunction>
520 template <
typename TGr
idFunction>
Definition: smart_pointer.h:108
constant scalar user data
Definition: const_user_data.h:153
Type based UserData.
Definition: user_data.h:501
Identifier for Local Finite Elements.
Definition: local_finite_element_id.h:98
@ LAGRANGE
Definition: local_finite_element_id.h:104
static SmartPtr< LuaUserData< TData, dim, TRet > > create(const std::string &name)
Definition: lua_user_data.h:223
a mathematical Vector with N entries.
Definition: math_vector.h:97
Group of subsets.
Definition: subset_group.h:51
size_t size() const
number of subsets in this group
Definition: subset_group.h:122
void add_all()
select all subsets of underlying subset handler
Definition: subset_group.cpp:133
int dim(size_t i) const
dimension of subset
Definition: subset_group.cpp:237
void add(int si)
adds a subset by number to this group
Definition: subset_group.cpp:64
Type based UserData.
Definition: user_data.h:143
@ PST_CONSISTENT
Definition: parallel_storage_type.h:68
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
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
@ ROID_TETRAHEDRON
Definition: grid_base_objects.h:80
void InterpolateOnElementsInner(SmartPtr< UserData< number, TGridFunction::dim > > spInterpolFunction, SmartPtr< TGridFunction > spGridFct, size_t fct, int si, number time, const MathVector< TGridFunction::dim > diff_pos)
Definition: interpolate_inner.h:68
number & DoFRef(TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
Definition: multi_index.h:276
void TokenizeString(const string &str, vector< string > &vToken, const char delimiter)
Definition: string_util.cpp:56
@ VOLUME
Definition: grid_base_objects.h:63
@ VERTEX
Definition: grid_base_objects.h:60
@ EDGE
Definition: grid_base_objects.h:61
@ FACE
Definition: grid_base_objects.h:62
void InterpolateInner(SmartPtr< UserData< number, TGridFunction::dim > > spInterpolFunction, SmartPtr< TGridFunction > spGridFct, const char *cmp, const char *subsets, number time)
interpolates a function on a subset
Definition: interpolate_inner.h:404
@ DIM_SUBSET_EMPTY_GRID
Definition: subset_dim_util.h:92
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition: smart_pointer.h:836
T value_type
Definition: sparsematrix_interface.h:2