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