Skip to content

Commit

Permalink
Merge pull request #96 from imadhammani/main
Browse files Browse the repository at this point in the history
XCore: update
  • Loading branch information
benoit128 authored Jul 22, 2024
2 parents 515113c + 079077a commit 87dcef0
Show file tree
Hide file tree
Showing 55 changed files with 1,132 additions and 1,110 deletions.
2 changes: 1 addition & 1 deletion Cassiopee/XCore/XCore/AdaptMesh/AdaptMesh_ExtractMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
PyObject *K_XCORE::AdaptMesh_ExtractMesh(PyObject *self, PyObject *args)
{
PyObject *MESH;
int conformize;
Int conformize;

if (!PYPARSETUPLE_(args, O_ I_, &MESH, &conformize)) {
RAISE("Wrong input.");
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/XCore/XCore/AdaptMesh/Edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
#include "Mesh.h"

int refine_edge(Int eid, Mesh *M)
Int refine_edge(Int eid, Mesh *M)
{
Int p = M->edges[eid].p;
Int q = M->edges[eid].q;
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/XCore/XCore/AdaptMesh/Edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ struct DEdge {
}
};

int refine_edge(Int eid, Mesh *M);
Int refine_edge(Int eid, Mesh *M);
12 changes: 6 additions & 6 deletions Cassiopee/XCore/XCore/AdaptMesh/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ void Mesh_update_ppatches(Mesh *M);
void Mesh_update_global_face_ids(Mesh *M);

inline
Int *Mesh_get_cell(Mesh *M, int cid)
Int *Mesh_get_cell(Mesh *M, Int cid)
{
return &M->cells[24*cid];
}

inline
Int *Mesh_get_crange(Mesh *M, int cid)
Int *Mesh_get_crange(Mesh *M, Int cid)
{
return &M->crange[6*cid];
}
Expand All @@ -222,13 +222,13 @@ Int Mesh_get_sizeNFace(Mesh *M)
}

inline
Int *Mesh_get_face(Mesh *M, int fid)
Int *Mesh_get_face(Mesh *M, Int fid)
{
return &M->faces[8*fid];
}

inline
Int *Mesh_get_frange(Mesh *M, int fid)
Int *Mesh_get_frange(Mesh *M, Int fid)
{
return &M->frange[4*fid];
}
Expand Down Expand Up @@ -326,7 +326,7 @@ void Mesh_free(Mesh *M);

Mesh *Mesh_from_Karray(Karray *karray);

PyObject *Mesh_export_karray(Mesh *M, int conformize);
PyObject *Mesh_export_karray(Mesh *M, Int conformize);


/* Parallel */
Expand Down Expand Up @@ -357,7 +357,7 @@ void Mesh_sort_ref_entities_by_level(Mesh *M,
void Mesh_refine(Mesh *M, std::vector<Int> &ref_cells,
std::vector<Int> &ref_faces, std::set<UEdge> &ref_edges);

int Mesh_conformize_cell_face(Mesh *M, Int cid, Int fid, Int fpos, Int nf);
Int Mesh_conformize_cell_face(Mesh *M, Int cid, Int fid, Int fpos, Int nf);

void Mesh_conformize_face_edge(Mesh *M);

Expand Down
14 changes: 0 additions & 14 deletions Cassiopee/XCore/XCore/AdaptMesh/MeshComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ Int *compute_cell_weights(Mesh *M)
for (Int i = 0; i < M->nc; i++) {
Int cval = M->cref[i];

//weights[i] = 1.0;
//if (cval > 0) weights[i] += gnc;

weights[i] = 1 << (3*cval);
}

Expand All @@ -70,8 +67,6 @@ Int *compute_cell_weights(Mesh *M)

Float gmin_weight;
MPI_Allreduce(&min_weight, &gmin_weight, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);

//assert(gmin_weight == 1);

Float sum = 0.0;
for (Int weight : weights) sum += weight;
Expand Down Expand Up @@ -179,8 +174,6 @@ Int *map_cell_graph(Mesh *M, Int *cwgts)
SCOTCH_dgraphExit(&graph);
SCOTCH_stratExit(&strat);

//for (Int i = 0; i < M->nc; i++) cmap[i] = M->pid;

return cmap;
}

Expand All @@ -205,10 +198,6 @@ struct xyz {
return (sx < 0) ||
(sx == 0 && sy < 0) ||
(sx == 0 && sy == 0 && sz < 0);

//return (x < p.x) ||
// (x == p.x && y < p.y) ||
// (x == p.x && y == p.y && z < p.z);
}
};

Expand Down Expand Up @@ -386,9 +375,6 @@ Int Mesh_redistribute(Mesh *M, Int *cmap)
rcells, rcount, rdist, XMPI_INT,
MPI_COMM_WORLD);




// Faces

if (M->pid == 0) puts("Distributing faces...");
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/XCore/XCore/AdaptMesh/MeshConformize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "Mesh.h"
#include "common/mem.h"

