Duplication¶
Description¶
Duplicate zones of a mesh with rotation around an axis. Typically used in turbomachinery.
Initial mesh on the left. Duplicated mesh on the right with 1 rotation of \(\pi/4\) for the front block and 2 rotations of \(\pi/3\) for the back block.
Construction¶
import antares
myt = antares.Treatment('duplication')
Parameters¶
- base:
Base
The input base to be duplicated.
- base:
- coordinates: list(str)
The variable names that define the set of coordinates. The coordinate system must be the cartesian coordinate system. The first coordinate is taken as the rotational axis.
- vectors: tuple/list(tuple(str)), default= []
Coordinate names of vectors that need to be rotated during the duplication. It is assumed that these are given in the cartesian coordinate system.
- nb_duplication: int or tuple(int) or in_attr, default= ‘in_attr’
Number of duplications if an integer is given. Range of duplications if a tuple is given (from first element to second element included). If in_attr, then each zone of the base must have an attribute nb_duplication.
- pitch: int or float or in_attr, default= ‘in_attr’
Angular sector of the mesh if a scalar is given. If in_attr, then each zone of the base must have an attribute pitch.
- axis: str, default= ‘x’
Name of the rotation axis. Must be in coordinates.
- omega: int or float or in_attr, default= 0.
Rotation speed expressed in radians per second. If time is given, then omega * time is added to the rotation angle. The input mesh is supposed to correspond to time =0. If in_attr, then each zone of the base must have an attribute omega.
- time: float, default= 0.
Time that corresponds to the flow field. If the flow field comes from a computation that is performed in a relative reference frame, then the input mesh is supposed to correspond to time =0, and does not change during the computation. The time and rotation speed omega of the mesh are needed to retrieve the mesh in the absolute reference frame.
Preconditions¶
Zones may be either structured or unstructured.
Zones must only contain one instant. Multi-instant base is not supported.
Postconditions¶
The output base is the assembly of the input base with nb_duplication-1 more bases that have been duplicated from the input base. The name of the duplicated zones is composed of the input zone name with a suffix ‘_DUP’ followed by the number of the duplication. This number has a leading zero for all numbers with less than 2 digits.
Warning
In the duplicated (rotated) zones, the coordinate or vector variables are clearly not the same that the ones of the input zones. If other variables computed from the coordinate or vector variables are present in the input base, then they will not be set correctly in the duplicated base.
e.g.: suppose that [‘x’, ‘y’, ‘z’] is the coordinate system, and a=f(y), then ‘a’ will not be set correctly in the duplicated base.
The boundary conditions are also duplicated.
The families that contains only zones or only boundaries are duplicated.
Example¶
The following example shows a duplication of a base with an angular sector of \(\pi/18\) around the rotation axis ‘x’ with the velocity vector to be rotated.
import antares
myt = antares.Treatment('duplication')
myt['base'] = base
myt['vectors'] = [('vx', 'vy', 'vz')]
myt['nb_duplication'] = 2
myt['pitch'] = np.pi / 18.
dupbase = myt.execute()
Main functions¶
Example¶
"""
This example illustrates the duplication of
a periodic field (for example turbomachinery
computations).
"""
import os
if not os.path.isdir('OUTPUT'):
os.makedirs('OUTPUT')
import numpy as np
from antares import Reader, Treatment, Writer
# ------------------
# Reading the files
# ------------------
r = Reader('bin_tp')
r['filename'] = os.path.join('..', 'data', 'ROTOR37', 'ELSA_CASE', 'MESH', 'mesh_<zone>.dat')
r['zone_prefix'] = 'Block'
r['topology_file'] = os.path.join('..', 'data', 'ROTOR37', 'ELSA_CASE', 'script_topo.py')
r['shared'] = True
r['location'] = 'node'
base = r.read()
r = Reader('bin_tp')
r['base'] = base
r['filename'] = os.path.join('..', 'data', 'ROTOR37', 'ELSA_CASE', 'FLOW', 'flow_<zone>.dat')
r['zone_prefix'] = 'Block'
r['location'] = 'cell'
r.read()
# ------------------
# Duplication
# ------------------
treatment = Treatment('duplication')
treatment['base'] = base
treatment['vectors'] = [('rovx', 'rovy', 'rovz')]
treatment['nb_duplication'] = 2
treatment['pitch'] = 2. * np.pi / 36.
result = treatment.execute()
# -------------------
# Writing the result
# -------------------
writer = Writer('bin_tp')
writer['filename'] = os.path.join('OUTPUT', 'ex_duplication.plt')
writer['base'] = result
writer['memory_mode'] = True
writer.dump()