neural_operators.pde#
- class neural_operators.pde.pdeModel.PDEModel(Vm, Vu, prior_sampler, seed=0)[source]#
Bases:
objectBase 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).
- neural_operators.pde.fenicsUtilities.build_vector_vertex_maps(V, debug=False)[source]#
Build index maps between
Function.x.arrayand vertex-ordered nodal values.For P1 Lagrange spaces on the geometry mesh, nodal values use the same interleaved component layout as
u.x.array(seeeval_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]andu_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.xrow 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 asu.x.arrayfor P1 spaces on the geometry mesh.
- 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_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, …]