nemocrys / pyelmer

A python interface to Elmer.
GNU General Public License v3.0
53 stars 15 forks source link

Referencing to other bodies / boundaries etc. not working #17

Closed arvedes closed 1 year ago

arvedes commented 1 year ago

In some setups it is required to reference another body, e.g. for definition of an intersection BC. In the sif it looks like this:

Boundary Condition 1
  Target Boundaries(1) = 1
End
Boundary Condition 2
  Target Boundaries(1) = 2
End
Boundary Condition 3
  Intersection BC(2) = Integer 1 2  ! reference to BCs defined above
  (...)
End
arvedes commented 1 year ago

Objects can now be referenced. If the entry is a single object, it can be directly used, e.g.:

body1 = Body(...)
bc1 = Boundary(...)
bc1.data = {
    "Radiation Target Body": body1
}

For combinations of multiple objects (including strings) the new class StringFromList has to be used:

from pyelmer.elmer import Boundary, StringFromList
bc1 = Boundary(...)
bc2 = Boundary(...)
bc3 = Boundary(...)
bc3.data = {
    "Intersection BC(2)": StringFromList(["Integer", bc1, bc2])
}

This will produce the output in the post above.