wiki:rp_xml_ele_field

Version 5 (modified by mmc, 14 years ago) (diff)

changed image() macro to rpimage() so images work properly

<field>

A field object represents the value of some function defined over a mesh. The mesh is usually a collection of points in space, but it can also represent points in energy, momentum, etc.

<cloud id="m2d">
  <about>
    <label>2D Mesh</label>
  </about>
  <units>um</units>
  <hide>yes</hide>
  <points>0 0
1 0
2 0
3 0
...
  </points>
</cloud>

<field id="f2d">
  <about>
    <label>2D Field</label>
  </about>
  <component>
    <mesh>output.cloud(m2d)</mesh>
    <values>0
0
0
0
...
    </values>
  </component>
</field>

In this example, the <cloud> contains a series of (x,y) points defining the mesh. The <field> includes a <mesh> attribute pointing to output.cloud(m2d) as the underlying mesh. The values within the field correspond to the points defined in the cloud. The first value represents the field at the first mesh point, the second value at the second mesh point, and so forth.


<mesh id="m3d">
  <about>
    <label>3D Mesh</label>
  </about>
  <units>um</units>
  <hide>yes</hide>
  <node id="0">0 0 0</node>
  <node id="1">1 0 0</node>
  <node id="2">2 0 0</node>
  <node id="3">3 0 0</node>
  ...
  <element id="0">
    <nodes>0 1 5 6 25 26 30 31</nodes>
  </element>
  <element id="1">
    <nodes>1 2 6 7 26 27 31 32</nodes>
  </element>
  ...
</mesh>

<field id="f3d">
  <about>
    <label>3D Field</label>
  </about>
  <component>
    <mesh>output.mesh(m3d)</mesh>
    <values>0
0
0
0
...
    </values>
  </component>
</field>

Meshes can also be defined with explicit connectivity. A <cloud> is just a set of points, which is converted into a mesh automatically via Delaunay triangularization. But a <mesh> element defines a set of points and their connectivity. Each point is defined as a <node> with a specific id. In this example, we have a 3D mesh, so each <node> contains an (x,y,z) coordinate. The mesh also contains a series of <element> objects, which indicate how the nodes are stitched together to form a mesh. The first element is a cube composed of nodes with identifiers (id=) 0, 1, 5, 6, 25, 26, 30, and 31. Note that this mesh has a hole in the center. There is no element defined that connects the inner nodes. This is not an error. It represents a hole in the underlying structure.

The <field> contains a <mesh> attribute that points to output.mesh(m3d) as the underlying mesh. Each value in the field corresponds to a node in the mesh. The first value represents the field at the first node (id=0), the next value at the next node (id=1), and so forth.

NOTE: The newlines after each value in the field and each point in the cloud are significant. They help Rappture differentiate between a scalar and a vector value in a field, or between a 2D point and a 3D point in a cloud.

You can see working code in the zoo of example's in the field example or on the hub in the directory /apps/rappture/examples/zoo/field.

Attachments (8)

Download all attachments as: .zip