@@ -114,7 +114,7 @@ def _init_api_env(self):
114114 @staticmethod
115115 def _field_create_internal_obj (
116116 api : property_field_abstract_api .PropertyFieldAbstractAPI ,
117- client ,
117+ server ,
118118 nature ,
119119 nentities ,
120120 location = locations .nodal ,
@@ -123,12 +123,23 @@ def _field_create_internal_obj(
123123 with_type = None ,
124124 ):
125125 dim = dimensionality .Dimensionality ([ncomp_n , ncomp_m ], nature )
126- if client is not None :
127- return api .csproperty_field_new_on_client (
128- client , nentities , nentities * dim .component_count
129- )
126+ client = server .client
127+ if meets_version (server .version , "11.0" ):
128+ if client is not None :
129+ return api .csproperty_field_new_location_on_client (
130+ client , nentities , nentities * dim .component_count , location
131+ )
132+ else :
133+ return api .csproperty_field_new_location (
134+ nentities , nentities * dim .component_count , location
135+ )
130136 else :
131- return api .csproperty_field_new (nentities , nentities * dim .component_count )
137+ if client is not None :
138+ return api .csproperty_field_new_on_client (
139+ client , nentities , nentities * dim .component_count
140+ )
141+ else :
142+ return api .csproperty_field_new (nentities , nentities * dim .component_count )
132143
133144 @version_requires ("8.1" )
134145 def _load_field_definition (self ):
@@ -141,8 +152,8 @@ def _load_field_definition(self):
141152 def location (self ):
142153 """Location of the property field.
143154
144- A property field contains a scoping, which is the location that is read .
145- To update location, directly update the scoping location.
155+ The property field location is the one contained in its field definition .
156+ To update location, just update the property field location.
146157
147158 Returns
148159 -------
@@ -156,16 +167,18 @@ def location(self):
156167
157168 >>> from ansys.dpf import core as dpf
158169 >>> pfield = dpf.PropertyField()
159- >>> list_ids = [1, 2, 4, 6, 7]
160- >>> scop = dpf.Scoping(ids = list_ids, location = dpf.locations.nodal)
161- >>> pfield.scoping = scop
162- >>> pfield.scoping.location = dpf.locations.nodal
170+ >>> pfield.location = dpf.locations.nodal
163171 >>> pfield.location
164172 'Nodal'
165173
166174 """
167- location = self .scoping .location
168- return location if location else None
175+ if meets_version (self ._server .version , "11.0" ):
176+ if self ._field_definition :
177+ return self ._field_definition .location
178+ elif self .scoping :
179+ return self .scoping .location
180+ else :
181+ return None
169182
170183 @location .setter
171184 def location (self , value ):
@@ -181,14 +194,27 @@ def location(self, value):
181194 --------
182195 >>> from ansys.dpf import core as dpf
183196 >>> pfield = dpf.PropertyField()
184- >>> scop = dpf.Scoping(ids = list_ids, location = dpf.locations.nodal)
185- >>> pfield.scoping = scop
197+ >>> list_ids = [1, 2, 4, 6, 7]
186198 >>> pfield.location = 'Nodal'
187199 >>> pfield.location
188200 'Nodal'
189201
190202 """
191- self .scoping .location = value
203+ if meets_version (self ._server .version , "11.0" ):
204+ if self ._field_definition :
205+ self ._field_definition .location = value
206+ return
207+ else :
208+ raise Exception (
209+ "Property field location is based on field definition, and field definition is not defined"
210+ )
211+ elif self .scoping :
212+ self .scoping .location = value
213+ return
214+ else :
215+ raise Exception (
216+ "Property field location before is based on scoping, and scoping is not defined"
217+ )
192218
193219 @property
194220 def component_count (self ):
0 commit comments