33 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__DATA_EVALUATOR_IMPL__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__DATA_EVALUATOR_IMPL__
38 template <
typename TDomain,
typename TElemDisc>
41 const std::vector<TElemDisc*>& vElemDisc,
43 const bool bNonRegularGrid,
45 const std::vector<number>* pvScaleMass,
46 const std::vector<number>* pvScaleStiff)
47 : m_spFctPattern(fctPat)
64 if(pLocTimeSeries != NULL && pvScaleMass != NULL && pvScaleStiff != NULL){
65 disc->set_time_dependent(*pLocTimeSeries, *pvScaleMass, *pvScaleStiff);
67 else if(pLocTimeSeries != NULL){
68 disc->set_time_dependent(*pLocTimeSeries, std::vector<number>(), std::vector<number>());
71 disc->set_time_independent();
75 disc->check_setup(bNonRegularGrid);
99 template <
typename TDomain,
typename TElemDisc>
105 if(vTryingToAdd.empty())
return;
108 typename std::vector<SmartPtr<ICplUserData<dim> > >::iterator it, itEnd;
109 it =
find(vEvalData.begin(), vEvalData.end(), vTryingToAdd.back());
112 if(it != vEvalData.end())
114 vTryingToAdd.pop_back();
121 itEnd = vTryingToAdd.end(); itEnd--;
122 it =
find(vTryingToAdd.begin(), itEnd, *itEnd);
126 UG_THROW(
"DataEvaluatorBase::add_data_to_eval_data:"
127 " Circle dependency of data detected for UserData.");
131 for(
size_t i = 0; i < data->num_needed_data(); ++i)
134 vTryingToAdd.push_back(data->needed_data(i));
135 add_data_to_eval_data(vEvalData, vTryingToAdd);
139 vEvalData.push_back(data);
142 if(!vTryingToAdd.empty())
143 vTryingToAdd.pop_back();
146 template <
typename TDomain,
typename TElemDisc>
149 clear_extracted_data_and_mappings();
152 std::vector<SmartPtr<ICplUserData<dim> > > vEvalData;
153 std::vector<SmartPtr<ICplUserData<dim> > > vTryingToAdd;
174 for(
size_t d = 0; d < m_vElemDisc[
PT_ALL].size(); ++d)
176 TElemDisc* disc = m_vElemDisc[
PT_ALL][d];
179 for(
size_t i = 0; i < disc->num_imports(); ++i)
188 if( !(iimp->
part() & discPart) )
continue;
192 if(!disc->is_time_dependent())
continue;
195 vTryingToAdd.push_back(iimp->
data());
199 add_data_to_eval_data(vEvalData, vTryingToAdd);
202 " Circle dependency of data detected for UserData.");
205 if(!vTryingToAdd.empty())
207 " Internal Error, UserData queue not empty after adding.");
217 m_vImport[
PT_ALL][iimp->
part()].push_back(iimp);
218 m_vImport[process][iimp->
part()].push_back(iimp);
245 for(
size_t i = 0; i < vEvalData.size(); ++i)
252 ipData->set_function_pattern(m_spFctPattern);
254 UG_CATCH_THROW(
"DataEvaluatorBase: Cannot set FunctionPattern to UserData.");
257 if(ipData->constant()) {m_vConstData.push_back(ipData);
continue;}
258 if(ipData->zero_derivative()){m_vPosData.push_back(ipData);
continue;}
261 m_vDependentData.push_back(ipData);
266 if(m_pLocTimeSeries != NULL){
267 for(
size_t i = 0; i < m_vPosData.size(); ++i)
268 m_vPosData[i]->set_times(m_pLocTimeSeries->times());
269 for(
size_t i = 0; i < m_vDependentData.size(); ++i)
270 m_vDependentData[i]->set_times(m_pLocTimeSeries->times());
274 for(
size_t i = 0; i < m_vPosData.size(); ++i)
275 m_vPosData[i]->set_subset(subsetIndex);
276 for(
size_t i = 0; i < m_vDependentData.size(); ++i)
277 m_vDependentData[i]->set_subset(subsetIndex);
280 template <
typename TDomain,
typename TElemDisc>
284 m_vImport[type][
MASS].clear();
285 m_vImport[type][
STIFF].clear();
286 m_vImport[type][
RHS].clear();
289 m_vConstData.clear();
291 m_vDependentData.clear();
296 template <
typename TDomain,
typename TElemDisc>
300 for(
size_t i = 0; i < m_vConstData.size(); ++i) m_vConstData[i]->clear();
301 for(
size_t i = 0; i < m_vPosData.size(); ++i) m_vPosData[i]->clear();
302 for(
size_t i = 0; i < m_vDependentData.size(); ++i) m_vDependentData[i]->clear();
310 template <
typename TDomain,
typename TElemDisc>
313 for(
size_t i = 0; i < m_vElemDisc[
PT_ALL].size(); ++i)
314 m_vElemDisc[
PT_ALL][i]->set_time_point(timePoint);
317 for(
size_t i = 0; i < m_vPosData.size(); ++i)
318 m_vPosData[i]->set_time_point(timePoint);
319 for(
size_t i = 0; i < m_vDependentData.size(); ++i)
320 m_vDependentData[i]->set_time_point(timePoint);
329 template <
typename TDomain,
typename TElemDisc>
335 for(
size_t i = 0; i < m_vElemDisc[
PT_ALL].size(); ++i)
336 m_vElemDisc[
PT_ALL][i]->do_prep_err_est_elem_loop(
id, si);
339 "Cannot prepare element loop.");
343 extract_imports_and_userdata(si, m_discPart);
346 "Cannot extract imports and userdata.");
350 for(
size_t i = 0; i < m_vImport[
PT_ALL][
MASS].size(); ++i)
352 for(
size_t i = 0; i < m_vImport[
PT_ALL][
STIFF].size(); ++i)
354 for(
size_t i = 0; i < m_vImport[
PT_ALL][
RHS].size(); ++i)
355 m_vImport[
PT_ALL][
RHS][i]->check_setup();
357 UG_CATCH_THROW(
"DataEvaluatorBase::prepare_err_est_elem_loop: Import not correctly implemented.");
361 for(
size_t i = 0; i < m_vDependentData.size(); ++i){
362 m_vDependentData[i]->check_setup();
365 UG_CATCH_THROW(
"DataEvaluatorBase::prepare_err_est_elem_loop: Dependent UserData "
366 " (e.g. Linker or Export) is not ready for evaluation.");
369 for(
size_t i = 0; i < m_vConstData.size(); ++i)
373 template <
typename TDomain,
typename TElemDisc>
378 for(
size_t i = 0; i < m_vElemDisc[
PT_ALL].size(); ++i)
379 m_vElemDisc[
PT_ALL][i]->do_fsh_err_est_elem_loop();
381 UG_CATCH_THROW(
"DataEvaluatorBase::finish_err_est_elem_loop: Cannot finish error estimator element loop");
384 clear_positions_in_user_data();
387 template <
typename TDomain,
typename TElemDisc>
394 for (
size_t i = 0; i < m_vElemDisc[
PT_ALL].size(); ++i)
395 m_vElemDisc[
PT_ALL][i]->do_prep_err_est_elem(u, elem, vCornerCoords);
397 UG_CATCH_THROW(
"DataEvaluatorBase::compute_elem_err_est: Cannot prepare element.");
400 for (
size_t i = 0; i < m_vPosData.size(); ++i)
401 m_vPosData[i]->
compute(&u, elem, vCornerCoords,
false);
413 for (
size_t i = 0; i < m_vDependentData.size(); ++i)
416 m_vDependentData[i]->compute(&u, elem, vCornerCoords,
false);
419 UG_CATCH_THROW(
"DataEvaluatorBase::compute_elem_err_est: Cannot compute data for Export or Linker.");
423 template <
typename TDomain,
typename TElemDisc>
433 UG_ASSERT(m_discPart &
STIFF,
"Using compute_err_est_A_elem, but not STIFF requested.");
436 for (std::size_t i = 0; i < m_vElemDisc[
PT_ALL].size(); ++i)
437 m_vElemDisc[
PT_ALL][i]->do_compute_err_est_A_elem(u, elem, vCornerCoords, scaleStiff);
439 UG_CATCH_THROW(
"DataEvaluatorBase::compute_err_est_A_elem: Cannot assemble stiffness part of error estimator");
442 template <
typename TDomain,
typename TElemDisc>
452 UG_ASSERT(m_discPart &
MASS,
"Using compute_err_est_M_elem, but not MASS requested.");
455 for (std::size_t i = 0; i < m_vElemDisc[
PT_ALL].size(); ++i)
456 m_vElemDisc[
PT_ALL][i]->do_compute_err_est_M_elem(u, elem, vCornerCoords, scaleMass);
458 UG_CATCH_THROW(
"DataEvaluatorBase::compute_err_est_A_elem: Cannot assemble stiffness part of error estimator");
461 template <
typename TDomain,
typename TElemDisc>
470 UG_ASSERT(m_discPart &
RHS,
"Using compute_err_est_rhs_elem, but not RHS requested.");
473 for (std::size_t i = 0; i < m_vElemDisc[
PT_ALL].size(); ++i)
474 m_vElemDisc[
PT_ALL][i]->do_compute_err_est_rhs_elem(elem, vCornerCoords, scaleStiff);
476 UG_CATCH_THROW(
"DataEvaluatorBase::compute_err_est_rhs_elem: Cannot assemble rhs part of error estimator");
Definition: smart_pointer.h:296
Definition: smart_pointer.h:108
bool m_bUseHanging
flag if hanging nodes are used
Definition: data_evaluator.h:128
void prepare_err_est_elem_loop(const ReferenceObjectID id, int si)
prepares the element loop for all IElemDiscs for the computation of the error estimator
Definition: data_evaluator_impl.h:331
bool m_bNeedLocTimeSeries
flag indicating if any elem disc needs local time series
Definition: data_evaluator.h:131
LocalVectorTimeSeries * m_pLocTimeSeries
local time series (non-const since mapping may change)
Definition: data_evaluator.h:134
std::vector< TElemDisc * > m_vElemDisc[MAX_PROCESS]
elem disc data
Definition: data_evaluator.h:122
void clear_positions_in_user_data()
clears all requested positions in user data
Definition: data_evaluator_impl.h:297
void clear_extracted_data_and_mappings()
clears imports and user data and mappings betweem commonFctGrp and local
Definition: data_evaluator_impl.h:281
DataEvaluatorBase(int discPart, const std::vector< TElemDisc * > &vElemDisc, ConstSmartPtr< FunctionPattern > fctPat, const bool bNonRegularGrid, LocalVectorTimeSeries *locTimeSeries=NULL, const std::vector< number > *vScaleMass=NULL, const std::vector< number > *vScaleStiff=NULL)
sets the elem discs to evaluate
Definition: data_evaluator_impl.h:40
int m_discPart
disc part needed (MASS and/or STIFF and/or RHS)
Definition: data_evaluator.h:119
void add_data_to_eval_data(std::vector< SmartPtr< ICplUserData< dim > > > &vEvalData, std::vector< SmartPtr< ICplUserData< dim > > > &vTryingToAdd)
tries to add the last entry of vTryingToAdd to the eval data
Definition: data_evaluator_impl.h:101
void prepare_err_est_elem(LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, bool bDeriv=false)
prepares the element for all IElemDiscs
Definition: data_evaluator_impl.h:389
void set_time_point(const size_t timePoint)
sets the time point for data evaluation
Definition: data_evaluator_impl.h:311
void extract_imports_and_userdata(int subsetIndex, int discPart)
extracts imports and userdata from IElemDiscs
Definition: data_evaluator_impl.h:147
void compute_err_est_rhs_elem(GridObject *elem, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, const number scaleMass=(number) 1.0, const number scaleStiff=(number) 1.0)
compute contributions of the local error indicators in one element for all IElemDiscs
Definition: data_evaluator_impl.h:464
void compute_err_est_M_elem(LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, const number scaleMass=(number) 1.0, const number scaleStiff=(number) 1.0)
compute contributions of the local error indicators in one element for all IElemDiscs
Definition: data_evaluator_impl.h:445
void finish_err_est_elem_loop()
finishes the error estimator element loop for all IElemDiscs
Definition: data_evaluator_impl.h:374
void compute_err_est_A_elem(LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, const number scaleMass=(number) 1.0, const number scaleStiff=(number) 1.0)
compute contributions of the local error indicators in one element for all IElemDiscs
Definition: data_evaluator_impl.h:426
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
Base class for UserData.
Definition: user_data.h:260
Base class for data import.
Definition: data_import.h:72
DiscPart part() const
returns if import is located in mass part (for time dependent problems)
Definition: data_import.h:104
bool zero_derivative() const
returns if data depends on unknown functions
Definition: data_import.h:119
virtual SmartPtr< ICplUserData< dim > > data()=0
returns the connected user data
virtual bool data_given() const =0
returns if data is set
Definition: local_algebra.h:50
Definition: local_algebra.h:198
void access_by_map(const FunctionIndexMapping &funcMap)
access only part of the functions using mapping (restrict functions)
Definition: local_algebra.h:306
time series of local vectors
Definition: solution_time_series.h:167
function util rates kinetic compute(ConvRateSetup)
#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
IndexLayout::Interface::iterator find(IndexLayout::Interface &interface, size_t i)
Definition: parallel_index_layout.h:77
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74
ProcessType
Definition: data_evaluator.h:42
@ MAX_PROCESS
Definition: data_evaluator.h:42
@ PT_INSTATIONARY
Definition: data_evaluator.h:42
@ PT_ALL
Definition: data_evaluator.h:42
@ PT_STATIONARY
Definition: data_evaluator.h:42
@ STIFF
Definition: data_import.h:46
@ RHS
Definition: data_import.h:47
@ MASS
Definition: data_import.h:45