How to use the libceed.CEED_USE_POINTER 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 / interface / ceed-python / tests(will want to move eventually) / t200-elemrestriction.py View on Github external
import numpy as np

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

  ne = 3

  x = ceed.Vector(ne+1)
  a = np.arange(10, 10 + n, dtype="float64")
  x.set_array(CEED_MEM_HOST, USE_POINTER, a)

  ind = np.zeros(2*ne)
  for i in range(n):
    ind[2*i+0] = i
    ind[2*i+1] = i+1
  r = ceed.ElemRestrictionCreate(ne, 2, ne+1, 1, CEED_MEM_HOST, CEED_USE_POINTER, ind)

  y = ceed.Vector(2*ne)
  y.set_value(0)

  r.apply(CEED_NOTRANSPOSE, CEED_NOTRASPOSE, x, y, CEED_REQUEST_IMMEDIATE)

  y_array = y.get_array(MEM_HOST)
  for i in range(2*ne):
    if (10+(i+1)/2 != y_array[i]):
      # LCOV_EXCL_START
      print("Error in restricted array y[%d] = %f"%(i, y_array[i]))
  # LCOV_EXCL_STOP
  y.restore_array()
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t101-vec.py View on Github external
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)
  check_values(ceed, x, 3.0)
  del x

  x = ceed.Vector(n)
  # Set value before setting or getting the array
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t100-vec.py View on Github external
# Test creation, setting, reading, restoring, and destroying of a 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)

  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(n):
    if b[i] != 10 + i:
      # LCOV_EXCL_START
      print("Error reading array b[%d] = %4.2f" %(i, b[i]))
  # LCOV_EXCL_STOP

  x.restore_array_read()
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t103-vec.py View on Github external
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:
      # LCOV_EXCL_START
      print("Error reading array y[%d] = %f"%(i, y_array[i]))
  # LCOV_EXCL_STOP

  y.restore_array_read()
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 / interface / ceed-python / tests(will want to move eventually) / t103-vec.py View on Github external
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:
      # LCOV_EXCL_START
      print("Error reading array y[%d] = %f"%(i, y_array[i]))
  # LCOV_EXCL_STOP

  y.restore_array_read()
github CEED / libCEED / interface / ceed-python / tests(will want to move eventually) / t105-vec.py View on Github external
# @file
# Test creation, setting, reading, restoring, and destroying of a vector using mem_device

import sys
from libceed import CEED_MEM_HOST, CEED_MEM_DEVICE, CEED_USE_POINTER, CEED_COPY_VALUES
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(CEED_MEM_HOST, CEED_USE_POINTER, a)

  b = x.get_array_read(CEED_MEM_DEVICE)
  y.set_array(CEED_MEM_DEVICE, CEED_COPY_VALUES, b)

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

  y.restore_array_read()