sfepy.discrete.materials module

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

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)[source]

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:
namestr

The name of the material.

kind‘time-dependent’ or ‘stationary’

The kind of the material.

functionfunction

The function for setting up the material values.

valuesdict

Constant material values.

flagsdict, optional

Special flags.

**kwargskeyword arguments, optional

Constant material values passed by their names.

static from_conf(conf, functions)[source]

Construct Material instance from configuration.

get_constant_data(name)[source]

Get constant data by name.

get_data(key, name)[source]

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)[source]

Get all data keys.

Parameters:
region_namestr

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

iter_terms(equations, only_new=True)[source]

Iterate terms for which the material data should be evaluated.

reduce_on_datas(reduce_fun, init=0.0)[source]

For non-special values only!

reset()[source]

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

set_all_data(datas)[source]

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

set_data(key, qps, data)[source]

Set the material data in quadrature points.

Parameters:
keytuple

The (region_name, integral_name) data key.

qpsStruct

Information about the quadrature points.

datadict

The material data.

set_extra_args(**extra_args)[source]

Extra arguments passed tu the material function.

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

Evaluate material parameters in physical quadrature points.

Parameters:
tsTimeStepper instance

The time stepper.

equationsEquations 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.

problemProblem instance, optional

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

update_data(key, ts, equations, term, problem=None)[source]

Update the material parameters in quadrature points.

Parameters:
keytuple

The (region_name, integral_name) data key.

tsTimeStepper

The time stepper.

equationsEquations

The equations for which the update occurs.

termTerm

The term for which the update occurs.

problemProblem, optional

The problem definition for which the update occurs.

update_special_constant_data(equations=None, problem=None)[source]

Update the special constant material parameters.

Parameters:
equationsEquations

The equations for which the update occurs.

problemProblem, optional

The problem definition for which the update occurs.

update_special_data(ts, equations, problem=None)[source]

Update the special material parameters.

Parameters:
tsTimeStepper

The time stepper.

equationsEquations

The equations for which the update occurs.

problemProblem, optional

The problem definition for which the update occurs.

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

Construct Materials instance from configuration.

reset()[source]

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)[source]

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

Parameters:
tsTimeStepper instance

The time stepper.

equationsEquations instance

The equations using the materials.

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

The update mode, see Material.time_update().

problemProblem instance, optional

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

verbosebool

If False, reduce verbosity.