Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Examples

spark.h File Reference

Header file required to define SPARK inverses. More...

#include <cmath>
#include <cstdio>
#include "problem.h"
#include "component.h"
#include "object.h"
#include "inverse.h"
#include "requests.h"
#include "sparkmath.h"
#include "sparkapi.h"
#include "classapi.h"
#include "consts.h"

Include dependency graph for spark.h:

Include dependency graph

Go to the source code of this file.

Preprocessor macro definitions used in the implementation of the various callbacks in the atomic classes

Note:
The callback prototypes defined for each callback type must match the typedef's in the file callback.h


#define CALLBACK_DECLSPEC(callback_type)   extern "C" callback_type
#define NON_MODIFIER_CALLBACK(func)   CALLBACK_DECLSPEC(void) func(SPARK::TObject* this_pointer, SPARK::ArgList args)
 Macros to define the prototype for a modifier callback.

#define MODIFIER_CALLBACK(func)   CALLBACK_DECLSPEC(void) func(SPARK::TObject* this_pointer, SPARK::ArgList args, SPARK::TargetList targets)
 Macros to define the prototype for a non-modifier callback.

#define PREDICATE_CALLBACK(func)   CALLBACK_DECLSPEC(bool) func(SPARK::TObject* this_pointer, SPARK::ArgList args)
 Macros to define the prototype for a predicate callback.

#define STATIC_NON_MODIFIER_CALLBACK(func)   CALLBACK_DECLSPEC(void) func(SPARK::TInverse* this_pointer)
 Macros to define the prototype for a static callback.

#define STATIC_PREDICATE_CALLBACK(func)   CALLBACK_DECLSPEC(bool) func(SPARK::TInverse* this_pointer)
 Macros to define the prototype for a static predicate callback.

#define EVALUATE(func)   MODIFIER_CALLBACK( func )
 Macros to declare an EVALUATE callback.

#define PREDICT(func)   MODIFIER_CALLBACK( func )
 Macros to declare a PREDICT callback.

#define CONSTRUCT(func)   NON_MODIFIER_CALLBACK( func )
 Macros to declare a CONSTRUCT callback.

#define PREPARE_STEP(func)   NON_MODIFIER_CALLBACK( func )
 Macros to declare a PREPARE_STEP callback.

#define CHECK_INTEGRATION_STEP(func)   PREDICATE_CALLBACK( func )
 Macros to declare a CHECK_INTEGRATION_STEP callback.

#define COMMIT(func)   NON_MODIFIER_CALLBACK( func )
 Macros to declare a COMMIT callback.

#define ROLLBACK(func)   NON_MODIFIER_CALLBACK( func )
 Macros to declare a ROLLBACK callback.

#define DESTRUCT(func)   NON_MODIFIER_CALLBACK( func )
 Macros to declare a DESTRUCT callback.

#define STATIC_CONSTRUCT(func)   STATIC_NON_MODIFIER_CALLBACK( func )
 Macros to declare a STATIC_CONSTRUCT callback.

#define STATIC_PREPARE_STEP(func)   STATIC_NON_MODIFIER_CALLBACK( func )
 Macros to declare a STATIC_PREPARE_STEP callback.

#define STATIC_CHECK_INTEGRATION_STEP(func)   STATIC_PREDICATE_CALLBACK( func )
 Macros to declare a STATIC_CHECK_INTEGRATION_STEP callback.

#define STATIC_COMMIT(func)   STATIC_NON_MODIFIER_CALLBACK( func )
 Macros to declare a STATIC_COMMIT callback.

#define STATIC_ROLLBACK(func)   STATIC_NON_MODIFIER_CALLBACK( func )
 Macros to declare a STATIC_ROLLBACK callback.

#define STATIC_DESTRUCT(func)   STATIC_NON_MODIFIER_CALLBACK( func )
 Macros to declare a STATIC_DESTRUCT callback.

#define TARGET(pos, name)   SPARK::TTarget& name = targets[pos]
 A macro that defines a reference named "name" to the TTarget object stored in position "pos" of the target list.

#define ARGUMENT(pos, name)   const SPARK::TArgument& name = args[pos]
 A macro that defines a const reference named "name" to the TArgument object of the argument stored in position "pos".

