SIM_Engine Class Reference

#include <SIM_Engine.h>

Inheritance diagram for SIM_Engine:

DOP_Engine

List of all members.

Public Member Functions

 SIM_Engine (OP_Node *owner)
 Constructor to create a new simulation.
virtual ~SIM_Engine ()
 Destructor to destroy all data associated with a simulation.
OP_NodegetOwner () const
const UT_StringgetOwnerFullPath () const
 Gets the full path to the DOP Network node that owns this simulation.
SIM_ObjectaddSimulationObject (bool solvefirstframe)
void removeSimulationObject (int index)
void removeSimulationObject (SIM_Object *object)
int getNumSimulationObjects () const
 Returns the number of objects currently in the simulation.
const SIM_ObjectgetSimulationObject (int index) const
const SIM_ObjectgetSimulationObjectFromId (int objectid) const
const SIM_ObjectgetNthSimulationObject (const SIM_DataFilter &filter, int n) const
SIM_RelationshipaddRelationship (const char *name, int creationflags)
int getNumRelationships () const
 Returns the number of relationships in the current simulation state.
const SIM_RelationshipgetRelationship (int index) const
 This function allows looping through the simulations relationships.
const SIM_RelationshipgetRelationship (const char *name) const
 Returns the relationship with the specified name.
void filterConstRelationships (const SIM_DataFilter &filter, SIM_ConstDataArray &rels) const
void removeRelationship (int index)
 Removes the relationship at the specified position.
void removeRelationship (const char *name)
 Removes the relationship with the specified name.
void removeRelationship (SIM_Relationship *rel)
 Removes the specified relationship.
void removeAllRelationships (int createdby, const SIM_RelationshipArray *except)
const SIM_RootDatagetRootDataFromId (const SIM_RootDataId &id) const
const SIM_ObjectgetObjectAtTime (const SIM_Object &object, const SIM_Time &time, bool allowinterpolation) const
SIM_ObjectgetAffectorAtTime (SIM_Object &object, const SIM_Time &time, bool allowinterpolation)
SIM_ObjectcreateSubStepObject (const SIM_Object &object, const SIM_Time &time)
void removeSubStepObject (SIM_Object *objectattime, bool allwithmatchingid)
bool mergeSimulationFile (const char *filename, const SIM_DataFilter &filter, const SIM_ObjectArray &replaceobjects, const OP_Node *defaultcreator, bool forcecreatortodefault, bool acceptnewobjects, bool matchbyname, const char *nameprefix)
void saveSimulationFile (const char *filename, const SIM_DataFilter &filter, const SIM_ObjectArray &objects, bool docompress=true) const
void saveSimulationState (ostream &os, bool docompress=true) const
 Saves the entire current state of the simulation immediately.
void setSimulationTime (const SIM_Time &t, bool resimlasttimestep, bool forceresetsim, bool allowsimulation)
const SIM_TimegetSimulationTime () const
 Returns the current simulation time.
const SIM_Time getEngineTime (const SIM_Time &t) const
 Returns the simulation time that corresponds to the given global time.
const SIM_Time getGlobalTime (const SIM_Time &t) const
 Returns the global time that corresponds to the given simulation time.
const SIM_TimegetEarliestCacheTime () const
 Returns the time of the earliest simulation state in the cache.
const SIM_CacheOptionsgetCacheOptions () const
 Returns a reference to the cache options for this simulation.
void setCacheOptions (const SIM_CacheOptions &o)
 Sets the cache options for this simulation.
const SIM_TimegetTimeStep () const
 Returns the time step size.
void setTimeStep (const SIM_Time &time)
 Sets the global time step size.
int getMaxFeedbackIterations () const
 Gets the maximum number of allowed feedback iterations.
void setMaxFeedbackIterations (int max)
 Sets the maximum number of allowed feedback iterations.
int getFeedbackIteration () const
bool getProvideDataHints () const
 Returns true if the engine is providing data hierarchy hints.
void setProvideDataHints (bool providehints)
 Specifies whether the engine should provide data hierarchy hints.
int getCurrentCreatorId () const
 Gets the id for the node that is currently being processed.
int getCurrentCreatorIndex () const
 Gets the index of the node output that is currently being processed.
