1
// --- Return NumPy arrays for Mesh::cells() and Mesh::coordinates() ---
3
%define ALL_COORDINATES(name)
5
PyObject* coordinates() {
6
// Get coordinates for all vertices in structure.
7
// returns a 3xnoVertices Numeric array, x in array[0], y in array[1]
9
int noVert = self->numVertices();
10
int dim = self->geometry().dim();
12
npy_intp adims[nadims];
17
PyArrayObject* arr = (PyArrayObject *)PyArray_SimpleNewFromData(nadims, adims, PyArray_DOUBLE, (char *)(self->coordinates()));
18
if ( arr == NULL ) return NULL;
20
return (PyObject *)arr;
25
%define ALL_CELLS(name)
28
// Get the node-id for all vertices.
30
npy_intp adims[nadims];
31
int no_cells = self->numCells();
32
int vertices_per_cell = (self->topology().dim() == 2) ? 3 : 4;
35
adims[1] = vertices_per_cell;
37
// the std. way of creating a Numeric array
38
PyArrayObject* arr = (PyArrayObject *)PyArray_SimpleNewFromData(nadims, adims, PyArray_INT, (char *)(self->cells()));
39
if (arr == NULL) return NULL;
41
return (PyObject *)arr;
46
ALL_COORDINATES(dolfin::Mesh)
47
ALL_CELLS(dolfin::Mesh)
49
%ignore dolfin::Mesh::cells;
50
%ignore dolfin::Mesh::coordinates;
52
//--- Mesh iterators ---
54
// Map increment operator and dereference operators for iterators
55
%rename(increment) dolfin::MeshEntityIterator::operator++;
56
%rename(dereference) dolfin::MeshEntityIterator::operator*;
58
// Rename the iterators to better match the Python syntax
59
%rename(vertices) dolfin::VertexIterator;
60
%rename(edges) dolfin::EdgeIterator;
61
%rename(faces) dolfin::FaceIterator;
62
%rename(facets) dolfin::FacetIterator;
63
%rename(cells) dolfin::CellIterator;
64
%rename(entities) dolfin::MeshEntityIterator;