int Mesh_conformize_cell_face(Mesh *M, Int cid, Int fid, Int fpos, Int nf)
Int Mesh_conformize_cell_face(Mesh *M, Int cid, Int fid, Int fpos, Int nf)
{
Int *cell = Mesh_get_cell(M, cid);
Int *crange = Mesh_get_crange(M, cid);
Expand Down
13 changes: 12 additions & 1 deletion Cassiopee/XCore/XCore/AdaptMesh/MeshIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,14 @@ PyObject *export_BE_mesh(Mesh *M)
// Comm is undefined
PyList_Append(out, Py_None);

// Procs
PyObject *PROCS = PyList_New(0);
for (Int i = 0; i < M->npp; i++) {
PyList_Append(PROCS, PyLong_FromLong(M->pps[i].nei));
}
PyList_Append(out, PROCS);
Py_DECREF(PROCS);

return out;
}

Expand Down Expand Up @@ -667,10 +675,13 @@ PyObject *export_conformal_mesh(Mesh *M)
PyList_Append(out, pps);
Py_DECREF(pps);

// Procs
PyList_Append(out, Py_None);

return out;
}

PyObject *Mesh_export_karray(Mesh *M, int conformize)
PyObject *Mesh_export_karray(Mesh *M, Int conformize)
{
if (conformize) return export_conformal_mesh(M);

Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/XCore/XCore/AdaptMesh/Q6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
#include "Quad.h"

int Q6_refine(Int quad, Mesh *M)
Int Q6_refine(Int quad, Mesh *M)
{
Int NODES[6];
for (Int i = 0; i < 6; i++) NODES[i] = -1;
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/XCore/XCore/AdaptMesh/Q9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
#include "Quad.h"

int Q9_refine(Int quad, Mesh *M)
Int Q9_refine(Int quad, Mesh *M)
{
Int NODES[8];

Expand Down
4 changes: 2 additions & 2 deletions Cassiopee/XCore/XCore/AdaptMesh/Quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include "common/common.h"
#include "Mesh.h"

int Q9_refine(Int quad, Mesh *M);
Int Q9_refine(Int quad, Mesh *M);

int Q6_refine(Int quad, Mesh *M);
Int Q6_refine(Int quad, Mesh *M);

void Q4_reorder(Int *pn, Int reorient, Int i0, Int local[4]);

Expand Down
5 changes: 4 additions & 1 deletion Cassiopee/XCore/XCore/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ def AdaptMesh_Adapt(AM):
return xcore.AdaptMesh_Adapt(AM)

def AdaptMesh_ExtractMesh(t, conformize=1):
mesh, bcs, comm = xcore.AdaptMesh_ExtractMesh(t, conformize)
mesh, bcs, comm, procs = xcore.AdaptMesh_ExtractMesh(t, conformize)
name = 'Proc' + '%d'%Cmpi.rank
zone = I.createZoneNode(name, mesh)

if procs is not None and len(procs) > 0:
I.newUserDefinedData(name='NeighbourProcessors', value=procs, parent=zone)

if comm is not None:
for data in comm:
cont = I.createUniqueChild(zone, 'ZoneGridConnectivity', 'ZoneGridConnectivity_t')
Expand Down
15 changes: 12 additions & 3 deletions Cassiopee/XCore/XCore/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
exit(0); \
} while (0);

#define RAISE(error) PyErr_SetString(PyExc_ValueError, (error))
#define RAISE(error) \
do { \
char msg[1024] = {}; \
strcat(msg, __func__); \
strcat(msg, ": "); \
strcat(msg, error); \
PyErr_SetString(PyExc_ValueError, msg); \
} while (0);

#define IntArray(n) (Int *)XCALLOC(n, sizeof(Int))
#define FloatArray(n) (Float *)XCALLOC(n, sizeof(Float))
Expand All @@ -43,7 +50,8 @@ typedef E_Float Float;

void parray(Int *arr, Int n);

inline Int Get_pos(Int e, Int *pn, Int size)
inline
Int Get_pos(Int e, Int *pn, Int size)
{
for (E_Int i = 0; i < size; i++) {
if (pn[i] == e) return i;
Expand All @@ -54,7 +62,8 @@ inline Int Get_pos(Int e, Int *pn, Int size)
return -1;
}

inline void Right_shift(E_Int *pn, E_Int pos, E_Int size)
inline
void Right_shift(E_Int *pn, E_Int pos, E_Int size)
{
E_Int tmp[24];
assert(size <= 24);
Expand Down
6 changes: 3 additions & 3 deletions Cassiopee/XCore/XCore/intersectMesh/cycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include "hedge.h"
#include "primitives.h"

E_Int Cycle::INNER = 0;
E_Int Cycle::OUTER = 1;
E_Int Cycle::DEGEN = 2;
Int Cycle::INNER = 0;
Int Cycle::OUTER = 1;
Int Cycle::DEGEN = 2;

Cycle::Cycle(Hedge *Rep)
: rep(Rep), inout(Dcel::NO_IDEA), left(NULL), prev(NULL), next(NULL)
Expand Down
9 changes: 5 additions & 4 deletions Cassiopee/XCore/XCore/intersectMesh/cycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@
#include <vector>

#include "xcore.h"
#include "common/common.h"

struct Hedge;
struct Vertex;

struct Cycle {
Hedge *rep;
E_Int inout;
Int inout;
Vertex *left;
Cycle *prev;
Cycle *next;

static E_Int INNER;
static E_Int OUTER;
static E_Int DEGEN;
static Int INNER;
static Int OUTER;
static Int DEGEN;

Cycle(Hedge *Rep);
void print() const;
Expand Down
Loading

0 comments on commit 87dcef0

Please sign in to comment.