void setCreatorInfo (int id, int index)
const SIM_DatagetConstDataWithId (const UT_Guid &id) const
 Returns the SIM_Data pointer with the specified unique id.
int getSimulationFrame (const SIM_Time &time) const
const SIM_Time getSimulationTime (int frame) const
void addError (const SIM_RootData *rootdata, const SIM_Data *data, int errorcode, const char *errorparm, UT_ErrorSeverity severity) const
int64 getTotalMemorySize () const
void removeAllOPInterests () const
 Removes all node interests from the engine.
void addOPInterest (OP_Node *node) const
void getDataTypes (UT_StringArray &datatypes, const char *datatype) const
void getDataTypeSources (UT_StringArray &datatypes, UT_StringArray &srcs) const
const char * getDescription (const char *datatype) const
const SIM_DopDescriptiongetDopDescription (const char *datatype) const
void findAllObjectsFromString (const char *objspec, SIM_ConstObjectArray &objects, const SIM_Time &t, bool interpolateobj) const
const SIM_ObjectfindObjectFromString (const char *objspec, int whichmatch, int *nummatch, const SIM_Time &t, bool interpolateobj) const
void findAllObjectsCreatedBy (OP_Node *creator, SIM_ConstObjectArray &objects) const
void findAllRelationshipsFromString (const char *relspec, SIM_ConstDataArray &relationships, const SIM_Time &t, bool interpolaterel) const
const SIM_RelationshipfindRelationshipFromString (const char *relspec, int whichmatch, int *nummatch, const SIM_Time &t, bool interpolaterel) const
void getSelection (SIM_ConstDataArray &data) const
 Gets a list of all selected data in the simulation.
void clearSelection () const
 Clears the selection flag on all data in this simulation.
fpreal scaleToMKS (const char *fromunits) const
fpreal scaleFromMKS (const char *tounits) const

Protected Member Functions

virtual void resetSimulation ()
virtual void preSimulationStep ()
virtual void postSimulationStep ()
 This function is run after all objects are processed by their solvers.
virtual void clearReferencesToMostRecentState ()
virtual void objectCreated (SIM_Object *object)
virtual void objectRemoved (SIM_Object *object)
virtual void handleExternalNodeChangeSubclass (OP_Node *changednode, OP_EventType eventtype, void *data)
virtual void addErrorSubclass (const SIM_RootData *rootdata, const SIM_Data *data, int errorcode, const char *errorparm, UT_ErrorSeverity severity) const
 The default implementation of this function does nothing.
virtual const SIM_Time getEngineTimeSubclass (const SIM_Time &t) const
 Returns the simulation time that corresponds to the given global time.
virtual const SIM_Time getGlobalTimeSubclass (const SIM_Time &t) const
 Returns the global time that corresponds to the given simulation time.
SIM_ObjectgetNonConstSimulationObject (int index)
virtual bool setIsSimulating (bool issimulating) const

Friends

class SIM_Data
class SIM_DataFactory
class SIM_DataFactoryCreator
class SIM_SimulationState
class SIM_SaveCommand
class SIM_BaseCache
class SIM_Cache


Detailed Description

This is the main engine behind all simulations. Any number of these can be created to create independent simulations. Generally a simulation will be owned by a particular OP_Node. For example, the DopNet object contains a SIM_Engine.
Examples:

SIM/SIM_GasAdd.C, SIM/SIM_GasAdd.h, SIM/SIM_SolverHair.C, SIM/SIM_SolverHair.h, SIM/SNOW_Solver.C, and SIM/SNOW_Solver.h.

Definition at line 49 of file SIM_Engine.h.


Constructor & Destructor Documentation

SIM_Engine::SIM_Engine ( OP_Node owner  ) 

Constructor to create a new simulation.

virtual SIM_Engine::~SIM_Engine (  )  [virtual]

Destructor to destroy all data associated with a simulation.


Member Function Documentation

void SIM_Engine::addError ( const SIM_RootData rootdata,
const SIM_Data data,
int  errorcode,
const char *  errorparm,
UT_ErrorSeverity  severity 
) const

Adds an error to the engine. The object and data parameters allow the DOP_Engine to put the error message on an appropriate DOP Node. Errors are found in the SIM error file. This function simply calls addErrorSubclass().

