Gradient Utility Functions

The following functions are only used internally in Antares. They give some insights on the methods used to compute gradients.

antares.utils.GradUtils.tri_face(pt0, pt1, pt2, instant, coord_names, vol, grad_variables=None, grad=None)

The face is a triangle with points \(p_0\), \(p_1\), and \(p_2\). The normal to this face is given by \(\displaystyle \vec{n} = \frac{1}{2} \vec{(p_1-p_0)} \vec{(p_2-p_0)}\). The contribution of this face to the volume is given by \(\displaystyle \frac{1}{3} (\frac{1}{3} (p_0 + p_1 + p_2)) \cdot \vec{n}\).

Parameters:
  • pt2 (int pt0, pt1,) – points of the triangle

  • instant (Instant) – instant containing the variables for which the gradient is to be computed

  • coord_names (list(str)) – coordinate names

  • vol (ndarray) – volume

  • grad_variables (None or list(str)) – list of variables for which the gradient is to be computed

  • grad (ndarray) – gradients

Return vol:

volume is incremented with the face contribution

Return grad:

gradients are incremented with the face contribution

antares.utils.GradUtils.qua_face(pt0, pt1, pt2, pt3, instant, coord_names, vol, grad_variables=None, grad=None)

The face is a quadrilateral with points \(p_0\), \(p_1\), \(p_2\), and \(p_3\). The normal to this face is given by \(\displaystyle \vec{n} = \frac{1}{2} \vec{(p_2-p_0)} \vec{(p_3-p_1)}\). The contribution of this face to the volume is given by \(\displaystyle \frac{1}{3} (\frac{1}{4} (p_0 + p_1 + p_2 + p_3)) \cdot \vec{n}\)

Parameters:
  • pt3 (int pt0, pt1, pt2,) – points of the quadrilateral

  • instant (Instant) – instant containing the variables for which the gradient is to be computed

  • coord_names (list(str)) – coordinate names

  • vol (ndarray) – volume

  • grad_variables (None or list(str)) – list of variables for which the gradient is to be computed

  • grad (ndarray) – gradients

Return vol:

volume is incremented with the face contribution

Return grad:

gradients are incremented with the face contribution

antares.utils.GradUtils.compute_grad(instant, coordinates, grad_variables=None)

Compute gradients at cell centers.

It handles both structured and unstructured grids.

if grad_variables is None, then only the cell volumes will be computed.

The method to compute the volume and the gradients of/in a cell is based on the Green-Ostrogradski theorem.

i.e. \(\displaystyle V = \frac{1}{3} \oint_S C.n \, dS\) with V the volume, C one point on the surface S, and n the normal.

Parameters:
  • instant (Instant) – container of variables

  • coordinates (list(str)) – coordinate names

  • grad_variables (list(str)) – variable names for which gradient will be computed.