Instant¶
Subclass of Antares data structure.
Contains several variables that can be located at the center of the cells, at the node, at the interfaces or at a mix of cells and interfaces: cellfict

class
antares.api.Instant.
Instant
(instant=None, connectivity=False, inherit_computer=None)¶ Sub class of Antares data structure.
Contains several variables that can be located at the center of the cells, at the node, at the interfaces or at a mix of cells and interfaces: cellfict
Methods
add_computer_function
(new_func)Setter of the function.
are_all_shared
(variables)Check if variables are all shared.
Return the cell shape of the instant.
clear
()closest
(value, variables)Get the closest indices to the values for the given variables.
compute
(var_name[, location, reset, store])Compute a given variable for the instant.
compute_cell_normal
([coordinates, …])Compute the normal vector of each cell.
compute_cell_volume
([coordinates])Compute the volume of the cells.
compute_coordinate_system
([ttype, …])Compute a new coordinate system in the instant.
delete_variables
(list_vars[, location])Delete variables in the instant.
deserialized
(pickable_instant)Build an instant from its representation.
Return the dimension.
duplicate_variables
(list_vars, list_newvars)Duplicate variables in the instant.
get
(k[,d])get_celltype
(celltype)Return the subset of the instant with only a given element type.
get_location
(location)Return a copy of the Instant containing only the variables located in the original Instant at the specified location.
Tell whether the instant is structured or not.
Tells whether the instant is unstructured or not.
items
()keys
([location, with_shared])List all the Instant variables.
mesh_orientation
(coordinate_names)Give the orientation of a 3D structured mesh.
node_to_cell
([variables])Compute variables at cell centers from values given at nodes.
pop
(k[,d])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem
()as a 2tuple; but raise KeyError if D is empty.
rel_to_abs
([coordinates, conservative_vars, …])Transform conservative variables in the instant from relative frame to absolute frame.
rename_variables
(list_vars, list_newvars[, …])Rename variables in the instant.
serialized
([data])Build a pickable representation of the instant.
set_computer_model
(modeling[, species_database])Setter of the computer.
set_formula
(formula)Setter of the formula.
setdefault
(k[,d])update
([E, ]**F)If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values
()Attributes
Computer of variables associated to the Instant.
Getter of the computer.
Attribute (of type
antares.core.CustomDict
) containing the connectivity for unstructured grid.Shape of the Instant.

add_computer_function
(new_func)¶ Setter of the function.
 Parameters
new_func (func) – a python function.
Check if variables are all shared.
 Parameters
variables (list(str), or list(tuple(str)) e.g.: ['x', 'y'] or [('x','node'), ('y','cell')]) – Variable names.
 Returns
says if all the variables passed as parameters are shared
 Return type
bool

cell_shape
()¶ Return the cell shape of the instant.

closest
(value, variables)¶ Get the closest indices to the values for the given variables.
 Parameters
value (list of floats) – values to be close to
variables (list of str) – variables scanned
 Returns
index and distance of the closest point
 Return type
(tuple of integer, real)

compute
(var_name, location=None, reset=False, store=True)¶ Compute a given variable for the instant.
This variable is computed with variables available in the instant.
 Parameters
var_name (str) – The name of the variable to compute.
location (str in LOCATIONS) – The location of the variable. If
None
, the default location is assumed.reset (bool) – Remove temporary fields stored in the equation manager.
store (bool) – Store temporary fields in the equation manager.

compute_cell_normal
(coordinates=['x', 'y', 'z'], orientation=1, origin=None, unit=False)¶ Compute the normal vector of each cell.
Its components are stored with the variable names: (‘normal_<coordinate_name>’, ‘cell’). The cell surface is stored under (‘surface’, ‘cell’).
Warning
works only on a 1D or 2D dataset.
 Parameters
coordinates (list of str) – list of coordinates
orientation (int) – sign of the normal orientation (1 is natural orientation defined by topology, 1 is the invert)
origin (list of floats) – coordinates of the origin point used to set up the normal orientation (if it is not given the orientation is depending on the topology node ordering)
unit (bool) – if True then the output vectors are unit vectors

compute_cell_volume
(coordinates=['x', 'y', 'z'])¶ Compute the volume of the cells. It is stored with the variable name (‘cell_volume’, ‘cell’).
 Parameters
coordinates (
list(str)
) – list of coordinate names

compute_coordinate_system
(ttype='cartesian2cylindrical', remove_actual=False, actual_coord_sys=['x', 'y', 'z'], new_coord_sys=['x', 'r', 'theta'], origin=[0.0, 0.0, 0.0])¶ Compute a new coordinate system in the instant.
name DEFAULT_CARTESIAN_COORDINATES name DEFAULT_CYLINDRICAL_COORDINATES
 Parameters
ttype (str in ['cartesian2cylindrical', 'cylindrical2cartesian']) – type of transformation
remove_actual (bool) – remove actual coordinate system after transformation
actual_coord_sys (list of 3 str) – names of the current coordinates
new_coord_sys (list of 3 str) – names of the new coordinates
origin (list of 3 float) – position of the origin
Warning
‘cylindrical2cartesian’ with non zero origin not implemented
for ‘ttype’=’cartesian2cylindrical’, in ‘new_coord_sys’, the first coordinate is the axial direction, the second the radial one, and the third the azimuthal one (by default (x, r, \(\theta\)))
The first coordinate name in ‘new_coord_sys’ must also be into ‘actual_coord_sys’.

delete_variables
(list_vars, location=None)¶ Delete variables in the instant.
 Parameters
