fields_factory#
Contains functions to simplify creating fields.
- ansys.dpf.core.fields_factory.field_from_array(arr)#
Create a DPF vector or scalar field from a numpy array or a Python list.
- Parameters
arr (np.ndarray or List) – Numpy array or Python list containing either 1 or 3 dimensions.
- Returns
field – Field constructed from the array.
- Return type
- ansys.dpf.core.fields_factory.create_matrix_field(num_entities, num_lines, num_col, location='Nodal', server=None)#
Create a matrix
ansys.dpf.core.Field
.This field contain entities that have a matrix format. This is a “reserve” mechanism, not a resize one. This means that you need to append data to grow the size of your field.
- Parameters
num_entities (int) – Number of entities to reserve.
num_lines (int) – Number of matrix line.
num_col (int) – Number of matrix columns.
location (str, optional) –
Location of the field. The default is
"Nodal"
. For example:ansys.dpf.core.natures.nodal
("Nodal"
)ansys.dpf.core.natures.elemental
("Elemental"
)ansys.dpf.core.natures.elemental_nodal
("ElementalNodal"
)…
server (ansys.dpf.core.server, optional) – Server with the channel connected to the remote or local instance. The default is
None
, in which case an attempt is made to use the global server.
- Returns
field – DPF field of the requested format.
- Return type
Examples
Create a field containing 3 matrix entities of a col*lines = 2*5 size with a nodal location (default).
>>> from ansys.dpf.core import fields_factory >>> field = fields_factory.create_matrix_field(3, 5, 2)
- ansys.dpf.core.fields_factory.create_3d_vector_field(num_entities, location='Nodal', server=None)#
Create a specific
ansys.dpf.core.Field
with entities that have 3D vector format.This is a “reserve” mechanism, not a resize one. This means that you need to append data to grow the size of your field.
- Parameters
num_entities (int) – Number of entities to reserve
location (str, optional) –
Location of the field. The default is
"Nodal"
. For example:ansys.dpf.core.natures.nodal (
"Nodal"
)ansys.dpf.core.natures.elemental (
"Elemental"
)ansys.dpf.core.natures.elemental_nodal (
"ElementalNodal"
)…
server (ansys.dpf.core.server, optional) – Server with the channel connected to the remote or local instance. The default is
None
, in which case an attempt is made to use the global server.
- Returns
field – DPF field of the requested format.
- Return type
Examples
Create a field containing 4 3D vector entities with a nodal location (default).
>>> from ansys.dpf.core import fields_factory >>> field = fields_factory.create_3d_vector_field(4)
- ansys.dpf.core.fields_factory.create_tensor_field(num_entities, location='Nodal', server=None)#
Create a specific
ansys.dpf.core.Field
with entities that have a 3*3 format.This is a “reserve” mechanism, not a resize one. This means that you need to append data to grow the size of your field.
- Parameters
num_entities (int) – Number of entities to reserve.
location (str, optional) –
Location of the field. The default is
"Nodal"
. For example:ansys.dpf.core.natures.nodal
("Nodal"
)ansys.dpf.core.natures.elemental
("Elemental"
)ansys.dpf.core.natures.elemental_nodal
("ElementalNodal"
)…
server (ansys.dpf.core.server, optional) – Server with the channel connected to the remote or local instance. The default is
None
, in which case an attempt is made to use the global server.
- Returns
field – DPF field in the requested format.
- Return type
Examples
Create a field containing 4 tensor entities with a nodal location (default).
>>> from ansys.dpf.core import fields_factory >>> field = fields_factory.create_tensor_field(4)
- ansys.dpf.core.fields_factory.create_scalar_field(num_entities, location='Nodal', server=None)#
Create a specific :class:`ansys.dpf.core.Field with entities that are scalar.
This is a “reserve” mechanism, not a resize one. This means that you need to append data to grow the size of your field.
- Parameters
num_entities (int) – Number of entities to reserve
location (str, optional) –
Location of the field. The default is
"Nodal"
. For example:ansys.dpf.core.natures.nodal (
"Nodal"
)ansys.dpf.core.natures.elemental (
"Elemental"
)ansys.dpf.core.natures.elemental_nodal (
"ElementalNodal"
)…
server (ansys.dpf.core.server, optional) – Server with the channel connected to the remote or local instance. The default is
None
, in which case an attempt is made to use the global server.
- Returns
field – DPF field in the requested format.
- Return type
Examples
Create a field containing 4 scalars with a nodal location (default).
>>> from ansys.dpf.core import fields_factory >>> field = fields_factory.create_scalar_field(4)
- ansys.dpf.core.fields_factory.create_vector_field(num_entities, num_comp, location='Nodal', server=None)#
Create a specific :class:`ansys.dpf.core.Field with entities that have a vector format.
This is a “reserve” mechanism, not a resize one. This means that you need to append data to grow the size of your field.
- Parameters
num_entities (int) – Number of entities to reserve.
num_comp (int) – Number of vector components.
location (str, optional) –
Location of the field. The default is
"Nodal"
. For example:ansys.dpf.core.natures.nodal (
"Nodal"
)ansys.dpf.core.natures.elemental (
"Elemental"
)ansys.dpf.core.natures.elemental_nodal (
"ElementalNodal"
)…
server (ansys.dpf.core.server, optional) – Server with the channel connected to the remote or local instance. The default is
None
, in which case an attempt is made to use the global server.
- Returns
field – DPF field in the requested format.
- Return type
Examples
Create a field containing 3 vector entities of 5 components each with a nodal location (default).
>>> from ansys.dpf.core import fields_factory >>> field = fields_factory.create_vector_field(3, 5)