#define ARGDEF(pos, name)   ARGUMENT( pos, name )
 A macro that defines a const reference named "name" to the TArgument object of the argument stored in position "pos".

#define RETURN(val)   { targets[0] = val; return; }
 A macro that returns the scalar val for a single-valued inverse.

#define ACCEPT_STEP   true
 Macros used in predicate callbacks to indicate that the step is accepted.

#define REJECT_STEP   false
 Macros used in predicate callbacks to indicate that the step is rejected.


Preprocessor macros to access active context from within a callback

#define THIS   this_pointer
 A macro to access the pointer to the current "this" pointer associated with the current callback.

#define GET_DATA(owner, concrete_type, name)   concrete_type* name = SPARK::AtomicClass::GetData<concrete_type>( owner )
 A macro to access the pointer to the private data object stored as part of an object.

#define SET_DATA(owner, concrete_type, name)   SPARK::AtomicClass::SetData<concrete_type>( owner, name )
 A macro to store the pointer to the private data stored as part of an object.

#define DELETE_DATA(owner, concrete_type, is_array_flag)   SPARK::AtomicClass::DeleteData<concrete_type, SPARK::deleter<is_array_flag> >( owner )
 A macro to delete data pointed to by an object.

#define ACTIVE_PROBLEM   THIS->GetProblem()
 Returns pointer to TProblem object this object belongs to.

#define ACTIVE_INVERSE   THIS->GetInverse()
 Returns pointer to TInverse object this object belongs to.

#define ACTIVE_COMPONENT   THIS->GetComponent()
 Returns pointer to TComponent object this object belongs to.

#define ERROR_LOG(msg)   SPARK::Log( SPARK::GetErrorLog(), THIS, __LINE__, msg )
 Writes msg specified as const char* to the error log file.

#define RUN_LOG(msg)   SPARK::Log( SPARK::GetRunLog(), THIS, __LINE__, msg )
 Writes msg specified as const char* to the run log file.


Preprocessor macros to send a request to the active problem from within a callback

#define REQUEST__HEADER(sender, target, context)   SPARK::Requests::THeader( (sender), (target), (context) )
 Macro to generate a request header with specific context information as const char*.

#define REQUEST__ABORT(context)   SPARK::Requests::TDispatcher::abort( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 Macro to send an abort request from an atomic class.

#define REQUEST__STOP(context)   SPARK::Requests::TDispatcher::stop( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 Macro to send a stop request from an atomic class.

#define REQUEST__SET_STOP_TIME(context, time)   SPARK::Requests::TDispatcher::set_stop_time( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), time )
 Macro to send a set stop time request from an atomic class.

#define REQUEST__REPORT(context)   SPARK::Requests::TDispatcher::report( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 Macro to send a report request from an atomic class.

#define REQUEST__SNAPSHOT(context, filename)   SPARK::Requests::TDispatcher::snapshot( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), filename )
 Macro to send a snapshot request from an atomic class.

#define REQUEST__SET_MEETING_POINT(context, time)   SPARK::Requests::TDispatcher::set_meeting_point( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), time )
 Macro to send a request to synchronize with a meeting point from an atomic class.

#define REQUEST__CLEAR_MEETING_POINTS(context)   SPARK::Requests::TDispatcher::clear_meeting_points( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 Macro to send a clear meeting points request from an atomic class.

#define REQUEST__RESTART(context)   SPARK::Requests::TDispatcher::restart( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 Macro to send a restart request from an atomic class.

#define REQUEST__SET_DYNAMIC_STEPPER(context, stepper)   SPARK::Requests::TDispatcher::set_dynamic_stepper( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), stepper )
 Macro to send a "set dynamic stepper" request from an atomic class.

#define REQUEST__SET_TIME_STEP(context, h)   SPARK::Requests::TDispatcher::set_time_step( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), h )
 Macro to send a "set time step" request from an atomic class.


Detailed Description

Header file required to define SPARK inverses.

This header file should be included in the file where the inverses of an atomic class are implemented :

Author:
Dimitri Curtil
Version:
SPARK 2.0
Date:
September 3, 2003 Added SET_DATA, GET_DATA and DELETE_DATA macros

December 18, 2002 Original implementation

