xref: /libCEED/examples/python/tutorial-0-ceed.ipynb (revision 346c77e6436e93de99b1714e06a264fc70d47960)
1edab6123Sjeremylt{
2edab6123Sjeremylt "cells": [
3edab6123Sjeremylt  {
4edab6123Sjeremylt   "cell_type": "markdown",
5edab6123Sjeremylt   "metadata": {},
6edab6123Sjeremylt   "source": [
7edab6123Sjeremylt    "# libCEED for Python examples\n",
8edab6123Sjeremylt    "\n",
9edab6123Sjeremylt    "This is a tutorial to illustrate the main feautures of the Python interface for [libCEED](https://github.com/CEED/libCEED/), the low-level API library for efficient high-order discretization methods developed by the co-design [Center for Efficient Exascale Discretizations](https://ceed.exascaleproject.org/) (CEED) of the [Exascale Computing Project](https://www.exascaleproject.org/) (ECP).\n",
10edab6123Sjeremylt    "\n",
1113964f07SJed Brown    "While libCEED's focus is on high-order finite/spectral element method implementations, the approach is mostly algebraic and thus applicable to other discretizations in factored form, as explained in the [user manual](https://libceed.org/)."
12edab6123Sjeremylt   ]
13edab6123Sjeremylt  },
14edab6123Sjeremylt  {
15edab6123Sjeremylt   "cell_type": "markdown",
16edab6123Sjeremylt   "metadata": {},
17edab6123Sjeremylt   "source": [
18edab6123Sjeremylt    "## Setting up libCEED for Python"
19edab6123Sjeremylt   ]
20edab6123Sjeremylt  },
21edab6123Sjeremylt  {
22edab6123Sjeremylt   "cell_type": "markdown",
23edab6123Sjeremylt   "metadata": {},
24edab6123Sjeremylt   "source": [
25edab6123Sjeremylt    "Install libCEED for Python by running"
26edab6123Sjeremylt   ]
27edab6123Sjeremylt  },
28edab6123Sjeremylt  {
29edab6123Sjeremylt   "cell_type": "code",
30edab6123Sjeremylt   "execution_count": null,
31edab6123Sjeremylt   "metadata": {},
32edab6123Sjeremylt   "outputs": [],
33edab6123Sjeremylt   "source": [
34edab6123Sjeremylt    "! python -m pip install libceed"
35edab6123Sjeremylt   ]
36edab6123Sjeremylt  },
37edab6123Sjeremylt  {
38edab6123Sjeremylt   "cell_type": "markdown",
39edab6123Sjeremylt   "metadata": {},
40edab6123Sjeremylt   "source": [
41edab6123Sjeremylt    "## Ceed\n",
42edab6123Sjeremylt    "\n",
43edab6123Sjeremylt    "Here we show some basic examples to illustrate the `Ceed` class. In libCEED, Ceeds represent library context representing control of logical hardware resources.\n",
44edab6123Sjeremylt    "\n",
45edab6123Sjeremylt    "Here we illustrate the simple declaration of a `Ceed`, with default resource (which is `/cpu/self`)"
46edab6123Sjeremylt   ]
47edab6123Sjeremylt  },
48edab6123Sjeremylt  {
49edab6123Sjeremylt   "cell_type": "code",
50edab6123Sjeremylt   "execution_count": null,
51edab6123Sjeremylt   "metadata": {},
52edab6123Sjeremylt   "outputs": [],
53edab6123Sjeremylt   "source": [
54edab6123Sjeremylt    "import libceed\n",
55edab6123Sjeremylt    "\n",
56edab6123Sjeremylt    "ceed = libceed.Ceed()"
57edab6123Sjeremylt   ]
58edab6123Sjeremylt  },
59edab6123Sjeremylt  {
60edab6123Sjeremylt   "cell_type": "markdown",
61edab6123Sjeremylt   "metadata": {},
62edab6123Sjeremylt   "source": [
63edab6123Sjeremylt    "You can visualize the memory address of the object instantiated by typing"
64edab6123Sjeremylt   ]
65edab6123Sjeremylt  },
66edab6123Sjeremylt  {
67edab6123Sjeremylt   "cell_type": "code",
68edab6123Sjeremylt   "execution_count": null,
69edab6123Sjeremylt   "metadata": {},
70edab6123Sjeremylt   "outputs": [],
71edab6123Sjeremylt   "source": [
72edab6123Sjeremylt    "print(ceed)"
73edab6123Sjeremylt   ]
74edab6123Sjeremylt  },
75edab6123Sjeremylt  {
76edab6123Sjeremylt   "cell_type": "markdown",
77edab6123Sjeremylt   "metadata": {},
78edab6123Sjeremylt   "source": [
79edab6123Sjeremylt    "To use a particular backend, for instance `/cpu/self/opt/blocked` you can specify"
80edab6123Sjeremylt   ]
81edab6123Sjeremylt  },
82edab6123Sjeremylt  {
83edab6123Sjeremylt   "cell_type": "code",
84edab6123Sjeremylt   "execution_count": null,
85edab6123Sjeremylt   "metadata": {},
86edab6123Sjeremylt   "outputs": [],
87edab6123Sjeremylt   "source": [
88edab6123Sjeremylt    "ceed = libceed.Ceed('/cpu/self/opt/blocked')"
89edab6123Sjeremylt   ]
90edab6123Sjeremylt  },
91edab6123Sjeremylt  {
92edab6123Sjeremylt   "cell_type": "markdown",
93edab6123Sjeremylt   "metadata": {},
94edab6123Sjeremylt   "source": [
95*346c77e6SJeremy L Thompson    "Similarly, if libCEED is built with GPU support, you can specify a GPU backend, e.g., `/gpu/hip` or `/gpu/cuda/gen`."
96edab6123Sjeremylt   ]
97*346c77e6SJeremy L Thompson  },
98*346c77e6SJeremy L Thompson  {
99*346c77e6SJeremy L Thompson   "cell_type": "code",
100*346c77e6SJeremy L Thompson   "execution_count": null,
101*346c77e6SJeremy L Thompson   "metadata": {},
102*346c77e6SJeremy L Thompson   "outputs": [],
103*346c77e6SJeremy L Thompson   "source": []
104edab6123Sjeremylt  }
105edab6123Sjeremylt ],
106edab6123Sjeremylt "metadata": {
107edab6123Sjeremylt  "kernelspec": {
108edab6123Sjeremylt   "display_name": "Python 3",
109edab6123Sjeremylt   "language": "python",
110edab6123Sjeremylt   "name": "python3"
111edab6123Sjeremylt  },
112edab6123Sjeremylt  "language_info": {
113edab6123Sjeremylt   "codemirror_mode": {
114edab6123Sjeremylt    "name": "ipython",
115edab6123Sjeremylt    "version": 3
116edab6123Sjeremylt   },
117edab6123Sjeremylt   "file_extension": ".py",
118edab6123Sjeremylt   "mimetype": "text/x-python",
119edab6123Sjeremylt   "name": "python",
120edab6123Sjeremylt   "nbconvert_exporter": "python",
121edab6123Sjeremylt   "pygments_lexer": "ipython3",
122edab6123Sjeremylt   "version": "3.8.5"
123edab6123Sjeremylt  }
124edab6123Sjeremylt },
125edab6123Sjeremylt "nbformat": 4,
126edab6123Sjeremylt "nbformat_minor": 4
127edab6123Sjeremylt}
128