virtual void SIM_Engine::addErrorSubclass ( const SIM_RootData rootdata,
const SIM_Data data,
int  errorcode,
const char *  errorparm,
UT_ErrorSeverity  severity 
) const [protected, virtual]

The default implementation of this function does nothing.

Reimplemented in DOP_Engine.

void SIM_Engine::addOPInterest ( OP_Node node  )  const

Adds an interest in the supplied node. When the node changes, the engine's handleExternalNodeChange function will be called.

SIM_Relationship* SIM_Engine::addRelationship ( const char *  name,
int  creationflags 
)

Creates a new relationship. The creationflags parameter accepts the same SIM_DATA_* flags accepted by the creationflags parameter of SIM_Data::createNamedSubData().

Examples:
DOP/DOP_GroupAndApply.C.

SIM_Object* SIM_Engine::addSimulationObject ( bool  solvefirstframe  ) 

Allocates a new SIM_Object and adds it to the simulation. The name parameter is assigned to the object. This name does not have to be unique.

virtual void SIM_Engine::clearReferencesToMostRecentState (  )  [protected, virtual]

This function is called by our cache whenever the most recent simulated timestep is being removed from memory (either deleted or moved onto disk).

Reimplemented in DOP_Engine.

void SIM_Engine::clearSelection (  )  const

Clears the selection flag on all data in this simulation.

SIM_Object* SIM_Engine::createSubStepObject ( const SIM_Object object,
const SIM_Time time 
)

Creates an object in the current state with a particular time stamp. This function is useful for solvers that need to do their own time stepping with step sizes smaller than the globally specified time step size. These explicitly stored subsamples are accessible later with the getObjectAtTime() function.

void SIM_Engine::filterConstRelationships ( const SIM_DataFilter filter,
SIM_ConstDataArray rels 
) const

Gets all the relationships of a particular type. The type of a relationship is defined by the one subdata on the SIM_Relationship.

void SIM_Engine::findAllObjectsCreatedBy ( OP_Node creator,
SIM_ConstObjectArray objects 
) const

Returns a list of objects created by the specified node, or any nodes inside the specified node (if it is a subnet).

void SIM_Engine::findAllObjectsFromString ( const char *  objspec,
SIM_ConstObjectArray objects,
const SIM_Time t,
bool  interpolateobj 
) const

Filters all our simulation objects based on a string pattern. Note that the time value is a simulation time, not global time.

void SIM_Engine::findAllRelationshipsFromString ( const char *  relspec,
SIM_ConstDataArray relationships,
const SIM_Time t,
bool  interpolaterel 
) const

Filters all our relationships based on a string pattern. Note that the time value is a simulation time, not global time.

const SIM_Object* SIM_Engine::findObjectFromString ( const char *  objspec,
int  whichmatch,
int *  nummatch,
const SIM_Time t,
bool  interpolateobj 
) const

Returns a single object matching a specified string pattern. Note that the time value is a simulation time, not global time.

const SIM_Relationship* SIM_Engine::findRelationshipFromString ( const char *  relspec,
int  whichmatch,
int *  nummatch,
const SIM_Time t,
bool  interpolaterel 
) const

Returns a single relationship matching a specified string pattern. Note that the time value is a simulation time, not global time.

SIM_Object* SIM_Engine::getAffectorAtTime ( SIM_Object object,
const SIM_Time time,
bool  allowinterpolation 
)

Returns a non-const pointer to an object for a particular time. This function is very similar to getObjectAtTime() except for two things. First, it requires a non-const starting object, and it is a non-const function. Second, if the specified time exactly matches a time in the past, the returned object will be a copy of that past object, not the object itself. Otherwise modifying that object could modify the past. However, if the current time is sepcified, the actual object (i.e. a pointer to the passed in SIM_Object) is returned. This function is for use by solvers that want to modify their affector objects and which do substepping.

const SIM_CacheOptions& SIM_Engine::getCacheOptions (  )  const

Returns a reference to the cache options for this simulation.

const SIM_Data* SIM_Engine::getConstDataWithId ( const UT_Guid id  )  const

Returns the SIM_Data pointer with the specified unique id.

int SIM_Engine::getCurrentCreatorId (  )  const

