Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
glob_attachment_user_data.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2015: G-CSC, Goethe University Frankfurt
3 * Author: Shuai Lu
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_USER_DATA__
34#define __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_USER_DATA__
35
36#include "common/common.h"
37
41
42
43namespace ug{
44
45template <int WDim, typename TData = number>
47: public StdUserData<GlobAttachmentElementUserData<WDim, TData>, TData, WDim>
48
49{
50 static const int dim = WDim;
51 typedef TData data_type;
54
55 private:
56 std::string m_attachment_name;
60
62 inline void eval_on_elem
63 (
64 elem_type * elem,
65 const size_t nip,
66 data_type vValue []
67 ) const
68 {
69 for (size_t ip = 0; ip < nip; ++ip)
70 vValue[ip] = m_aatt [elem];
71 }
72
73 public:
74
78 {
80 UG_THROW ("GlobAttachmentElementUserData: No global attachment '" << m_attachment_name << "' found.");
81 m_att = GlobalAttachments::attachment<attachment_type> (m_attachment_name);
82 m_aatt.access (*grid, m_att);
83 };
84
85 // UserData interface
86
87 virtual bool continuous () const
88 {
89 return false;
90 }
91
92 virtual bool requires_grid_fct () const
93 {
94 return true;
95 }
96
97 // StdUserData interface
98 template <int refDim>
99 inline void evaluate
100 (
101 data_type vValue[],
102 const MathVector<dim> vGlobIP[],
103 number time, int si,
104 GridObject* elem,
105 const MathVector<dim> vCornerCoords[],
106 const MathVector<refDim> vLocIP[],
107 const size_t nip,
108 LocalVector* u,
109 const MathMatrix<refDim, dim>* vJT = NULL
110 ) const
111 {
112 UG_ASSERT (refDim == dim, "GlobAttachmentElementUserData: Dimensionality of the element should be equal to the world dimensionality.");
113
114 eval_on_elem ((elem_type *) elem, nip, vValue);
115 }
116
117 // StdUserData interface
118
119 virtual void compute
120 (
121 LocalVector* u,
122 GridObject* elem,
123 const MathVector<dim> vCornerCoords[],
124 bool bDeriv = false
125 )
126 {
127 UG_ASSERT (elem->base_object_id() == dim, "GlobAttachmentElementUserData: Dimensionality of the element should be equal to the world dimensionality.");
128
129 for (size_t s = 0; s < this->num_series (); ++s)
130 eval_on_elem ((elem_type *) elem, this->num_ip (s), this->values (s));
131 }
132
133 virtual void compute
134 (
136 GridObject* elem,
137 const MathVector<dim> vCornerCoords[],
138 bool bDeriv = false
139 )
140 {
141 UG_ASSERT (elem->base_object_id() == dim, "GlobAttachmentElementUserData: Dimensionality of the element should be equal to the world dimensionality.");
142
143 for (size_t s = 0; s < this->num_series (); ++s)
144 eval_on_elem ((elem_type *) elem, this->num_ip (s), this->values (s));
145 }
146
147 virtual void operator ()
148 (
152 ) const
153 {
154 UG_THROW("GlobAttachmentElementUserData: Element required"
155 " for evaluation, but not passed. Cannot evaluate.");
156 }
157
158 virtual void operator ()
159 (
160 data_type vValue[],
163 const size_t nip
164 ) const
165 {
166 UG_THROW("GlobAttachmentElementUserData: Element required"
167 " for evaluation, but not passed. Cannot evaluate.");
168 }
169};
170
171
172} // end namespace ug
173
174#endif /* __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_USER_DATA__ */
parameterString s
location name
Definition checkpoint_util.lua:128
Definition smart_pointer.h:108
A generic specialization of IAttachment.
Definition attachment_pipe.h:263
const TData * values(size_t s) const
returns all values for a series
Definition user_data.h:516
const TData & value(size_t s, size_t ip) const
returns the value at ip
Definition user_data.h:512
size_t num_ip(size_t s) const
returns the number of integration points
Definition user_data.h:327
size_t num_series() const
explicitly forward some functions
Definition user_data.h:324
Definition glob_attachment_user_data.h:49
void evaluate(data_type 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, const MathMatrix< refDim, dim > *vJT=NULL) const
Definition glob_attachment_user_data.h:100
std::string m_attachment_name
Definition glob_attachment_user_data.h:56
virtual void const MathVector< dim > vGlobIP[]
Definition glob_attachment_user_data.h:161
SmartPtr< Grid > m_spGrid
Definition glob_attachment_user_data.h:57
virtual void compute(LocalVector *u, GridObject *elem, const MathVector< dim > vCornerCoords[], bool bDeriv=false)
compute values (and derivatives iff compDeriv == true)
Definition glob_attachment_user_data.h:120
attachment_type m_att
Definition glob_attachment_user_data.h:58
GlobAttachmentElementUserData(SmartPtr< Grid > grid, const char *name)
constructor
Definition glob_attachment_user_data.h:76
virtual void compute(LocalVectorTimeSeries *u, GridObject *elem, const MathVector< dim > vCornerCoords[], bool bDeriv=false)
compute values (and derivatives iff compDeriv == true, but only for the 'current' time point)
Definition glob_attachment_user_data.h:134
virtual void const MathVector< dim > number int si
Definition glob_attachment_user_data.h:162
Attachment< data_type > attachment_type
Definition glob_attachment_user_data.h:53
virtual void operator()(data_type vValue[]
grid_dim_traits< dim >::grid_base_object elem_type
Definition glob_attachment_user_data.h:52
virtual bool requires_grid_fct() const
returns if grid function is needed for evaluation
Definition glob_attachment_user_data.h:92
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition glob_attachment_user_data.h:87
TData data_type
Definition glob_attachment_user_data.h:51
virtual void const MathVector< dim > number time
Definition glob_attachment_user_data.h:151
void eval_on_elem(elem_type *elem, const size_t nip, data_type vValue[]) const
Evalutation of the attachment in one element.
Definition glob_attachment_user_data.h:63
static const int dim
Definition glob_attachment_user_data.h:50
virtual void const MathVector< dim > & globIP
Definition glob_attachment_user_data.h:150
Grid::AttachmentAccessor< elem_type, attachment_type > m_aatt
Definition glob_attachment_user_data.h:59
static bool is_declared(const std::string &name)
Definition global_attachments.h:111
the generic attachment-accessor for access to grids attachment pipes.
Definition grid.h:182
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition grid_base_objects.h:157
virtual int base_object_id() const =0
const MathVector< dim > & ip(size_t s, size_t ip) const
returns global ip
Definition user_data.h:401
Definition local_algebra.h:198
time series of local vectors
Definition solution_time_series.h:167
A class for fixed size, dense matrices.
Definition math_matrix.h:63
a mathematical Vector with N entries.
Definition math_vector.h:97
Definition std_user_data.h:63
#define UG_ASSERT(expr, msg)
Definition assert.h:70
#define UG_THROW(msg)
Definition error.h:57
double number
Definition types.h:124
the ug namespace
Definition grid_dim_traits.h:53