33 #ifndef __H__UG__LIB_DISC__TIME_DISC__TIME_INTEGRATOR_SUBJECT
34 #define __H__UG__LIB_DISC__TIME_DISC__TIME_INTEGRATOR_SUBJECT
50 template<
class TDomain,
class TAlgebra>
106 #define DECLARE_CHECK_STATIC_ATTACH(stage, container) \
107 bool check_attach_##stage(SmartPtr<process_observer_type> obs)\
109 SmartPtr<stage##_observer_type> sp_staticObs = obs.template cast_dynamic<stage##_observer_type>();\
110 if (sp_staticObs.valid())\
112 (container).push_back(sp_staticObs);\
130 const bool isStaticallyAttached =
131 check_attach_init(obs) ||
132 check_attach_rewind(obs) ||
133 check_attach_finalize(obs) ||
134 check_attach_preprocess(obs) ||
135 check_attach_postprocess(obs) ||
136 check_attach_start(obs) ||
137 check_attach_end(obs);
139 if (!isStaticallyAttached)
144 { attach_to_group<TIO_GROUP_INIT_STEP>(obs); }
147 { attach_to_group<TIO_GROUP_REWIND_STEP>(obs); }
150 { attach_to_group<TIO_GROUP_FINALIZE_STEP>(obs); }
153 { attach_to_group<TIO_GROUP_PREPROCESS_STEP>(obs); }
156 { attach_to_group<TIO_GROUP_POSTPROCESS_STEP>(obs); }
159 { attach_to_group<TIO_GROUP_START>(obs); }
162 { attach_to_group<TIO_GROUP_END>(obs); }
191 for (
typename process_observer_container_type::iterator it = observers.begin(); it!= observers.end(); ++it)
193 result = (*it)->step_process(u, step, time, dt) && result;
202 #define DECLARE_NOTIFY_STEP(functionName, stageName, stageID, container) \
203 bool notify_##functionName(SmartPtr<grid_function_type> u, int step, number time, number dt)\
205 bool res = notify_group<(stageID)>(u, step, time, dt);\
206 const size_t numObs = (container).size();\
207 for (size_t o = 0; o < numObs; ++o)\
208 res &= (container)[o]->stageName##_action(u, step, time, dt);\
Definition: smart_pointer.h:108
represents numerical solutions on a grid using an algebraic vector
Definition: grid_function.h:121
Abstract base class for time integration observer.
Definition: time_integrator_observer_interface.h:43
Base class for a subject notifying observers attachment.
Definition: time_integrator_subject.hpp:52
ITimeIntegratorStageObserver_finalize< TDomain, TAlgebra > finalize_observer_type
Definition: time_integrator_subject.hpp:58
void reset_observers()
Definition: time_integrator_subject.hpp:164
ITimeIntegratorObserver< TDomain, TAlgebra > process_observer_type
Definition: time_integrator_subject.hpp:55
std::vector< SmartPtr< finalize_observer_type > > m_vFinalizeObservers
Definition: time_integrator_subject.hpp:82
void attach_init_observer(SmartPtr< process_observer_type > obs)
Definition: time_integrator_subject.hpp:143
ITimeIntegratorStageObserver_rewind< TDomain, TAlgebra > rewind_observer_type
Definition: time_integrator_subject.hpp:57
void attach_postprocess_observer(SmartPtr< process_observer_type > obs)
Definition: time_integrator_subject.hpp:155
observer_group_type
Definition: time_integrator_subject.hpp:65
@ TIO_GROUP_REWIND_STEP
Definition: time_integrator_subject.hpp:67
@ TIO_GROUP_SIZE
Definition: time_integrator_subject.hpp:73
@ TIO_GROUP_END
Definition: time_integrator_subject.hpp:72
@ TIO_GROUP_POSTPROCESS_STEP
Definition: time_integrator_subject.hpp:70
@ TIO_GROUP_PREPROCESS_STEP
Definition: time_integrator_subject.hpp:69
@ TIO_GROUP_FINALIZE_STEP
Definition: time_integrator_subject.hpp:68
@ TIO_GROUP_START
Definition: time_integrator_subject.hpp:71
@ TIO_GROUP_INIT_STEP
Definition: time_integrator_subject.hpp:66
std::vector< SmartPtr< end_observer_type > > m_vEndObservers
Definition: time_integrator_subject.hpp:86
ITimeIntegratorStageObserver_preprocess< TDomain, TAlgebra > preprocess_observer_type
Definition: time_integrator_subject.hpp:59
void attach_observer(SmartPtr< process_observer_type > obs)
Definition: time_integrator_subject.hpp:128
std::vector< SmartPtr< init_observer_type > > m_vInitObservers
Definition: time_integrator_subject.hpp:80
process_observer_container_type m_vProcessObservers[TIO_GROUP_SIZE]
Definition: time_integrator_subject.hpp:77
ITimeIntegratorStageObserver_init< TDomain, TAlgebra > init_observer_type
Definition: time_integrator_subject.hpp:56
std::vector< SmartPtr< preprocess_observer_type > > m_vPreprocessObservers
Definition: time_integrator_subject.hpp:83
ITimeIntegratorStageObserver_start< TDomain, TAlgebra > start_observer_type
Definition: time_integrator_subject.hpp:61
void attach_rewind_observer(SmartPtr< process_observer_type > obs)
Definition: time_integrator_subject.hpp:146
ITimeIntegratorStageObserver_postprocess< TDomain, TAlgebra > postprocess_observer_type
Definition: time_integrator_subject.hpp:60
bool notify_group(SmartPtr< grid_function_type > u, int step, number time, number dt)
Notify all observers for a certain group.
Definition: time_integrator_subject.hpp:186
std::vector< SmartPtr< start_observer_type > > m_vStartObservers
Definition: time_integrator_subject.hpp:85
GridFunction< TDomain, TAlgebra > grid_function_type
Definition: time_integrator_subject.hpp:54
ITimeIntegratorStageObserver_end< TDomain, TAlgebra > end_observer_type
Definition: time_integrator_subject.hpp:62
void attach_to_group(SmartPtr< process_observer_type > obs)
register observer (default: postprocess)
Definition: time_integrator_subject.hpp:92
void attach_end_observer(SmartPtr< process_observer_type > obs)
Definition: time_integrator_subject.hpp:161
std::vector< SmartPtr< process_observer_type > > process_observer_container_type
Definition: time_integrator_subject.hpp:63
void attach_finalize_observer(SmartPtr< process_observer_type > obs)
Definition: time_integrator_subject.hpp:149
void attach_start_observer(SmartPtr< process_observer_type > obs)
Definition: time_integrator_subject.hpp:158
std::vector< SmartPtr< postprocess_observer_type > > m_vPostprocessObservers
Definition: time_integrator_subject.hpp:84
void attach_preprocess_observer(SmartPtr< process_observer_type > obs)
Definition: time_integrator_subject.hpp:152
void attach_to_group(int tGroup, SmartPtr< process_observer_type > obs)
register observer (default: postprocess)
Definition: time_integrator_subject.hpp:99
std::vector< SmartPtr< rewind_observer_type > > m_vRewindObservers
Definition: time_integrator_subject.hpp:81
double number
Definition: types.h:124
#define DECLARE_CHECK_STATIC_ATTACH(stage, container)
Definition: time_integrator_subject.hpp:106
#define DECLARE_NOTIFY_STEP(functionName, stageName, stageID, container)
Definition: time_integrator_subject.hpp:202