From b507809e0801b4d66703da51f47d2a5d5624c091 Mon Sep 17 00:00:00 2001 From: Jenna Paikowsky Date: Thu, 9 Jan 2025 14:02:55 -0500 Subject: [PATCH 1/9] Added examples from operators section --- src/ansys/dpf/core/field.py | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index 763b7298a9..5ea7865ed1 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -51,6 +51,14 @@ class Field(_FieldBase): The field's scoping defines the order of the data, for example: the first ID in the ``scoping`` identifies to which entity the first ``entity data`` belongs. + The minimum requirement for a well defined field is for it to have a dimensionality + (scalar, three components vector, six components symmetrical matrix, and so on), a location + ("Nodal", "Elemental", "ElementalNodal", "Timefrq"), a data vector and a scoping with IDs. + You can also set the number of shell layers. If the field has one elementary data by entity + (elementary data size equals the number of components for "Nodal" or "Elemental" field for example), + then the data vector can be set directly. If a more complex field is required + ("ElementalNodal" field for example), the data can be set entity by entity. + For more information, see the `Fields container and fields `_ documentation section. @@ -81,12 +89,41 @@ class Field(_FieldBase): -------- Create a field from scratch. - >>> from ansys.dpf.core import fields_factory >>> from ansys.dpf.core import locations >>> from ansys.dpf import core as dpf >>> field_with_classic_api = dpf.Field() >>> field_with_classic_api.location = locations.nodal - >>> field_with_factory = fields_factory.create_scalar_field(10) + + + Create a field from scratch for the most common dimensionalities + >>> from ansys.dpf import core as dpf + >>> my_field = dpf.Field(num_entities, dpf.natures.scalar, "Nodal") + >>> my_field = dpf.Field(num_entities, dpf.natures.vector, "ElementalNodal") + >>> my_field = dpf.Field(num_entities, dpf.natures.symmatrix, "Elemental") + >>> my_scoping = dpf.Scoping() + >>> my_scoping.location = "Elemental" + >>> my_scoping.ids = list(range(1,3)) + >>> my_field.scoping = my_scoping + + Add all the data at once + + >>> from ansys.dpf import core as dpf + >>> my_data = [1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0] + >>> my_field.data = my_data + + Add data entity by entity + >>> from ansys.dpf import core as dpf + >>> my_elem_data = [1.0,1.0,1.0,0.0,0.0,0.0] + >>> my_field.append(my_elem_data, scopingid=1) + >>> my_field.append(my_elem_data, scopingid=2) + + Create a field using the fields factory + + >>> from ansys.dpf.core import fields_factory + >>> from ansys.dpf.core import locations + >>> from ansys.dpf import core as dpf + >>> field_with_factory = fields_factory.create_scalar_field(2) + >>> my_scalar_field.data = [1.0, 3.0] Extract a displacement field from a transient result file. From 4c3d63d42244cdc4d3ae59a0abc46e018a3e89bf Mon Sep 17 00:00:00 2001 From: Jenna Paikowsky Date: Thu, 9 Jan 2025 14:06:32 -0500 Subject: [PATCH 2/9] formatting changes --- src/ansys/dpf/core/field.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index 5ea7865ed1..f07bfab6ee 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -51,12 +51,12 @@ class Field(_FieldBase): The field's scoping defines the order of the data, for example: the first ID in the ``scoping`` identifies to which entity the first ``entity data`` belongs. - The minimum requirement for a well defined field is for it to have a dimensionality - (scalar, three components vector, six components symmetrical matrix, and so on), a location - ("Nodal", "Elemental", "ElementalNodal", "Timefrq"), a data vector and a scoping with IDs. - You can also set the number of shell layers. If the field has one elementary data by entity - (elementary data size equals the number of components for "Nodal" or "Elemental" field for example), - then the data vector can be set directly. If a more complex field is required + The minimum requirement for a well defined field is for it to have a dimensionality + (scalar, three components vector, six components symmetrical matrix, and so on), a location + ("Nodal", "Elemental", "ElementalNodal", "Timefrq"), a data vector and a scoping with IDs. + You can also set the number of shell layers. If the field has one elementary data by entity + (elementary data size equals the number of components for "Nodal" or "Elemental" field for example), + then the data vector can be set directly. If a more complex field is required ("ElementalNodal" field for example), the data can be set entity by entity. For more information, see the `Fields container and fields @@ -116,7 +116,7 @@ class Field(_FieldBase): >>> my_elem_data = [1.0,1.0,1.0,0.0,0.0,0.0] >>> my_field.append(my_elem_data, scopingid=1) >>> my_field.append(my_elem_data, scopingid=2) - + Create a field using the fields factory >>> from ansys.dpf.core import fields_factory From 19ce826540506d2d57597b404b6e3a2675b3c412 Mon Sep 17 00:00:00 2001 From: Jenna Paikowsky Date: Thu, 9 Jan 2025 14:47:39 -0500 Subject: [PATCH 3/9] Added missing code line --- src/ansys/dpf/core/field.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index f07bfab6ee..77b3738c84 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -97,6 +97,7 @@ class Field(_FieldBase): Create a field from scratch for the most common dimensionalities >>> from ansys.dpf import core as dpf + >>> num_entities = 2 >>> my_field = dpf.Field(num_entities, dpf.natures.scalar, "Nodal") >>> my_field = dpf.Field(num_entities, dpf.natures.vector, "ElementalNodal") >>> my_field = dpf.Field(num_entities, dpf.natures.symmatrix, "Elemental") From 41bdae6d535213785bfd573955a025350d386058 Mon Sep 17 00:00:00 2001 From: Jenna Paikowsky Date: Thu, 9 Jan 2025 14:59:46 -0500 Subject: [PATCH 4/9] Fixed code error --- src/ansys/dpf/core/field.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index 77b3738c84..3e7e4364e7 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -123,7 +123,7 @@ class Field(_FieldBase): >>> from ansys.dpf.core import fields_factory >>> from ansys.dpf.core import locations >>> from ansys.dpf import core as dpf - >>> field_with_factory = fields_factory.create_scalar_field(2) + >>> my_scalar_field = fields_factory.create_scalar_field(2) >>> my_scalar_field.data = [1.0, 3.0] Extract a displacement field from a transient result file. From 23a339a824d6655c2254126ae2ca5161acefbe13 Mon Sep 17 00:00:00 2001 From: JennaPaikowsky <98607744+JennaPaikowsky@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:08:23 -0500 Subject: [PATCH 5/9] Apply suggestions from code review Co-authored-by: Paul Profizi <100710998+PProfizi@users.noreply.github.com> --- src/ansys/dpf/core/field.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index 3e7e4364e7..bd3bc82ab3 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -53,7 +53,7 @@ class Field(_FieldBase): The minimum requirement for a well defined field is for it to have a dimensionality (scalar, three components vector, six components symmetrical matrix, and so on), a location - ("Nodal", "Elemental", "ElementalNodal", "Timefrq"), a data vector and a scoping with IDs. + ("Nodal", "Elemental", "ElementalNodal", "TimeFreq"), a data vector and a scoping with IDs. You can also set the number of shell layers. If the field has one elementary data by entity (elementary data size equals the number of components for "Nodal" or "Elemental" field for example), then the data vector can be set directly. If a more complex field is required @@ -95,15 +95,11 @@ class Field(_FieldBase): >>> field_with_classic_api.location = locations.nodal - Create a field from scratch for the most common dimensionalities + Create a symmetrical matrix elemental field from scratch >>> from ansys.dpf import core as dpf >>> num_entities = 2 - >>> my_field = dpf.Field(num_entities, dpf.natures.scalar, "Nodal") - >>> my_field = dpf.Field(num_entities, dpf.natures.vector, "ElementalNodal") - >>> my_field = dpf.Field(num_entities, dpf.natures.symmatrix, "Elemental") - >>> my_scoping = dpf.Scoping() - >>> my_scoping.location = "Elemental" - >>> my_scoping.ids = list(range(1,3)) + >>> my_field = dpf.Field(num_entities, dpf.natures.symmatrix, locations.elemental) + >>> my_scoping = dpf.Scoping(location=locations.elemental, ids=[1, 2]) >>> my_field.scoping = my_scoping Add all the data at once @@ -118,12 +114,11 @@ class Field(_FieldBase): >>> my_field.append(my_elem_data, scopingid=1) >>> my_field.append(my_elem_data, scopingid=2) - Create a field using the fields factory + Create a nodal scalar field using the fields factory >>> from ansys.dpf.core import fields_factory - >>> from ansys.dpf.core import locations >>> from ansys.dpf import core as dpf - >>> my_scalar_field = fields_factory.create_scalar_field(2) + >>> my_scalar_field = fields_factory.create_scalar_field(num_entities=2, location=locations.nodal) >>> my_scalar_field.data = [1.0, 3.0] Extract a displacement field from a transient result file. From 67d265a2ec320fb2d4dabb43299b34b1a29e3044 Mon Sep 17 00:00:00 2001 From: JennaPaikowsky <98607744+JennaPaikowsky@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:09:52 -0500 Subject: [PATCH 6/9] Apply suggestions from code review Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --- src/ansys/dpf/core/field.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index bd3bc82ab3..62d8a87c3f 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -59,9 +59,8 @@ class Field(_FieldBase): then the data vector can be set directly. If a more complex field is required ("ElementalNodal" field for example), the data can be set entity by entity. - For more information, see the `Fields container and fields - `_ - documentation section. + For more information, see `Fields container and fields + `_. Parameters From e6859d00efe06ad27af4b4cfa0eabcc4ef9e142a Mon Sep 17 00:00:00 2001 From: JennaPaikowsky <98607744+JennaPaikowsky@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:17:37 -0500 Subject: [PATCH 7/9] More code changes from review --- src/ansys/dpf/core/field.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index 62d8a87c3f..ace62bdfea 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -53,7 +53,7 @@ class Field(_FieldBase): The minimum requirement for a well defined field is for it to have a dimensionality (scalar, three components vector, six components symmetrical matrix, and so on), a location - ("Nodal", "Elemental", "ElementalNodal", "TimeFreq"), a data vector and a scoping with IDs. + ("Nodal", "Elemental", "ElementalNodal", "TimeFreq"), a data vector, and a scoping with IDs. You can also set the number of shell layers. If the field has one elementary data by entity (elementary data size equals the number of components for "Nodal" or "Elemental" field for example), then the data vector can be set directly. If a more complex field is required @@ -93,8 +93,8 @@ class Field(_FieldBase): >>> field_with_classic_api = dpf.Field() >>> field_with_classic_api.location = locations.nodal - Create a symmetrical matrix elemental field from scratch + >>> from ansys.dpf import core as dpf >>> num_entities = 2 >>> my_field = dpf.Field(num_entities, dpf.natures.symmatrix, locations.elemental) @@ -102,12 +102,13 @@ class Field(_FieldBase): >>> my_field.scoping = my_scoping Add all the data at once - + >>> from ansys.dpf import core as dpf >>> my_data = [1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0] >>> my_field.data = my_data Add data entity by entity + >>> from ansys.dpf import core as dpf >>> my_elem_data = [1.0,1.0,1.0,0.0,0.0,0.0] >>> my_field.append(my_elem_data, scopingid=1) From 35a626d99f88be4816abacfd2b6f56a6774e2edb Mon Sep 17 00:00:00 2001 From: JennaPaikowsky <98607744+JennaPaikowsky@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:20:59 -0500 Subject: [PATCH 8/9] Added periods to examples --- src/ansys/dpf/core/field.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index ace62bdfea..420bea47f0 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -93,7 +93,7 @@ class Field(_FieldBase): >>> field_with_classic_api = dpf.Field() >>> field_with_classic_api.location = locations.nodal - Create a symmetrical matrix elemental field from scratch + Create a symmetrical matrix elemental field from scratch. >>> from ansys.dpf import core as dpf >>> num_entities = 2 @@ -101,20 +101,20 @@ class Field(_FieldBase): >>> my_scoping = dpf.Scoping(location=locations.elemental, ids=[1, 2]) >>> my_field.scoping = my_scoping - Add all the data at once + Add all the data at once. >>> from ansys.dpf import core as dpf >>> my_data = [1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0] >>> my_field.data = my_data - Add data entity by entity + Add data entity by entity. >>> from ansys.dpf import core as dpf >>> my_elem_data = [1.0,1.0,1.0,0.0,0.0,0.0] >>> my_field.append(my_elem_data, scopingid=1) >>> my_field.append(my_elem_data, scopingid=2) - Create a nodal scalar field using the fields factory + Create a nodal scalar field using the fields factory. >>> from ansys.dpf.core import fields_factory >>> from ansys.dpf import core as dpf From ae7329c94c2c499c72df51df870838fdecf7c534 Mon Sep 17 00:00:00 2001 From: Jenna Paikowsky Date: Fri, 10 Jan 2025 08:55:23 -0500 Subject: [PATCH 9/9] Fixed formatting --- src/ansys/dpf/core/field.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/dpf/core/field.py b/src/ansys/dpf/core/field.py index 420bea47f0..b76563e711 100644 --- a/src/ansys/dpf/core/field.py +++ b/src/ansys/dpf/core/field.py @@ -94,7 +94,7 @@ class Field(_FieldBase): >>> field_with_classic_api.location = locations.nodal Create a symmetrical matrix elemental field from scratch. - + >>> from ansys.dpf import core as dpf >>> num_entities = 2 >>> my_field = dpf.Field(num_entities, dpf.natures.symmatrix, locations.elemental) @@ -102,13 +102,13 @@ class Field(_FieldBase): >>> my_field.scoping = my_scoping Add all the data at once. - + >>> from ansys.dpf import core as dpf >>> my_data = [1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0] >>> my_field.data = my_data Add data entity by entity. - + >>> from ansys.dpf import core as dpf >>> my_elem_data = [1.0,1.0,1.0,0.0,0.0,0.0] >>> my_field.append(my_elem_data, scopingid=1)