xref: /libCEED/python/tests/test-0-ceed.py (revision 547dbd6f5071ad3a6569362aeaf8c427ad429b62)
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
17# @file
18# Test Ceed functionality
19
20import libceed
21import pytest
22
23# -------------------------------------------------------------------------------
24# Test creation and destruction of a Ceed object
25# -------------------------------------------------------------------------------
26
27
28def test_000(ceed_resource):
29    ceed = libceed.Ceed(ceed_resource)
30
31# -------------------------------------------------------------------------------
32# Test return of Ceed backend prefered memory type
33# -------------------------------------------------------------------------------
34
35
36def test_001(ceed_resource):
37    ceed = libceed.Ceed(ceed_resource)
38
39    memtype = ceed.get_preferred_memtype()
40
41    assert memtype != "error"
42
43# -------------------------------------------------------------------------------
44# Test return of a CEED object full resource name
45# -------------------------------------------------------------------------------
46
47
48def test_002(ceed_resource):
49    ceed = libceed.Ceed(ceed_resource)
50
51    resource = ceed.get_resource()
52
53    assert resource == ceed_resource
54
55# -------------------------------------------------------------------------------
56# Test viewing of a CEED object
57# -------------------------------------------------------------------------------
58
59
60def test_003(ceed_resource):
61    ceed = libceed.Ceed(ceed_resource)
62
63    print(ceed)
64
65# -------------------------------------------------------------------------------
66# Test CEED object error handling
67# -------------------------------------------------------------------------------
68
69
70def test_005(ceed_resource):
71    ceed = libceed.Ceed(ceed_resource)
72
73    vec = ceed.Vector(5)
74    vec.set_value(0.0)
75    array1 = vec.get_array()
76
77    exception_raised = False
78    try:
79        array2 = vec.get_array()
80    except BaseException:
81        exception_raised = True
82
83    assert exception_raised
84
85    vec.restore_array()
86
87# -------------------------------------------------------------------------------
88