list_vars (list(str)) – list of variables to delete
location (str in LOCATIONS or ‘None’) – if
None
, delete the variables at all locations

classmethod
deserialized
(pickable_instant)¶ Build an instant from its representation.

dimension
()¶ Return the dimension.
 Returns
dimension of the Instant
 Return type
int

duplicate_variables
(list_vars, list_newvars, location=None)¶ Duplicate variables in the instant.
 Parameters
list_vars (list of str) – list of variables to duplicate
list_newvars (list of str) – list of new variable names
location (str in LOCATIONS) – if different from
None
, change only the variables at the location specified
Duplication is performed elementwise.

get_celltype
(celltype)¶ Return the subset of the instant with only a given element type.
 Parameters
celltype (str) – type of cells in [‘tet’, ‘pyr’, ‘hex’, ‘pri’, ‘tri’, ‘qua’]
 Returns
a copy of the instant with only element of the given type

get_location
(location)¶ Return a copy of the Instant containing only the variables located in the original Instant at the specified location.
Variables (numpy arrays) are NOT deep copied. They are references to the original variables.

is_structured
()¶ Tell whether the instant is structured or not.
 Returns
the boolean telling if the Instant is structured or not.
 Return type
bool

is_unstructured
()¶ Tells whether the instant is unstructured or not.
 Returns
the boolean telling if the Instant is unstructured or not.
 Return type
bool

keys
(location=None, with_shared=True)¶ List all the Instant variables.
 Parameters
location (string in LOCATIONS) – if different from
None
, lists only the variables at the location specifiedwith_shared (bool) – if True, it will include the variables contained in the shared Instant
 Returns
the Instant variables
 Return type
list(str) when location is set list(tuple(str, str)) when location is None

mesh_orientation
(coordinate_names)¶ Give the orientation of a 3D structured mesh.
A 3D structured mesh has orientation 1 if at each node, (i, j, k) directions form a righthanded oriented basis. Otherwise, it has a 1 orientation.
The coordinates must be at node.
 Parameters
coordinate_names (list(str)) – the name of variables defining the coordinates
 Returns
1 if righthanded oriented, 1 if lefthanded oriented, 0 if undefined
 Return type
int

node_to_cell
(variables=None)¶ Compute variables at cell centers from values given at nodes.
 Parameters
variables (list(str) or None) – list of variables to compute at cell, if
None
, compute all variables from node to cell

rel_to_abs
(coordinates=['x', 'y', 'z'], conservative_vars=['ro', 'rovx', 'rovy', 'rovz', 'roE'], omega='in_attr', angle='in_attr')¶ Transform conservative variables in the instant from relative frame to absolute frame.
 Parameters
coordinates (list(str)) – List of coordinate names.
conservative_vars (list(str)) – List of conservative variables names in the following order: density, momentum along the xaxis; momentum along the yaxis, momentum along the zaxis and total energy per unit of volume
omega (float) – Angular speed of the current base. If
in_attr
use the omega stored in the attrs, necessary if different angular speeds in the base (for example one angular speed per superblock)angle (float) – Angular deviation of the current base. If
in_attr
use the angle stored in the attrs, necessary if different angular deviations in the base (for example one angular deviation per superblock and per instant)
Note
may be moved elsewhere in future releases
Warning
the angular speed must be perpendicular to the xaxis

rename_variables
(list_vars, list_newvars, location=None)¶ Rename variables in the instant.
 Parameters
list_vars (list of str) – list of variables to rename
list_newvars (list of str) – list of new variable names
location (str in LOCATIONS) – if different from
None
, change only the variables at the location specified
Replacement is performed elementwise.

serialized
(data=True)¶ Build a pickable representation of the instant.

set_computer_model
(modeling, species_database=None)¶ Setter of the computer.
 Parameters
modeling (str) – The name of a set of equations. This modeling contains equations that can be found in the directory that has the same name in the directory named formula. ex: the modeling internal must be in the directory formula
species_database (str) – The filename that contains the information about chemical species in some specific modelings.

set_formula
(formula)¶ Setter of the formula.
 Parameters
formula (str) – The name of the new formula.

property
attrs
¶ Computer of variables associated to the Instant. No default set of equations is provided to avoid confusion. Use the setter.

property
computer
¶ Getter of the computer.

property
connectivity
¶ Attribute (of type
antares.core.CustomDict
) containing the connectivity for unstructured grid. See the section Connectivity for more information.

locations
= ['node', 'cell']¶

property
shape
¶ Shape of the Instant.
The shape is considered to be the shape of the node variable numpy array contained in the Instant.

Connectivity¶
The connectivity object is an Instant attribute of type CustomDict
.
It is used to store the connectivity arrays of unstructured grids. Antares can only handle
unstructured grids made of standard (or canonical) elements: segment, triangle, quadrilateral,
tetrahedron, hexahedron, prism, and pyramid. Highorder elements are not considered.
The number of vertices per element (or nodes per cell) for each element type is given by:

Constants.
NODES_PER_CELL
= {'bi': 2, 'hex': 8, 'pri': 6, 'pyr': 5, 'qua': 4, 'tet': 4, 'tri': 3}¶
Only elementbased connectivity is handled right now. Facebased connectivity is not available.
The grid connectivity of each element type is stored in the connectivity attribute:
Instant.connectivity['tri'] = tri_table
Instant.connectivity['qua'] = qua_table
The connectivity table is a twodimensional numpy array of shape (number of cells of this element type, number of nodes per cell for this element type). The order in which the nodes of a cell are listed is important, and is described in the following picture for the various cell types.