Skip to content

jvidalor/locations in property field #2322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/_static/dpf_operators.html
Original file line number Diff line number Diff line change
Expand Up @@ -8954,7 +8954,7 @@ <h2 class="h2-main">Configurating operators</h2>
</div></figure><h2 class="op-des-h2">Inputs</h2><div><table class="pin-box"><tbody><tr><td><pin-number-optional n="1" ellipsis = "false"></pin-number-optional></td><td><pin-name name="scoping"></pin-name></td><td><req-type typeName="(scoping)"></req-type></td></tr></tbody></table><table class="pin-box"><tbody><tr><td><pin-number-optional n="2" ellipsis = "false"></pin-number-optional></td><td><pin-name name="displacement"></pin-name></td><td><req-type typeName="(fields_container)"></req-type></td><td><div class = "pin-des-text"><p>Displacement field's container. Must contain the mesh if mesh not specified in input.</p>
</div></td></tr></tbody></table><table class="pin-box"><tbody><tr><td><pin-number-optional n="7" ellipsis = "false"></pin-number-optional></td><td><pin-name name="mesh"></pin-name></td><td><req-type typeName="(abstract_meshed_region)"></req-type></td><td><div class = "pin-des-text"><p>Mesh must be defined if the displacement field's container does not contain it, or if there is no displacement.</p>
</div></td></tr></tbody></table></div><h2 class="op-des-h2">Outputs</h2><div><table class="pin-box"><tbody><tr><td><pin-number n="0" ellipsis = "false"></pin-number></td><td><pin-name name="fields_container"></pin-name></td><td><req-type typeName="(fields_container)"></req-type></td></tr></tbody></table></div><h2 class="op-des-h2">Configurations</h2><config-spec name="mutex" default="false" doc="If this option is set to true, the shared memory is prevented from being simultaneously accessed by multiple threads." types="bool" ></config-spec><h2 class="op-des-h2">Scripting</h2><scripting-part scripting_name="elements_volumes_over_time" license="any_dpf_supported_increments" cat="geo" plugin="core" cpp-name="volumes_provider"></scripting-part></div><div class="operator" id="window bartlett" scripting_name="window_bartlett"plugin="core"cat="math"><h1 class="op-des-h1">math: window bartlett</h1><figure class="figure-op-des"> <figcaption > Description </figcaption><div class = "figure-op-des-text"><p>Apply bartlett windowing on a given FieldsContainer having time label or a Field located on time. Assume that time sampling is evenly spaced (use time_freq_interpolation before otherwise).</p>
</div></figure><h2 class="op-des-h2">Inputs</h2><div><table class="pin-box"><tbody><tr><td><pin-number n="0" ellipsis = "false"></pin-number></td><td><pin-name name="field"></pin-name></td><td><req-type typeName="(field | fields_container)"></req-type></td></tr></tbody></table></div><h2 class="op-des-h2">Outputs</h2><div><table class="pin-box"><tbody><tr><td><pin-number n="0" ellipsis = "false"></pin-number></td><td><pin-name name="field"></pin-name></td><td><req-type typeName="(field | fields_container)"></req-type></td></tr></tbody></table></div><h2 class="op-des-h2">Configurations</h2><config-spec name="mutex" default="false" doc="If this option is set to true, the shared memory is prevented from being simultaneously accessed by multiple threads." types="bool" ></config-spec><h2 class="op-des-h2">Scripting</h2><scripting-part scripting_name="window_bartlett" license="none" cat="math" plugin="core" cpp-name="window::bartlett"></scripting-part></div><div class="operator" id="from scoping" scripting_name="from_scoping"plugin="core"cat="mesh"><h1 class="op-des-h1">mesh: from scoping</h1><figure class="figure-op-des"> <figcaption > Description </figcaption><div class = "figure-op-des-text"><p>Extracts a meshed region from another meshed region based on a scoping. Regarding the property fields of the meshed region: the 'Elemental', 'Face', and 'Nodal' property fields are scoped to the elements, faces or nodes of the output mesh, the 'Global' property fields are transferred from the input mesh to the output mesh without changes, and the rest of the property fields are not present in the output mesh.</p>
</div></figure><h2 class="op-des-h2">Inputs</h2><div><table class="pin-box"><tbody><tr><td><pin-number n="0" ellipsis = "false"></pin-number></td><td><pin-name name="field"></pin-name></td><td><req-type typeName="(field | fields_container)"></req-type></td></tr></tbody></table></div><h2 class="op-des-h2">Outputs</h2><div><table class="pin-box"><tbody><tr><td><pin-number n="0" ellipsis = "false"></pin-number></td><td><pin-name name="field"></pin-name></td><td><req-type typeName="(field | fields_container)"></req-type></td></tr></tbody></table></div><h2 class="op-des-h2">Configurations</h2><config-spec name="mutex" default="false" doc="If this option is set to true, the shared memory is prevented from being simultaneously accessed by multiple threads." types="bool" ></config-spec><h2 class="op-des-h2">Scripting</h2><scripting-part scripting_name="window_bartlett" license="none" cat="math" plugin="core" cpp-name="window::bartlett"></scripting-part></div><div class="operator" id="from scoping" scripting_name="from_scoping"plugin="core"cat="mesh"><h1 class="op-des-h1">mesh: from scoping</h1><figure class="figure-op-des"> <figcaption > Description </figcaption><div class = "figure-op-des-text"><p>Extracts a meshed region from another meshed region based on a scoping. Regarding the property fields whose scoping location is 'Elemental', 'Faces', and 'Nodal', they are scoped to the elements, faces or nodes of the output mesh. The ones whose scoping location is 'Global' are transferred from the input mesh to the output mesh without changes, and the rest of the property fields are not present in the output mesh.</p>
</div></figure><h2 class="op-des-h2">Inputs</h2><div><table class="pin-box"><tbody><tr><td><pin-number n="1" ellipsis = "false"></pin-number></td><td><pin-name name="scoping"></pin-name></td><td><req-type typeName="(scoping)"></req-type></td><td><div class = "pin-des-text"><p>if nodal/face scoping, then the scoping is transposed respecting the inclusive pin</p>
</div></td></tr></tbody></table><table class="pin-box"><tbody><tr><td><pin-number-optional n="2" ellipsis = "false"></pin-number-optional></td><td><pin-name name="inclusive"></pin-name></td><td><req-type typeName="(int32)"></req-type></td><td><div class = "pin-des-text"><p>if inclusive == 1 then all the elements/faces adjacent to the nodes/faces ids in input are added, if inclusive == 0, only the elements/faces which have all their nodes/faces in the scoping are included</p>
</div></td></tr></tbody></table><table class="pin-box"><tbody><tr><td><pin-number-optional n="3" ellipsis = "false"></pin-number-optional></td><td><pin-name name="nodes_only"></pin-name></td><td><req-type typeName="(bool)"></req-type></td><td><div class = "pin-des-text"><p>returns mesh with nodes only (without any elements or property fields). Default is false.</p>
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/dpf/core/custom_type_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _init_api_env(self):
@staticmethod
def _field_create_internal_obj(
api,
client,
server,
nature,
nentities,
location=locations.nodal,
Expand All @@ -168,6 +168,7 @@ def _field_create_internal_obj(
with_type=None,
):
dpf_type_name = numpy_type_to_dpf[with_type]
client = server.client
if client is not None:
return api.cscustom_type_field_new_on_client(
client, dpf_type_name, with_type.itemsize, nentities, nentities
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/dpf/core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def _init_api_env(self):
@staticmethod
def _field_create_internal_obj(
api: field_abstract_api.FieldAbstractAPI,
client,
server,
nature,
nentities,
location=locations.nodal,
Expand All @@ -241,6 +241,7 @@ def _field_create_internal_obj(
with_type=None,
):
dim = dimensionality.Dimensionality([ncomp_n, ncomp_m], nature)
client = server.client

if dim.is_1d_dim():
if client is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/core/field_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
else:
self._internal_obj = self.__class__._field_create_internal_obj(
self._api,
client=self._server.client,
server=self._server,
nature=nature,
nentities=nentities,
location=location,
Expand All @@ -97,7 +97,7 @@ def _api(self):
@abstractmethod
def _field_create_internal_obj(
api: field_abstract_api.FieldAbstractAPI,
client,
server,
nature,
nentities,
location=locations.nodal,
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/fields_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def _create_field(server, nature, nentities, location=locations.nodal, ncomp_n=0
api.init_field_environment(server)
internal_obj = Field._field_create_internal_obj(
api=api,
client=server.client,
server=server,
nature=nature,
nentities=nentities,
location=location,
Expand Down
20 changes: 10 additions & 10 deletions src/ansys/dpf/core/operators/mesh/from_scoping.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

class from_scoping(Operator):
r"""Extracts a meshed region from another meshed region based on a scoping.
Regarding the property fields of the meshed region: the ‘Elemental’,
Face’, and ‘Nodal’ property fields are scoped to the elements, faces or
nodes of the output mesh, the ‘Global’ property fields are transferred
from the input mesh to the output mesh without changes, and the rest of
the property fields are not present in the output mesh.
Regarding the property fields whose scoping location is ‘Elemental’,
Faces’, and ‘Nodal’, they are scoped to the elements, faces or nodes of
the output mesh. The ones whose scoping location is ‘Global’ are
transferred from the input mesh to the output mesh without changes, and
the rest of the property fields are not present in the output mesh.


Parameters
Expand Down Expand Up @@ -91,11 +91,11 @@ def __init__(
@staticmethod
def _spec() -> Specification:
description = r"""Extracts a meshed region from another meshed region based on a scoping.
Regarding the property fields of the meshed region: the ‘Elemental’,
Face’, and ‘Nodal’ property fields are scoped to the elements, faces or
nodes of the output mesh, the ‘Global’ property fields are transferred
from the input mesh to the output mesh without changes, and the rest of
the property fields are not present in the output mesh.
Regarding the property fields whose scoping location is ‘Elemental’,
Faces’, and ‘Nodal’, they are scoped to the elements, faces or nodes of
the output mesh. The ones whose scoping location is ‘Global’ are
transferred from the input mesh to the output mesh without changes, and
the rest of the property fields are not present in the output mesh.
"""
spec = Specification(
description=description,
Expand Down
28 changes: 20 additions & 8 deletions src/ansys/dpf/core/property_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(
field=property_field,
server=server,
)
self._field_definition_instance = None
self._field_definition_instance = self._load_field_definition()

@property
def _api(self) -> property_field_abstract_api.PropertyFieldAbstractAPI:
Expand All @@ -114,7 +114,7 @@ def _init_api_env(self):
@staticmethod
def _field_create_internal_obj(
api: property_field_abstract_api.PropertyFieldAbstractAPI,
client,
server,
nature,
nentities,
location=locations.nodal,
Expand All @@ -123,12 +123,21 @@ def _field_create_internal_obj(
with_type=None,
):
dim = dimensionality.Dimensionality([ncomp_n, ncomp_m], nature)
if client is not None:
return api.csproperty_field_new_on_client(
client, nentities, nentities * dim.component_count
)
client = server.client
if meets_version(server.version, "11.0"):
if client is not None:
return api.csproperty_field_new_location_on_client(
client, nentities, nentities * dim.component_count, location
)
else:
return api.csproperty_field_new_location(nentities, nentities * dim.component_count, location)
else:
return api.csproperty_field_new(nentities, nentities * dim.component_count)
if client is not None:
return api.csproperty_field_new_on_client(
client, nentities, nentities * dim.component_count
)
else:
return api.csproperty_field_new(nentities, nentities * dim.component_count)

@version_requires("8.1")
def _load_field_definition(self):
Expand All @@ -152,7 +161,7 @@ def location(self):

Examples
--------
Create a property field and request the location.
Create a property field and request the location. ##TODO Important, modify this example! as well as the description

>>> from ansys.dpf import core as dpf
>>> pfield = dpf.PropertyField()
Expand All @@ -164,6 +173,9 @@ def location(self):
'Nodal'

"""
if meets_version(self._server.version, "11.0"):
if self._field_definition:
return self._field_definition.location
if self.scoping:
return self.scoping.location
else:
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/dpf/core/string_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ def _init_api_env(self):
@staticmethod
def _field_create_internal_obj(
api: string_field_abstract_api.StringFieldAbstractAPI,
client,
server,
nature,
nentities,
location=locations.nodal,
ncomp_n=0,
ncomp_m=0,
with_type=None,
):
client = server.client
if client is not None:
return api.csstring_field_new_on_client(client, nentities, nentities)
else:
Expand Down
12 changes: 12 additions & 0 deletions src/ansys/dpf/gate/generated/property_field_abstract_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def property_field_get_location(field):
def csproperty_field_new(numEntities, data_size):
raise NotImplementedError

@staticmethod
def csproperty_field_new_location(numEntities, data_size, location):
raise NotImplementedError

@staticmethod
def csproperty_field_new_with_transformation(numEntities, data_size, wf, input_name, output_name):
raise NotImplementedError
Expand Down Expand Up @@ -119,6 +123,10 @@ def csproperty_field_set_cscoping(field, scoping):
def csproperty_field_set_entity_data(field, index, id, size, data):
raise NotImplementedError

@staticmethod
def csproperty_field_set_location(field, location):
raise NotImplementedError

@staticmethod
def csproperty_field_resize(field, dataSize, scopingSize):
raise NotImplementedError
Expand Down Expand Up @@ -183,6 +191,10 @@ def property_get_data_fast(f, index, data, id, size, n_comp):
def csproperty_field_new_on_client(client, numEntities, data_size):
raise NotImplementedError

@staticmethod
def csproperty_field_new_location_on_client(client, numEntities, data_size, location):
raise NotImplementedError

@staticmethod
def csproperty_field_get_copy(id, client):
raise NotImplementedError
Expand Down
27 changes: 27 additions & 0 deletions src/ansys/dpf/gate/generated/property_field_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ def csproperty_field_new(numEntities, data_size):
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def csproperty_field_new_location(numEntities, data_size, location):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
res = capi.dll.CSPropertyField_new_location(utils.to_int32(numEntities), utils.to_int32(data_size), utils.to_char_ptr(location), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def csproperty_field_new_with_transformation(numEntities, data_size, wf, input_name, output_name):
errorSize = ctypes.c_int(0)
Expand Down Expand Up @@ -262,6 +271,15 @@ def csproperty_field_set_entity_data(field, index, id, size, data):
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def csproperty_field_set_location(field, location):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
res = capi.dll.CSPropertyField_SetLocation(field._internal_obj if field is not None else None, utils.to_char_ptr(location), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def csproperty_field_resize(field, dataSize, scopingSize):
errorSize = ctypes.c_int(0)
Expand Down Expand Up @@ -406,6 +424,15 @@ def csproperty_field_new_on_client(client, numEntities, data_size):
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def csproperty_field_new_location_on_client(client, numEntities, data_size, location):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
res = capi.dll.CSPropertyField_new_location_on_client(client._internal_obj if client is not None else None, utils.to_int32(numEntities), utils.to_int32(data_size), utils.to_char_ptr(location), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def csproperty_field_get_copy(id, client):
errorSize = ctypes.c_int(0)
Expand Down
Binary file modified src/ansys/dpf/gatebin/Ans.Dpf.GrpcClient.dll
Binary file not shown.
Binary file modified src/ansys/dpf/gatebin/DPFClientAPI.dll
Binary file not shown.
Binary file modified src/ansys/dpf/gatebin/libAns.Dpf.GrpcClient.so
Binary file not shown.
Binary file modified src/ansys/dpf/gatebin/libDPFClientAPI.so
Binary file not shown.
Loading