33 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__DATA_IMPORT_IMPL__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__DATA_IMPORT_IMPL__
44 template <
typename TData,
int dim>
47 if(data_given()) m_spUserData->unregister_storage_callback(
this);
50 template <
typename TData,
int dim>
54 UG_THROW(
"DataImport::set_roid: Setting unknown ReferenceObjectId.");
59 template <
typename TData,
int dim>
63 if(!this->m_bCompLinDefect)
return;
66 UG_THROW(
"DataImport::check_setup: The reference element "
67 "type has not been set for evaluation.");
70 if(m_vLinDefectFunc[m_id] != NULL)
74 UG_THROW(
"DataImport::check_setup: No evaluation function for computation of "
75 "linearized defect registered for "<<m_id<<
", but required. "
76 "(world dim: "<<
dim<<
", part: "<<this->part()<<
")");
79 template <
typename TData,
int dim>
80 template <
typename TClass>
85 std::vector<std::vector<TData> > vvvLinDefect[],
89 UG_THROW(
"Reference Object id invalid: "<<
id);
91 m_vLinDefectFunc[id] = boost::bind(
func, obj, _1, _2, _3);
94 template <
typename TData,
int dim>
99 std::vector<std::vector<TData> > vvvLinDefect[],
103 UG_THROW(
"Reference Object id invalid: "<<
id);
105 m_vLinDefectFunc[id] =
func;
108 template <
typename TData,
int dim>
112 m_vLinDefectFunc[i] = NULL;
116 template <
typename TData,
int dim>
120 m_spUserData = spData;
123 this->m_spICplUserData = spData;
126 m_spDependentUserData = m_spUserData.template cast_dynamic<DependentUserData<TData, dim> >();
129 template <
typename TData,
int dim>
133 m_vValue = m_spUserData->values(m_seriesID);
136 m_numIP = m_spUserData->num_ip(m_seriesID);
139 template <
typename TData,
int dim>
145 if(!data_given())
return;
150 m_seriesID = m_spUserData->template
151 register_local_ip_series<ldim>(vPos,numIP,timePointSpec,bMayChange);
160 resize_defect_array();
163 UG_ASSERT(m_numIP == numIP,
"Different number of ips than requested.");
168 UG_THROW(
"DataImport: Setting different local ips to non-changable ip series.");
171 m_spUserData->template set_local_ips<ldim>(m_seriesID,vPos,numIP);
172 m_spUserData->set_time_point(m_seriesID,timePointSpec);
180 resize_defect_array();
184 UG_ASSERT(m_numIP == numIP,
"Different number of ips than requested.");
188 template <
typename TData,
int dim>
192 set_local_ips<dim>(vPos, numIP, timePointSpec, bMayChange);
195 template <
typename TData,
int dim>
200 set_local_ips<ldim>(vPos, numIP, -1, bMayChange);
203 template <
typename TData,
int dim>
207 set_local_ips<dim>(vPos, numIP, -1, bMayChange);
210 template <
typename TData,
int dim>
213 m_spUserData->set_time_point(m_seriesID,timePointSpec);
216 template <
typename TData,
int dim>
220 if(!data_given())
return;
223 UG_ASSERT(m_seriesID >= 0,
"Wrong series id.");
224 m_spUserData->set_global_ips(m_seriesID,vPos,numIP);
227 template <
typename TData,
int dim>
230 if(data_given()) m_spUserData->unregister_storage_callback(
this);
234 m_vvvLinDefect.resize(num_ip());
237 template <
typename TData,
int dim>
240 UG_ASSERT(m_spDependentUserData.valid(),
"No Export set.");
243 if (! m_spUserData->at_current_time (m_seriesID))
250 for(
size_t ip = 0; ip < num_ip(); ++ip)
253 for(
size_t fct1 = 0; fct1 < this->num_fct(); ++fct1)
254 for(
size_t fct2 = 0; fct2 < m_spDependentUserData->num_fct(); ++fct2)
257 const TData* LinDef = lin_defect(ip, fct1);
258 const TData* Deriv = m_spDependentUserData->deriv(m_seriesID, ip, fct2);
261 for(
size_t sh1 = 0; sh1 < num_sh(fct1); ++sh1)
262 for(
size_t sh2 = 0; sh2 < m_spDependentUserData->num_sh(fct2); ++sh2)
264 J(fct1, sh1, fct2, sh2) += scale*(LinDef[sh1]*Deriv[sh2]);
270 template <
typename TData,
int dim>
278 m_vvNumDoFPerFct.resize(map.
num_fct());
279 for(
size_t fct = 0; fct < m_vvNumDoFPerFct.size(); ++fct)
280 m_vvNumDoFPerFct[fct] = ind.
num_dof(map[fct]);
282 m_vvvLinDefect.clear();
283 resize_defect_array();
286 template <
typename TData,
int dim>
291 const size_t oldSize = m_vvvLinDefect.size();
294 m_vvvLinDefect.resize(num_ip());
297 for(
size_t ip = oldSize; ip < num_ip(); ++ip)
300 m_vvvLinDefect[ip].resize(m_vvNumDoFPerFct.size());
303 for(
size_t fct = 0; fct < m_vvNumDoFPerFct.size(); ++fct)
304 m_vvvLinDefect[ip][fct].
resize(m_vvNumDoFPerFct[fct]);
308 template <
typename TData,
int dim>
312 UG_ASSERT(ip < m_vvvLinDefect.size(),
"Invalid index.");
313 UG_ASSERT(fct < m_vvvLinDefect[ip].size(),
"Invalid index.");
316 template <
typename TData,
int dim>
319 check_ip_fct(ip, fct);
320 UG_ASSERT(sh < m_vvvLinDefect[ip][fct].size(),
"Invalid index.");
323 template <
typename TData,
int dim>
326 UG_ASSERT(ip < m_numIP,
"Invalid index.");
329 template <
typename TData,
int dim>
332 UG_ASSERT(m_vValue != NULL,
"Data Value field not set.");
Definition: smart_pointer.h:108
Type based UserData.
Definition: user_data.h:501
Data import.
Definition: data_import.h:180
void add_jacobian(LocalMatrix &J, const number scale)
compute jacobian for derivative w.r.t. non-system owned unknowns
Definition: data_import_impl.h:238
virtual void clear_ips()
removes the positions
Definition: data_import_impl.h:228
void check_ip(size_t ip) const
checks in debug mode the correct index
Definition: data_import_impl.h:324
virtual void update_dof_sizes(const LocalIndices &ind)
resize lin defect arrays
Definition: data_import_impl.h:271
void clear_fct()
clear all evaluation functions
Definition: data_import_impl.h:109
virtual void set_roid(ReferenceObjectID id)
sets the geometric object type
Definition: data_import_impl.h:51
void set_data(SmartPtr< CplUserData< TData, dim > > spData)
set the user data
Definition: data_import_impl.h:117
~DataImport()
Destructor.
Definition: data_import_impl.h:45
void set_global_ips(const MathVector< dim > *vPos, size_t numIP)
sets the global positions
Definition: data_import_impl.h:217
void cache_data_access()
caches data access
Definition: data_import_impl.h:130
void resize_defect_array()
resizes the lin defect arrays for current number of ips.
Definition: data_import_impl.h:287
void check_ip_fct_sh(size_t ip, size_t fct, size_t sh) const
checks in debug mode the correct index
Definition: data_import_impl.h:317
void set_fct(ReferenceObjectID id, TClass *obj, void(TClass::*func)(const LocalVector &u, std::vector< std::vector< TData > > vvvLinDefect[], const size_t nip))
register evaluation of linear defect for a element
Definition: data_import_impl.h:83
virtual void check_setup()
checks if ready for evaluation
Definition: data_import_impl.h:60
void set_local_ips(const MathVector< ldim > *vPos, size_t numIP, int timePointSpec, bool bMayChange=true)
set the local integration points
Definition: data_import_impl.h:141
void check_values() const
checks in debug mode the correct index
Definition: data_import_impl.h:330
void check_ip_fct(size_t ip, size_t fct) const
checks in debug mode the correct index
Definition: data_import_impl.h:309
void set_time_point(int timePointSpec)
set the time point specification
Definition: data_import_impl.h:211
describes a mapping between two local index sets
Definition: function_group.h:186
size_t num_fct() const
returns the number of indices that are mapped
Definition: function_group.h:195
Definition: local_algebra.h:50
size_t num_dof(size_t fct) const
number of dofs for accessible function
Definition: local_algebra.h:117
Definition: local_algebra.h:422
void access_by_map(const FunctionIndexMapping &funcMap)
access only part of the functions using mapping (restrict functions)
Definition: local_algebra.h:538
Definition: local_algebra.h:198
a mathematical Vector with N entries.
Definition: math_vector.h:97
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74
@ NUM_REFERENCE_OBJECTS
Definition: grid_base_objects.h:85
@ ROID_UNKNOWN
Definition: grid_base_objects.h:75
function func(x, y, z, t, si)
bool resize(size_t newRows, size_t newCols)