2. Creating, Loading, and Re-loading

To create a Field object, first the corresponding Model object must be present (see The Model Object).

2.1. With the Graphical User Interface

This is done in several steps:

  1. Make sure that the Model object is selected.

  2. Select Object->Create empty Field.... This will create a new, empty Field object, whose editor will be displayed.

  3. On the "Load" page of the Field editor, the chooser is displayed. Make your choice among the available solution fields. See Section 4 for details.

  4. Press the "Apply" button on the bottom of the chooser. This will attempt to load the solution data from database into memory.

2.2. From the Python Environment

When all enumerator values are known, the Field object can be created by specifying the enumerator values in the constructor. For example:

  • A nonlinear stress-analysis using the B2000++ solver:

    f = Field(m, name='STRESS', cycle=10, case=2)
  • A CFD-analysis using the NSMB flow solver:

    f = Field(m, name='VELO', cycle=1)
  • A free-vibration analysis using the B2000++ solver:

    f = Field(m, name='MODE', case=1, mode=5)

Doing so will attempt to load the Field object from database with the given enumerator values. If these values are not valid, an exception will be raised.

When some of the enumerator values are not known a priori, for instance the last computational cycle, a different technique can be used. This is illustrated by the following example, where the last computed DISP field should be loaded:

f = Field(m, name='DISP', case=1, cycle_index=-1)

The value of -1 for the cycle_index argument indicates that the last cycle should be taken, this works in the same way as for Python lists: -1 selects the last element, -2 the second to last, etc., while 0 selects the first element, 1 the second, etc.

This technique can be applied to all kinds of enumerators. Example:

f = Field(m, name='DISP', case_index=0)

2.3. Re-Loading

Any Field object's enumerator values can be changed, and the Field object may be subsequently re-loaded. Any dependent baspl++ objects, such as NPart objects, will be updated accordingly.

This is illustrated with the following script example:

# First create a Model object.
m = Model('panel.b2m')

# Then create an Field object.
f = Field(m, name='DISP', case=1, cycle_index=0)

# Create an NPart object, use the Field for colouring
# and deforming, and extract all elements.
p = NPart(m)
p.contour.compname = 'amplitude'
p.contour.field = f
p.deform.field = f
p.elements.extract = True

# Animation loop.  The NPart is automatically updated 
# and re-displayed each time the Field object is re-loaded.
for c in f.ch.cycles:
    f.ch.cycle = c
    f.load()