@@ -339,6 +339,8 @@ class IncomprRandMeth(RandMeth):
339339        the mean velocity in x-direction 
340340    mode_no : :class:`int`, optional 
341341        number of Fourier modes. Default: ``1000`` 
342+     vec_dim : :class:`int`, optional 
343+         vector dimension, in case it mismatches the model dimension 
342344    seed : :class:`int` or :any:`None`, optional 
343345        the seed of the random number generator. 
344346        If "None", a random seed is used. Default: :any:`None` 
@@ -391,18 +393,27 @@ def __init__(
391393        model ,
392394        mean_velocity = 1.0 ,
393395        mode_no = 1000 ,
396+         vec_dim = None ,
394397        seed = None ,
395398        verbose = False ,
396399        sampling = "auto" ,
397400        ** kwargs ,
398401    ):
399-         if  model .dim  <  2  or  model .dim  >  3 :
402+         if  vec_dim   is   None   and  ( model .dim  <  2  or  model .dim  >  3 ) :
400403            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." 
402409            )
403410        super ().__init__ (model , mode_no , seed , verbose , sampling , ** kwargs )
404411
405412        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 
406417        self ._value_type  =  "vector" 
407418
408419    def  __call__ (self , pos ):
@@ -425,7 +436,7 @@ def __call__(self, pos):
425436        """ 
426437        pos  =  np .asarray (pos , dtype = np .double )
427438        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 
429440        )
430441        nugget  =  self .get_nugget (summed_modes .shape )
431442
@@ -458,7 +469,7 @@ def _create_unit_vector(self, broadcast_shape, axis=0):
458469            the unit vector 
459470        """ 
460471        shape  =  np .ones (len (broadcast_shape ), dtype = int )
461-         shape [0 ] =  self .model . dim 
472+         shape [0 ] =  self .vec_dim 
462473
463474        e1  =  np .zeros (shape )
464475        e1 [axis ] =  1.0 
0 commit comments