# sfepy.discrete.materials module

class sfepy.discrete.materials.Material(name, kind='time-dependent', function=None, values=None, flags=None, **kwargs)

  A class holding constitutive and other material parameters.

  Example input:

      material_2 = {
         'name' : 'm',
         'values' : {'E' : 1.0},
      }

  Material parameters are passed to terms using the dot notation, i.e. ‘m.E’ in our example case.

  __init__(name, kind='time-dependent', function=None, values=None, flags=None, **kwargs)

    A material is defined either by a function, or by a set of constant values, potentially distinct per region. Therefore, either function must be specified, or a combination of values and **kwargs.

    For constant materials, **kwargs are simply combined with values into a dictionary mapping material parameter names to parameter values. The parameter values may either be specified as a constant value, or as another dictionary mapping region names to constant values (see `sfepy.discrete.functions.ConstantFunctionByRegion`).

    Special material parameters, that are not evaluated in quadrature points - for example flags or geometry independent data - are denoted by parameter names starting with ‘.’ - in this case the values argument need to be used, or a function that returns the parameters when `mode == 'special'`.

    Parameters:
      name str

        The name of the material.

      kind‘time-dependent’ or ‘stationary’

        The kind of the material.

      function function

        The function for setting up the material values.

      values dict

        Constant material values.

      flags dict, optional

        Special flags.

      **kwargs keyword arguments, optional

        Constant material values passed by their names.

  static from_conf(conf, functions)

    Construct Material instance from configuration.

  get_constant_data(name)

    Get constant data by name.

  get_data(key, name)

    name can be a dict - then a Struct instance with data as attributes named as the dict keys is returned.

  get_keys(region_name=None)

    Get all data keys.

    Parameters:
      region_name str

        If not None, only keys with this region are returned.

  iter_terms(equations, only_new=True)

    Iterate terms for which the material data should be evaluated.

  reduce_on_datas(reduce_fun, init=0.0)

    For non-special values only!

  reset()

    Clear all data created by a call to `time_update()`, set `self.mode` to `None`.

  set_all_data(datas)

    Use the provided data, set mode to ‘user’.

  set_data(key, qps, data)

    Set the material data in quadrature points.

    Parameters:
      key tuple

        The (region_name, integral_name) data key.

      qps Struct

        Information about the quadrature points.

      data dict

        The material data.

  set_extra_args(**extra_args)

    Extra arguments passed tu the material function.

  set_function(function)
  time_update(ts, equations, mode='normal', problem=None)

    Evaluate material parameters in physical quadrature points.

    Parameters:
      ts TimeStepper instance

        The time stepper.

      equations Equations instance

        The equations using the materials.

      mode‘normal’, ‘update’ or ‘force’

        The update mode. In ‘force’ mode, `self.datas` is cleared and all updates are redone. In ‘update’ mode, existing data are preserved and new can be added. The ‘normal’ mode depends on other attributes: for stationary (`self.kind == 'stationary'`) materials and materials in ‘user’ mode, nothing is done if `self.datas` is not empty. For time-dependent materials (`self.kind == 'time-dependent'`, the default) that are not constant, i.e., are given by a user function, ‘normal’ mode behaves like ‘force’ mode. For constant materials it behaves like ‘update’ mode - existing data are reused.

      problem Problem instance, optional

        The problem that can be passed to user functions as a context.

  update_data(key, ts, equations, term, problem=None)

    Update the material parameters in quadrature points.

    Parameters:
      key tuple

        The (region_name, integral_name) data key.

      ts TimeStepper

        The time stepper.

      equations Equations

        The equations for which the update occurs.

      term Term

        The term for which the update occurs.

      problem Problem, optional

        The problem definition for which the update occurs.

  update_special_constant_data(equations=None, problem=None)

    Update the special constant material parameters.

    Parameters:
      equations Equations

        The equations for which the update occurs.

      problem Problem, optional

        The problem definition for which the update occurs.

  update_special_data(ts, equations, problem=None)

    Update the special material parameters.

    Parameters:
      ts TimeStepper

        The time stepper.

      equations Equations

        The equations for which the update occurs.

      problem Problem, optional

        The problem definition for which the update occurs.

class sfepy.discrete.materials.Materials(objs=None, **kwargs)
  static from_conf(conf, functions, wanted=None)

    Construct Materials instance from configuration.

  reset()

    Clear material data so that next materials.time_update() is performed even for stationary materials.

  time_update(ts, equations, mode='normal', problem=None, verbose=True)

    Update material parameters for given time, problem, and equations.

    Parameters:
      ts TimeStepper instance

        The time stepper.

      equations Equations instance

        The equations using the materials.

      mode‘normal’, ‘update’ or ‘force’

        The update mode, see `Material.time_update()`.

      problem Problem instance, optional

        The problem that can be passed to user functions as a context.

      verbose bool

        If False, reduce verbosity.