Skip to content

Commit

Permalink
XCore AdaptMesh: added cell ranges extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
imadhammani committed Jul 25, 2024
1 parent 5a95ff0 commit b5478b3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
39 changes: 36 additions & 3 deletions Cassiopee/XCore/XCore/AdaptMesh/AdaptMesh_ExtractData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PyObject *K_XCORE::AdaptMesh_ExtractOwners(PyObject *self, PyObject *args)

Mesh *M = (Mesh *)PyCapsule_GetPointer(MESH, "AdaptMesh");

if (M->pid == 0) puts("Extracting owners...");
if (M->pid == 0) puts("Extracting face owners...");

npy_intp dims[2];

Expand Down Expand Up @@ -68,7 +68,7 @@ PyObject *K_XCORE::AdaptMesh_ExtractNeighbours(PyObject *self, PyObject *args)

Mesh *M = (Mesh *)PyCapsule_GetPointer(MESH, "AdaptMesh");

if (M->pid == 0) puts("Extracting owners...");
if (M->pid == 0) puts("Extracting face neighbours...");

npy_intp dims[2];

Expand Down Expand Up @@ -119,6 +119,39 @@ PyObject *K_XCORE::AdaptMesh_ExtractCellLevels(PyObject *self, PyObject *args)
}


PyObject *K_XCORE::AdaptMesh_ExtractCellRanges(PyObject *self, PyObject *args)
{
PyObject *MESH;

if (!PYPARSETUPLE_(args, O_, &MESH)) {
RAISE("Wrong input.");
return NULL;
}

if (!PyCapsule_IsValid(MESH, "AdaptMesh")) {
RAISE("Bad mesh hook.");
return NULL;
}

Mesh *M = (Mesh *)PyCapsule_GetPointer(MESH, "AdaptMesh");

if (M->pid == 0) puts("Extracting cell ranges...");

PyObject *STR = K_NUMPY::buildNumpyArray(M->nc, 6, 1, 1);

Int *ptr = K_NUMPY::getNumpyPtrI(STR);

for (Int cid = 0; cid < M->nc; cid++) {
Int *crange = Mesh_get_crange(M, cid);

for (Int j = 0; j < M->cstride[cid]; j++) {
ptr[cid + j*M->nc] = crange[j];
}
}

return (PyObject *)STR;
}

PyObject *K_XCORE::AdaptMesh_ExtractHaloCellLevels(PyObject *self, PyObject *args)
{
PyObject *MESH;
Expand All @@ -135,7 +168,7 @@ PyObject *K_XCORE::AdaptMesh_ExtractHaloCellLevels(PyObject *self, PyObject *arg

Mesh *M = (Mesh *)PyCapsule_GetPointer(MESH, "AdaptMesh");

if (M->pid == 0) puts("Extracting neighbour cell levels...");
if (M->pid == 0) puts("Extracting halo cell levels...");

// Allocate

Expand Down
3 changes: 3 additions & 0 deletions Cassiopee/XCore/XCore/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def AdaptMesh_ExtractNeighbours(AM):
def AdaptMesh_ExtractCellLevels(AM):
return xcore.AdaptMesh_ExtractCellLevels(AM)

def AdaptMesh_ExtractCellRanges(AM):
return xcore.AdaptMesh_ExtractCellRanges(AM)

def AdaptMesh_ExtractHaloCellLevels(AM):
return xcore.AdaptMesh_ExtractHaloCellLevels(AM)

Expand Down
1 change: 1 addition & 0 deletions Cassiopee/XCore/XCore/xcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static PyMethodDef Pyxcore [] =
{"AdaptMesh_ExtractOwners", K_XCORE::AdaptMesh_ExtractOwners, METH_VARARGS},
{"AdaptMesh_ExtractNeighbours", K_XCORE::AdaptMesh_ExtractNeighbours, METH_VARARGS},
{"AdaptMesh_ExtractCellLevels", K_XCORE::AdaptMesh_ExtractCellLevels, METH_VARARGS},
{"AdaptMesh_ExtractCellRanges", K_XCORE::AdaptMesh_ExtractCellRanges, METH_VARARGS},
{"AdaptMesh_ExtractHaloCellLevels", K_XCORE::AdaptMesh_ExtractHaloCellLevels, METH_VARARGS},

{"intersectSurf", K_XCORE::intersectSurf, METH_VARARGS},
Expand Down
1 change: 1 addition & 0 deletions Cassiopee/XCore/XCore/xcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace K_XCORE
PyObject *AdaptMesh_ExtractOwners(PyObject *self, PyObject *args);
PyObject *AdaptMesh_ExtractNeighbours(PyObject *self, PyObject *args);
PyObject *AdaptMesh_ExtractCellLevels(PyObject *self, PyObject *args);
PyObject *AdaptMesh_ExtractCellRanges(PyObject *self, PyObject *args);
PyObject *AdaptMesh_ExtractHaloCellLevels(PyObject *self, PyObject *args);

PyObject *intersectSurf(PyObject *self, PyObject *args);
Expand Down

0 comments on commit b5478b3

Please sign in to comment.