Functions
Indicator Fields
- flatiron_tk.functions.indicator_fields.build_field_scalar_function(domain_mesh, fictitious_mesh, inside_value, outside_value, name=None)[source]
Create a scalar function defined on the domain mesh that is constant inside the fictitious mesh and has a different value outside. :param domain_mesh: The mesh of the domain where the function is defined. :type domain_mesh: flatironx.mesh :param fictitious_mesh: The mesh of the fictitious region where the function takes the inside value. :type fictitious_mesh: flatironx.mesh :param inside_value: The value of the function inside the fictitious region. :type inside_value: float :param outside_value: The value of the function outside the fictitious region. :type outside_value: float :param name: The name of the function. If not provided, name will default to “field_scalar_function”. :type name: str, optional
- Returns:
A function defined on the domain mesh, where each local degree of freedom (DOF) is assigned the inside value if it is in the fictitious region, and the outside value otherwise.
- Return type:
dolfinx.fem.Function
- flatiron_tk.functions.indicator_fields.build_rank_indicator_function(mesh, name=None)[source]
Create a scalar function that indicates the rank of the process on which it is defined. :param mesh: The mesh on which the function is defined. :type mesh: flatironx.mesh :param name: The name of the function. If not provided, name will default to “PID”. :type name: str, optional
- Returns:
A function defined on the mesh, where each local degree of freedom (DOF) is assigned the rank ID.
- Return type:
dolfinx.fem.Function
Utilities
- class flatiron_tk.functions.utils.PointEvaluator(mesh)[source]
Bases:
objectEfficiently evaluate finite element functions at user-specified points without rebuilding the bounding box tree each time.
- Parameters:
mesh (flatiron_tk.Mesh) – The mesh on which the function is defined.
- evaluate_point(function, point, show_warning=True)[source]
Evaluate a Dolfinx Function at a single point in parallel. Returns the value or None if the point is outside the mesh.
- Parameters:
function (dolfinx.fem.Function) – The function to evaluate.
point (array-like) – Point at which to evaluate.
show_warning (bool, optional) – Whether to show a warning if the point is outside the mesh. Default is True.
- Returns:
value – Function value at the point (as a list) or None if outside the mesh.
- Return type:
list or None
- evaluate_set(function, points)[source]
Evaluate a Dolfinx Function at multiple points in parallel. Returns the points (as Nx3 array) and a list of values (or None if outside mesh).
- Parameters:
function (dolfinx.fem.Function) – The function to evaluate.
points (sequence of array-like) – Points at which to evaluate.
- Returns:
points_3d (np.ndarray) – Nx3 array of points.
merged (list) – List of function values at each point (None if outside mesh).
- flatiron_tk.functions.utils.compute_flowrate(flow_physics, id, previous=False)[source]
Computes the flow rate across a specified boundary in the Navier-Stokes simulation.
- Parameters:
flow_physics (TransientNavierStokes, SteadyNavierStokes, or SteadyStokes) – The flow physics object containing the solution and mesh information.
id (int) – The boundary ID across which to compute the flow rate.
previous (bool, optional) – If True, use the previous time step’s solution for transient simulations. Default is False.
- Returns:
flowrate – A function representing the flow rate across the specified boundary.
- Return type:
dolfinx.fem.Function
- flatiron_tk.functions.utils.constant(mesh: Mesh, value: float | tuple) dolfinx.fem.Constant[source]
Create a dolfinx.fem.Constant with a specified value on a given mesh.
- Parameters:
mesh (flatiron_tk.Mesh) – The mesh to associate the constant with.
value (float or tuple) – The value to assign to the constant. Can be a single float or a tuple of floats.
- Returns:
The constant object defined on the mesh with the specified value.
- Return type:
dolfinx.fem.Constant