Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fe9b0d0
add dirichlet projectors and tests
jowezarek Oct 30, 2025
a898cae
fix periodic BC in conforming projectors and add test
FrederikSchnack Oct 31, 2025
b8d618c
add preliminary DirichletMultipatchBoundaryProjector
FrederikSchnack Oct 31, 2025
090652e
Merge branch 'devel' into dirichlet
jowezarek Oct 31, 2025
f35d98e
move Dirichlet projectors to fem.projectors
jowezarek Oct 31, 2025
9f6231e
move import, add dirichlet_proj as attribute, return tuple, add ident…
jowezarek Nov 3, 2025
8bbb6b6
remove periodic from _get_bcs in multipatch case
jowezarek Nov 3, 2025
08f5525
change tolerance in _test_LO_equality...
jowezarek Nov 3, 2025
07b14cb
make dim a parameter, add sqrts, compute errs better
jowezarek Nov 3, 2025
8e1466e
add empty lines
jowezarek Nov 3, 2025
19b54ca
include type checks
jowezarek Nov 3, 2025
ed03e23
bug fix
jowezarek Nov 3, 2025
051ebf6
add docstrings
jowezarek Nov 3, 2025
e1de56a
addressing comments
jowezarek Nov 4, 2025
bf1d441
Codacity fix
jowezarek Nov 4, 2025
daaabd6
addressing comments pt. 2
jowezarek Nov 4, 2025
2cf7a3b
add docstrings to conforming projections, change DiscreteDeRhamMultip…
FrederikSchnack Nov 5, 2025
c803120
add toarray, tosparse, and tests
jowezarek Nov 7, 2025
01beb17
move dirichlet projector tests to new file
jowezarek Nov 7, 2025
9b13382
Improve DirMultipatch constructor, fix typos, bcs always tuple
jowezarek Nov 7, 2025
65fa7d2
Merge branch 'devel' into dirichlet
jowezarek Nov 7, 2025
b1e6865
Merge branch 'dirichlet' of github.com:pyccel/psydac into dirichlet
jowezarek Nov 7, 2025
ec7f146
add parallel test, shorten tests
jowezarek Nov 11, 2025
ff3a5b2
addressing comments pt. N
jowezarek Nov 21, 2025
424f2d5
...
jowezarek Nov 21, 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
80 changes: 79 additions & 1 deletion psydac/api/feec.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import numpy as np

from scipy.sparse import dia_matrix

from sympde.expr import integral, BilinearForm
from sympde.topology import elements_of, Line, Derham

Comment thread
FrederikSchnack marked this conversation as resolved.
Outdated
from psydac.api.basic import BasicDiscrete

from psydac.feec.derivatives import Derivative1D, Gradient2D, Gradient3D
Expand Down Expand Up @@ -26,7 +33,12 @@

from psydac.fem.basic import FemSpace, FemLinearOperator
from psydac.fem.vector import VectorFemSpace
from psydac.linalg.basic import IdentityOperator

from psydac.linalg.basic import LinearOperator, IdentityOperator
from psydac.linalg.block import BlockLinearOperator
from psydac.linalg.direct_solvers import BandedSolver
from psydac.linalg.kron import KroneckerLinearSolver, KroneckerStencilMatrix
from psydac.linalg.stencil import StencilVectorSpace
Comment thread
yguclu marked this conversation as resolved.
Outdated

__all__ = ('DiscreteDeRham', 'DiscreteDeRhamMultipatch',)

Expand Down Expand Up @@ -288,6 +300,39 @@ def derivatives(self, kind='femlinop'):
elif kind == 'linop':
return tuple(b_diff.linop for b_diff in self._derivatives)

#--------------------------------------------------------------------------
def dirichlet_projectors(self, kind='femlinop'):
"""
Returns operators that apply the correct Dirichlet boundary conditions.

Parameters
----------
kind : str
The kind of the projector, can be 'femlinop' or 'linop'.
- 'femlinop' returns a psydac FemLinearOperator (default)
- 'linop' returns a psydac LinearOperator

Returns
-------
d_projectors : list
List of <psydac.fem.basic.FemLinearOperator> or <psydac.linalg.basic.LinearOperator>
The Dirichlet boundary projectors of each space and in desired form.

Notes
-----
See examples/vector_potential_3d.py for a use case of these operators in LinearOperator form.

"""
assert kind in ('femlinop', 'linop')

