In this tutorial you will learn about the important concept of Family.

We will detail the creation of Family.

Suppose you want to operate on entities that share common characteristics

  • blocks (zones),

    • e.g.: turbomachine row, etc.

  • boundary conditions (interfaces)

    • e.g.: wing wall surface, input plane, etc.

You can tag these entities to be part of a family. Then, a family can be viewed as a set of objects.

This family can be used to operate transparently on the set of objects.

base.families is an ordered dictionary containing Family objects.

To build an example, download the file https://cgns.github.io/CGNSFiles/Poinot/sqnz_s.hdf.cgns.gz and untar the archive in your working directory.

import antares as ant
r = ant.Reader('hdf_cgns')
r['filename'] = 'sqnz_s.hdf.cgns'
base = r.read()
print(base)
print(base[0][0])
print(base.families)

Let’s remember this content. And look at the existing families.

The Family object that is referenced with the key ‘inflow’ in the dictionary base.families contains 4 elements.

print(type(base.families['inflow']))
print(base.families['inflow'])

The Family object is a container of elements. The first element is an object of type Boundary.

print(base.families['inflow'][0])
print(type(base.families['wall'][0]))
print(base.families['wall'])
print(base.families['wall'][0])

Create a Family object that will handle other objects

# create a Family object that will handle other objects
my_family = ant.Family()
print(my_family)

The instance my_family of the class Family contains an item named ‘zone_0’ which is the object base[0] i.e. a Zone of the Base.

# my family contains an item named 'zone_0' which is the object base[0] i.e. a Zone of the Base
my_family['zone_0'] = base[0]
print(my_family)
print(my_family[0])

I gather what I wanted in a new object which is of type Family (which is basically an ordered dictionary).

What can I do next.

If the objects we put in the family object comes from a base, then it is quite logical to assign this family object to the base itself.

So I can put my family in the dictionary of families already existing in the Base.

# Put my family in the set of families already existing in Base
base.families['family_0'] = my_family
print(base.families)

Family Slicing

We will see how to use the operator [ ] to extract a sub-part of a Base.

If the argument of the operator [ ] is of type Family, then the result will be a Base that contains all the objects contained in the family.

sub_base = base[my_family]
print(sub_base)

Remember that slicing always returns an object of the same type.

We have obtained a new Base on which we can use all the compatible Antares treatments.

A family can contain Zones, Boundaries, and … Families.

Most of the time, Antares readers already give families described in the databases (files).

print(base.families)
sym_fam = base.families['sym']
print(sym_fam)
sub_base = base[sym_fam]
print(sub_base)
print(sub_base[0])