xref: /libCEED/python/ceed_constants.py (revision 8a059566a00d2f44ccef3f872c398f1e412e74dd)
1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3# reserved. See files LICENSE and NOTICE for details.
4#
5# This file is part of CEED, a collection of benchmarks, miniapps, software
6# libraries and APIs for efficient high-order finite element and spectral
7# element discretizations for exascale applications. For more information and
8# source code availability see http://github.com/ceed.
9#
10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11# a collaborative effort of two U.S. Department of Energy organizations (Office
12# of Science and the National Nuclear Security Administration) responsible for
13# the planning and preparation of a capable exascale ecosystem, including
14# software, applications, hardware, advanced system engineering and early
15# testbed platforms, in support of the nation's exascale computing imperative.
16
17from _ceed_cffi import ffi, lib
18from abc import ABC
19
20# ------------------------------------------------------------------------------
21# Ceed Enums
22# ------------------------------------------------------------------------------
23# CeedMemType
24MEM_HOST = lib.CEED_MEM_HOST
25MEM_DEVICE = lib.CEED_MEM_DEVICE
26mem_types = {MEM_HOST: "host",
27             MEM_DEVICE: "device"}
28
29# CeedCopyMode
30COPY_VALUES = lib.CEED_COPY_VALUES
31USE_POINTER = lib.CEED_USE_POINTER
32OWN_POINTER = lib.CEED_OWN_POINTER
33copy_modes = {COPY_VALUES: "copy values",
34              USE_POINTER: "use pointer",
35              OWN_POINTER: "own pointer"}
36
37# CeedNormType
38NORM_1 = lib.CEED_NORM_1
39NORM_2 = lib.CEED_NORM_2
40NORM_MAX = lib.CEED_NORM_MAX
41norm_types = {NORM_1: "L1 norm",
42              NORM_2: "L2 norm",
43              NORM_MAX: "max norm"}
44
45# CeedTransposeMode
46TRANSPOSE = lib.CEED_TRANSPOSE
47NOTRANSPOSE = lib.CEED_NOTRANSPOSE
48transpose_modes = {TRANSPOSE: "transpose",
49                   NOTRANSPOSE: "no transpose"}
50
51# CeedEvalMode
52EVAL_NONE = lib.CEED_EVAL_NONE
53EVAL_INTERP = lib.CEED_EVAL_INTERP
54EVAL_GRAD = lib.CEED_EVAL_GRAD
55EVAL_DIV = lib.CEED_EVAL_DIV
56EVAL_CURL = lib.CEED_EVAL_CURL
57EVAL_WEIGHT = lib.CEED_EVAL_WEIGHT
58eval_modes = {EVAL_NONE: "none",
59              EVAL_INTERP: "interpolation",
60              EVAL_GRAD: "gradient",
61              EVAL_DIV: "divergence",
62              EVAL_CURL: "curl",
63              EVAL_WEIGHT: "quadrature weights"}
64
65# CeedQuadMode
66GAUSS = lib.CEED_GAUSS
67GAUSS_LOBATTO = lib.CEED_GAUSS_LOBATTO
68quad_modes = {GAUSS: "Gauss",
69              GAUSS_LOBATTO: "Gauss Lobatto"}
70
71# CeedElemTopology
72LINE = lib.CEED_LINE
73TRIANGLE = lib.CEED_TRIANGLE
74QUAD = lib.CEED_QUAD
75TET = lib.CEED_TET
76PYRAMID = lib.CEED_PYRAMID
77PRISM = lib.CEED_PRISM
78HEX = lib.CEED_HEX
79elem_topologies = {LINE: "line",
80                   TRIANGLE: "triangle",
81                   QUAD: "quadrilateral",
82                   TET: "tetrahedron",
83                   PYRAMID: "pyramid",
84                   PRISM: "prism",
85                   HEX: "hexahedron"}
86
87# ------------------------------------------------------------------------------
88# Ceed Constants
89# ------------------------------------------------------------------------------
90
91# Requests
92REQUEST_IMMEDIATE = lib.CEED_REQUEST_IMMEDIATE
93REQUEST_ORDERED = lib.CEED_REQUEST_ORDERED
94
95# Object shell
96
97
98class _CeedConstantObject(ABC):
99    """Shell for holding constant Vector and Basis constants."""
100
101    def __init__(self, constant):
102        self._pointer = [constant]
103
104
105# Vectors
106VECTOR_ACTIVE = _CeedConstantObject(lib.CEED_VECTOR_ACTIVE)
107VECTOR_NONE = _CeedConstantObject(lib.CEED_VECTOR_NONE)
108
109# ElemRestriction
110ELEMRESTRICTION_NONE = _CeedConstantObject(lib.CEED_ELEMRESTRICTION_NONE)
111
112# Basis
113BASIS_COLLOCATED = _CeedConstantObject(lib.CEED_BASIS_COLLOCATED)
114
115# ------------------------------------------------------------------------------
116