33 #ifndef __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_USER_DATA__
34 #define __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_USER_DATA__
64 template <
typename TGr
idFunction>
67 number, TGridFunction::dim>
95 this->set_functions(cmp);
98 m_fct = spGridFct->fct_id_by_name(cmp);
101 if(
m_fct >= spGridFct->num_fct())
102 UG_THROW(
"GridFunctionNumberData: Function space does not contain"
103 " a function with name " << cmp <<
".");
114 template <
int refDim>
125 std::vector<std::vector<number> > vvvDeriv[],
134 LocalFiniteElementProvider::get<refDim>(roid,
m_lfeID);
137 std::vector<number> vShape;
139 std::vector<DoFIndex> ind;
142 for(
size_t ip = 0;
ip < nip; ++
ip)
145 rTrialSpace.
shapes(vShape, vLocIP[
ip]);
152 for(
size_t sh = 0; sh < vShape.size(); ++sh)
155 vValue[
ip] += valSH * vShape[sh];
160 for(
size_t ip = 0;
ip < nip; ++
ip){
162 rTrialSpace.
shapes(vShape, vLocIP[
ip]);
164 for(
size_t sh = 0; sh < vShape.size(); ++sh)
165 vvvDeriv[
ip][0][sh] = vShape[sh];
169 UG_CATCH_THROW(
"GridFunctionNumberData: Shape Function Set missing for"
170 " Reference Object: "<<roid<<
", Trial Space: "
171 <<
m_lfeID<<
", refDim="<<refDim);
180 std::vector<DoFIndex> ind;
182 UG_THROW (
"GridFunctionNumberData: Values at vertices of the grid function are not uniquely defined.");
201 template <
typename TGr
idFunction>
204 MathVector<TGridFunction::dim>, TGridFunction::dim>
225 this->set_functions(cmp);
230 std::string fctString = std::string(cmp);
233 std::vector<std::string> tokens;
236 for(
size_t i = 0; i < tokens.size(); ++i)
239 if((
int)tokens.size() !=
dim)
240 UG_THROW(
"GridFunctionVectorData: Needed "<<
dim<<
" components "
241 "in symbolic function names, but given: "<<cmp);
244 for(
int i = 0; i <
dim; ++i){
245 m_vfct[i] = spGridFct->fct_id_by_name(tokens[i].c_str());
249 }
UG_CATCH_THROW(
"GridFunctionVectorData: Cannot find some symbolic function "
250 "name in '"<<cmp<<
"'.");
256 this->set_functions(vCmp);
261 if ((
int)vCmp.size() !=
dim)
262 UG_THROW(
"GridFunctionVectorData: Needed "<<
dim<<
" components "
263 "in symbolic function names, but given: "<< (
int) vCmp.size());
266 for (
size_t i = 0; i < (size_t)
dim; ++i)
268 m_vfct[i] = spGridFct->fct_id_by_name(vCmp[i].c_str());
272 }
UG_CATCH_THROW(
"GridFunctionVectorData: Cannot find some symbolic function "
273 "name in component vector.");
278 for(
int i = 0; i <
dim; ++i)
284 template <
int refDim>
302 std::vector<number> vShape;
304 std::vector<DoFIndex> ind;
308 for(
size_t ip = 0;
ip < nip; ++
ip)
310 for(
int d = 0; d <
dim; ++d)
313 LocalFiniteElementProvider::get<refDim>(roid,
m_vlfeID[d]);
316 rTrialSpace.
shapes(vShape, vLocIP[
ip]);
323 for(
size_t sh = 0; sh < vShape.size(); ++sh)
326 vValue[
ip][d] += valSH * vShape[sh];
333 for(
size_t ip = 0;
ip < nip; ++
ip){
334 for(
int d = 0; d <
dim; ++d)
337 LocalFiniteElementProvider::get<refDim>(roid,
m_vlfeID[d]);
339 rTrialSpace.
shapes(vShape, vLocIP[
ip]);
341 for(
size_t sh = 0; sh < vShape.size(); ++sh)
342 vvvDeriv[
ip][d][sh][d] = vShape[sh];
349 <<roid<<
", refDim="<<refDim);
357 std::vector<DoFIndex> ind;
358 for(
int d = 0; d <
dim; ++d)
361 UG_THROW (
"GridFunctionVectorData: Values at vertices of the grid function are not uniquely defined.");
382 template <
typename TGr
idFunction>
385 MathVector<TGridFunction::dim>, TGridFunction::dim>
406 this->set_functions(cmp);
409 m_fct = spGridFct->fct_id_by_name(cmp);
412 if(
m_fct >= spGridFct->num_fct())
413 UG_THROW(
"GridFunctionGradientData: Function space does not contain"
414 " a function with name " << cmp <<
".");
425 template <
int refDim>
443 std::vector<MathMatrix<refDim, dim> > vJTTmp(nip);
447 = ReferenceMappingProvider::get<refDim, dim>(roid, vCornerCoords);
460 LocalFiniteElementProvider::get<refDim>(roid,
m_lfeID);
463 std::vector<MathVector<refDim> > vLocGrad;
470 for(
size_t ip = 0;
ip < nip; ++
ip)
473 rTrialSpace.
grads(vLocGrad, vLocIP[
ip]);
476 std::vector<DoFIndex > ind;
481 for(
size_t sh = 0; sh < vLocGrad.size(); ++sh)
491 UG_CATCH_THROW(
"GridFunctionNumberData: Shape Function Set missing for"
492 " Reference Object: "<<roid<<
", Trial Space: "
493 <<
m_lfeID<<
", refDim="<<refDim);
510 template <
typename TGr
idFunction>
513 number, TGridFunction::dim>
544 this->set_functions(cmp);
547 if ( component >
static_cast<size_t>(
dim) && component > 0 ) {
548 UG_THROW(
"GridFunctionGradientComponentData: Requested component index "
549 << component <<
" out of bounds [1," <<
dim <<
"]." );
554 m_fct = spGridFct->fct_id_by_name( cmp );
557 if(
m_fct >= spGridFct->num_fct() ) {
558 UG_THROW(
"GridFunctionGradientComponentData: Function space does not contain"
559 " a function with name " << cmp <<
"." );
574 template <
int refDim>
585 std::vector<std::vector<number> > vvvDeriv[],
592 std::vector<MathMatrix<refDim, dim> > vJTTmp( nip );
596 = ReferenceMappingProvider::get< refDim, dim >( roid, vCornerCoords );
609 LocalFiniteElementProvider::get<refDim>( roid,
m_lfeID );
612 std::vector<MathVector<refDim> > vLocGrad;
614 std::vector<MathVector<dim> > vValueVec;
615 vValueVec.resize( nip );
621 for(
size_t ip = 0;
ip < nip; ++
ip ) {
623 rTrialSpace.
grads( vLocGrad, vLocIP[
ip] );
626 std::vector<DoFIndex> ind;
631 for(
size_t sh = 0; sh < vLocGrad.size(); ++sh ) {
642 for(
size_t ip = 0;
ip < nip; ++
ip ) {
644 "Single component expected, but "<<vvvDeriv[
ip].size())
645 UG_ASSERT(vvvDeriv[
ip][0].size() == vLocGrad.size(),
646 "Wrong number sh: "<<vvvDeriv[
ip][0].size()<<
", but expected: "<<vLocGrad.size())
648 for(
size_t sh = 0; sh < vLocGrad.size(); ++sh ) {
656 UG_CATCH_THROW(
"GridFunctionNumberData: Shape Function Set missing for"
657 " Reference Object: "<<roid<<
", Trial Space: "
658 <<
m_lfeID<<
", refDim="<<refDim);
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
Retrieve component of gradient of GridFunction.
Definition: grid_function_user_data.h:514
static const int dim
World dimension of GridFunction m_spGridFct.
Definition: grid_function_user_data.h:517
size_t m_fct
Component ID of function to be used.
Definition: grid_function_user_data.h:524
LFEID m_lfeID
Local Finite Element ID.
Definition: grid_function_user_data.h:530
SmartPtr< TGridFunction > m_spGridFct
GridFunction to loop over.
Definition: grid_function_user_data.h:521
void eval_and_deriv(number vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< number > > vvvDeriv[], const MathMatrix< refDim, dim > *vJT=NULL) const
Definition: grid_function_user_data.h:575
size_t m_component
Component index of gradient to return (0-based)
Definition: grid_function_user_data.h:527
GridFunctionGradientComponentData(SmartPtr< TGridFunction > spGridFct, const char *cmp, size_t component)
Constructor.
Definition: grid_function_user_data.h:539
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition: grid_function_user_data.h:566
Definition: grid_function_user_data.h:386
void eval_and_deriv(MathVector< dim > vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< MathVector< dim > > > vvvDeriv[], const MathMatrix< refDim, dim > *vJT=NULL) const
Definition: grid_function_user_data.h:426
GridFunctionGradientData(SmartPtr< TGridFunction > spGridFct, const char *cmp)
constructor
Definition: grid_function_user_data.h:403
static const int dim
Definition: grid_function_user_data.h:389
size_t m_fct
Definition: grid_function_user_data.h:396
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition: grid_function_user_data.h:420
SmartPtr< TGridFunction > m_spGridFct
Definition: grid_function_user_data.h:393
LFEID m_lfeID
Definition: grid_function_user_data.h:399
Definition: grid_function_user_data.h:68
GridFunctionNumberData()
Definition: grid_function_user_data.h:90
GridFunctionNumberData(SmartPtr< TGridFunction > spGridFct, const char *cmp)
constructor
Definition: grid_function_user_data.h:85
virtual void operator()(number &value, const MathVector< dim > &globIP, number time, int si, Vertex *vrt) const
Definition: grid_function_user_data.h:175
size_t m_fct
Definition: grid_function_user_data.h:78
LFEID m_lfeID
Definition: grid_function_user_data.h:81
void eval_and_deriv(number vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< number > > vvvDeriv[], const MathMatrix< refDim, dim > *vJT=NULL) const
Definition: grid_function_user_data.h:115
static const int dim
Definition: grid_function_user_data.h:71
SmartPtr< TGridFunction > m_spGridFct
Definition: grid_function_user_data.h:75
void assign(SmartPtr< TGridFunction > spGridFct, const char *cmp)
Definition: grid_function_user_data.h:92
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition: grid_function_user_data.h:109
Definition: grid_function_user_data.h:205
GridFunctionVectorData(SmartPtr< TGridFunction > spGridFct, const char *cmp)
constructor
Definition: grid_function_user_data.h:222
GridFunctionVectorData(SmartPtr< TGridFunction > spGridFct, std::vector< std::string > vCmp)
Definition: grid_function_user_data.h:253
virtual void operator()(MathVector< dim > &value, const MathVector< dim > &globIP, number time, int si, Vertex *vrt) const
Definition: grid_function_user_data.h:352
static const int dim
Definition: grid_function_user_data.h:208
SmartPtr< TGridFunction > m_spGridFct
Definition: grid_function_user_data.h:212
void eval_and_deriv(MathVector< dim > vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< MathVector< dim > > > vvvDeriv[], const MathMatrix< refDim, dim > *vJT=NULL) const
Definition: grid_function_user_data.h:285
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition: grid_function_user_data.h:276
size_t m_vfct[dim]
Definition: grid_function_user_data.h:215
LFEID m_vlfeID[dim]
Definition: grid_function_user_data.h:218
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
virtual ReferenceObjectID reference_object_id() const =0
const MathVector< dim > & ip(size_t s, size_t ip) const
returns global ip
Definition: user_data.h:401
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
Definition: local_algebra.h:198
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
Definition: std_user_data.h:133
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
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
void RemoveWhitespaceFromString(std::string &str)
removes all white space from a string, also within the string
Definition: string_util.cpp:50
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#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
void TokenizeString(const string &str, vector< string > &vToken, const char delimiter)
Definition: string_util.cpp:56