Source code for sharpy.generators.steadyvelocityfield

import numpy as np

import sharpy.utils.generator_interface as generator_interface
import sharpy.utils.settings as settings

[docs]@generator_interface.generator class SteadyVelocityField(generator_interface.BaseGenerator): """ Steady Velocity Field Generator ``SteadyVelocityField`` class inherited from ``BaseGenerator`` The object creates a steady velocity field with the velocity and flow direction specified by the user. To call this generator, the ``generator_id = SteadyVelocityField`` shall be used. This is parsed as the value for the ``velocity_field_generator`` key in the desired aerodynamic solver's settings. Args: in_dict (dict): Input data in the form of dictionary. See acceptable entries below: Attributes: settings_types (dict): Acceptable data types of the input data settings_default (dict): Default values for input data should the user not provide them u_inf (float): Free stream velocity selection u_inf_direction (list(float)): ``x``, ``y`` and ``z`` relative contributions to the free stream velocity See Also: .. py:class:: sharpy.utils.generator_interface.BaseGenerator """ generator_id = 'SteadyVelocityField' generator_classification = 'velocity-field' settings_types = dict() settings_default = dict() settings_description = dict() settings_types['u_inf'] = 'float' settings_default['u_inf'] = None settings_description['u_inf'] = 'Module of the free stream velocity' settings_types['u_inf_direction'] = 'list(float)' settings_default['u_inf_direction'] = np.array([1.0, 0, 0]) settings_description['u_inf_direction'] = 'Direction of the free stream velocity' settings_table = settings.SettingsTable() __doc__ += settings_table.generate(settings_types, settings_default, settings_description) def __init__(self): self.in_dict = dict() self.u_inf = 0. self.u_inf_direction = None def initialise(self, in_dict, restart=False): self.in_dict = in_dict settings.to_custom_types(self.in_dict, self.settings_types, self.settings_default) self.u_inf = self.in_dict['u_inf'] self.u_inf_direction = self.in_dict['u_inf_direction'] def generate(self, params, uext): zeta = params['zeta'] override = params['override'] for i_surf in range(len(zeta)): if override: uext[i_surf].fill(0.0) for i in range(zeta[i_surf].shape[1]): for j in range(zeta[i_surf].shape[2]): uext[i_surf][:, i, j] += self.u_inf*self.u_inf_direction