Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
efa1387
minor improvements in the calculation of the restriction operator
FrederikSchnack Jun 26, 2025
e9c8c5b
move non_matching_operators to operators, remove obsolete code, move …
FrederikSchnack Jun 26, 2025
108e53d
move content of feec/multipatch/api to api/feec and api/discretization
FrederikSchnack Jun 26, 2025
7ee1a5c
restructure multipatch/operators. Make sure that DiscreteDerhamMultip…
FrederikSchnack Jun 26, 2025
f0b8887
add HodgeOperator to DiscreteDeRhamMultipatch
FrederikSchnack Jun 26, 2025
6ba5ffe
Merge branch 'devel' into improve_fem_api
FrederikSchnack Jun 30, 2025
64e1ae9
remove DiffOperator class and subclass FemLinearOperator instead
FrederikSchnack Jul 9, 2025
2597861
fix typo in linalg/basic
FrederikSchnack Jul 9, 2025
555fcb3
add SparseMatrixLinearOperator
FrederikSchnack Jul 9, 2025
82bbde6
modify multipatch operators and projectors
FrederikSchnack Jul 9, 2025
526d920
add Hodge operators to discrete derham, add option which kind of oper…
FrederikSchnack Jul 9, 2025
7a5c483
update conforming projections and Hodge operators for single patch
FrederikSchnack Jul 10, 2025
3127969
add callable mapping to DiscreteDeRhamMultipatch
FrederikSchnack Jul 14, 2025
0e02d3a
restructured files in psydac/feec/multipatch
FrederikSchnack Jul 14, 2025
44fec73
make conf proj test run
FrederikSchnack Jul 14, 2025
a67d1d9
fix notation in old tests. disable multipatch tests for now
FrederikSchnack Jul 14, 2025
20df3ab
make the conforming projections more consistent
FrederikSchnack Jul 14, 2025
cf877f5
add doc strings to discretize derham multipatch
FrederikSchnack Jul 14, 2025
87e8f2f
fix indentation
FrederikSchnack Jul 14, 2025
a980acc
Merge branch 'devel' into improve_fem_api
FrederikSchnack Jul 14, 2025
b9edf1d
make the multipatch examples run for the tests
FrederikSchnack Jul 15, 2025
c643758
small fix in tests
FrederikSchnack Jul 15, 2025
be9726a
removed plot_dir by accident
FrederikSchnack Jul 15, 2025
5631334
improve projectors interface in DiscreteDeRhamMultipatch
FrederikSchnack Jul 16, 2025
1e45f85
improve docstrings in psydac/api/feec
FrederikSchnack Jul 16, 2025
b88340b
improve docstrings in FemLinearOperators and psydac/feec/derivatives
FrederikSchnack Jul 16, 2025
2ee57ee
remove backend from maxwell source pbm tests
FrederikSchnack Jul 16, 2025
f36a0d3
pass python backend to feec maxwell tests
FrederikSchnack Jul 16, 2025
b4f2ddc
revert changes in tests
FrederikSchnack Jul 16, 2025
05c2531
remove commenteed imports
FrederikSchnack Jul 16, 2025
dbb6167
clean up test file
FrederikSchnack Jul 16, 2025
8f3c696
expose pads argument to discretize_space and the included SplineSpace
FrederikSchnack Jul 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 54 additions & 8 deletions psydac/api/discretization.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from psydac.api.fem import DiscreteLinearForm
from psydac.api.fem import DiscreteFunctional
from psydac.api.fem import DiscreteSumForm
from psydac.api.feec import DiscreteDerham
from psydac.api.feec import DiscreteDerham, DiscreteDerhamMultipatch
from psydac.api.glt import DiscreteGltExpr
from psydac.api.expr import DiscreteExpr
from psydac.api.equation import DiscreteEquation
Expand All @@ -47,6 +47,7 @@
__all__ = (
'discretize',
'discretize_derham',
'discretize_derham_multipatch',
'reduce_space_degrees',
'discretize_space',
'discretize_domain'
Expand Down Expand Up @@ -175,11 +176,9 @@ def discretize_derham(derham, domain_h, *, get_H1vec_space=False, **kwargs):
See Also
--------
discretize_space

"""

ldim = derham.shape
mapping = domain_h.domain.mapping # NOTE: assuming single-patch domain!
bases = ['B'] + ldim * ['M']
spaces = [discretize_space(V, domain_h, basis=basis, **kwargs)
for V, basis in zip(derham.spaces, bases)]
Expand All @@ -192,7 +191,48 @@ def discretize_derham(derham, domain_h, *, get_H1vec_space=False, **kwargs):
#We still need to specify the symbolic space because of "_recursive_element_of" not implemented in sympde
spaces.append(Xh)

return DiscreteDerham(mapping, *spaces)
return DiscreteDerham(domain_h, *spaces)

#==============================================================================
def discretize_derham_multipatch(derham, domain_h, *args, **kwargs):
"""
Create a discrete multipatch De Rham sequence from a symbolic one.

This function creates the broken discrete spaces from the symbolic ones, and then
creates a DiscreteDerhamMultipatch object from them.

Parameters
----------
derham : sympde.topology.space.Derham
The symbolic Derham sequence.

domain_h : Geometry
Discrete domain where the spaces will be discretized.

**kwargs : dict
Optional parameters for the space discretization.

Returns
-------
DiscreteDerhamMultipatch
The discrete multipatch De Rham sequence containing the discrete spaces,
differential operators and projectors.

See Also
--------
discretize_derham
discretize_space
"""

ldim = derham.shape
bases = ['B'] + ldim * ['M']
spaces = [discretize_space(V, domain_h, *args, basis=basis, **kwargs) \
for V, basis in zip(derham.spaces, bases)]

return DiscreteDerhamMultipatch(
domain_h = domain_h,
spaces = spaces
)

#==============================================================================
def reduce_space_degrees(V, Vh, *, basis='B', sequence='DR'):
Expand Down Expand Up @@ -329,7 +369,7 @@ def reduce_space_degrees(V, Vh, *, basis='B', sequence='DR'):

#==============================================================================
# TODO knots
def discretize_space(V, domain_h, *, degree=None, multiplicity=None, knots=None, basis='B', sequence='DR'):
def discretize_space(V, domain_h, *, degree=None, multiplicity=None, knots=None, basis='B', sequence='DR', pads=None):
"""
This function creates the discretized space starting from the symbolic space.

Expand Down Expand Up @@ -457,6 +497,9 @@ def discretize_space(V, domain_h, *, degree=None, multiplicity=None, knots=None,
min_coords = interior.min_coords
max_coords = interior.max_coords

if pads == None:
pads = [None] * len(degree_i)

assert len(ncells) == len(periodic) == len(degree_i) == len(multiplicity_i) == len(min_coords) == len(max_coords)

if knots is None:
Expand All @@ -465,10 +508,10 @@ def discretize_space(V, domain_h, *, degree=None, multiplicity=None, knots=None,
for xmin, xmax, ne in zip(min_coords, max_coords, ncells)]

# Create 1D finite element spaces and precompute quadrature data
spaces[i] = [SplineSpace( p, multiplicity=m, grid=grid , periodic=P) for p,m,grid,P in zip(degree_i, multiplicity_i,grids, periodic)]
spaces[i] = [SplineSpace( p, multiplicity=m, grid=grid , periodic=P, pads=pd) for p,m,grid,P,pd in zip(degree_i, multiplicity_i,grids, periodic, pads)]
else:
# Create 1D finite element spaces and precompute quadrature data
spaces[i] = [SplineSpace( p, knots=T , periodic=P) for p,T, P in zip(degree_i, knots[interior.name], periodic)]
spaces[i] = [SplineSpace( p, knots=T , periodic=P, pads=pd) for p,T,P,pd in zip(degree_i, knots[interior.name], periodic, pads)]


carts = create_cart(ddms, spaces)
Expand Down Expand Up @@ -607,9 +650,12 @@ def discretize(a, *args, **kwargs):
elif isinstance(a, BasicFunctionSpace):
return discretize_space(a, *args, **kwargs)

elif isinstance(a, Derham):
elif isinstance(a, Derham) and not a.V0.is_broken:
return discretize_derham(a, *args, **kwargs)

elif isinstance(a, Derham) and a.V0.is_broken:
return discretize_derham_multipatch(a, *args, **kwargs)

elif isinstance(a, Domain):
return discretize_domain(a, *args, **kwargs)

Expand Down
Loading