33 #ifndef __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_GLOBAL_USER_DATA__
34 #define __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_GLOBAL_USER_DATA__
55 template <
typename TGr
idFunction,
int elemDim = TGr
idFunction::dim>
57 :
public StdGlobPosData<GlobalGridFunctionNumberData<TGridFunction, elemDim>, number, TGridFunction::dim>
62 typedef typename TGridFunction::template dim_traits<elemDim>::grid_base_object
element_t;
81 m_tree(*spGridFct->domain()->grid(), spGridFct->domain()->position_attachment())
86 m_fct = spGridFct->fct_id_by_name(cmp);
89 if(
m_fct >= spGridFct->num_fct())
90 UG_THROW(
"GridFunctionNumberData: Function space does not contain"
91 " a function with name " << cmp <<
".");
103 std::vector<size_t> subsetsOfGridFunction;
104 std::vector<element_t*> elemsWithGridFunctions;
106 typename TGridFunction::template dim_traits<elemDim>::const_iterator iterEnd, iter;
109 for(
size_t si = 0; si < ssGrp.
size(); si++){
110 if( spGridFct->is_def_in_subset(
m_fct, si) )
111 subsetsOfGridFunction.push_back(si);
115 for(
size_t i = 0; i<subsetsOfGridFunction.size(); i++){
116 size_t si = subsetsOfGridFunction[i];
117 iter = spGridFct->template begin<element_t>(si);
118 iterEnd = spGridFct->template end<element_t>(si);
120 for(;iter!=iterEnd; ++iter){
122 elemsWithGridFunctions.push_back(elem);
129 m_tree.
create_tree(elemsWithGridFunctions.begin(), elemsWithGridFunctions.end());
144 UG_THROW(
"For function "<<
m_fct<<
" couldn't find an element containing the specified point: " << x);
151 UG_THROW(
"For function "<<
m_fct<<
" couldn't find an element containing the specified point: " << x);
166 std::vector<MathVector<dim> > vCornerCoords;
174 = ReferenceMappingProvider::get<elemDim, dim>(roid, vCornerCoords);
177 map.global_to_local(locPos, x);
181 LocalFiniteElementProvider::get<elemDim>(roid,
m_lfeID);
182 std::vector<number> vShape;
183 rTrialSpace.
shapes(vShape, locPos);
186 std::vector<DoFIndex> ind;
191 for(
size_t sh = 0; sh < vShape.size(); ++sh)
194 value += valSH * vShape[sh];
209 bool bFound = this->
evaluate(value, x);
214 int numFound = (bFound ? 1 : 0);
218 if(!bFound)
value = 0.0;
231 UG_THROW(
"Global mean "<<globValue<<
" != local value "<<
value);
240 UG_THROW(
"Couldn't find an element containing the specified point: " << x);
246 if((
int)vPos.size() !=
dim)
247 UG_THROW(
"Expected "<<
dim<<
" components, but given "<<vPos.size());
250 for(
int i = 0; i <
dim; i++) x[i] = vPos[i];
261 template <
typename TGr
idFunction>
263 :
public StdGlobPosData<GlobalGridFunctionGradientData<TGridFunction>, MathVector<TGridFunction::dim>, TGridFunction::dim>
287 m_tree(*spGridFct->domain()->grid(), spGridFct->domain()->position_attachment())
292 m_fct = spGridFct->fct_id_by_name(cmp);
295 if(
m_fct >= spGridFct->num_fct())
296 UG_THROW(
"GridFunctionNumberData: Function space does not contain"
297 " a function with name " << cmp <<
".");
309 std::vector<size_t> subsetsOfGridFunction;
310 std::vector<element_t*> elemsWithGridFunctions;
312 typename TGridFunction::const_element_iterator iterEnd, iter;
315 for(
size_t si = 0; si < ssGrp.
size(); si++){
316 if( spGridFct->is_def_in_subset(
m_fct, si) )
317 subsetsOfGridFunction.push_back(si);
321 for(
size_t i = 0; i<subsetsOfGridFunction.size(); i++){
322 size_t si = subsetsOfGridFunction[i];
323 iter = spGridFct->template begin<element_t>(si);
324 iterEnd = spGridFct->template end<element_t>(si);
326 for(;iter!=iterEnd; ++iter){
328 elemsWithGridFunctions.push_back(elem);
335 m_tree.
create_tree(elemsWithGridFunctions.begin(), elemsWithGridFunctions.end());
350 UG_THROW(
"For function "<<
m_fct<<
" couldn't find an element containing the specified point: " << x);
356 static const int refDim =
dim;
366 std::vector<MathVector<dim> > vCornerCoords;
374 = ReferenceMappingProvider::get<dim, dim>(roid, vCornerCoords);
377 map.global_to_local(locPos, x);
383 = ReferenceMappingProvider::get<refDim, dim>(roid, vCornerCoords);
392 LocalFiniteElementProvider::get<dim>(roid,
m_lfeID);
393 std::vector<MathVector<refDim> > vLocGrad;
394 rTrialSpace.
grads(vLocGrad, locPos);
402 std::vector<DoFIndex> ind;
410 for(
size_t sh = 0; sh < vLocGrad.size(); ++sh)
422 UG_CATCH_THROW(
"GlobalGridFunctionGradientData: Evaluation failed."
423 <<
"Point: " << x <<
", Element: "
431 bool bFound = this->
evaluate(value, x);
436 UG_THROW(
"Couldn't find an element containing the specified point: " << x);
442 if((
int)vPos.size() !=
dim)
443 UG_THROW(
"Expected "<<
dim<<
" components, but given "<<vPos.size());
446 for(
int i = 0; i <
dim; i++) x[i] = vPos[i];
451 for(
int i = 0; i <
dim; i++) vPos[i] =
value[i];
Definition: pcl_process_communicator.h:70
void allreduce(const void *sendBuf, void *recBuf, int count, DataType type, ReduceOperation op) const
performs MPI_Allreduce on the processes of the communicator.
Definition: pcl_process_communicator.cpp:318
const TData & value(size_t s, size_t ip) const
returns the value at ip
Definition: user_data.h:512
virtual base class for reference mappings
Definition: reference_mapping_provider.h:53
virtual void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const =0
returns transposed of jacobian
Definition: grid_function_global_user_data.h:264
static const int dim
world dimension of grid function
Definition: grid_function_global_user_data.h:267
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition: grid_function_global_user_data.h:341
void evaluate_global(MathVector< dim > &value, const MathVector< dim > &x) const
evaluate value on all procs
Definition: grid_function_global_user_data.h:428
size_t m_fct
component of function
Definition: grid_function_global_user_data.h:275
bool evaluate(MathVector< dim > &value, const MathVector< dim > &x) const
evaluates the data at a given point, returns false if point not found
Definition: grid_function_global_user_data.h:354
lg_ntree< dim, dim, element_t > tree_t
Definition: grid_function_global_user_data.h:280
std::vector< number > evaluate_global(std::vector< number > vPos)
Definition: grid_function_global_user_data.h:440
LFEID m_lfeID
local finite element id
Definition: grid_function_global_user_data.h:278
SmartPtr< TGridFunction > m_spGridFct
grid function
Definition: grid_function_global_user_data.h:272
GlobalGridFunctionGradientData(SmartPtr< TGridFunction > spGridFct, const char *cmp)
constructor
Definition: grid_function_global_user_data.h:285
tree_t m_tree
Definition: grid_function_global_user_data.h:281
void evaluate(MathVector< dim > &value, const MathVector< dim > &x, number time, int si) const
to full-fill UserData-Interface
Definition: grid_function_global_user_data.h:347
TGridFunction::element_type element_t
Definition: grid_function_global_user_data.h:268
virtual ~GlobalGridFunctionGradientData()
Definition: grid_function_global_user_data.h:339
Definition: grid_function_global_user_data.h:58
lg_ntree< dim, dim, element_t > tree_t
Definition: grid_function_global_user_data.h:74
static const int dim
world dimension of grid function
Definition: grid_function_global_user_data.h:61
virtual ~GlobalGridFunctionNumberData()
Definition: grid_function_global_user_data.h:133
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition: grid_function_global_user_data.h:135
bool evaluate(number &value, const MathVector< dim > &x) const
evaluates the data at a given point, returns false if point not found
Definition: grid_function_global_user_data.h:156
void evaluate(number &value, const MathVector< dim > &x, number time, int si) const
to full-fill UserData-Interface
Definition: grid_function_global_user_data.h:141
number evaluate_global(std::vector< number > vPos)
Definition: grid_function_global_user_data.h:244
GlobalGridFunctionNumberData(SmartPtr< TGridFunction > spGridFct, const char *cmp)
constructor
Definition: grid_function_global_user_data.h:79
void evaluate_global(number &value, const MathVector< dim > &x) const
evaluate value on all procs
Definition: grid_function_global_user_data.h:206
size_t m_fct
component of function
Definition: grid_function_global_user_data.h:69
tree_t m_tree
Definition: grid_function_global_user_data.h:75
SmartPtr< TGridFunction > m_spGridFct
grid function
Definition: grid_function_global_user_data.h:66
number evaluate(const MathVector< dim > &x) const
Definition: grid_function_global_user_data.h:147
TGridFunction::template dim_traits< elemDim >::grid_base_object element_t
Definition: grid_function_global_user_data.h:62
LFEID m_lfeID
local finite element id
Definition: grid_function_global_user_data.h:72
number time() const
get the current evaluation time
Definition: user_data.h:285
Identifier for Local Finite Elements.
Definition: local_finite_element_id.h:98
static bool continuous(const LFEID &id, bool bCreate=true)
returns if a Local Shape Function Set is continuous
Definition: local_finite_element_provider.cpp:749
virtual base class for local shape function sets
Definition: local_shape_function_set.h:70
virtual void grads(grad_type *vGrad, const MathVector< dim > &x) const =0
returns all gradients evaluated at a point
virtual void shapes(shape_type *vShape, const MathVector< dim > &x) const =0
returns all shape functions evaluated at a point
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
Definition: std_glob_pos_data.h:55
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
const FunctionIndexMapping & map() const
get function mapping
Definition: user_data.h:78
void create_tree(TIterator elemsBegin, TIterator elemsEnd)
Definition: lg_ntree.h:356
void CollectCornerCoordinates(std::vector< typename TAAPos::ValueType > &vCornerCoordsOut, const TElem &elem, const TAAPos &aaPos, bool clearContainer=true)
returns the corner coordinates of a geometric object
Definition: domain_util_impl.h:75
std::string ElementDebugInfo(const Grid &grid, GridObject *e)
Returns a string containing information on the given element.
Definition: debug_util.cpp:991
MathMatrix< N, M, T >::value_type RightInverse(MathMatrix< N, M, T > &mOut, const MathMatrix< M, N, T > &m)
Right-Inverse of a Matrix.
Definition: math_matrix_functions_common_impl.hpp:679
#define PCL_RO_SUM
Definition: pcl_methods.h:63
int NumProcs()
returns the number of processes
Definition: pcl_base.cpp:91
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
void MatVecMult(vector_t_out &vOut, const matrix_t &m, const vector_t_in &v)
Matrix - Vector Multiplication.
Definition: math_matrix_vector_functions_common_impl.hpp:49
void VecScaleAppend(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1)
Scales a Vector and adds it to a second vector.
Definition: math_vector_functions_common_impl.hpp:126
void VecSet(vector_t &vInOut, typename vector_t::value_type s)
Set each vector component to scalar (componentwise)
Definition: math_vector_functions_common_impl.hpp:539
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74
number & DoFRef(TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
Definition: multi_index.h:276
bool FindContainingElement(typename tree_t::elem_t &elemOut, const tree_t &tree, const typename tree_t::vector_t &point)
Definition: ntree_traverser.h:210