sfepy.fem.fields_base module

Notes

Important attributes of continuous (order > 0) Field and SurfaceField instances:

  • vertex_remap : econn[:, :n_vertex] = vertex_remap[conn]
  • vertex_remap_i : conn = vertex_remap_i[econn[:, :n_vertex]]

where conn is the mesh vertex connectivity, econn is the region-local field connectivity.

class sfepy.fem.fields_base.Field(name, dtype, shape, region, approx_order=1)[source]

Base class for finite element fields.

Notes

  • Region can span over several groups -> different Aproximation instances
  • interps and hence node_descs are per region (must have single geometry!)
  • no two interps can be in a same group -> no two aps (with different regions) can be in a same group -> aps can be uniquely indexed with ig
clear_dof_conns()[source]
clear_mappings(clear_all=False)[source]

Clear current reference mappings.

create_mapping(ig, region, integral, integration)[source]

Create a new reference mapping.

create_mesh(extra_nodes=True)[source]

Create a mesh from the field region, optionally including the field extra nodes.

create_output(dofs, var_name, dof_names=None, key=None, extend=True, fill_value=None, linearization=None)[source]

Convert the DOFs corresponding to the field to a dictionary of output data usable by Mesh.write().

Parameters:

dofs : array, shape (n_nod, n_component)

The array of DOFs reshaped so that each column corresponds to one component.

var_name : str

The variable name corresponding to dofs.

dof_names : tuple of str

The names of DOF components.

key : str, optional

The key to be used in the output dictionary instead of the variable name.

extend : bool

Extend the DOF values to cover the whole domain.

fill_value : float or complex

The value used to fill the missing DOF values if extend is True.

linearization : Struct or None

The linearization configuration for higher order approximations.

Returns:

out : dict

The output dictionary.

extend_dofs(dofs, fill_value=None)[source]

Extend DOFs to the whole domain using the fill_value, or the smallest value in dofs if fill_value is None.

static from_args(name, dtype, shape, region, approx_order=1, space='H1', poly_space_base='lagrange')[source]

Create a Field subclass instance corresponding to a given space.

Parameters:

name : str

The field name.

dtype : numpy.dtype

The field data type: float64 or complex128.

shape : int/tuple/str

The field shape: 1 or (1,) or ‘scalar’, space dimension (2, or (2,) or 3 or (3,)) or ‘vector’. The field shape determines the shape of the FE base functions and can be different from a FieldVariable instance shape. (TODO)

region : Region

The region where the field is defined.

approx_order : int/str

The FE approximation order, e.g. 0, 1, 2, ‘1B’ (1 with bubble).

space : str

The function space name.

poly_space_base : str

The name of polynomial space base.

Notes

Assumes one cell type for the whole region!

static from_conf(conf, regions)[source]

Create a Field subclass instance based on the configuration.

get_coor(nods=None)[source]

Get coordinates of the field nodes.

Parameters:

nods : array, optional

The indices of the required nodes. If not given, the coordinates of all the nodes are returned.

get_dofs_in_region(region, merge=False, clean=False, warn=False, igs=None)[source]

Return indices of DOFs that belong to the given region.

get_dofs_in_region_group(region, ig, merge=True)[source]

Return indices of DOFs that belong to the given region and group.

get_mapping(ig, region, integral, integration, get_saved=False, return_key=False)[source]

For given region, integral and integration type, get a reference mapping, i.e. jacobians, element volumes and base function derivatives for Volume-type geometries, and jacobians, normals and base function derivatives for Surface-type geometries corresponding to the field approximation.

The mappings are cached in the field instance in mappings attribute. The mappings can be saved to mappings0 using Field.save_mappings. The saved mapping can be retrieved by passing get_saved=True. If the required (saved) mapping is not in cache, a new one is created.

Returns:

geo : VolumeGeometry or SurfaceGeometry instance

The geometry object that describes the mapping.

mapping : VolumeMapping or SurfaceMapping instance

The mapping.

key : tuple

The key of the mapping in mappings or mappings0.

get_output_approx_order()[source]

Get the approximation order used in the output file.

get_true_order()[source]

Get the true approximation order depending on the reference element geometry.

For example, for P1 (linear) approximation the true order is 1, while for Q1 (bilinear) approximation in 2D the true order is 2.

get_vertices()[source]

Return indices of vertices belonging to the field region.

interp_to_qp(dofs)[source]

Interpolate DOFs into quadrature points.

The quadrature order is given by the field approximation order.

Parameters:

dofs : array

The array of DOF values of shape (n_nod, n_component).

Returns:

data_qp : array

The values interpolated into the quadrature points.

integral : Integral

The corresponding integral defining the quadrature points.

is_higher_order()[source]

Return True, if the field’s approximation order is greater than one.

linearize(dofs, min_level=0, max_level=1, eps=0.0001)[source]

Linearize the solution for post-processing.

Parameters:

