How to use the libceed.Ceed function in libceed

To help you get started, we’ve selected a few libceed examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CEED / libCEED / tests / python / test-3-ceed-basis.py View on Github external
def test_314(ceed_resource):
  ceed = libceed.Ceed(ceed_resource)

  for dim in range (1, 4):
    P, Q = 8, 10
    Pdim = P**dim
    Qdim = Q**dim
    Xdim = 2**dim
    sum1 = sum2 = 0
    x = np.empty(Xdim*dim, dtype="float64")
    u = np.empty(Pdim, dtype="float64")

    for d in range(dim):
      for i in range(Xdim):
        x[d*Xdim + i] = 1 if (i % (2**(dim-d))) // (2**(dim-d-1)) else -1

    X = ceed.Vector(Xdim*dim)
    X.set_array(x, cmode=libceed.USE_POINTER)
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t101-vec.py View on Github external
import sys
from libceed import CEED_MEM_HOST, CEED_USE_POINTER
import libceed
import numpy as np

def check_values(ceed, x, value):
  b = x.get_array_read(CEED_MEM_HOST)
  for i in range(len(b)):
    if b[i] != value:
      # LCOV_EXCL_START
      print("Error reading array b[%d] = %f"%(i,b[i]))
      # LCOV_EXCL_STOP
  x.restore_array_read()

if __name__ == "__main__":
  ceed = libceed.Ceed(sys.argv[1])
  n = 10
  x = ceed.Vector(n)
  value = 1
  a = np.arange(10, 10 + n, dtype="float64")
  x.set_array(CEED_MEM_HOST, CEED_USE_POINTER, a)

  b = x.get_array_read(CEED_MEM_HOST)
  for i in range(len(b)):
    if b[i] != 10+i:
      # LCOV_EXCL_START
      print("Error reading array b[%d] = %f"%(i,b[i]))
  # LCOV_EXCL_STOP

  x.restore_array_read()

  x.set_value(3.0)
github CEED / libCEED / tests / python / test-5-ceed-operator.py View on Github external
def test_505(ceed_resource):
  ceed = libceed.Ceed(ceed_resource)

  nelem = 15
  p = 5
  q = 8
  nx = nelem + 1
  nu = nelem*(p-1) + 1

  # Vectors
  x = ceed.Vector(nx)
  x_array = np.zeros(nx)
  for i in range(nx):
    x_array[i] = i / (nx - 1.0)
  x.set_array(x_array, cmode=libceed.USE_POINTER)

  qdata = ceed.Vector(nelem*q)
  u = ceed.Vector(nu)
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t103-vec.py View on Github external
# @file
# Test setting one vector from array of another vector

import sys
from libceed import CEED_MEM_HOST, CEED_USE_POINTER
import libceed
import numpy as np

if __name__ == "__main__":
  ceed = libceed.Ceed(sys.argv[1])

  n = 10

  x = ceed.Vector(n)
  y = ceed.Vector(n)

  a = np.arange(10, 10 + n, dtype="float64")
  x.set_array(MEM_HOST, CEED_USE_POINTER, a)

  x_array = x.GetArray(CEED_MEM_HOST)
  y.set_array(CEED_MEM_HOST, CEED_USE_POINTER, x_array)
  x.restore_array()

  y_array = y.get_array_read(CEED_MEM_HOST)
  for i in range(n):
    if y_array[i] != 10+i:
github CEED / libCEED / tests / python / test-3-ceed-basis.py View on Github external
def test_304(ceed_resource, capsys):
  ceed = libceed.Ceed(ceed_resource)

  A = np.array([0.19996678, 0.0745459, -0.07448852, 0.0332866,
                0.0745459, 1., 0.16666509, -0.07448852,
                -0.07448852, 0.16666509, 1., 0.0745459,
                0.0332866, -0.07448852, 0.0745459, 0.19996678], dtype="float64")

  lam = libceed.Basis.symmetric_schur_decomposition(ceed, A, 4)

  print("Q: ")
  for i in range(4):
    for j in range(4):
      if A[j+4*i] <= 1E-14 and A[j+4*i] >= -1E-14:
         A[j+4*i] = 0
      print("%12.8f"%A[j+4*i])

  print("lambda: ")
github CEED / libCEED / tests / python / test-5-ceed-operator.py View on Github external
def test_511(ceed_resource):
  ceed = libceed.Ceed(ceed_resource)

  nelem = 12
  dim = 2
  p = 6
  q = 4
  nx, ny = 3, 2
  ndofs = (nx*2+1)*(ny*2+1)
  nqpts = nelem*q

  # Vectors
  x = ceed.Vector(dim*ndofs)
  x_array = np.zeros(dim*ndofs)
  for i in range(ndofs):
    x_array[i] = (1. / (nx*2)) * (i % (nx*2+1))
    x_array[i+ndofs] = (1. / (ny*2)) * (i / (nx*2+1))
  x.set_array(x_array, cmode=libceed.USE_POINTER)
github CEED / libCEED / tests / python / test-5-ceed-operator.py View on Github external
def test_500(ceed_resource):
  ceed = libceed.Ceed(ceed_resource)

  nelem = 15
  p = 5
  q = 8
  nx = nelem + 1
  nu = nelem*(p-1) + 1

  # Vectors
  x = ceed.Vector(nx)
  x_array = np.zeros(nx)
  for i in range(nx):
    x_array[i] = i / (nx - 1.0)
  x.set_array(x_array, cmode=libceed.USE_POINTER)

  qdata = ceed.Vector(nelem*q)
  u = ceed.Vector(nu)
github CEED / libCEED / tests / python / test-5-ceed-operator.py View on Github external
def test_523(ceed_resource, capsys):
  ceed = libceed.Ceed(ceed_resource)

  nelem_tet, p_tet, q_tet = 6, 6, 4
  nelem_hex, p_hex, q_hex = 6, 3, 4
  nx, ny = 3, 3
  dim = 2
  nx_tet, ny_tet, nx_hex = 3, 1, 3
  ndofs = (nx*2+1)*(ny*2+1)
  nqpts_tet, nqpts_hex = nelem_tet*q_tet, nelem_hex*q_hex*q_hex

  # Vectors
  qdata_hex = ceed.Vector(nqpts_hex)
  qdata_tet = ceed.Vector(nqpts_tet)

  ## ------------------------- Tet Elements -------------------------

  # Restrictions
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t107-vec.py View on Github external
# @file
# Test view

import sys
from libceed import CEED_MEM_HOST, CEED_USE_POINTER
import libceed
import numpy as np

if __name__ == "__main__":
  ceed = libceed.Ceed(sys.argv[1])

  n = 10
  x = ceed.Vector(n)

  a = np.arange(10, 10 + n, dtype="float64")
  x.set_array(CEED_MEM_HOST, CEED_USE_POINTER, a)

  print(x)
github CEED / libCEED / tests / python / test-3-ceed-basis.py View on Github external
def test_322(ceed_resource):
  ceed = libceed.Ceed(ceed_resource)

  P, Q, dim = 6, 4, 2

  xr = np.array([0., 0.5, 1., 0., 0.5, 0., 0., 0., 0., 0.5, 0.5, 1.], dtype="float64")
  in_array = np.empty(P, dtype="float64")
  qref = np.empty(dim*Q, dtype="float64")
  qweight = np.empty(Q, dtype="float64")

  interp, grad = bm.buildmats(qref, qweight)

  b = ceed.BasisH1(libceed.TRIANGLE, 1, P, Q, interp, grad, qref, qweight)

  # Interpolate function to quadrature points
  for i in range(P):
    in_array[i] = feval(xr[0*P+i], xr[1*P+i])