Attention:
PORTIONS COPYRIGHT (C) 2003 AYRES SOWELL ASSOCIATES, INC.
PORTIONS COPYRIGHT (C) 2003 THE REGENTS OF THE UNIVERSITY OF CALIFORNIA . PENDING APPROVAL BY THE US DEPARTMENT OF ENERGY. ALL RIGHTS RESERVED.

Define Documentation

#define NON_MODIFIER_CALLBACK func   )     CALLBACK_DECLSPEC(void) func(SPARK::TObject* this_pointer, SPARK::ArgList args)
 

Macros to define the prototype for a modifier callback.

#define MODIFIER_CALLBACK func   )     CALLBACK_DECLSPEC(void) func(SPARK::TObject* this_pointer, SPARK::ArgList args, SPARK::TargetList targets)
 

Macros to define the prototype for a non-modifier callback.

#define PREDICATE_CALLBACK func   )     CALLBACK_DECLSPEC(bool) func(SPARK::TObject* this_pointer, SPARK::ArgList args)
 

Macros to define the prototype for a predicate callback.

#define STATIC_NON_MODIFIER_CALLBACK func   )     CALLBACK_DECLSPEC(void) func(SPARK::TInverse* this_pointer)
 

Macros to define the prototype for a static callback.

#define STATIC_PREDICATE_CALLBACK func   )     CALLBACK_DECLSPEC(bool) func(SPARK::TInverse* this_pointer)
 

Macros to define the prototype for a static predicate callback.

#define EVALUATE func   )     MODIFIER_CALLBACK( func )
 

Macros to declare an EVALUATE callback.

Examples:
analytical_frst_ord.cc, analytical_spring.cc, integrator_euler.cc, and sum.cc.

#define PREDICT func   )     MODIFIER_CALLBACK( func )
 

Macros to declare a PREDICT callback.

Examples:
integrator_euler.cc.

#define CONSTRUCT func   )     NON_MODIFIER_CALLBACK( func )
 

Macros to declare a CONSTRUCT callback.

Examples:
analytical_frst_ord.cc, analytical_spring.cc, and integrator_euler.cc.

#define PREPARE_STEP func   )     NON_MODIFIER_CALLBACK( func )
 

Macros to declare a PREPARE_STEP callback.

Examples:
integrator_euler.cc.

#define CHECK_INTEGRATION_STEP func   )     PREDICATE_CALLBACK( func )
 

Macros to declare a CHECK_INTEGRATION_STEP callback.

Examples:
integrator_euler.cc.

#define COMMIT func   )     NON_MODIFIER_CALLBACK( func )
 

Macros to declare a COMMIT callback.

Examples:
integrator_euler.cc.

#define ROLLBACK func   )     NON_MODIFIER_CALLBACK( func )
 

Macros to declare a ROLLBACK callback.

Examples:
integrator_euler.cc.

#define DESTRUCT func   )     NON_MODIFIER_CALLBACK( func )
 

Macros to declare a DESTRUCT callback.

Examples:
analytical_frst_ord.cc, analytical_spring.cc, and integrator_euler.cc.

#define STATIC_CONSTRUCT func   )     STATIC_NON_MODIFIER_CALLBACK( func )
 

Macros to declare a STATIC_CONSTRUCT callback.

Examples:
integrator_euler.cc.

#define STATIC_PREPARE_STEP func   )     STATIC_NON_MODIFIER_CALLBACK( func )
 

Macros to declare a STATIC_PREPARE_STEP callback.

Examples:
integrator_euler.cc.

#define STATIC_CHECK_INTEGRATION_STEP func   )     STATIC_PREDICATE_CALLBACK( func )
 

Macros to declare a STATIC_CHECK_INTEGRATION_STEP callback.

Examples:
integrator_euler.cc.

#define STATIC_COMMIT func   )     STATIC_NON_MODIFIER_CALLBACK( func )
 

Macros to declare a STATIC_COMMIT callback.

Examples:
integrator_euler.cc.

#define STATIC_ROLLBACK func   )     STATIC_NON_MODIFIER_CALLBACK( func )
 

Macros to declare a STATIC_ROLLBACK callback.

Examples:
integrator_euler.cc.

#define STATIC_DESTRUCT func   )     STATIC_NON_MODIFIER_CALLBACK( func )
 

Macros to declare a STATIC_DESTRUCT callback.

