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