h2lib 13.1.304__py3-none-win_amd64.whl → 13.1.502__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
h2lib/HAWC2Lib.dll CHANGED
Binary file
h2lib/_h2lib.py CHANGED
@@ -209,6 +209,8 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
209
209
  """
210
210
  if time is None:
211
211
  time = self.get_time()
212
+ uvw = np.asarray(uvw, dtype=np.float32)
213
+ assert np.all(np.isfinite(uvw)), "uvw passed to h2lib.set_windfield contains nan or inf"
212
214
  return H2LibSignatures.set_windfield(self, np.asarray(uvw, dtype=np.float32),
213
215
  np.float64(box_offset_x), np.float64(time))
214
216
 
@@ -300,6 +302,191 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
300
302
  vx, vy, vz = self.get_rotor_avg_wsp(1, rotor)
301
303
  return [vy, vx, -vz]
302
304
 
305
+ def init_static_solver(self):
306
+ """
307
+ Initialize the static solver.
308
+
309
+ Raises
310
+ ------
311
+ RuntimeError
312
+ If the static solver has already been initialized.
313
+
314
+ Returns
315
+ -------
316
+ None.
317
+
318
+ """
319
+ error_code = H2LibSignatures.init_static_solver(self, restype=np.int64)[1]
320
+ if error_code > 0:
321
+ if error_code == 102:
322
+ raise RuntimeError("STATIC_SOLVER_ALREADY_INITIALIZED")
323
+ raise RuntimeError(error_code) # pragma: no cover
324
+
325
+ def get_number_of_bodies_and_constraints(self):
326
+ """
327
+ Get number of bodies and constraints.
328
+
329
+ Raises
330
+ ------
331
+ RuntimeError
332
+ If the structure is confidential.
333
+
334
+ Returns
335
+ -------
336
+ nbdy : int
337
+ Number of bodies.
338
+ ncst : int
339
+ Number of constraints.
340
+
341
+ """
342
+ nbdy = -1
343
+ ncst = -1
344
+ error_code = -1
345
+ (
346
+ nbdy,
347
+ ncst,
348
+ error_code,
349
+ ) = H2LibSignatures.get_number_of_bodies_and_constraints(
350
+ self, nbdy, ncst, error_code
351
+ )[
352
+ 0
353
+ ]
354
+ if error_code > 0:
355
+ if error_code == 4:
356
+ raise RuntimeError("STRUCTURE_IS_CONFIDENTIAL")
357
+ raise RuntimeError(error_code) # pragma: no cover
358
+ return nbdy, ncst
359
+
360
+ def get_number_of_elements(self):
361
+ """
362
+ Get the number of elements for each body.
363
+
364
+ Raises
365
+ ------
366
+ RuntimeError
367
+ If the structure is confidential.
368
+
369
+ Returns
370
+ -------
371
+ nelem : (nbdy) ndarray, int
372
+ Number of elements for each body.
373
+
374
+ """
375
+ nbdy, _ = self.get_number_of_bodies_and_constraints()
376
+
377
+ nelem = np.zeros((nbdy, ), dtype=np.int64, order="F")
378
+ error_code = -1
379
+ _, nelem, error_code = H2LibSignatures.get_number_of_elements(
380
+ self, nbdy, nelem, error_code
381
+ )[0]
382
+
383
+ if error_code > 0:
384
+ if error_code == 4: # pragma: no cover
385
+ # This cannot happen because if the structure is confidential we will
386
+ # get this error from get_number_of_bodies_and_constraints().
387
+ raise RuntimeError("STRUCTURE_IS_CONFIDENTIAL") # pragma: no cover
388
+ elif error_code == 7: # pragma: no cover
389
+ # This cannot happen because we call get_number_of_bodies_and_constraints().
390
+ raise ValueError("WRONG_NUMBER_OF_BODIES") # pragma: no cover
391
+ raise RuntimeError(error_code) # pragma: no cover
392
+ return nelem
393
+
394
+ def get_timoshenko_location(self, ibdy, ielem):
395
+ """
396
+ Get the location and orientation of an element.
397
+
398
+ Parameters
399
+ ----------
400
+ ibdy : int
401
+ Body index, starting from 0.
402
+ ielem : int
403
+ Element index, starting from 0.
404
+
405
+ Raises
406
+ ------
407
+ RuntimeError
408
+ If the structure is confidential.
409
+ IndexError
410
+ If the body or the element do not exist.
411
+
412
+ Returns
413
+ -------
414
+ l : float
415
+ Element length.
416
+ r1 : (3) ndarray
417
+ Location of node 1.
418
+ r12 : (3) ndarray
419
+ Vector from node 1 to node 2.
420
+ tes : (3, 3) ndarray
421
+ Transformation matrix describing orientation.
422
+
423
+ """
424
+
425
+ l = 0.0
426
+ r1 = np.zeros((3), order="F")
427
+ r12 = np.zeros((3), order="F")
428
+ tes = np.zeros((3, 3), order="F")
429
+ error_code = -1
430
+ (
431
+ _,
432
+ _,
433
+ l,
434
+ r1,
435
+ r12,
436
+ tes,
437
+ error_code,
438
+ ) = H2LibSignatures.get_timoshenko_location(
439
+ self, ibdy + 1, ielem + 1, l, r1, r12, tes, error_code
440
+ )[
441
+ 0
442
+ ]
443
+ if error_code > 0:
444
+ if error_code == 4:
445
+ raise RuntimeError("STRUCTURE_IS_CONFIDENTIAL")
446
+ elif error_code == 5:
447
+ raise IndexError("BODY_DOES_NOT_EXIST")
448
+ elif error_code == 6:
449
+ raise IndexError("ELEMENT_DOES_NOT_EXIST")
450
+ raise RuntimeError(error_code) # pragma: no cover
451
+
452
+ return l, r1, r12, tes
453
+
454
+ def get_body_rotation_tensor(self, ibdy):
455
+ """
456
+ Get the rotation tensor of the requested body, that transforms from local to global base.
457
+
458
+ Parameters
459
+ ----------
460
+ ibdy : int
461
+ Body index, starting from 0.
462
+
463
+ Raises
464
+ ------
465
+ RuntimeError
466
+ If the structure is confidential.
467
+ IndexError
468
+ If the body does not exist.
469
+
470
+ Returns
471
+ -------
472
+ amat : (3, 3) ndarray
473
+ Rotation tensor.
474
+
475
+ """
476
+ amat = np.zeros((3, 3), order="F")
477
+ error_code = -1
478
+ _, amat, error_code = H2LibSignatures.get_body_rotation_tensor(
479
+ self, ibdy + 1, amat, error_code
480
+ )[0]
481
+ if error_code > 0:
482
+ if error_code == 4:
483
+ raise RuntimeError("STRUCTURE_IS_CONFIDENTIAL")
484
+ elif error_code == 5:
485
+ raise IndexError("BODY_DOES_NOT_EXIST")
486
+ raise RuntimeError(error_code) # pragma: no cover
487
+
488
+ return amat
489
+
303
490
 
304
491
  @contextmanager
305
492
  def set_LD_LIBRARY_PATH():
h2lib/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is autogenerated and should not be modified manually
2
- __version__ = '13.1.304'
3
- h2lib_version = '13.1.304'
4
- hawc2_version = '13.1.3'
2
+ __version__ = '13.1.502'
3
+ h2lib_version = '13.1.502'
4
+ hawc2_version = '13.1.5+4-g20eca1a'
h2lib/dll_wrapper.py CHANGED
@@ -8,6 +8,7 @@ import ctypes
8
8
  from _ctypes import POINTER
9
9
  from ctypes import c_int, c_double, c_char, c_char_p, c_long, c_longlong
10
10
  from contextlib import contextmanager
11
+ import tempfile
11
12
  try:
12
13
  from ctypes import windll
13
14
  except ImportError:
@@ -26,23 +27,20 @@ in_use = []
26
27
 
27
28
  class SuppressStream(object):
28
29
 
29
- def __init__(self, stream=sys.stderr):
30
+ def __init__(self, suppressed_output_file, stream=sys.stderr):
30
31
  self.orig_stream_fileno = stream.fileno()
31
32
  self.stream = stream
33
+ self.suppressed_output_file = suppressed_output_file
32
34
 
33
35
  def __enter__(self):
34
36
  # save stream file descriptor
35
37
  self.orig_stream_dup = os.dup(self.orig_stream_fileno)
36
- self.devnull = open(os.devnull, 'w')
37
38
  self.stream.flush()
38
- os.dup2(self.devnull.fileno(), self.orig_stream_fileno)
39
+ os.dup2(self.suppressed_output_file.fileno(), self.orig_stream_fileno)
39
40
 
40
41
  def __exit__(self, type, value, traceback):
41
- os.close(self.orig_stream_fileno)
42
42
  os.dup2(self.orig_stream_dup, self.orig_stream_fileno)
43
43
  os.close(self.orig_stream_dup)
44
- self.devnull.flush()
45
- self.devnull.close()
46
44
 
47
45
 
48
46
  def suppress_output(f):
@@ -124,7 +122,7 @@ def wrap(self, f, *args, **kwargs):
124
122
  f.restype = restype
125
123
  with chdir(self.cwd):
126
124
  if self.suppress_output:
127
- with SuppressStream(sys.stdout), SuppressStream(sys.stderr):
125
+ with SuppressStream(self.suppressed_output_file, sys.stdout), SuppressStream(self.suppressed_output_file, sys.stderr):
128
126
  res = f(*c_args)
129
127
  else:
130
128
  res = f(*c_args)
@@ -152,6 +150,7 @@ class DLLWrapper(object):
152
150
  self.cdecl = cdecl
153
151
  self.fortran = fortran
154
152
  self.suppress_output = False
153
+ self.suppressed_output_file = tempfile.TemporaryFile('w')
155
154
  self.open()
156
155
  in_use.append(os.path.abspath(self.filename))
157
156
  atexit.register(self.close)
@@ -211,6 +210,7 @@ class DLLWrapper(object):
211
210
  else:
212
211
  _ctypes.dlclose(self.lib._handle)
213
212
  del self.lib
213
+ self.suppressed_output_file.close()
214
214
  atexit.unregister(self.close)
215
215
  in_use.remove(os.path.abspath(self.filename))
216
216
 
h2lib/h2lib_signatures.py CHANGED
@@ -98,6 +98,14 @@ END SUBROUTINE'''
98
98
  end subroutine'''
99
99
  return self.get_lib_function('get_bem_grid_dim')(rotor, nazi, nrad)
100
100
 
101
+ def get_body_rotation_tensor(self, ibdy, amat, error_code):
102
+ '''subroutine get_body_rotation_tensor(ibdy, amat, error_code) &
103
+ integer(kind=8), intent(in) :: ibdy
104
+ real(kind=c_double), dimension(3, 3), intent(out) :: amat
105
+ integer(kind=8), intent(out) :: error_code
106
+ end subroutine'''
107
+ return self.get_lib_function('get_body_rotation_tensor')(ibdy, amat, error_code)
108
+
101
109
  def get_diameter(self, rotor, restype):
102
110
  '''function get_diameter(rotor) bind(C, name="get_diameter")
103
111
  !DEC$ ATTRIBUTES DLLEXPORT :: get_diameter
@@ -152,6 +160,22 @@ END SUBROUTINE'''
152
160
  end function'''
153
161
  return self.get_lib_function('get_nrotors')(restype=restype)
154
162
 
163
+ def get_number_of_bodies_and_constraints(self, nbdy, ncst, error_code):
164
+ '''subroutine get_number_of_bodies_and_constraints(nbdy, ncst, error_code) &
165
+ integer(kind=8), intent(out) :: nbdy
166
+ integer(kind=8), intent(out) :: ncst
167
+ integer(kind=8), intent(out) :: error_code
168
+ end subroutine'''
169
+ return self.get_lib_function('get_number_of_bodies_and_constraints')(nbdy, ncst, error_code)
170
+
171
+ def get_number_of_elements(self, nbdy, nelem, error_code):
172
+ '''subroutine get_number_of_elements(nbdy, nelem, error_code) &
173
+ integer(kind=8), intent(in) :: nbdy
174
+ integer(kind=8), dimension(nbdy), intent(out) :: nelem
175
+ integer(kind=8), intent(out) :: error_code
176
+ end subroutine'''
177
+ return self.get_lib_function('get_number_of_elements')(nbdy, nelem, error_code)
178
+
155
179
  def get_rotor_avg_wsp(self, coo, rotor, wsp):
156
180
  '''subroutine get_rotor_avg_wsp(coo, rotor, wsp) bind(C, name="get_rotor_avg_wsp")
157
181
  integer*8, intent(in) :: rotor
@@ -199,6 +223,18 @@ END SUBROUTINE'''
199
223
  subroutine'''
200
224
  return self.get_lib_function('get_time')(time)
201
225
 
226
+ def get_timoshenko_location(self, ibdy, ielem, l, r1, r12, tes, error_code):
227
+ '''subroutine get_timoshenko_location(ibdy, ielem, l, r1, r12, tes, error_code) &
228
+ integer(kind=8), intent(in) :: ibdy
229
+ integer(kind=8), intent(in) :: ielem
230
+ real(kind=c_double), intent(out) :: l
231
+ real(kind=c_double), dimension(3), intent(out) :: r1
232
+ real(kind=c_double), dimension(3), intent(out) :: r12
233
+ real(kind=c_double), dimension(3,3), intent(out) :: tes
234
+ integer(kind=8), intent(out) :: error_code
235
+ end subroutine'''
236
+ return self.get_lib_function('get_timoshenko_location')(ibdy, ielem, l, r1, r12, tes, error_code)
237
+
202
238
  def get_version(self, s):
203
239
  '''subroutine get_version(s) BIND(C, NAME='get_version')
204
240
  character(kind=c_char, len=1), intent(inout) :: s(255)
@@ -211,6 +247,12 @@ subroutine'''
211
247
  end subroutine'''
212
248
  return self.get_lib_function('init')()
213
249
 
250
+ def init_static_solver(self, restype):
251
+ '''function init_static_solver() result(error_code) &
252
+ !DEC$ ATTRIBUTES DLLEXPORT :: init_static_solver
253
+ end function'''
254
+ return self.get_lib_function('init_static_solver')(restype=restype)
255
+
214
256
  def init_windfield(self, Nxyz, dxyz, box_offset_yz, transport_speed):
215
257
  '''subroutine init_windfield(Nxyz, dxyz, box_offset_yz, transport_speed) bind(C, name="init_windfield")
216
258
  integer*8, dimension(3), intent(in) :: Nxyz
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: h2lib
3
- Version: 13.1.304
4
- Summary: Python interface to HAWC2 (13.1.3)
3
+ Version: 13.1.502
4
+ Summary: Python interface to HAWC2 (13.1.5+4-g20eca1a)
5
5
  Download-URL:
6
6
  Author: Mads M. Pedersen, S.G.Horcas and N.G.Ramos
7
7
  Author-email: mmpe@dtu.dk
@@ -0,0 +1,10 @@
1
+ h2lib/HAWC2Lib.dll,sha256=2JrIAyXlyeUiAyOOX9inxULx_bAgWop63-hg2dvcKMQ,30576128
2
+ h2lib/__init__.py,sha256=f3fO4I6IEFRM9LaV2O3w9Pioj3GPI8qRl7P5Tg5ONtE,528
3
+ h2lib/_h2lib.py,sha256=itCf0sXkdYekNLg9fFu_zi9n_pCV660SvbRoD8clPDk,20558
4
+ h2lib/_version.py,sha256=9aTddFhC7_u7dLkV6GCDiIhcgLJ1Ut8MRjf6wzuQQjI,157
5
+ h2lib/dll_wrapper.py,sha256=RC5_gJ1cwHXVfUaSvmsatyQrvks-aZJFAiXrG4B-FEI,12061
6
+ h2lib/h2lib_signatures.py,sha256=j0TL8Zv6kX18F28X5cdzTlwQd1ZKiyg_zVBRqdOCPhY,16858
7
+ h2lib-13.1.502.dist-info/METADATA,sha256=CTzQQAHq9U-4BIisfWmEbr_OY0kWT87Hn_O6yMTyaTM,738
8
+ h2lib-13.1.502.dist-info/WHEEL,sha256=3vidnDuZ-QSnHIxLhNbI1gIM-KgyEcMHuZuv1mWPd_Q,101
9
+ h2lib-13.1.502.dist-info/top_level.txt,sha256=y_a-tUqphEZQ_0nsWSMaSb21P8Lsd8hUxUdE9g2Dcbk,6
10
+ h2lib-13.1.502.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-win_amd64
5
5
 
@@ -1,10 +0,0 @@
1
- h2lib/HAWC2Lib.dll,sha256=KSsiNknsQ_PEfMkmpNKVUv7FAAiKo-nC_tVWEF9EOnc,29877248
2
- h2lib/__init__.py,sha256=f3fO4I6IEFRM9LaV2O3w9Pioj3GPI8qRl7P5Tg5ONtE,528
3
- h2lib/_h2lib.py,sha256=RBwI5FPkepo05pFSg50Go6i_ye9hthgmgSCm8k6DEyg,14990
4
- h2lib/_version.py,sha256=iizTBXTu347A-uMlr6INY1FMuezX-9BSyagu6qZtgmk,146
5
- h2lib/dll_wrapper.py,sha256=xQicDPnhK0Zgr3ifHX1peLJ6uwYZvXxLQAt9LIu45RY,11922
6
- h2lib/h2lib_signatures.py,sha256=KO7HJzoy6GUXnkRt_VBbwa5_RVKZlLV1cKonHTMm2TQ,14732
7
- h2lib-13.1.304.dist-info/METADATA,sha256=kNXLUUDqqpzPAM8g4isV3Th7UBwW7Fj17snXmZhz2C0,727
8
- h2lib-13.1.304.dist-info/WHEEL,sha256=KNRoynpGu-d6mheJI-zfvcGl1iN-y8BewbiCDXsF3cY,101
9
- h2lib-13.1.304.dist-info/top_level.txt,sha256=y_a-tUqphEZQ_0nsWSMaSb21P8Lsd8hUxUdE9g2Dcbk,6
10
- h2lib-13.1.304.dist-info/RECORD,,