|
8 | 8 | from ansys.dpf.core.common import natures, types, locations, ShellLayers |
9 | 9 | from ansys.dpf.core import operators_helper, scoping, meshed_region, time_freq_support |
10 | 10 | from ansys.dpf.core.plotter import Plotter |
| 11 | +from ansys.dpf.core import errors |
11 | 12 |
|
12 | 13 |
|
13 | 14 | class Field: |
@@ -92,9 +93,6 @@ def __init__(self, nentities=0, nature=natures.vector, |
92 | 93 |
|
93 | 94 | self._field_definition = self._load_field_definition() |
94 | 95 |
|
95 | | - # add dynamic methods |
96 | | - self._update_dynamic_methods() |
97 | | - |
98 | 96 | @property |
99 | 97 | def size(self): |
100 | 98 | """Number of elements times the number of components""" |
@@ -123,12 +121,6 @@ def elementary_data_shape(self): |
123 | 121 | else: |
124 | 122 | return self.component_count |
125 | 123 |
|
126 | | - def _update_dynamic_methods(self): |
127 | | - """Add or remove dynamic methods to this instance based on the |
128 | | - field type""" |
129 | | - if self.location in [locations.elemental_nodal, locations.elemental]: |
130 | | - self.to_nodal = self.__to_nodal |
131 | | - |
132 | 124 | @property |
133 | 125 | def location(self): |
134 | 126 | """Return the field location. |
@@ -161,8 +153,20 @@ def shell_layers(self): |
161 | 153 | if self._field_definition: |
162 | 154 | return self._field_definition.shell_layers |
163 | 155 |
|
164 | | - def __to_nodal(self): |
165 | | - """create a to_nodal operator and evaluates it""" |
| 156 | + def to_nodal(self): |
| 157 | + """Convert this field to one with a Nodal location. |
| 158 | +
|
| 159 | + Only valid when this field's location is ElementalNodal or |
| 160 | + Elemental. |
| 161 | +
|
| 162 | + Returns |
| 163 | + ------- |
| 164 | + Field |
| 165 | + Field with ``location=='Nodal'``. |
| 166 | + """ |
| 167 | + if self.location == 'Nodal': |
| 168 | + raise errors.LocationError('Location is already "Nodal"') |
| 169 | + |
166 | 170 | op = dpf.core.Operator("to_nodal") |
167 | 171 | op.inputs.connect(self) |
168 | 172 | return op.outputs.field() |
|
0 commit comments