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

Datatype DAEMesh for DAEs #384

Merged
merged 42 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
901e3e4
Added DAE mesh
lisawim Nov 30, 2023
18806f3
Updated all DAE problems and the SDC-DAE sweeper
lisawim Nov 30, 2023
2ca0d5c
Updated playgrounds with new DAE datatype
lisawim Nov 30, 2023
64dbb94
Adapted tests
lisawim Nov 30, 2023
c7f4cfd
Minor changes
lisawim Nov 30, 2023
eaf4448
Black.. :o
lisawim Nov 30, 2023
20b8f40
Merge remote-tracking branch 'upstream/master' into dae_meshtype
lisawim Jan 9, 2024
b001b7c
Merge remote-tracking branch 'upstream/master' into dae_meshtype
lisawim Jan 12, 2024
0fd9525
Added DAEMesh only to semi-explicit DAEs + update for FI-SDC and Prob…
lisawim Jan 12, 2024
49de7ef
Black :D
lisawim Jan 12, 2024
bbb605a
Removed unnecessary approx_solution hook + replaced by LogSolution hook
lisawim Jan 12, 2024
9594e1d
Update WSCC9 problem class
lisawim Jan 12, 2024
68cc407
Removed unnecessary comments
lisawim Jan 12, 2024
6315781
Removed test_misc.py
lisawim Jan 12, 2024
88e8175
Removed registering of newton_tol from child classes
lisawim Jan 12, 2024
af1848e
Update test_problems.py
lisawim Jan 12, 2024
87d6d56
Rename error hook class for logging global error in differential vari…
lisawim Jan 12, 2024
ad0ca26
Merge remote-tracking branch 'upstream/master' into dae_meshtype
lisawim Jan 12, 2024
bda5014
Merge remote-tracking branch 'upstream/master' into dae_meshtype
lisawim Feb 14, 2024
c68305b
Added MultiComponentMesh - @brownbaerchen + @tlunet + @pancetta Thank…
lisawim Feb 14, 2024
1555ee9
Updated stuff with new version of DAE data type
lisawim Feb 14, 2024
561061e
(Hopefully) faster test for WSCC9
lisawim Feb 14, 2024
4b3c09c
Test for DAEMesh
lisawim Feb 14, 2024
da5e663
Renaming
lisawim Feb 14, 2024
a45900d
..for DAEMesh.py
lisawim Feb 14, 2024
82b692d
Bug fix
lisawim Feb 14, 2024
be4f248
Another bug fix..
lisawim Feb 14, 2024
04fdedc
Preparation for PDAE stuff (?)
lisawim Feb 14, 2024
58101ea
Changes + adapted first test for PDAE stuff
lisawim Feb 14, 2024
522d80c
Commented out test_WSCC9_SDC_detection() - too long runtime
lisawim Feb 15, 2024
3af100f
Minor changes for test_DAEMesh.py
lisawim Feb 15, 2024
bdc548c
Extended test for DAEMesh - credits for @brownbaerchen
lisawim Feb 15, 2024
9540354
Merge remote-tracking branch 'upstream/master' into dae_meshtype
lisawim Feb 15, 2024
40bf6c6
Test for HookClass_DAE.py
lisawim Feb 15, 2024
70ef02e
Merge remote-tracking branch 'upstream/master' into dae_meshtype
lisawim Feb 16, 2024
75d1d8b
Update for DAEMesh + tests
lisawim Feb 16, 2024
27ea264
Merge remote-tracking branch 'upstream/master' into dae_meshtype
lisawim Feb 19, 2024
d44e2a2
:tada: - speed up test a bit (at least locally..)
lisawim Feb 20, 2024
e24ff2b
Forgot to enable other tests again
lisawim Feb 20, 2024
486cfbb
Removed if-else-statements for mesh type
lisawim Feb 23, 2024
c359d22
Merge remote-tracking branch 'upstream/master' into dae_meshtype
lisawim Feb 23, 2024
5921aff
View for unknowns in implSysFlatten
lisawim Feb 23, 2024
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
13 changes: 4 additions & 9 deletions pySDC/implementations/datatype_classes/MultiComponentMesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ class MultiComponentMesh(mesh):

components = []

def __new__(cls, init, val=0.0, offset=0, buffer=None, strides=None, order=None, *args, **kwargs):
if isinstance(init, tuple) and isinstance(init[0], int):
obj = super().__new__(cls, ((len(cls.components), init[0]), *init[1:]), *args, **kwargs)
elif isinstance(init, tuple) and isinstance(init[0], tuple):
obj = np.ndarray.__new__(
cls, (len(cls.components), *init[0]), dtype=init[2], buffer=buffer, offset=offset, strides=strides, order=order
)
obj.fill(val)
obj._comm = init[1]
def __new__(cls, init, *args, **kwargs):
if isinstance(init, tuple):
shape = (init[0],) if type(init[0]) is int else init[0]
obj = super().__new__(cls, ((len(cls.components), *shape), *init[1:]), *args, **kwargs)
else:
obj = super().__new__(cls, init, *args, **kwargs)

Expand Down
16 changes: 13 additions & 3 deletions pySDC/tests/test_projects/test_DAE/test_DAEMesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,26 @@ def testInitialization():
import numpy as np
from pySDC.projects.DAE.misc.DAEMesh import DAEMesh

init = (6, None, np.dtype('float64'))
nvars_1d = 6
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just give the shape as an argument to the function and call the function multiple times with the decorator scipy.mark.parametrize(shape, [(6,), (4, 6)]). You can just assign random values.

init = (nvars_1d, None, np.dtype('float64'))
mesh1 = DAEMesh(init)
mesh1.diff[:] = np.arange(6)
mesh1.alg[:] = np.arange(6, 12)

mesh2 = DAEMesh(mesh1)

for mesh in [mesh1, mesh2]:
nvars_multi = (4, 6)
init_multi = (nvars_multi, None, np.dtype('float64'))
mesh_multi = DAEMesh(init_multi)

for nvar, mesh in zip([nvars_1d, nvars_1d, nvars_multi], [mesh1, mesh2, mesh_multi]):
assert 'diff' in dir(mesh), 'ERROR: DAEMesh does not have a diff attribute!'
assert 'alg' in dir(mesh), 'ERROR: DAEMesh does not have a diff attribute!'

assert len(mesh.diff) == 6 and len(mesh.alg) == 6, 'ERROR: Components does not have the desired length!'
if isinstance(nvar, int):
assert np.shape(mesh.diff)[0] == nvar and np.shape(mesh.alg)[0] == nvar, 'ERROR: Components does not have the desired length!'
else:
assert np.shape(mesh.diff) == nvar and np.shape(mesh.alg) == nvar, 'ERROR: Components does not have the desired length!'

assert len(mesh.components) == len(mesh), 'ERROR: Mesh does not contain two component arrays!'

Expand All @@ -29,6 +38,7 @@ def testInitialization():
), 'ERROR: Components in initialized meshes do not match!'


testInitialization()
@pytest.mark.base
def testArrayUFuncOperator():
"""
Expand Down
Loading