Skip to content

Add interface types for FEM/FVM/DG discretizations on general domains#61

Open
ChrisRackauckas-Claude wants to merge 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:investigate-issue-5
Open

Add interface types for FEM/FVM/DG discretizations on general domains#61
ChrisRackauckas-Claude wants to merge 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:investigate-issue-5

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

This PR addresses issue #5 by providing foundational abstract types and interfaces for discretizations on unstructured meshes and general domains.

Domain Types (src/domains.jl)

  • AbstractDiscretizedDomain{T}: Abstract supertype for mesh-based domains (subtype of DomainSets.Domain{T})
  • MeshDomain{T,M}: Generic wrapper for mesh objects from external libraries (Ferrite, Gridap, etc.)
  • BoundaryRegion{D}: Named boundary regions for BC specification
  • ConditionalBoundary{D,C}: Boundary selection via coordinate conditions

Variational Method Types (src/variational.jl)

  • AbstractVariationalMethod: Base type for variational formulations
  • AbstractGalerkinMethod, AbstractRitzGalerkin, AbstractPetrovGalerkin: Type hierarchy for Galerkin methods
  • RitzGalerkin: Concrete marker type for standard Galerkin FEM
  • AbstractUnstructuredDiscretization, AbstractUnstructuredDiscreteSpace: For unstructured mesh discretizations
  • FEM traits (SupportsWeakForm, SupportsStrongForm, SupportsBothForms) for querying discretization capabilities

Interface Functions

  • get_mesh, get_boundary_markers, mark_boundary!: Mesh access and boundary management
  • get_parent_domain, get_boundary_name, get_condition: Boundary region access
  • get_variational_method, is_galerkin, is_symmetric_galerkin: Variational method queries
  • get_supported_form: Query what form (weak/strong) a discretization supports

Documentation

  • Added docs/src/domains.md explaining domain types and usage with external mesh libraries
  • Added docs/src/variational.md explaining FEM interface types and implementation patterns

This provides the foundation discussed in issue #5 while leaving framework-specific implementations to downstream packages.

Closes #5

cc @ChrisRackauckas @termi-official @xtalax @koehlerson

Test Plan

  • All existing tests pass
  • Package precompiles successfully
  • JET static analysis tests pass
  • Allocation tests pass

🤖 Generated with Claude Code

This addresses issue SciML#5 by providing foundational abstract types and interfaces
for discretizations on unstructured meshes. The key additions are:

Domain types (src/domains.jl):
- AbstractDiscretizedDomain{T}: Abstract supertype for mesh-based domains
- MeshDomain{T,M}: Generic wrapper for mesh objects from external libraries
- BoundaryRegion{D}: Named boundary regions for BC specification
- ConditionalBoundary{D,C}: Boundary selection via conditions

Variational method types (src/variational.jl):
- AbstractVariationalMethod: Base type for variational formulations
- AbstractGalerkinMethod, AbstractRitzGalerkin, AbstractPetrovGalerkin
- RitzGalerkin: Marker type for standard Galerkin FEM
- AbstractUnstructuredDiscretization, AbstractUnstructuredDiscreteSpace
- FEM traits for querying weak/strong form support

Interface functions:
- get_mesh, get_boundary_markers, mark_boundary!
- get_parent_domain, get_boundary_name, get_condition
- get_variational_method, is_galerkin, is_symmetric_galerkin
- get_supported_form

Documentation added for both domain types and variational methods.

Closes SciML#5

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove @ref link to AbstractCartesianDiscreteSpace which doesn't have
a docstring, causing Documenter.jl to fail.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some first comments to get the discussion started.

Comment thread src/domains.jl
Comment on lines +60 to +61
mesh::M
boundary_markers::Dict{String, Any}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this design here. Shouldn't we either have also the domain markers (e.g. in a fluid-solid interaction domain some maker for the fluid domain and for the solid subdomain) or retrieve everything directly from the mesh?

Comment thread src/variational.jl
where B(·,·) is a bilinear (or semilinear) form and L(·) is a linear form.

# Subtypes
- [`AbstractRitzGalerkin`](@ref): Vₕ = Wₕ (standard Galerkin)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you mean here is Bubnov-Galerkin. Ritz-Galerkin is typically some functional minimization (as e.g. in energy minimization), implying symmetry of the resulting bilinear form.

Comment thread src/variational.jl
"""
is_symmetric_galerkin(method::AbstractVariationalMethod) -> Bool

Check if a Galerkin method uses symmetric test/trial spaces (Ritz-Galerkin).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that this association is correct. You can choose your test and trial spaces to match and still construct a non-symmetric problem.

Comment thread src/variational.jl
- [`AbstractRitzGalerkin`](@ref): Vₕ = Wₕ (standard Galerkin)
- [`AbstractPetrovGalerkin`](@ref): Vₕ ≠ Wₕ (e.g., SUPG, DG)
"""
abstract type AbstractGalerkinMethod <: AbstractVariationalMethod end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the wrong way around in the type hierarchy?

Comment thread src/variational.jl
Comment on lines +47 to +48
Standard finite element methods use Ritz-Galerkin formulations. The weak form is:
Find uₕ ∈ Vₕ such that a(uₕ, vₕ) = b(vₕ) for all vₕ ∈ Vₕ
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just true for linear problems, right?

Comment thread src/variational.jl

Base type for traits describing FEM discretization capabilities.
"""
abstract type AbstractFEMTrait end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More a general question on such designs: Why do we need a common supertype for traits?

Comment thread docs/src/variational.md

When working with weak forms, the PDE is expressed as:

**Find u in V such that:** `a(u, v) = L(v)` for all v in V
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the interface is really restricted to linear problems for now?

Comment thread docs/src/variational.md
# 1. Introduce test functions v for each trial function u
# 2. Multiply equations by test functions
# 3. Integrate over domain
# 4. Apply integration by parts where needed
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we control this step?

Comment thread docs/src/variational.md
Comment on lines +116 to +117
polynomial_order::Int
quadrature::Q
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is fine for an example, we need to make sure that we do not rely on the existence of these fields. For example, different parts of the weak form can use different quadrature rules and different fields can use different ansatz functions (or just different orders, as e.g. in Taylor-Hood elements for incompressible problems).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interface for PDE solver on more general domains

3 participants