Example #1
0
 def test_constant_resample(self):
     field = ConstantField([0, 1])
     self.assertEqual(field.component_count, 2)
     # --- Resample to CenteredGrid ---
     at_cgrid = field.at(CenteredGrid(np.zeros([1, 4, 4, 1])))
     np.testing.assert_equal(at_cgrid.data.shape, [1, 4, 4, 2])
     # --- Resample to StaggeredGrid ---
     at_sgrid = field.at(Fluid([4, 4]).velocity)
     np.testing.assert_equal(at_sgrid.unstack()[0].data.shape, [1, 5, 4, 1])
     np.testing.assert_equal(at_sgrid.unstack()[1].data.shape, [1, 4, 5, 1])
Example #2
0
    else:
        raise ValueError('Invalid mode: %s' % effect.mode)


# pylint: disable-msg = invalid-name
Inflow = lambda geometry, rate=1.0, target='density': FieldEffect(
    GeometryMask([geometry], value=rate, name='inflow'),
    target,
    GROW,
    tags=('inflow', 'effect'))
Accelerator = lambda geometry, acceleration: FieldEffect(
    GeometryMask([geometry], value=acceleration, name='fan'), ('velocity', ),
    GROW,
    tags=('fan', 'effect'))
ConstantVelocity = lambda geometry, velocity: FieldEffect(
    ConstantField(velocity),
    bounds=geometry,
    targets=('velocity', ),
    mode=FIX,
    tags=('effect', ))
HeatSource = lambda geometry, rate: FieldEffect(
    GeometryMask([geometry], value=rate, name='heat-source'),
    ('temperature', ), GROW)
ColdSource = lambda geometry, rate: FieldEffect(
    GeometryMask([geometry], value=-rate, name='heat-source'),
    ('temperature', ), GROW)


def Fan(*args, **kwargs):
    # pylint: disable-msg = invalid-name
    warnings.warn("'Fan' was renamed to 'Accelerator' in version 1.0.2.",
Example #3
0
def ConstantVelocity(geometry, velocity):
    return FieldEffect(ConstantField(velocity),
                       bounds=geometry,
                       targets=('velocity', ),
                       mode=FIX,
                       tags=('effect', ))