Gets the id for the node that is currently being processed.

int SIM_Engine::getCurrentCreatorIndex (  )  const

Gets the index of the node output that is currently being processed.

void SIM_Engine::getDataTypes ( UT_StringArray datatypes,
const char *  datatype 
) const

Returns all available data type names. If a null type pointer is passed in, this function returns a list of every data type that the SIM_Engine can create. If a data type name is passed in, the list returned will only contain those data types that can be cast to the specified data type using the SIM_Data::getPointerToType() function.

void SIM_Engine::getDataTypeSources ( UT_StringArray datatypes,
UT_StringArray srcs 
) const

Returns all available data types and the source of their definition. The definition source will be an empty string if the data type is defined internally to Houdini. Otherwise it will be the name of the DSO or DLL file that contains the data type.

const char* SIM_Engine::getDescription ( const char *  datatype  )  const

Returns the descriptive name for a data type. Given the unique identifying name for a data type this function finds the appropriate data factory and returns the descriptive string assigned to the type.

const SIM_DopDescription* SIM_Engine::getDopDescription ( const char *  datatype  )  const

Returns the SIM_DopDescription from the SIM_DataFactory of a particular data type.

const SIM_Time& SIM_Engine::getEarliestCacheTime (  )  const

Returns the time of the earliest simulation state in the cache.

const SIM_Time SIM_Engine::getEngineTime ( const SIM_Time t  )  const

Returns the simulation time that corresponds to the given global time.

virtual const SIM_Time SIM_Engine::getEngineTimeSubclass ( const SIM_Time t  )  const [protected, virtual]

Returns the simulation time that corresponds to the given global time.

Reimplemented in DOP_Engine.

int SIM_Engine::getFeedbackIteration (  )  const

Gets the current feedback iteration we are on. If we are not currently solving, this function will return -1;

const SIM_Time SIM_Engine::getGlobalTime ( const SIM_Time t  )  const

Returns the global time that corresponds to the given simulation time.

virtual const SIM_Time SIM_Engine::getGlobalTimeSubclass ( const SIM_Time t  )  const [protected, virtual]

Returns the global time that corresponds to the given simulation time.

Reimplemented in DOP_Engine.

int SIM_Engine::getMaxFeedbackIterations (  )  const

Gets the maximum number of allowed feedback iterations.

SIM_Object* SIM_Engine::getNonConstSimulationObject ( int  index  )  [protected]

This function is the only way for a SIM_Engine subclass to get a non-const SIM_Object pointer.

const SIM_Object* SIM_Engine::getNthSimulationObject ( const SIM_DataFilter filter,
int  n 
) const

Returns the "nth" simulation object that matches a supplied filter. If less than the supplied n objects match the filter, 0 is returned.

int SIM_Engine::getNumRelationships (  )  const

Returns the number of relationships in the current simulation state.

int SIM_Engine::getNumSimulationObjects (  )  const

Returns the number of objects currently in the simulation.

const SIM_Object* SIM_Engine::getObjectAtTime ( const SIM_Object object,
const SIM_Time time,
bool  allowinterpolation 
) const

Returns a pointer to the state of an object at some time in the past. This function searches for these past object states in three ways. First, if the specified time is equal to a past time step, the state for that time step is returned. Second, if the specified time is not equal to a past time step, then past time steps are searched for object states stored explicitly with createSubStepObject(). Finally, if both these methods fail to find a matching object state, then the closest object states before and after the specified time are found using the first two approaches. Then a new object state is created by interpolating between these two states using SIM_Data::interpolate(). This third approach is skipped if allowinterpolation is set to false. If no previous or no future object state can be found, then this function returns null.

OP_Node* SIM_Engine::getOwner (  )  const

Returns the OP_Node that owns this engine. This may be null if the engine isn't associated with a particular node.

const UT_String& SIM_Engine::getOwnerFullPath (  )  const

Gets the full path to the DOP Network node that owns this simulation.

bool SIM_Engine::getProvideDataHints (  )  const

Returns true if the engine is providing data hierarchy hints.

const SIM_Relationship* SIM_Engine::getRelationship ( const char *  name  )  const

Returns the relationship with the specified name.

const SIM_Relationship* SIM_Engine::getRelationship ( int  index  )  const

