Skip to content

Commit ef84e71

Browse files
authored
Switch to qmat in SWEET (#14)
* TL: added DNODES qDelta coeffs, renamed min -> diag * TL: updated roadmap * TL: added missing test and renaming * TL: updated README
1 parent 91090cc commit ef84e71

4 files changed

Lines changed: 64 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ and the current [Development Roadmap](https://qmat.readthedocs.io/en/latest/devd
7070
## Projects relying on `qmat`
7171

7272
- [pySDC](https://github.com/Parallel-in-Time/pySDC) : _Python implementation of the spectral deferred correction (SDC) approach and its flavors, esp. the multilevel extension MLSDC and PFASST._
73+
- [SWEET](https://gitlab.inria.fr/sweet/sweet) : _Shallow Water Equation Environment for Tests, Awesome! (C++)_
7374

7475
## Links
7576

docs/devdoc/roadmap.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ Detailed description of all specific versions and their associated changes is av
2121
- ✅ citation file and zenodo releases
2222
- ✅ integration of `qmat` into [pySDC](https://github.com/Parallel-in-Time/pySDC), _c.f_ [associated PR](https://github.com/Parallel-in-Time/pySDC/pull/445)
2323
- ✅ refined design for $Q_\Delta$ generators
24-
- full documentation of classes and functions
24+
- full documentation of classes and functions
2525
- finalization of extended usage tutorials ($S$-matrix, `dTau` coefficient for initial sweep, prolongation)
2626
- ✅ full definition and documentation of the version update pipeline
2727

2828
**Status 5 - Production/Stable** : `v1.0.*`
2929

3030
- base console script interfacing `qmat` API for $Q$-coefficients and SDC coefficients generation (with IMEX)
31-
- integration of `qmat` into [SWEET](https://gitlab.inria.fr/sweet/sweet)
32-
- use of `qmat` for [Dedalus](https://github.com/DedalusProject/dedalus) IMEX SDC time-steppers developed within [pySDC](https://github.com/Parallel-in-Time/pySDC)
31+
- integration of `qmat` into [SWEET](https://gitlab.inria.fr/sweet/sweet)
32+
- use of `qmat` for [Dedalus](https://github.com/DedalusProject/dedalus) IMEX SDC time-steppers developed within [pySDC](https://github.com/Parallel-in-Time/pySDC)
3333
- distribution to other people using former version of the core `qmat` code (_e.g_ Alex Brown from Exeter, ...)
3434
- addition of a few advanced usage tutorials :
3535
- `qmat` for non-linear ODE
Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
>>> from qmat import genQDeltaCoeffs
1313
>>> QDelta = genQDeltaCoeffs("MIN-SR-NS", nodes=coll.nodes)
1414
>>>
15-
>>> from qmat.qdelta.min import MIN_SR_S, MIN_SR_FLEX
15+
>>> from qmat.qdelta.diag import MIN_SR_S, MIN_SR_FLEX
1616
>>> minSRS= MIN_SR_S(coll.nNodes, coll.nodeType, coll.quadType)
1717
>>> QDelta = minSRS.getQDelta()
1818
>>> minSRFLEX = MIN_SR_FLEX(coll.nNodes, coll.nodeType, coll.quadType)
@@ -30,8 +30,7 @@
3030
def check(k):
3131
"""Utility function to check k parameter for k-dependent generators"""
3232
if k is None: k = 1
33-
if k < 1:
34-
raise ValueError(f"k must be greater than 0 ({k})")
33+
if k < 1: raise ValueError(f"k must be greater than 0 ({k})")
3534
return k
3635

3736

@@ -291,3 +290,38 @@ def computeQDelta(self, k=1):
291290
k = check(k)
292291
divider = 1 if k == 1 else 2*(k-1)
293292
return np.diag(self.nodes)/divider
293+
294+
295+
@register
296+
class DNODES(MIN_SR_NS):
297+
"""Diagonal coefficients build on divided node (1 here)"""
298+
divider = 1
299+
aliases = ["DNODES-1"]
300+
301+
def computeQDelta(self, k=None):
302+
return np.diag(self.nodes)/self.divider
303+
304+
@register
305+
class DNODES2(DNODES):
306+
"""Diagonal coefficients build on divided node (2 here)"""
307+
divider = 2
308+
aliases = ["DNODES-2"]
309+
310+
@register
311+
class DNODES3(DNODES):
312+
"""Diagonal coefficients build on divided node (3 here)"""
313+
divider = 3
314+
aliases = ["DNODES-3"]
315+
316+
@register
317+
class DNODES4(DNODES):
318+
"""Diagonal coefficients build on divided node (4 here)"""
319+
divider = 4
320+
aliases = ["DNODES-4"]
321+
322+
@register
323+
class DNODES5(DNODES):
324+
"""Diagonal coefficients build on divided node (5 here)"""
325+
divider = 5
326+
aliases = ["DNODES-5"]
327+
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33

44
from qmat.qdelta import QDELTA_GENERATORS
5-
import qmat.qdelta.min as module
5+
import qmat.qdelta.diag as module
66
from qmat.qcoeff.collocation import Collocation
77
from qmat.nodes import NODE_TYPES, QUAD_TYPES
88

@@ -145,4 +145,25 @@ def testJumper(nNodes, nodeType, quadType):
145145
QDeltas2 = gen2.genCoeffs(k)
146146

147147
assert np.allclose(QDeltas2[0], QDeltasFlex[0])
148-
assert np.allclose(QDeltas2[1:], QDeltas[:-1])
148+
assert np.allclose(QDeltas2[1:], QDeltas[:-1])
149+
150+
151+
@pytest.mark.parametrize("quadType", ["GAUSS", "RADAU-RIGHT"])
152+
@pytest.mark.parametrize("nodeType", NODE_TYPES)
153+
@pytest.mark.parametrize("nNodes", [2, 3, 4])
154+
@pytest.mark.parametrize("divider", [1, 2, 3, 4, 5])
155+
def testDNODES(divider, nNodes, nodeType, quadType):
156+
coll = Collocation(nNodes=nNodes, nodeType=nodeType, quadType=quadType)
157+
nodes = coll.nodes
158+
159+
Generator = {
160+
1: module.DNODES,
161+
2: module.DNODES2,
162+
3: module.DNODES3,
163+
4: module.DNODES4,
164+
5: module.DNODES5,
165+
}[divider]
166+
gen:module.DNODES = Generator(nodes=nodes)
167+
QDeltas = gen.genCoeffs()
168+
169+
assert np.allclose(QDeltas, np.diag(nodes)/divider)

0 commit comments

Comments
 (0)