33 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__DATA_LINKER_IMPL__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__DATA_LINKER_IMPL__
44 template <
typename TImpl,
typename TData,
int dim>
50 getImpl().evaluate(value,globIP,time,si);
53 template <
typename TImpl,
typename TData,
int dim>
57 number time,
int si,
const size_t nip)
const
59 for(
size_t ip = 0; ip < nip; ++ip)
60 getImpl().evaluate(vValue[ip],vGlobIP[ip],time,si);
63 template <
typename TImpl,
typename TData,
int dim>
76 getImpl().template evaluate<refDim>(vValue,vGlobIP,time,si,elem,
77 vCornerCoords,vLocIP,nip,u,vJT);
80 template <
typename TImpl,
typename TData,
int dim>
85 const int si = this->subset();
87 std::vector<std::vector<TData> >* vvvDeriv = NULL;
89 for(
size_t s = 0;
s < this->num_series(); ++
s){
91 if(bDeriv && this->m_vvvvDeriv[s].size() > 0)
92 vvvDeriv = &this->m_vvvvDeriv[s][0];
96 getImpl().template eval_and_deriv<refDim>(this->values(s), this->ips(s), this->time(s), si,
98 this->
template local_ips<refDim>(s), this->num_ip(s),
99 u, bDeriv, s, vvvDeriv);
103 template <
typename TImpl,
typename TData,
int dim>
104 template <
int refDim>
108 const int si = this->subset();
110 std::vector<std::vector<TData> >* vvvDeriv = NULL;
112 for(
size_t s = 0;
s < this->num_series(); ++
s){
114 bool bDoDeriv = bDeriv && this->at_current_time (
s);
116 if(bDoDeriv && this->m_vvvvDeriv[
s].size() > 0)
117 vvvDeriv = &this->m_vvvvDeriv[
s][0];
121 getImpl().template eval_and_deriv<refDim>(this->values(
s), this->ips(
s), this->time(
s), si,
123 this->
template local_ips<refDim>(
s), this->num_ip(
s),
124 &(u->
solution(this->time_point(
s))), bDoDeriv,
s, vvvDeriv);
128 template <
typename TImpl,
typename TData,
int dim>
134 "local ip dimension and reference element dimension mismatch.");
136 switch(this->dim_local_ips()){
137 case 1: eval_deriv<1>(u,elem,vCornerCoords,bDeriv);
break;
138 case 2: eval_deriv<2>(u,elem,vCornerCoords,bDeriv);
break;
139 case 3: eval_deriv<3>(u,elem,vCornerCoords,bDeriv);
break;
140 default:
UG_THROW(
"StdDataLinker: Dimension not supported.");
144 template <
typename TImpl,
typename TData,
int dim>
150 "local ip dimension and reference element dimension mismatch.");
152 switch(this->dim_local_ips()){
153 case 1: eval_deriv<1>(u,elem,vCornerCoords,bDeriv);
break;
154 case 2: eval_deriv<2>(u,elem,vCornerCoords,bDeriv);
break;
155 case 3: eval_deriv<3>(u,elem,vCornerCoords,bDeriv);
break;
156 default:
UG_THROW(
"StdDataLinker: Dimension not supported.");
160 template <
typename TImpl,
typename TData,
int dim>
163 for(
size_t i = 0; i < this->m_vspICplUserData.size(); ++i)
164 if(this->m_vspUserDataInfo[i]->requires_grid_fct())
169 template <
typename TImpl,
typename TData,
int dim>
173 for(
size_t i = 0; i < this->m_vspICplUserData.size(); ++i)
174 bRet &= this->m_vspUserDataInfo[i]->continuous();
178 template <
typename TImpl,
typename TData,
int dim>
182 for(
size_t i = 0; i < m_vspICplUserData.size(); ++i)
183 bRet &= m_vspICplUserData[i]->zero_derivative();
187 template <
typename TImpl,
typename TData,
int dim>
191 for(
size_t i = 0; i < num_input(); ++i)
192 if(!m_vspICplUserData[i].valid())
193 UG_THROW(
"StdDataLinker::check_setup: Input number "<<i<<
" missing.");
196 template <
typename TImpl,
typename TData,
int dim>
201 std::vector<const FunctionGroup*> vFctGrp(num_input(), NULL);
202 for(
size_t i = 0; i < m_vspICplUserData.size(); ++i){
203 if(m_vspICplUserData[i].valid()){
204 m_vspUserDataInfo[i]->set_function_pattern(fctPatt);
205 vFctGrp[i] = &(m_vspUserDataInfo[i]->function_group());
216 this->m_fctGrp.set_function_pattern(fctPatt);
218 }
UG_CATCH_THROW(
"'StdDataLinker::set_function_pattern': Cannot create"
219 " common function group.");
224 "Cannot create Function Index Mapping for Common Functions.");
227 m_vMap.resize(vFctGrp.size());
228 for(
size_t i = 0; i < vFctGrp.size(); ++i)
230 if(vFctGrp[i] != NULL)
235 "Cannot create Function Index Mapping for input "<<i<<
".");
240 template <
typename TImpl,
typename TData,
int dim>
244 const size_t s = seriesID;
247 m_vvSeriesID.resize(m_vspICplUserData.size());
250 for(
size_t i = 0; i < m_vspICplUserData.size(); ++i)
253 UG_ASSERT(m_vspICplUserData[i].valid(),
"No Input set, but requested.");
256 m_vvSeriesID[i].resize(
s+1);
259 switch(this->dim_local_ips())
263 m_vspICplUserData[i]->template register_local_ip_series<1>
264 (this->
template local_ips<1>(
s), this->num_ip(
s),
265 this->m_vTimePoint[
s], this->m_vMayChange[
s]);
269 m_vspICplUserData[i]->template register_local_ip_series<2>
270 (this->
template local_ips<2>(
s), this->num_ip(
s),
271 this->m_vTimePoint[
s], this->m_vMayChange[
s]);
275 m_vspICplUserData[i]->template register_local_ip_series<3>
276 (this->
template local_ips<3>(
s), this->num_ip(
s),
277 this->m_vTimePoint[
s], this->m_vMayChange[
s]);
279 default:
UG_THROW(
"Dimension not supported.");
break;
288 template <
typename TImpl,
typename TData,
int dim>
292 const size_t s = seriesID;
295 for(
size_t i = 0; i < m_vspICplUserData.size(); ++i)
298 UG_ASSERT(m_vspICplUserData[i].valid(),
"No Input set, but requested.");
300 switch(this->dim_local_ips())
302 case 1: m_vspICplUserData[i]->template set_local_ips<1>
303 (m_vvSeriesID[i][
s], this->
template local_ips<1>(
s), this->num_ip(
s));
305 case 2: m_vspICplUserData[i]->template set_local_ips<2>
306 (m_vvSeriesID[i][
s], this->
template local_ips<2>(
s), this->num_ip(
s));
308 case 3: m_vspICplUserData[i]->template set_local_ips<3>
309 (m_vvSeriesID[i][
s], this->
template local_ips<3>(
s), this->num_ip(
s));
311 default:
UG_THROW(
"Dimension not supported.");
break;
319 template <
typename TImpl,
typename TData,
int dim>
324 for(
size_t i = 0; i < m_vspICplUserData.size(); ++i)
327 UG_ASSERT(m_vspICplUserData[i].valid(),
"No Input set, but requested.");
329 m_vspICplUserData[i]->clear ();
336 template <
typename TImpl,
typename TData,
int dim>
341 for(
size_t i = 0; i < m_vspICplUserData.size(); ++i)
344 UG_ASSERT(m_vspICplUserData[i].valid(),
"No Input set, but requested.");
347 m_vspICplUserData[i]->set_global_ips(m_vvSeriesID[i][seriesID], vPos, numIP);
Definition: smart_pointer.h:296
virtual void local_ip_series_to_be_cleared()
implement callback, invoked when local ips are cleared
Definition: user_data_impl.h:535
virtual void local_ip_series_added(const size_t seriesID)
resizes the derivative field when local ip change is signaled
Definition: user_data_impl.h:525
virtual void local_ips_changed(const size_t seriesID, const size_t newNumIP)
implement callback, called when local IPs changed
Definition: user_data_impl.h:545
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
Definition: local_algebra.h:198
time series of local vectors
Definition: solution_time_series.h:167
const LocalVector & solution(size_t i) const
returns the local vector for the i'th time point
Definition: solution_time_series.h:182
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
void eval_deriv(LocalVector *u, GridObject *elem, const MathVector< dim > vCornerCoords[], bool bDeriv=false)
Definition: linker_impl.h:82
virtual void local_ips_changed(const size_t seriesID, const size_t newNumIP)
forwards the local positions to the data inputs
Definition: linker_impl.h:290
virtual void local_ip_series_to_be_cleared()
requests cleaning of the ip series in the data inputs
Definition: linker_impl.h:321
virtual void set_function_pattern(ConstSmartPtr< FunctionPattern > fctPatt)
updates the function group
Definition: linker_impl.h:198
virtual void operator()(TData &value, const MathVector< dim > &globIP, number time, int si) const
returns value for a global position
Definition: linker_impl.h:46
virtual bool zero_derivative() const
returns if derivative is zero
Definition: linker_impl.h:179
virtual void global_ips_changed(const size_t seriesID, const MathVector< dim > *vPos, const size_t numIP)
forwards the global positions to the data inputs
Definition: linker_impl.h:338
virtual void local_ip_series_added(const size_t seriesID)
requests series id's from input data
Definition: linker_impl.h:242
virtual void check_setup() const
returns if data is ok
Definition: linker_impl.h:188
virtual void compute(LocalVector *u, GridObject *elem, const MathVector< dim > vCornerCoords[], bool bDeriv=false)
compute values (and derivatives iff compDeriv == true)
Definition: linker_impl.h:130
void evaluate(TData 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: linker_impl.h:66
virtual bool requires_grid_fct() const
returns that a grid function is needed for evaluation
Definition: linker_impl.h:161
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition: linker_impl.h:170
#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 CreateUnionOfFunctionGroups(FunctionGroup &fctGrp, const vector< const FunctionGroup * > &vFctGrp, bool sortFct)
Definition: groups_util.cpp:93
void CreateFunctionIndexMapping(FunctionIndexMapping &map, const FunctionGroup &grpFromSmall, const FunctionGroup &grpToLarge)
Definition: groups_util.cpp:44