API Reference#
Top-level package for 1D networks simulations with FEniCSx.
- class networks_fenicsx.HydraulicNetworkAssembler(mesh: NetworkMesh, flux_degree: int = 1, pressure_degree: int = 0)[source]#
Assembler for the variational formulation of an hydraulic network.
\[\begin{split}R q + \frac{\mathrm{d}}{\mathrm{d}s} p = 0 \\ \frac{\mathrm{d}}{\mathrm{d}s} q = f\end{split}\]- Parameters:
mesh – The network mesh
flux_degree – The polynomial degree for the flux functions
pressure_degree – The polynomial degree for the pressure functions
- assemble(A: Mat | None = None, b: Mat | None = None, assemble_lhs: bool = True, assemble_rhs: bool = True, kind: str | Sequence[Sequence[str]] | None = None) tuple[Mat, Vec][source]#
Assemble system matrix and rhs vector.
Note
If neither A or b is provided, they are created inside this class.
- Parameters:
A –
PETSc matrixto assembleHydraulicNetworkAssembler.bilinear_formsinto.b –
PETSc vectorto assembleHydraulicNetworkAssembler.linear_formsinto.assemble_lhs – Whether to assemble the system matrix.
assemble_rhs – Whether to assemble the rhs vector.
kind – If no matrix or vector is provided, “kind” is used to determine what kind of matrix/vector to create.
- compute_forms(p_bc_ex: Callable[[ndarray[tuple[int, ...], dtype[floating]]], ndarray[tuple[int, ...], dtype[inexact]]] | Expression | Expr, f: Expr | None = None, jit_options: dict | None = None, form_compiler_options: dict | None = None)[source]#
Compute forms for hydraulic network model
\[\begin{split}R q + \frac{\mathrm{d}}{\mathrm{d}s} p = 0\\ \frac{\mathrm{d}}{\mathrm{d}s} q = f\end{split}\]on graph G, with bifurcation condition q_in = q_out and jump vectors the bifurcation conditions
- Parameters:
f – source term
p_bc – neumann bc for pressure
- property flux_spaces: list[FunctionSpace]#
List of function spaces for each flux function. The ith function corresponds to the edges of the
networkx.DiGraphthat were colored with color i.
- property function_spaces: list[FunctionSpace]#
List of all function-spaces in the order [flux, pressure, lm], the same order as used by the
assemble()
- property lm_space: FunctionSpace#
The function space of the bifurcation Lagrange multipliers
- property network: NetworkMesh#
Return the underlying network mesh.
- property pressure_space: FunctionSpace#
The function space of the pressure function
- class networks_fenicsx.NetworkMesh(graph: ~networkx.classes.digraph.DiGraph, N: int, color_strategy: str | ~typing.Callable[[~networkx.classes.graph.Graph, dict[int, int]], ~typing.Iterable[int]] | None = None, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, graph_rank: int = 0)[source]#
A representation of a
Directional Networkxgraph inDOLFINx.Stores the resulting
mesh,subdomains, andfacet markersfor bifurcations and boundary nodes. Has asubmeshfor each edge in theNetworkx graph.- Parameters:
graph – The directional networkx graph to convert.
N – Number of elements per segment.
color_strategy – Strategy to use for coloring the graph edges. If set to None, no-graphcoloring is used (not recommended).
comm – The MPI communicator to distribute the mesh on.
graph_rank – The MPI rank of the process that holds the graph.
- property lm_map: EntityMap#
Entity map for the
Lagrange multiplier mesh
- property tangent#
Return DG-0 field containing the tangent vector of the graph.
- class networks_fenicsx.Solver(assembler: HydraulicNetworkAssembler, petsc_options_prefix: str = 'NetworkSolver_', petsc_options: dict | None = None, kind: str | Sequence[Sequence[str]] | None = None)[source]#
PETSc solver interface for the Network problems.
- Parameters:
assembler – The hydraulic network assembler.
petsc_options_prefix – Prefix for PETSc options.
petsc_options – Dictionary of PETSc options.
kind – Kind of PETSc matrix and vectors to create.
- assemble(lhs: bool = True, rhs: bool = True)[source]#
Assemble the system matrix and rhs vector.
- Parameters:
lhs – Whether to assemble the system matrix.
rhs – Whether to assemble the rhs vector.
- property assembler: HydraulicNetworkAssembler#
The hydraulic network assembler.
- solve(functions: list[Function] | None = None) list[Function][source]#
Solve the linear system of equations and assign them to a set of corresponding DOLFINx functions.
- Parameters:
functions – List of DOLFINx functions to assign the solution to. If not provided they are created based on the assembler information.
- Returns:
The functions.