1313from ..utils import run_if_all_none
1414
1515
16- class Discretization (object ):
17- """Space discretization scheme parameters."""
16+ class Scheme (object ):
17+ """Fractional Laplacian discretization.
1818
19- def __init__ (self , dim , meshtype , resolution ):
20- self .dim = dim
21- self .meshtype , self .resolution = meshtype , resolution
19+ Discretize fractional Laplacian uisng quadrature rule for the integral with respect to the directions
20+ and Grunwald-Letnikov (GL) formula for the Riemann-Liouville directional fractional derivative.
2221
22+ Args:
23+ meshtype (string): "static" or "dynamic".
24+ resolution: A list of integer. The first number is the number of quadrature points in the first direction, ...,
25+ and the last number is the GL parameter.
26+ """
27+
28+ def __init__ (self , meshtype , resolution ):
29+ self .meshtype = meshtype
30+ self .resolution = resolution
31+
32+ self .dim = len (resolution )
2333 self ._check ()
2434
2535 def _check (self ):
@@ -29,11 +39,6 @@ def _check(self):
2939 raise ValueError (
3040 "Do not support meshtype static for dimension %d" % self .dim
3141 )
32- if self .dim != len (self .resolution ):
33- raise ValueError (
34- "Resolution %s does not math dimension %d."
35- % (self .resolution , self .dim )
36- )
3742
3843
3944class FPDE (PDE ):
@@ -58,7 +63,8 @@ def __init__(
5863 fpde ,
5964 alpha ,
6065 bcs ,
61- disc ,
66+ resolution ,
67+ meshtype = "dynamic" ,
6268 num_domain = 0 ,
6369 num_boundary = 0 ,
6470 train_distribution = "random" ,
@@ -67,7 +73,7 @@ def __init__(
6773 num_test = None ,
6874 ):
6975 self .alpha = alpha
70- self .disc = disc
76+ self .disc = Scheme ( meshtype , resolution )
7177 self .frac_train , self .frac_test = None , None
7278
7379 super (FPDE , self ).__init__ (
@@ -118,10 +124,6 @@ def train_next_batch(self, batch_size=None):
118124 if self .disc .meshtype == "static" :
119125 if self .geom .idstr != "Interval" :
120126 raise ValueError ("Only Interval supports static mesh." )
121- if self .num_domain + 2 != self .disc .resolution [0 ]:
122- raise ValueError (
123- "Mesh resolution does not match the number of points inside the domain."
124- )
125127
126128 self .frac_train = Fractional (self .alpha , self .geom , self .disc , None )
127129 X = self .frac_train .get_x ()
@@ -198,7 +200,8 @@ def __init__(
198200 fpde ,
199201 alpha ,
200202 ic_bcs ,
201- disc ,
203+ resolution ,
204+ meshtype = "dynamic" ,
202205 num_domain = 0 ,
203206 num_boundary = 0 ,
204207 num_initial = 0 ,
@@ -213,7 +216,8 @@ def __init__(
213216 fpde ,
214217 alpha ,
215218 ic_bcs ,
216- disc ,
219+ resolution ,
220+ meshtype = meshtype ,
217221 num_domain = num_domain ,
218222 num_boundary = num_boundary ,
219223 train_distribution = train_distribution ,
0 commit comments