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