This function allows looping through the simulations relationships.

const SIM_RootData* SIM_Engine::getRootDataFromId ( const SIM_RootDataId id  )  const

Returns either a SIM_Relationship or SIM_Object depending on the information stored in the id parameter.

void SIM_Engine::getSelection ( SIM_ConstDataArray data  )  const

Gets a list of all selected data in the simulation.

int SIM_Engine::getSimulationFrame ( const SIM_Time time  )  const

Returns the simulation frame number that corresponds to the given time. The simulation frame number is the number of timesteps that need to be run to get to the specified time, plus one (so that time zero is frame 1).

const SIM_Object* SIM_Engine::getSimulationObject ( int  index  )  const

Returns a pointer to the SIM_Object at the specified index. The index value is the current location of the object in the simulations's list of objects. This value will not be the same as the SIM_Object::getObjectId() value.

const SIM_Object* SIM_Engine::getSimulationObjectFromId ( int  objectid  )  const

Returns a pointer to the SIM_Object with the specified unique id. This function searches the current list of objects for the specified objectid. If the objectid is not found, this function returns null.

const SIM_Time SIM_Engine::getSimulationTime ( int  frame  )  const

Returns the simulation time that corresponds to the given simulation frame.

const SIM_Time& SIM_Engine::getSimulationTime (  )  const

Returns the current simulation time.

const SIM_Time& SIM_Engine::getTimeStep (  )  const

Returns the time step size.

int64 SIM_Engine::getTotalMemorySize (  )  const

Returns the total amount of memory used by all data currently in this simulation, at the current time or in the cache.

virtual void SIM_Engine::handleExternalNodeChangeSubclass ( OP_Node changednode,
OP_EventType  eventtype,
void *  data 
) [protected, virtual]

Override this method to handle changes to external nodes in which we have an interest. The default implementation does nothing.

Reimplemented in DOP_Engine.

bool SIM_Engine::mergeSimulationFile ( const char *  filename,
const SIM_DataFilter filter,
const SIM_ObjectArray replaceobjects,
const OP_Node defaultcreator,
bool  forcecreatortodefault,
bool  acceptnewobjects,
bool  matchbyname,
const char *  nameprefix 
)

Loads a simulation state from a file and merges it into the current simulation state. The data that gets loaded is not allowed to do any sharing of data with the current state, since the data id's can't be expected to match. Objects from the file will replace objects from the current state if their object ids match. Objects loaded from the file will be flagged so that they will not be solved in the current timestep. In subsequent timesteps these objects will be solved. The filter parameter specifies which objects stored in the file are merged in.

virtual void SIM_Engine::objectCreated ( SIM_Object object  )  [protected, virtual]

Initializes a newly created object. This function is called by addSimulationObject(). The default implementation does nothing.

Reimplemented in DOP_Engine.

virtual void SIM_Engine::objectRemoved ( SIM_Object object  )  [protected, virtual]

Allows special handling of objects that are being removed. This function is called by removeSimulationObject(). The default implementation does nothing.

Reimplemented in DOP_Engine.

virtual void SIM_Engine::postSimulationStep (  )  [protected, virtual]

This function is run after all objects are processed by their solvers.

Reimplemented in DOP_Engine.

virtual void SIM_Engine::preSimulationStep (  )  [protected, virtual]

This function is run before passing each object to its solver. The implementation at this level clears out all temporary data from the simulation objects.

Reimplemented in DOP_Engine.

void SIM_Engine::removeAllOPInterests (  )  const

Removes all node interests from the engine.

void SIM_Engine::removeAllRelationships ( int  createdby,
const SIM_RelationshipArray except 
)

Removes all relationships created by a particular DOP node. If -1 is specified, then all relationships are removed. Relationships in the "except" array are not removed.

void SIM_Engine::removeRelationship ( SIM_Relationship rel  ) 

Removes the specified relationship.

void SIM_Engine::removeRelationship ( const char *  name  ) 

Removes the relationship with the specified name.

void SIM_Engine::removeRelationship ( int  index  ) 

Removes the relationship at the specified position.

void SIM_Engine::removeSimulationObject ( SIM_Object object  ) 

