neural_operators.pde#

class neural_operators.pde.pdeModel.PDEModel(Vm, Vu, prior_sampler, seed=0)[source]#

Bases: object

Base class for a forward PDE model on coefficient field m and state u, over function spaces Vm/Vu on a shared mesh. Handles the FE bookkeeping (DOF/vertex maps, dims, node coordinates); assemble, solveFwd, compute_mean, samplePrior are meant to be overridden by a subclass (see ReactionDiffusionModel/HyperelasticityModel in the applications repo).

assemble(assemble_lhs=True, assemble_rhs=True)[source]#
static boundaryU(x, on_boundary)[source]#
compute_mean(m)[source]#
empty_m()[source]#
empty_u()[source]#
function_to_vector(m_fn, m_vec=None, is_m=True)[source]#
function_to_vertex(m_fn, m_vv=None, is_m=True)[source]#
static is_point_on_dirichlet_boundary(x)[source]#
samplePrior(m=None, transform_m=False)[source]#
solveFwd(u=None, m=None, transform_m=False)[source]#
vector_to_function(m_vec, m_fn=None, is_m=True)[source]#
vertex_to_function(m_vv, m_fn=None, is_m=True)[source]#
neural_operators.pde.fenicsUtilities.build_vector_vertex_maps(V, debug=False)[source]#

Build index maps between Function.x.array and vertex-ordered nodal values.

For P1 Lagrange spaces on the geometry mesh, nodal values use the same interleaved component layout as u.x.array (see eval_at_vertices). Maps are usually identity; the slow probe loop handles non-matching layouts.

Returns:

Arrays such that u_vv = u_vec[map_vec_to_vertex] and u_vec = u_vv[map_vertex_to_vec].

Return type:

map_vec_to_vertex, map_vertex_to_vec

neural_operators.pde.fenicsUtilities.eval_at_vertices(u)[source]#

Evaluate a Lagrange function at mesh geometry vertices.

Returns a 1D array aligned with mesh.geometry.x row order. Scalars: one value per vertex. Vectors (block size > 1): interleaved components per vertex, [u_0(v0), u_1(v0), u_0(v1), u_1(v1), ...] — same layout as u.x.array for P1 spaces on the geometry mesh.

neural_operators.pde.fenicsUtilities.function_to_vector(u, u_vec=None)[source]#
neural_operators.pde.fenicsUtilities.function_to_vertex(u, u_vv=None, V=None, map_vec_to_vertex=None)[source]#
neural_operators.pde.fenicsUtilities.vector_to_function(u_vec, u)[source]#
neural_operators.pde.fenicsUtilities.vector_to_vertex(u_vec, u_vv=None, V=None, map_vec_to_vertex=None)[source]#
neural_operators.pde.fenicsUtilities.vertex_to_function(u_vv, u=None, V=None, map_vertex_to_vec=None)[source]#
neural_operators.pde.fenicsUtilities.vertex_to_vector(u_vv, u_vec=None, V=None, map_vertex_to_vec=None)[source]#
neural_operators.pde.meshUtilities.apply_grid_vector_dirichlet_bc(grid_u, boundary_ij, value=0.0)[source]#

Set all vector components to value at grid Dirichlet points.

neural_operators.pde.meshUtilities.get_dirichlet_bc(bdry_fn, x)[source]#

Indices of nodes where bdry_fn is True.

neural_operators.pde.meshUtilities.get_grid_dirichlet_bc(bdry_fn, x, y)[source]#

Same as get_dirichlet_bc, for a regular grid: returns (i, j) pairs.

neural_operators.pde.meshUtilities.interpolate_mixed_vector_to_grid(nodes, u, grid_x, grid_y, u_comps=2, method='linear')[source]#

Interpolate a FEniCSx mixed mesh vector to a regular grid.

Mesh layout (mixed): [u_x(v0), u_y(v0), u_x(v1), u_y(v1), …] Grid layout: grid_u[i, j, c] is component c at grid point (i, j) Flat mixed: grid_u.reshape(-1) gives [ux0, uy0, ux1, uy1, …]

neural_operators.pde.meshUtilities.mesh_cells(domain)[source]#

Return (n_cells, n_vertices_per_cell) connectivity in geometry vertex indices.

neural_operators.pde.meshUtilities.test_dirichlet_bc_functions()[source]#
neural_operators.pde.meshUtilities.write_mesh_xdmf(domain, path, comm)[source]#

Write a dolfinx mesh to XDMF (path should end in .xdmf).