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# CeedTransposeMode 38TRANSPOSE = lib.CEED_TRANSPOSE 39NOTRANSPOSE = lib.CEED_NOTRANSPOSE 40transpose_modes = {TRANSPOSE: "transpose", 41 NOTRANSPOSE: "no transpose"} 42 43# CeedEvalMode 44EVAL_NONE = lib.CEED_EVAL_NONE 45EVAL_INTERP = lib.CEED_EVAL_INTERP 46EVAL_GRAD = lib.CEED_EVAL_GRAD 47EVAL_DIV = lib.CEED_EVAL_DIV 48EVAL_CURL = lib.CEED_EVAL_CURL 49EVAL_WEIGHT = lib.CEED_EVAL_WEIGHT 50eval_modes = {EVAL_NONE: "none", 51 EVAL_INTERP: "interpolation", 52 EVAL_GRAD: "gradient", 53 EVAL_DIV: "divergence", 54 EVAL_CURL: "curl", 55 EVAL_WEIGHT: "quadrature weights"} 56 57# CeedQuadMode 58GAUSS = lib.CEED_GAUSS 59GAUSS_LOBATTO = lib.CEED_GAUSS_LOBATTO 60quad_modes = {GAUSS: "Gauss", 61 GAUSS_LOBATTO: "Gauss Lobatto"} 62 63# CeedElemTopology 64LINE = lib.CEED_LINE 65TRIANGLE = lib.CEED_TRIANGLE 66QUAD = lib.CEED_QUAD 67TET = lib.CEED_TET 68PYRAMID = lib.CEED_PYRAMID 69PRISM = lib.CEED_PRISM 70HEX = lib.CEED_HEX 71elem_topologies = {LINE: "line", 72 TRIANGLE: "triangle", 73 QUAD: "quadrilateral", 74 TET: "tetrahedron", 75 PYRAMID: "pyramid", 76 PRISM: "prism", 77 HEX: "hexahedron"} 78 79# ------------------------------------------------------------------------------ 80# Ceed Constants 81# ------------------------------------------------------------------------------ 82 83# Requests 84REQUEST_IMMEDIATE = lib.CEED_REQUEST_IMMEDIATE 85REQUEST_ORDERED = lib.CEED_REQUEST_ORDERED 86 87# Object shell 88class _CeedConstantObject(ABC): 89 """Shell for holding constant Vector and Basis constants.""" 90 91 def __init__(self, constant): 92 self._pointer = [constant] 93 94# Vectors 95VECTOR_ACTIVE = _CeedConstantObject(lib.CEED_VECTOR_ACTIVE) 96VECTOR_NONE = _CeedConstantObject(lib.CEED_VECTOR_NONE) 97 98# Basis 99BASIS_COLLOCATED = _CeedConstantObject(lib.CEED_BASIS_COLLOCATED) 100 101# ------------------------------------------------------------------------------ 102