| 44 | === Adding New Objects === |
| 45 | |
| 46 | The object system in AstroBEAR is intended to be flexible. There are, however, a few object management routines common to most objects. These routines amount to a standardized interface, and are recommended for any object that might one day be part of the regular build. |
| 47 | |
| 48 | To create your new object of type {{{Object}}}, create a new module file in modules/objects. Then implement the following functions: |
| 49 | |
| 50 | * ''{{{InitObjects()}}}'': Sets up a global list of pointers to objects of type {{{Object}}}. This routine gets called in {{{modules/module_control.f90::ModuleInit()}}}. The list pointer itself is usually part of the object module. |
| 51 | * ''{{{CreateObject(ObjPointer[, args])}}}'': Creates a new {{{Object}}}-type object, allocating whatever variables are needed. This is usually called in a problem's {{{ProblemModuleInit()}}} routine. |
| 52 | * ''{{{InitializeObject(ObjPointer[, args])}}}'': Sets the data attributes of the new object. This also gets called in a problem's {{{ProblemModuleInit()}}} routine, shortly after the object's creation. |
| 53 | * ''{{{AddObjectToList(ObjPointer)}}}'': Adds the object {{{ObjPointer}}} to the global list of {{{Object}}}-type objects. While it is consider part of the standard object interface, this routine is more often than not called from within {{{InitializeObject()}}}. |
| 54 | * ''{{{RemoveObjectFromList(ObjPointer)}}}'': Adds the object {{{ObjPointer}}} to the global list of {{{Object}}}-type objects. This routine is usually part of the object destruction process, so it is often called in the {{{DestroyObject()}}} routine. |
| 55 | * ''{{{DestroyObject(ObjPointer[, args])}}}'': Deletes an object, freeing up the object's allocated memory. This can be used almost anywhere, but is most often used in control modules. |
| 56 | |
| 57 | Objects which have a physical representation in the problem data have some additional standard routines: |
| 58 | * ''{{{ObjectGridInit(Info)}}}'': It takes a grid structure {{{Info}}}, finds all the objects of type {{{Object}}} that exist at least partially inside it, and creates their representations within {{{Info}}}'s data. This routine gets called in {{{modules/module_control.f90::GridInit()}}}. |
| 59 | * ''{{{ObjectBeforeStep(Info)}}}'': This routine is only needed objects which have a regularly renewed effect. It takes a grid structure {{{Info}}}, finds all the objects of type {{{Object}}} that exist at least partially inside it, and applies their timestep condition to {{{Info}}}'s data. This routine gets called in {{{modules/module_control.f90::BeforeStep()}}}. |
| 60 | |
| 61 | These are just the routines required so that AstroBEAR can consistently interact with your object; you will no doubt have others. |