コード例 #1
0
ファイル: function.py プロジェクト: connorjward/firedrake
class _CFunction(ctypes.Structure):
    r"""C struct collecting data from a :class:`Function`"""
    _fields_ = [("n_cols", c_int),
                ("extruded", c_int),
                ("n_layers", c_int),
                ("coords", c_void_p),
                ("coords_map", POINTER(as_ctypes(IntType))),
                ("f", c_void_p),
                ("f_map", POINTER(as_ctypes(IntType))),
                ("sidx", c_void_p)]
コード例 #2
0
ファイル: function.py プロジェクト: zxdhpc/firedrake
    def _constant_ctypes(self):
        # Retrieve data from Python object
        function_space = self.function_space()
        mesh = function_space.mesh()
        coordinates = mesh.coordinates
        coordinates_space = coordinates.function_space()

        # Store data into ``C struct''
        c_function = _CFunction()
        c_function.n_cols = mesh.num_cells()
        if mesh.layers is not None:
            # TODO: assert constant layer. Can we do variable though?
            c_function.extruded = 1
            c_function.n_layers = mesh.layers - 1
        else:
            c_function.extruded = 0
            c_function.n_layers = 1
        c_function.coords = coordinates.dat.data.ctypes.data_as(c_void_p)
        c_function.coords_map = coordinates_space.cell_node_list.ctypes.data_as(
            POINTER(as_ctypes(IntType)))
        c_function.f = self.dat.data.ctypes.data_as(c_void_p)
        c_function.f_map = function_space.cell_node_list.ctypes.data_as(
            POINTER(as_ctypes(IntType)))
        return c_function