source: CPL/oasis3-mct_5.0/pyoasis/src/mod_oasis_method.py @ 6328

Last change on this file since 6328 was 6328, checked in by aclsce, 17 months ago

First import of oasis3-mct_5.0 (from oasis git server, branch OASIS3-MCT_5.0)

File size: 2.3 KB
Line 
1# pyOASIS - A Python wrapper for OASIS
2# Authors: Philippe Gambron, Rupert Ford
3# Copyright (C) 2019 UKRI - STFC
4
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as
7# published by the Free Software Foundation, either version 3 of the
8# License, or any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Lesser General Public License for more details.
14
15# A copy of the GNU Lesser General Public License, version 3, is supplied
16# with this program, in the file lgpl-3.0.txt. It is also available at
17# <https://www.gnu.org/licenses/lgpl-3.0.html>.
18
19
20"""High level OASIS user interfaces"""
21
22import ctypes
23from ctypes import cdll, CDLL, c_int, c_char_p
24
25
26cdll.LoadLibrary("liboasis.cbind.so")
27LIB = CDLL("liboasis.cbind.so")
28
29
30LIB.oasis_c_init_comp_with_comm_iso2c.argtypes = [ctypes.POINTER(ctypes.c_int), c_char_p,
31                          ctypes.c_bool, ctypes.c_int]
32LIB.oasis_c_init_comp_with_comm_iso2c.restype = ctypes.c_int
33
34
35def init_comp_with_comm(comp_name, coupled, communicator):
36    """OASIS user init method"""
37    comp_id = c_int(0)
38    kinfo = c_int(0)
39    kinfo = LIB.oasis_c_init_comp_with_comm_iso2c(comp_id, comp_name.encode(), coupled,
40                  communicator.py2f())
41    return comp_id.value, kinfo
42
43
44LIB.oasis_c_init_comp_iso2c.argtypes = [ctypes.POINTER(ctypes.c_int), c_char_p,
45                          ctypes.c_bool]
46LIB.oasis_c_init_comp_iso2c.restype = ctypes.c_int
47
48
49def init_comp(comp_name, coupled):
50    """OASIS user init method"""
51    comp_id = c_int(0)
52    kinfo = c_int(0)
53    kinfo = LIB.oasis_c_init_comp_iso2c(comp_id, comp_name.encode(), coupled)
54    return comp_id.value, kinfo
55
56
57LIB.oasis_c_enddef.argtypes = None
58LIB.oasis_c_enddef.restype = ctypes.c_int
59
60
61def enddef():
62    """OASIS user interface specifying the OASIS definition phase is complete"""
63    kinfo = c_int(0)
64    kinfo = LIB.oasis_c_enddef()
65    return kinfo
66
67
68LIB.oasis_c_terminate.argtypes = None
69LIB.oasis_c_terminate.restype = ctypes.c_int
70
71
72def terminate():
73    """OASIS user finalize method"""
74    kinfo = c_int(0)
75    kinfo = LIB.oasis_c_terminate()
76    return kinfo
Note: See TracBrowser for help on using the repository browser.