@@ -339,6 +339,8 @@ class IncomprRandMeth(RandMeth):
339
339
the mean velocity in x-direction
340
340
mode_no : :class:`int`, optional
341
341
number of Fourier modes. Default: ``1000``
342
+ vec_dim : :class:`int`, optional
343
+ vector dimension, in case it mismatches the model dimension
342
344
seed : :class:`int` or :any:`None`, optional
343
345
the seed of the random number generator.
344
346
If "None", a random seed is used. Default: :any:`None`
@@ -391,18 +393,27 @@ def __init__(
391
393
model ,
392
394
mean_velocity = 1.0 ,
393
395
mode_no = 1000 ,
396
+ vec_dim = None ,
394
397
seed = None ,
395
398
verbose = False ,
396
399
sampling = "auto" ,
397
400
** kwargs ,
398
401
):
399
- if model .dim < 2 or model .dim > 3 :
402
+ if vec_dim is None and ( model .dim < 2 or model .dim > 3 ) :
400
403
raise ValueError (
401
- "Only 2D and 3D incompressible fields can be generated."
404
+ "Only 2D and 3D incompressible vectors can be generated."
405
+ )
406
+ if vec_dim is not None and (vec_dim < 2 or vec_dim > 3 ):
407
+ raise ValueError (
408
+ "Only 2D and 3D incompressible vectors can be generated."
402
409
)
403
410
super ().__init__ (model , mode_no , seed , verbose , sampling , ** kwargs )
404
411
405
412
self .mean_u = mean_velocity
413
+ if vec_dim is None :
414
+ self .vec_dim = model .dim
415
+ else :
416
+ self .vec_dim = vec_dim
406
417
self ._value_type = "vector"
407
418
408
419
def __call__ (self , pos ):
@@ -425,7 +436,7 @@ def __call__(self, pos):
425
436
"""
426
437
pos = np .asarray (pos , dtype = np .double )
427
438
summed_modes = summate_incompr (
428
- self ._cov_sample , self ._z_1 , self ._z_2 , pos
439
+ self .vec_dim , self . _cov_sample , self ._z_1 , self ._z_2 , pos
429
440
)
430
441
nugget = self .get_nugget (summed_modes .shape )
431
442
@@ -458,7 +469,7 @@ def _create_unit_vector(self, broadcast_shape, axis=0):
458
469
the unit vector
459
470
"""
460
471
shape = np .ones (len (broadcast_shape ), dtype = int )
461
- shape [0 ] = self .model . dim
472
+ shape [0 ] = self .vec_dim
462
473
463
474
e1 = np .zeros (shape )
464
475
e1 [axis ] = 1.0
0 commit comments