next up previous contents index
Next: Replacing the "compute-explicit" Method Up: Project Explicit Previous: An Explicit Example

User-Defined Domain Transformations

 

For class Time_Object the user must replace the "compute-send" method to compute his own objects (see section 8.2.1, especially 8.2.1.3), but for Explicit this is different. Since the geometry structure for Surface instances is fixed -- both the domain and the geometry consist of a list of TimeStep sequences with Geom2d instances -- the Explicit "compute-send" method can handle all the memory management and compute the data. The computation is done in three steps:

A domain transformation can be defined by setting the compute_arg pointer of the Explicit instance (see 7.4.5.1), this is usually done by replacing the (empty default) "set-compute-arg" method which is called when a description file is read in:

EXPLICIT *explicit_set_compute_arg()
{
  EXPLICIT *self = (EXPLICIT *)START_METHOD(G_INSTANCE);
  ASSURE(self, "", END_METHOD(NULL));

  self->compute_arg = transform_domain;

  END_METHOD(self);
}

The name of the transformation function is arbitrary, its arguments are the Explicit instance (to be able to access the Explicit name and parameter), the number of the surface part that is computed (only used by subclasses at the moment), and the coordinates of the point that should be transformed. The transformed point has to be returned in a COMPLEX variable:

static COMPLEX transform_domain(EXPLICIT *explicit, int part, double u, double v)
{
  if(!strcmp(explicit->name, "paraboloid")) {
    double a = explicit->time_parm->double_parm[0];
    double b = explicit->time_parm->double_parm[1];
    return g_cmplx(a * (u + v) / 2.0, b * (u - v) / 2.0);
  }

  return g_cmplx(u, v);
}

As Time_Object "compute-send" (compare 8.2.1.3) the domain transformation function has to check the name of the instance to find out which surface should be computed. Since the transformation function is called for all instances it also has to handle the default case, i.e. return g_cmplx(u, v) if nothing special has to be computed.

This example transformation function belongs to an input file paraboloid.ex with two double parameter which computes a hyperbolical paraboloid:

# Hyperbolical Paraboloid

GEOMETRY;        # task
0; 1;            # frame / number of frames

0; 2;            # number of int / double parameter

# double parameter
1.0;             # a
2.0;             # b

1; 1;            # part number / max number of parts

# part 1
0; 10; 10; 0; 0; # flag / number of u- and v-lines / u- and v-sub
-1; -1; 1; 1;    # umin / vmin / umax / vmax

# formulas
x;
y;
x^2 / a^2 - y^2 / b^2; # + for elliptical paraboloid

The description file also can be used without the transformation function but with the function the parameter lines (which can be computed by sending "assign-cons-send" to the Explicit instance and switched on with the tex2html_wrap45084 and tex2html_wrap45086 checkboxes) are more interesting, they are straight lines on the surface.

Of course we really don't need the transformation function for this example, we just have to substitute tex2html_wrap_inline45102 and tex2html_wrap_inline45104 for x and y in the formulas of the description file (i.e. use tex2html_wrap_inline45102 ; tex2html_wrap_inline45104 ; tex2html_wrap_inline45110 ; as formulas) to get the same result.

Domain transformations for subclasses of Explicit are implemented in the same way, of course it is possible to have different transformation functions for subclasses by providing "set-compute-arg" methods for them. In section 8.2.6.1 you can find an example for the Amandus subclass of Explicit.


next up previous contents index
Next: Replacing the "compute-explicit" Method Up: Project Explicit Previous: An Explicit Example

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.