Usage of tagged Data objects

Created by Lutz Gross on on 2009-03-24
Keywords:
Tagging

How do I use tagged Data ?

A Here comes an example of tagged scalar data for a Domain mydom:

    s=Scalar(0.,Function(mydom))
    s.setTaggedValue(1000,1.)
    s.setTaggedValue(2000,2.)

In this case the Data object s uses 1. for all samples which have been tagged with the value 1000 and the value 2. for samples tagged with 2000. All other samples use the dafault value 0. set tn the Scalar() call. In case of finley, the FunctionSpace Function is represented by elements so the tag refer to the tags assigned to the elements, typically during mesh generation.

There is a way to modify the tags after the mesh as been generated: If you want to set tag 1000 for element left from x0=0.5 and tag 2000 for element right from x0=0.5 you can use:

x0=Function(mydom).getX()[0]
Function(mydom).setTags(1000,whereNegative(x0-0.5))
Function(mydom).setTags(2000,whereNegative(0.5-x0))

Note that although setTags is called for different instances of Function(mydom) is still changes the element tag as it effects the underlying mydom. It also important to point out that a tag sticks to the element even if the element coordinates are altered by a mydom.setX() call and is considered when the mesh is written to a file.