Removes a SIM_Object from the simulation. This version of this function takes a SIM_Object pointer instead of an index. The pointer is converted to an index and the indexed version of removeSimulationObject() is called.

void SIM_Engine::removeSimulationObject ( int  index  ) 

Removes a SIM_Object from the simulation. The index value is the current location of the object in the simulations's list of objects. This value will not be the same as the SIM_Object::getObjectId() value, and may change when objects are added to or removed from the simulation.

void SIM_Engine::removeSubStepObject ( SIM_Object objectattime,
bool  allwithmatchingid 
)

Removes an object previously created by createSubStepObject(). If the allwithmatchingid parameter is set to true, not only will the specified object be destroyed, but all other objects with the same object id created using createSubStepObject() will be destroyed. This provides a quick way to destroy all temporary working copies of a particular object.

virtual void SIM_Engine::resetSimulation (  )  [protected, virtual]

Resets the simulation to a clean state. This function calls clearSimulation(), then builds a single empty simulation state.

Reimplemented in DOP_Engine.

void SIM_Engine::saveSimulationFile ( const char *  filename,
const SIM_DataFilter filter,
const SIM_ObjectArray objects,
bool  docompress = true 
) const

Schedules some objects to be saved to a files at the end of the current timestep. The filter parameter makes it possible to save only some of the objects to the file. The actual save happens in the postSimulationStep().

void SIM_Engine::saveSimulationState ( ostream &  os,
bool  docompress = true 
) const

Saves the entire current state of the simulation immediately.

fpreal SIM_Engine::scaleFromMKS ( const char *  tounits  )  const

Returns the scale factor to convert a value in MKS units into the equivalent value in the provided units.

fpreal SIM_Engine::scaleToMKS ( const char *  fromunits  )  const

Returns the scale factor to convert a value in the provided units into the equivalent MKS value.

void SIM_Engine::setCacheOptions ( const SIM_CacheOptions o  ) 

Sets the cache options for this simulation.

void SIM_Engine::setCreatorInfo ( int  id,
int  index 
)

Set the creator information. These values are automatically reset to (-1, -1) before performing a simulation step.

virtual bool SIM_Engine::setIsSimulating ( bool  issimulating  )  const [protected, virtual]

Alerts our owner that we are simulating due to an internally generated need. Returns the previous state

Reimplemented in DOP_Engine.

void SIM_Engine::setMaxFeedbackIterations ( int  max  ) 

Sets the maximum number of allowed feedback iterations.

void SIM_Engine::setProvideDataHints ( bool  providehints  ) 

Specifies whether the engine should provide data hierarchy hints.

void SIM_Engine::setSimulationTime ( const SIM_Time t,
bool  resimlasttimestep,
bool  forceresetsim,
bool  allowsimulation 
)

Sets the current time for the simulation. If the new simulation time is less than the current time, the SIM_Cache is simply set to use its best match for the chosen time. If the new simulation time is greater than the current time, the simulation is stepped forward in time to the new time. The resimlasttimestep parameter causes the most recent cache entry to be deleted before trying to set the current time. This is useful if some parameter of the simulation changes on the current timestep. It causes the timestep to be recooked with the new parameter. This resimulation may also happen if the simulation was interrupted the last time this function was called. The forceresetsim parameter tells the SIM_Engine to reset the simulation before trying to move to the specified time, whether the reset is required or not.

void SIM_Engine::setTimeStep ( const SIM_Time time  ) 

Sets the global time step size.


Friends And Related Function Documentation

friend class SIM_BaseCache [friend]

Definition at line 524 of file SIM_Engine.h.

friend class SIM_Cache [friend]

Definition at line 525 of file SIM_Engine.h.

friend class SIM_Data [friend]

Definition at line 519 of file SIM_Engine.h.

friend class SIM_DataFactory [friend]

Definition at line 520 of file SIM_Engine.h.

friend class SIM_DataFactoryCreator [friend]

Definition at line 521 of file SIM_Engine.h.

friend class SIM_SaveCommand [friend]

Definition at line 523 of file SIM_Engine.h.

friend class SIM_SimulationState [friend]

Definition at line 522 of file SIM_Engine.h.


The documentation for this class was generated from the following file:

Generated on Mon Jan 28 00:29:59 2013 for HDK by  doxygen 1.5.9