Next: Other Methods on TimeStep
Up: TimeStep
Previous: Memory Methods on TimeStep
- (TIMESTEP * ) GRAPE(TimeStep/step, "put")(pre, post, t)
- CLASS * TimeStep
TIMESTEP * step
INSTANCE * pre, * post
double t
This method adds a new TimeStep with pre and post as its
pre_object and post_object and time t to an existing
TimeStep sequence step or -- if called on the class
TimeStep -- creates a new TimeStep. If there already is a step
with time t in the step sequence only this existing step is
returned (no new step is created), otherwise "put" returns the new
step. Note that pre and post are ASSIGNed to the
appropriate variables so if these objects go out of scope afterwards you
have to send them "delete" to get the number of references right.
An example:
{
TIMESCENE *tsc;
INSTANCE *pre, *post, *first, *last;
double t = 0.0;
tsc = (TIMESCENE *)GRAPE(TimeScene, "new-instance")(<<name>>);
first = <<read/create object>>(t);
tsc->dynamic = (INSTANCE *)GRAPE(TimeStep, "put")(first, first, t);
GRAPE (first, "delete")(); /* now first is only referred by the TimeStep */
while (t < 1.0) {
t += delta;
pre = <<pre-object for time>>(t);
post = <<post-object for time>>(t);
tsc->dynamic = (INSTANCE *)GRAPE (tsc->dynamic, "put")(pre, post, t);
GRAPE (pre, "delete")();
GRAPE (post, "delete")();
}
/* t >= 1.0 */
last = <<last object>>(t);
GRAPE (tsc->dynamic, "put")(last, last, t);
GRAPE (last, "delete")();
}
Of course one can delete first or post a little later if they are
needed to construct the next objects:
{
TIMESTEP *tsp;
MYCLASS *obj, *result, *next;
double t = 0.0;
obj = <<the object>>;
tsp = (TIMESTEP *)GRAPE(TimeStep, "put")(obj, obj, t);
while (t < 1.0) {
result = (MYCLASS *)GRAPE (obj, "change-time")(t);
GRAPE (obj, "delete")();
t += delta;
next = (MYCLASS *)GRAPE (result, "change-geometry")(t);
GRAPE (tsp, "put")(result, next, t);
GRAPE (result, "delete")();
obj = next;
}
...
}
- (TIMESTEP * ) GRAPE(TimeStep, "alloc")(num, tstart, tend, name)
- CLASS * TimeStep
int num
double tstart, tend
char * name
In contrast to "put" which just adds one step to an existing sequence
"alloc" creates a complete TimeStep sequence with num
steps with equidistant times in the interval [tstart, tend]. The
first step gets the name name, all following steps are named
step i/num with i in [2, num].
Only the TimeSteps itself are created, to create objects for the
sequence you can use
- GRAPE(step, "create-objects")(class, name)
- TIMESTEP * step
CLASS * class
char * name
This method creates for each TimeStep in the sequence step an
object of class class with name name (the pre_object is
created and then ASSIGNed to the post_object).
- GRAPE(step, "insert-step")(time)
- TIMESTEP * step
double time
Insert a new TimeStep at time time in the sequence step
and return it, if already a step for time exists nothing happens and
NULL is returned.
If the time is within the time range of the step sequence
"insert-step" creates the object for the new step by calling
"get-object"(NULL, time), otherwise the first or last
object of the sequence is copied. If the new step is inserted at the start
or end of the sequence the times are renormalized.
Next: Other Methods on TimeStep
Up: TimeStep
Previous: Memory Methods on TimeStep
SFB 256 Universität Bonn and IAM Universität Freiburg Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik,
Universität Bonn.