dofs : array, shape (n_nod, n_component)

The array of DOFs reshaped so that each column corresponds to one component.

min_level : int

The minimum required level of mesh refinement.

max_level : int

The maximum level of mesh refinement.

eps : float

The relative tolerance parameter of mesh adaptivity.

Returns:

mesh : Mesh instance

The adapted, nonconforming, mesh.

vdofs : array

The DOFs defined in vertices of mesh.

levels : array of ints

The refinement level used for each element group.

remove_extra_dofs(dofs)[source]

Remove DOFs defined in higher order nodes (order > 1).

save_mappings()[source]

Save current reference mappings to mappings0 attribute.

setup_coors(coors=None)[source]

Setup coordinates of field nodes.

setup_dof_conns(dof_conns, dpn, dc_type, region, is_trace=False)[source]

Setup dof connectivities of various kinds as needed by terms.

class sfepy.fem.fields_base.SurfaceField(name, dtype, shape, region, approx_order=1)[source]

Finite element field base class over surface (element dimension is one less than space dimension).

average_qp_to_vertices(data_qp, integral)[source]

Average data given in quadrature points in region elements into region vertices.

System Message: WARNING/2 (u_n = \sum_e (u_{e,avg} * area_e) / \sum_e area_e = \sum_e \int_{area_e} u / \sum area_e )

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.
setup_dof_conns(dof_conns, dpn, dc_type, region, is_trace=False)[source]

Setup dof connectivities of various kinds as needed by terms.

setup_extra_data(geometry, info, is_trace)[source]
class sfepy.fem.fields_base.VolumeField(name, dtype, shape, region, approx_order=1)[source]

Finite element field base class over volume elements (element dimension equals space dimension).

average_qp_to_vertices(data_qp, integral)[source]

Average data given in quadrature points in region elements into region vertices.

System Message: WARNING/2 (u_n = \sum_e (u_{e,avg} * volume_e) / \sum_e volume_e = \sum_e \int_{volume_e} u / \sum volume_e )

latex exited with error [stdout] This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/TeX Live for SUSE Linux) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2011/06/27> Babel <3.9f> and hyphenation patterns for 78 languages loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/base/inputenc.sty ! LaTeX Error: File `utf8x.def’ not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: def) Enter file name: ! Emergency stop. <read *> l.131 \endinput ^^M No pages of output. Transcript written on math.log.
setup_dof_conns(dof_conns, dpn, dc_type, region, is_trace=False)[source]

Setup dof connectivities of various kinds as needed by terms.

setup_extra_data(geometry, info, is_trace)[source]
sfepy.fem.fields_base.create_dof_conn(conn, dpn)[source]

Given element a node connectivity, create the dof connectivity.

sfepy.fem.fields_base.create_expression_output(expression, name, primary_field_name, fields, materials, variables, functions=None, mode='eval', term_mode=None, extra_args=None, verbose=True, kwargs=None, min_level=0, max_level=1, eps=0.0001)[source]

Create output mesh and data for the expression using the adaptive linearizer.

Parameters:

expression : str

The expression to evaluate.

name : str

The name of the data.

primary_field_name : str

The name of field that defines the element groups and polynomial spaces.

fields : dict

The dictionary of fields used in variables.

materials : Materials instance

The materials used in the expression.

variables : Variables instance

The variables used in the expression.

functions : Functions instance, optional

The user functions for materials etc.

mode : one of ‘eval’, ‘el_avg’, ‘qp’

The evaluation mode - ‘qp’ requests the values in quadrature points, ‘el_avg’ element averages and ‘eval’ means integration over each term region.

term_mode : str

The term call mode - some terms support different call modes and depending on the call mode different values are returned.

extra_args : dict, optional

Extra arguments to be passed to terms in the expression.

verbose : bool

If False, reduce verbosity.

kwargs : dict, optional

The variables (dictionary of (variable name) : (Variable instance)) to be used in the expression.

min_level : int

The minimum required level of mesh refinement.

max_level : int

The maximum level of mesh refinement.

eps : float

The relative tolerance parameter of mesh adaptivity.

Returns:

out : dict

The output dictionary.

sfepy.fem.fields_base.fields_from_conf(conf, regions)[source]
sfepy.fem.fields_base.get_eval_expression(expression, ig, fields, materials, variables, functions=None, mode='eval', term_mode=None, extra_args=None, verbose=True, kwargs=None)[source]

Get the function for evaluating an expression given a list of elements, and reference element coordinates.

sfepy.fem.fields_base.parse_approx_order(approx_order)[source]

Parse the uniform approximation order value (str or int).

sfepy.fem.fields_base.setup_dof_conns(conn_info, dof_conns=None, make_virtual=False, verbose=True)[source]
Dof connectivity key:
(field.name, var.n_components, region.name, type, ig)
sfepy.fem.fields_base.setup_extra_data(conn_info)[source]

Setup extra data required for non-volume integration.