Examples:
integrator_euler.cc.

#define TARGET pos,
name   )     SPARK::TTarget& name = targets[pos]
 

A macro that defines a reference named "name" to the TTarget object stored in position "pos" of the target list.

Examples:
analytical_frst_ord.cc, analytical_spring.cc, and integrator_euler.cc.

#define ARGUMENT pos,
name   )     const SPARK::TArgument& name = args[pos]
 

A macro that defines a const reference named "name" to the TArgument object of the argument stored in position "pos".

Examples:
analytical_frst_ord.cc, analytical_spring.cc, and integrator_euler.cc.

#define ARGDEF pos,
name   )     ARGUMENT( pos, name )
 

A macro that defines a const reference named "name" to the TArgument object of the argument stored in position "pos".

Note:
This macro is defined for backward-compatibility reasons since it was used in the HVAC toolkit and globalclass implementations of SPARK 1.xx. The new macro ARGUMENT should be preferred to this one.
Examples:
sum.cc.

#define RETURN val   )     { targets[0] = val; return; }
 

A macro that returns the scalar val for a single-valued inverse.

Note:
There is no equivalent macro for multivalued inverses. The target value must be explicitly assigned to each declared TTarget instances.
Examples:
sum.cc.

#define ACCEPT_STEP   true
 

Macros used in predicate callbacks to indicate that the step is accepted.

#define REJECT_STEP   false
 

Macros used in predicate callbacks to indicate that the step is rejected.

#define THIS   this_pointer
 

A macro to access the pointer to the current "this" pointer associated with the current callback.

Note:
In an instance callback the private data object is implemented as a pointer to a TObject instance

In a static callback the private data object is implemented as a pointer to a TInverse instance

#define GET_DATA owner,
concrete_type,
name   )     concrete_type* name = SPARK::AtomicClass::GetData<concrete_type>( owner )
 

A macro to access the pointer to the private data object stored as part of an object.

Parameters:
owner Either SPARK::TInverse* or SPARK::TObject* owner of the data
concrete_type Concrete type of the data stored in owner used for type-casting
name Name of the variable pointing to the data of type concrete_type to be stored in owner
Note:
The macro implements a static_cast from void* to the specified concrete_type.
Examples:
analytical_frst_ord.cc, and integrator_euler.cc.

#define SET_DATA owner,
concrete_type,
name   )     SPARK::AtomicClass::SetData<concrete_type>( owner, name )
 

A macro to store the pointer to the private data stored as part of an object.

Parameters:
owner Either SPARK::TInverse* or SPARK::TObject* owner of the data
concrete_type Concrete type of the data stored in owner used for type-casting
name Name of the variable pointing to the data of type concrete_type to be stored in owner
Examples:
analytical_frst_ord.cc, and integrator_euler.cc.

#define DELETE_DATA owner,
concrete_type,
is_array_flag   )     SPARK::AtomicClass::DeleteData<concrete_type, SPARK::deleter<is_array_flag> >( owner )
 

A macro to delete data pointed to by an object.

Parameters:
owner Either SPARK::TInverse* or SPARK::TObject* owner of the data
concrete_type Concrete type of the data stored in owner used for type-casting
is_array_flag Boolean value (true or false) indicating whether the data is a built-in array or not
Warning:
When deleting a built-in array, make sure to specify isArray == true to call the delete [] operator. Otherwise specify isArray = false for non "built-in array" types.
Examples:
analytical_frst_ord.cc, and integrator_euler.cc.

#define ACTIVE_PROBLEM   THIS->GetProblem()
 

Returns pointer to TProblem object this object belongs to.

Note:
This applies to both static and non-static callbacks.

#define ACTIVE_INVERSE   THIS->GetInverse()
 

Returns pointer to TInverse object this object belongs to.

Warning:
This applies only to instance callbacks.

#define ACTIVE_COMPONENT   THIS->GetComponent()
 

Returns pointer to TComponent object this object belongs to.

Warning:
This applies only to instance callbacks.

#define ERROR_LOG msg   )     SPARK::Log( SPARK::GetErrorLog(), THIS, __LINE__, msg )
 

Writes msg specified as const char* to the error log file.

Note:
Users could also use the API function SPARK::GetErrorLog() to retrieve a reference to the std::ostream object for the error log file.