from psydac.fem.projectors import DirichletBoundaryProjector
Comment thread
FrederikSchnack marked this conversation as resolved.
Outdated
d_projectors = [DirichletBoundaryProjector(Vh) for Vh in self.spaces[:-1]]
Comment thread
FrederikSchnack marked this conversation as resolved.
Outdated

if kind == 'femlinop':
d_projectors = [FemLinearOperator(fem_domain=Vh, fem_codomain=Vh, linop=d_projector) for Vh, d_projector in zip(self.spaces[:-1], d_projectors)]

return d_projectors
Comment thread
FrederikSchnack marked this conversation as resolved.
Outdated

#--------------------------------------------------------------------------
def conforming_projectors(self, kind='femlinop', mom_pres=False, p_moments=-1, hom_bc=False):
"""
Expand Down Expand Up @@ -606,3 +651,36 @@ def projectors(self, *, kind='global', nquads=None):

elif self.dim == 3:
raise NotImplementedError("3D projectors are not available")

#--------------------------------------------------------------------------
def dirichlet_projectors(self, kind='femlinop'):
"""
Returns operators that apply the correct Dirichlet boundary conditions.

Parameters
----------
kind : str
The kind of the projector, can be 'femlinop' or 'linop'.
- 'femlinop' returns a psydac FemLinearOperator (default)
- 'linop' returns a psydac LinearOperator

Returns
-------
d_projectors : list
List of <psydac.fem.basic.FemLinearOperator> or <psydac.linalg.basic.LinearOperator>
The Dirichlet boundary projectors of each space and in desired form.

Notes
-----
See examples/vector_potential_3d.py for a use case of these operators in LinearOperator form.

"""
assert kind in ('femlinop', 'linop')

from psydac.fem.projectors import DirichletMultipatchBoundaryProjector
d_projectors = [DirichletMultipatchBoundaryProjector(Vh) for Vh in self.spaces[:-1]]

if kind == 'femlinop':
d_projectors = [FemLinearOperator(fem_domain=Vh, fem_codomain=Vh, linop=d_projector) for Vh, d_projector in zip(self.spaces[:-1], d_projectors)]

return d_projectors
Comment thread
FrederikSchnack marked this conversation as resolved.
Outdated
14 changes: 12 additions & 2 deletions psydac/feec/conforming_projectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,8 +1211,8 @@ def construct_h1_singlepatch_conforming_projection(Vh, reg_orders=0, p_moments=-


def get_vertex_index(coords):
Comment thread
yguclu marked this conversation as resolved.
nbasis0 = Vh.spaces[coords[0]].nbasis - 1
nbasis1 = Vh.spaces[coords[1]].nbasis - 1
nbasis0 = Vh.spaces[0].nbasis - 1
nbasis1 = Vh.spaces[1].nbasis - 1

# patch local index
multi_index = [None] * ndim
Expand All @@ -1233,6 +1233,9 @@ def vertex_moment_indices(axis, coords, p_moments):

for co in [(0,0), (1,0), (0,1), (1,1)]:

if all(Vh.periodic):
break

# global index
ig = get_vertex_index(co)

Expand Down Expand Up @@ -1304,6 +1307,10 @@ def get_mu_minus(j, coarse_space, fine_space, R):

# boundary condition
for bn in domain.boundary:

if Vh.periodic[bn.axis]:
continue

space_k = Vh
axis = bn.axis

Expand Down Expand Up @@ -1402,6 +1409,9 @@ def edge_moment_index(p, i, axis, ext):
# boundary condition
for bn in domain.boundary:

if Vh.periodic[bn.axis]:
continue

axis = bn.axis
d = 1 - axis
ext = bn.ext
Expand Down
Loading