Skip to content

Commit 766cc63

Browse files
update generated code (#1452)
1 parent 0316972 commit 766cc63

21 files changed

+2169
-169
lines changed

doc/source/_static/dpf_operators.html

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.
Lines changed: 383 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,383 @@
1+
"""
2+
apply_svd
3+
=========
4+
Autogenerated DPF operator classes.
5+
"""
6+
7+
from warnings import warn
8+
from ansys.dpf.core.dpf_operator import Operator
9+
from ansys.dpf.core.inputs import Input, _Inputs
10+
from ansys.dpf.core.outputs import Output, _Outputs
11+
from ansys.dpf.core.operators.specification import PinSpecification, Specification
12+
13+
14+
class apply_svd(Operator):
15+
"""Computes the coefficients (=U*Sigma) and VT components from SVD.
16+
17+
Parameters
18+
----------
19+
field_contaner_to_compress : FieldsContainer
20+
Fields container to be compressed
21+
scalar_int : int
22+
Number of vectors (r) to keep for the future
23+
reconstraction of the matrix a, ex.
24+
a[m,n]=coef[m,r]*vt[r,n], where
25+
coef=u*sigma
26+
scalar_double : float
27+
Threshold (precision) as a double, default
28+
value is 1e-7
29+
boolean : bool
30+
Apply svd on the initial input data (true) or
31+
transposed (square matrix), default
32+
value is false
33+
34+
35+
Examples
36+
--------
37+
>>> from ansys.dpf import core as dpf
38+
39+
>>> # Instantiate operator
40+
>>> op = dpf.operators.compression.apply_svd()
41+
42+
>>> # Make input connections
43+
>>> my_field_contaner_to_compress = dpf.FieldsContainer()
44+
>>> op.inputs.field_contaner_to_compress.connect(my_field_contaner_to_compress)
45+
>>> my_scalar_int = int()
46+
>>> op.inputs.scalar_int.connect(my_scalar_int)
47+
>>> my_scalar_double = float()
48+
>>> op.inputs.scalar_double.connect(my_scalar_double)
49+
>>> my_boolean = bool()
50+
>>> op.inputs.boolean.connect(my_boolean)
51+
52+
>>> # Instantiate operator and connect inputs in one line
53+
>>> op = dpf.operators.compression.apply_svd(
54+
... field_contaner_to_compress=my_field_contaner_to_compress,
55+
... scalar_int=my_scalar_int,
56+
... scalar_double=my_scalar_double,
57+
... boolean=my_boolean,
58+
... )
59+
60+
>>> # Get output data
61+
>>> result_us_svd = op.outputs.us_svd()
62+
>>> result_vt_svd = op.outputs.vt_svd()
63+
>>> result_sigma = op.outputs.sigma()
64+
"""
65+
66+
def __init__(
67+
self,
68+
field_contaner_to_compress=None,
69+
scalar_int=None,
70+
scalar_double=None,
71+
boolean=None,
72+
config=None,
73+
server=None,
74+
):
75+
super().__init__(name="svd_operator", config=config, server=server)
76+
self._inputs = InputsApplySvd(self)
77+
self._outputs = OutputsApplySvd(self)
78+
if field_contaner_to_compress is not None:
79+
self.inputs.field_contaner_to_compress.connect(field_contaner_to_compress)
80+
if scalar_int is not None:
81+
self.inputs.scalar_int.connect(scalar_int)
82+
if scalar_double is not None:
83+
self.inputs.scalar_double.connect(scalar_double)
84+
if boolean is not None:
85+
self.inputs.boolean.connect(boolean)
86+
87+
@staticmethod
88+
def _spec():
89+
description = (
90+
"""Computes the coefficients (=U*Sigma) and VT components from SVD."""
91+
)
92+
spec = Specification(
93+
description=description,
94+
map_input_pin_spec={
95+
0: PinSpecification(
96+
name="field_contaner_to_compress",
97+
type_names=["fields_container"],
98+
optional=False,
99+
document="""Fields container to be compressed""",
100+
),
101+
1: PinSpecification(
102+
name="scalar_int",
103+
type_names=["int32"],
104+
optional=False,
105+
document="""Number of vectors (r) to keep for the future
106+
reconstraction of the matrix a, ex.
107+
a[m,n]=coef[m,r]*vt[r,n], where
108+
coef=u*sigma""",
109+
),
110+
2: PinSpecification(
111+
name="scalar_double",
112+
type_names=["double"],
113+
optional=False,
114+
document="""Threshold (precision) as a double, default
115+
value is 1e-7""",
116+
),
117+
3: PinSpecification(
118+
name="boolean",
119+
type_names=["bool"],
120+
optional=False,
121+
document="""Apply svd on the initial input data (true) or
122+
transposed (square matrix), default
123+
value is false""",
124+
),
125+
},
126+
map_output_pin_spec={
127+
0: PinSpecification(
128+
name="us_svd",
129+
type_names=["fields_container"],
130+
optional=False,
131+
document="""The output entity is a field container (time
132+
dependant); it contains the
133+
multiplication of two matrices, u and
134+
s, where a=u.s.vt""",
135+
),
136+
1: PinSpecification(
137+
name="vt_svd",
138+
type_names=["fields_container"],
139+
optional=False,
140+
document="""The output entity is a field container (space
141+
dependant), containing the vt, where
142+
a=u.s.vt""",
143+
),
144+
2: PinSpecification(
145+
name="sigma",
146+
type_names=["field"],
147+
optional=False,
148+
document="""The output entity is a field, containing
149+
singular (s) values of the input
150+
data, where a=u.s.vt""",
151+
),
152+
},
153+
)
154+
return spec
155+
156+
@staticmethod
157+
def default_config(server=None):
158+
"""Returns the default config of the operator.
159+
160+
This config can then be changed to the user needs and be used to
161+
instantiate the operator. The Configuration allows to customize
162+
how the operation will be processed by the operator.
163+
164+
Parameters
165+
----------
166+
server : server.DPFServer, optional
167+
Server with channel connected to the remote or local instance. When
168+
``None``, attempts to use the global server.
169+
"""
170+
return Operator.default_config(name="svd_operator", server=server)
171+
172+
@property
173+
def inputs(self):
174+
"""Enables to connect inputs to the operator
175+
176+
Returns
177+
--------
178+
inputs : InputsApplySvd
179+
"""
180+
return super().inputs
181+
182+
@property
183+
def outputs(self):
184+
"""Enables to get outputs of the operator by evaluating it
185+
186+
Returns
187+
--------
188+
outputs : OutputsApplySvd
189+
"""
190+
return super().outputs
191+
192+
193+
class InputsApplySvd(_Inputs):
194+
"""Intermediate class used to connect user inputs to
195+
apply_svd operator.
196+
197+
Examples
198+
--------
199+
>>> from ansys.dpf import core as dpf
200+
>>> op = dpf.operators.compression.apply_svd()
201+
>>> my_field_contaner_to_compress = dpf.FieldsContainer()
202+
>>> op.inputs.field_contaner_to_compress.connect(my_field_contaner_to_compress)
203+
>>> my_scalar_int = int()
204+
>>> op.inputs.scalar_int.connect(my_scalar_int)
205+
>>> my_scalar_double = float()
206+
>>> op.inputs.scalar_double.connect(my_scalar_double)
207+
>>> my_boolean = bool()
208+
>>> op.inputs.boolean.connect(my_boolean)
209+
"""
210+
211+
def __init__(self, op: Operator):
212+
super().__init__(apply_svd._spec().inputs, op)
213+
self._field_contaner_to_compress = Input(
214+
apply_svd._spec().input_pin(0), 0, op, -1
215+
)
216+
self._inputs.append(self._field_contaner_to_compress)
217+
self._scalar_int = Input(apply_svd._spec().input_pin(1), 1, op, -1)
218+
self._inputs.append(self._scalar_int)
219+
self._scalar_double = Input(apply_svd._spec().input_pin(2), 2, op, -1)
220+
self._inputs.append(self._scalar_double)
221+
self._boolean = Input(apply_svd._spec().input_pin(3), 3, op, -1)
222+
self._inputs.append(self._boolean)
223+
224+
@property
225+
def field_contaner_to_compress(self):
226+
"""Allows to connect field_contaner_to_compress input to the operator.
227+
228+
Fields container to be compressed
229+
230+
Parameters
231+
----------
232+
my_field_contaner_to_compress : FieldsContainer
233+
234+
Examples
235+
--------
236+
>>> from ansys.dpf import core as dpf
237+
>>> op = dpf.operators.compression.apply_svd()
238+
>>> op.inputs.field_contaner_to_compress.connect(my_field_contaner_to_compress)
239+
>>> # or
240+
>>> op.inputs.field_contaner_to_compress(my_field_contaner_to_compress)
241+
"""
242+
return self._field_contaner_to_compress
243+
244+
@property
245+
def scalar_int(self):
246+
"""Allows to connect scalar_int input to the operator.
247+
248+
Number of vectors (r) to keep for the future
249+
reconstraction of the matrix a, ex.
250+
a[m,n]=coef[m,r]*vt[r,n], where
251+
coef=u*sigma
252+
253+
Parameters
254+
----------
255+
my_scalar_int : int
256+
257+
Examples
258+
--------
259+
>>> from ansys.dpf import core as dpf
260+
>>> op = dpf.operators.compression.apply_svd()
261+
>>> op.inputs.scalar_int.connect(my_scalar_int)
262+
>>> # or
263+
>>> op.inputs.scalar_int(my_scalar_int)
264+
"""
265+
return self._scalar_int
266+
267+
@property
268+
def scalar_double(self):
269+
"""Allows to connect scalar_double input to the operator.
270+
271+
Threshold (precision) as a double, default
272+
value is 1e-7
273+
274+
Parameters
275+
----------
276+
my_scalar_double : float
277+
278+
Examples
279+
--------
280+
>>> from ansys.dpf import core as dpf
281+
>>> op = dpf.operators.compression.apply_svd()
282+
>>> op.inputs.scalar_double.connect(my_scalar_double)
283+
>>> # or
284+
>>> op.inputs.scalar_double(my_scalar_double)
285+
"""
286+
return self._scalar_double
287+
288+
@property
289+
def boolean(self):
290+
"""Allows to connect boolean input to the operator.
291+
292+
Apply svd on the initial input data (true) or
293+
transposed (square matrix), default
294+
value is false
295+
296+
Parameters
297+
----------
298+
my_boolean : bool
299+
300+
Examples
301+
--------
302+
>>> from ansys.dpf import core as dpf
303+
>>> op = dpf.operators.compression.apply_svd()
304+
>>> op.inputs.boolean.connect(my_boolean)
305+
>>> # or
306+
>>> op.inputs.boolean(my_boolean)
307+
"""
308+
return self._boolean
309+
310+
311+
class OutputsApplySvd(_Outputs):
312+
"""Intermediate class used to get outputs from
313+
apply_svd operator.
314+
315+
Examples
316+
--------
317+
>>> from ansys.dpf import core as dpf
318+
>>> op = dpf.operators.compression.apply_svd()
319+
>>> # Connect inputs : op.inputs. ...
320+
>>> result_us_svd = op.outputs.us_svd()
321+
>>> result_vt_svd = op.outputs.vt_svd()
322+
>>> result_sigma = op.outputs.sigma()
323+
"""
324+
325+
def __init__(self, op: Operator):
326+
super().__init__(apply_svd._spec().outputs, op)
327+
self._us_svd = Output(apply_svd._spec().output_pin(0), 0, op)
328+
self._outputs.append(self._us_svd)
329+
self._vt_svd = Output(apply_svd._spec().output_pin(1), 1, op)
330+
self._outputs.append(self._vt_svd)
331+
self._sigma = Output(apply_svd._spec().output_pin(2), 2, op)
332+
self._outputs.append(self._sigma)
333+
334+
@property
335+
def us_svd(self):
336+
"""Allows to get us_svd output of the operator
337+
338+
Returns
339+
----------
340+
my_us_svd : FieldsContainer
341+
342+
Examples
343+
--------
344+
>>> from ansys.dpf import core as dpf
345+
>>> op = dpf.operators.compression.apply_svd()
346+
>>> # Connect inputs : op.inputs. ...
347+
>>> result_us_svd = op.outputs.us_svd()
348+
""" # noqa: E501
349+
return self._us_svd
350+
351+
@property
352+
def vt_svd(self):
353+
"""Allows to get vt_svd output of the operator
354+
355+
Returns
356+
----------
357+
my_vt_svd : FieldsContainer
358+
359+
Examples
360+
--------
361+
>>> from ansys.dpf import core as dpf
362+
>>> op = dpf.operators.compression.apply_svd()
363+
>>> # Connect inputs : op.inputs. ...
364+
>>> result_vt_svd = op.outputs.vt_svd()
365+
""" # noqa: E501
366+
return self._vt_svd
367+
368+
@property
369+
def sigma(self):
370+
"""Allows to get sigma output of the operator
371+
372+
Returns
373+
----------
374+
my_sigma : Field
375+
376+
Examples
377+
--------
378+
>>> from ansys.dpf import core as dpf
379+
>>> op = dpf.operators.compression.apply_svd()
380+
>>> # Connect inputs : op.inputs. ...
381+
>>> result_sigma = op.outputs.sigma()
382+
""" # noqa: E501
383+
return self._sigma

0 commit comments

Comments
 (0)