#define RUN_LOG msg   )     SPARK::Log( SPARK::GetRunLog(), THIS, __LINE__, msg )
 

Writes msg specified as const char* to the run log file.

Note:
Users could also use the API function SPARK::GetRunLog() to retrieve a reference to the std::ostream object for the run log file.
Examples:
analytical_frst_ord.cc, and analytical_spring.cc.

#define REQUEST__HEADER sender,
target,
context   )     SPARK::Requests::THeader( (sender), (target), (context) )
 

Macro to generate a request header with specific context information as const char*.

Parameters:
sender is a TInverse* or TObject* or TProblem*
target is a TProblem*
context is a const char* object that contains the description of the calling context

#define REQUEST__ABORT context   )     SPARK::Requests::TDispatcher::abort( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 

Macro to send an abort request from an atomic class.

See SPARK::Requests::TDispatcher::abort()

Parameters:
context is a const char* that contains the description of the calling context
Examples:
analytical_frst_ord.cc, analytical_spring.cc, and integrator_euler.cc.

#define REQUEST__STOP context   )     SPARK::Requests::TDispatcher::stop( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 

Macro to send a stop request from an atomic class.

See SPARK::Requests::TDispatcher::stop()

Parameters:
context is a const char* that contains the description of the calling context

#define REQUEST__SET_STOP_TIME context,
time   )     SPARK::Requests::TDispatcher::set_stop_time( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), time )
 

Macro to send a set stop time request from an atomic class.

See SPARK::Requests::TDispatcher::set_stop_time()

Parameters:
context is a const char* that contains the description of the calling context
time is a double value that speicifies the desired stopping time for the simulator

#define REQUEST__REPORT context   )     SPARK::Requests::TDispatcher::report( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 

Macro to send a report request from an atomic class.

See SPARK::Requests::TDispatcher::report()

Parameters:
context is a const char* that contains the description of the calling context

#define REQUEST__SNAPSHOT context,
filename   )     SPARK::Requests::TDispatcher::snapshot( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), filename )
 

Macro to send a snapshot request from an atomic class.

See SPARK::Requests::TDispatcher::snapshot()

Parameters:
context is a const char* that contains the description of the calling context
filename is a const char* that contains the file name used to generate the problem snapshot

#define REQUEST__SET_MEETING_POINT context,
time   )     SPARK::Requests::TDispatcher::set_meeting_point( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), time )
 

Macro to send a request to synchronize with a meeting point from an atomic class.

See SPARK::Requests::TDispatcher::set_meeting_point()

Parameters:
context is a const char* that contains the description of the calling context
time is a double value that indicates the meeting point the simulator will try to synchronize with

#define REQUEST__CLEAR_MEETING_POINTS context   )     SPARK::Requests::TDispatcher::clear_meeting_points( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 

Macro to send a clear meeting points request from an atomic class.

See SPARK::Requests::TDispatcher::clear_meeting_points()

Parameters:
context is a const char* that contains the description of the calling context

#define REQUEST__RESTART context   )     SPARK::Requests::TDispatcher::restart( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ) )
 

Macro to send a restart request from an atomic class.

See SPARK::Requests::TDispatcher::restart()

Parameters:
context is a const char* that contains the description of the calling context

#define REQUEST__SET_DYNAMIC_STEPPER context,
stepper   )     SPARK::Requests::TDispatcher::set_dynamic_stepper( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), stepper )
 

Macro to send a "set dynamic stepper" request from an atomic class.

See SPARK::Requests::TDispatcher::set_dynamic_stepper()

Parameters:
context is a const char* that contains the description of the calling context.
stepper is a TDynamicStepper object that defines the structure of the dynamic steps.
Warning:
Not implemented yet.

#define REQUEST__SET_TIME_STEP context,
 )     SPARK::Requests::TDispatcher::set_time_step( REQUEST__HEADER( THIS, ACTIVE_PROBLEM, context ), h )
 

Macro to send a "set time step" request from an atomic class.

See SPARK::Requests::TDispatcher::set_time_step()

Parameters:
context is a const char* that contains the description of the calling context
h is a double value that indicates the next candidate time step to try
Examples:
integrator_euler.cc.


Generated on 5 Nov 2003 for VisualSPARK 2.01