PyMPDATA.boundary_conditions.constant
boundary condition filling halos with a constant value
1"""boundary condition filling halos with a constant value""" 2 3# pylint: disable=too-many-arguments 4from functools import lru_cache 5 6import numba 7 8from PyMPDATA.impl.traversals_common import ( 9 make_fill_halos_loop, 10 make_fill_halos_loop_vector, 11) 12 13 14class Constant: 15 """class which instances are to be passed in boundary_conditions tuple to the 16 `PyMPDATA.scalar_field.ScalarField` and 17 `PyMPDATA.vector_field.VectorField` __init__ methods""" 18 19 def __init__(self, value): 20 self.value = value 21 22 def make_scalar(self, indexers, _, __, jit_flags, ___): 23 """returns (lru-cached) Numba-compiled scalar halo-filling callable""" 24 return _make_scalar_constant( 25 self.value, 26 indexers.set, 27 jit_flags, 28 ) 29 30 def make_vector(self, indexers, _, __, jit_flags, dimension_index): 31 """returns (lru-cached) Numba-compiled vector halo-filling callable""" 32 return _make_vector_constant( 33 self.value, indexers.set, jit_flags, dimension_index 34 ) 35 36 37@lru_cache() 38def _make_scalar_constant(value, set_value, jit_flags): 39 @numba.njit(**jit_flags) 40 def fill_halos(_1, _2, _3): 41 return value 42 43 return make_fill_halos_loop(jit_flags, set_value, fill_halos) 44 45 46@lru_cache() 47def _make_vector_constant(value, set_value, jit_flags, dimension_index): 48 @numba.njit(**jit_flags) 49 def fill_halos_parallel(_1, _2, _3): 50 return value 51 52 @numba.njit(**jit_flags) 53 def fill_halos_normal(_1, _2, _3, _4): 54 return value 55 56 return make_fill_halos_loop_vector( 57 jit_flags, set_value, fill_halos_parallel, fill_halos_normal, dimension_index 58 )
class
Constant:
15class Constant: 16 """class which instances are to be passed in boundary_conditions tuple to the 17 `PyMPDATA.scalar_field.ScalarField` and 18 `PyMPDATA.vector_field.VectorField` __init__ methods""" 19 20 def __init__(self, value): 21 self.value = value 22 23 def make_scalar(self, indexers, _, __, jit_flags, ___): 24 """returns (lru-cached) Numba-compiled scalar halo-filling callable""" 25 return _make_scalar_constant( 26 self.value, 27 indexers.set, 28 jit_flags, 29 ) 30 31 def make_vector(self, indexers, _, __, jit_flags, dimension_index): 32 """returns (lru-cached) Numba-compiled vector halo-filling callable""" 33 return _make_vector_constant( 34 self.value, indexers.set, jit_flags, dimension_index 35 )
class which instances are to be passed in boundary_conditions tuple to the
PyMPDATA.scalar_field.ScalarField
and
PyMPDATA.vector_field.VectorField
__init__ methods
def
make_scalar(self, indexers, _, __, jit_flags, ___):
23 def make_scalar(self, indexers, _, __, jit_flags, ___): 24 """returns (lru-cached) Numba-compiled scalar halo-filling callable""" 25 return _make_scalar_constant( 26 self.value, 27 indexers.set, 28 jit_flags, 29 )
returns (lru-cached) Numba-compiled scalar halo-filling callable
def
make_vector(self, indexers, _, __, jit_flags, dimension_index):
31 def make_vector(self, indexers, _, __, jit_flags, dimension_index): 32 """returns (lru-cached) Numba-compiled vector halo-filling callable""" 33 return _make_vector_constant( 34 self.value, indexers.set, jit_flags, dimension_index 35 )
returns (lru-cached) Numba-compiled vector halo-filling callable