Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix None value in Pushforward #393

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
3 changes: 2 additions & 1 deletion psydac/feec/pushforward.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def __init__(
self.npts_per_cell = npts_per_cell
self.cell_indexes = cell_indexes
self.grid_type=grid_type
grid_local=grid_local
if grid_local is None:
grid_local=grid

if isinstance(mapping, Mapping):
self._mesh_grids = np.meshgrid(*grid_local, indexing='ij', sparse=True)
Expand Down
40 changes: 40 additions & 0 deletions psydac/feec/tests/test_pushforward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import numpy as np
import pytest

from psydac.api.discretization import discretize
from sympde.topology import ScalarFunctionSpace
from sympde.topology import Square
from sympde.topology import Mapping
from psydac.mapping.discrete import SplineMapping
from psydac.feec.pushforward import Pushforward

def test_basic_call():

logical_domain = Square('Omega')

ncells = [2**4, 2**4]
degree = [2, 2]

# Mapping and physical domain
class CollelaMapping2D(Mapping):

_ldim = 2
_pdim = 2
_expressions = {'x': 'a * (x1 + eps / (2*pi) * sin(2*pi*x1) * sin(2*pi*x2))',
'y': 'b * (x2 + eps / (2*pi) * sin(2*pi*x1) * sin(2*pi*x2))'}

mapping = CollelaMapping2D('M', a=1, b=1, eps=.2)
domain = mapping(logical_domain)

hat_V0 = ScalarFunctionSpace('hat V0', logical_domain)
domain_h = discretize(logical_domain, ncells = ncells, periodic = [False, True])
hat_V0_h = discretize(hat_V0, domain_h, degree = degree)

grid_x1 = hat_V0_h.breaks[0]
grid_x2 = hat_V0_h.breaks[1]

F = SplineMapping.from_mapping(hat_V0_h, mapping.get_callable_mapping())
Pushforward(grid=(grid_x1, grid_x2), mapping=F, grid_type=0)

F = mapping
Pushforward(grid=(grid_x1, grid_x2), mapping=F, grid_type=0)
yguclu marked this conversation as resolved.
Show resolved Hide resolved
Loading