xref: /libCEED/python/ceed_constants.py (revision 50c301a53d2cec48a2aa861bf6f38393f4831c2f)
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# CeedScalarType
30SCALAR_FP32 = lib.CEED_SCALAR_FP32
31SCALAR_FP64 = lib.CEED_SCALAR_FP64
32scalar_types = {SCALAR_FP32: "float32",
33                SCALAR_FP64: "float64"}
34# Machine eps corresponding to CeedScalar
35EPSILON = lib.CEED_EPSILON
36
37# CeedCopyMode
38COPY_VALUES = lib.CEED_COPY_VALUES
39USE_POINTER = lib.CEED_USE_POINTER
40OWN_POINTER = lib.CEED_OWN_POINTER
41copy_modes = {COPY_VALUES: "copy values",
42              USE_POINTER: "use pointer",
43              OWN_POINTER: "own pointer"}
44
45# CeedNormType
46NORM_1 = lib.CEED_NORM_1
47NORM_2 = lib.CEED_NORM_2
48NORM_MAX = lib.CEED_NORM_MAX
49norm_types = {NORM_1: "L1 norm",
50              NORM_2: "L2 norm",
51              NORM_MAX: "max norm"}
52
53# CeedTransposeMode
54TRANSPOSE = lib.CEED_TRANSPOSE
55NOTRANSPOSE = lib.CEED_NOTRANSPOSE
56transpose_modes = {TRANSPOSE: "transpose",
57                   NOTRANSPOSE: "no transpose"}
58
59# CeedEvalMode
60EVAL_NONE = lib.CEED_EVAL_NONE
61EVAL_INTERP = lib.CEED_EVAL_INTERP
62EVAL_GRAD = lib.CEED_EVAL_GRAD
63EVAL_DIV = lib.CEED_EVAL_DIV
64EVAL_CURL = lib.CEED_EVAL_CURL
65EVAL_WEIGHT = lib.CEED_EVAL_WEIGHT
66eval_modes = {EVAL_NONE: "none",
67              EVAL_INTERP: "interpolation",
68              EVAL_GRAD: "gradient",
69              EVAL_DIV: "divergence",
70              EVAL_CURL: "curl",
71              EVAL_WEIGHT: "quadrature weights"}
72
73# CeedQuadMode
74GAUSS = lib.CEED_GAUSS
75GAUSS_LOBATTO = lib.CEED_GAUSS_LOBATTO
76quad_modes = {GAUSS: "Gauss",
77              GAUSS_LOBATTO: "Gauss Lobatto"}
78
79# CeedElemTopology
80LINE = lib.CEED_TOPOLOGY_LINE
81TRIANGLE = lib.CEED_TOPOLOGY_TRIANGLE
82QUAD = lib.CEED_TOPOLOGY_QUAD
83TET = lib.CEED_TOPOLOGY_TET
84PYRAMID = lib.CEED_TOPOLOGY_PYRAMID
85PRISM = lib.CEED_TOPOLOGY_PRISM
86HEX = lib.CEED_TOPOLOGY_HEX
87elem_topologies = {LINE: "line",
88                   TRIANGLE: "triangle",
89                   QUAD: "quadrilateral",
90                   TET: "tetrahedron",
91                   PYRAMID: "pyramid",
92                   PRISM: "prism",
93                   HEX: "hexahedron"}
94
95# ------------------------------------------------------------------------------
96# Ceed Constants
97# ------------------------------------------------------------------------------
98
99# Requests
100REQUEST_IMMEDIATE = lib.CEED_REQUEST_IMMEDIATE
101REQUEST_ORDERED = lib.CEED_REQUEST_ORDERED
102
103# Object shell
104
105
106class _CeedConstantObject(ABC):
107    """Shell for holding constant Vector and Basis constants."""
108
109    def __init__(self, constant):
110        self._pointer = [constant]
111
112
113# Vectors
114VECTOR_ACTIVE = _CeedConstantObject(lib.CEED_VECTOR_ACTIVE)
115VECTOR_NONE = _CeedConstantObject(lib.CEED_VECTOR_NONE)
116
117# ElemRestriction
118ELEMRESTRICTION_NONE = _CeedConstantObject(lib.CEED_ELEMRESTRICTION_NONE)
119
120# Basis
121BASIS_COLLOCATED = _CeedConstantObject(lib.CEED_BASIS_COLLOCATED)
122
123# ------------------------------------------------------------------------------
124