Skip to content
Snippets Groups Projects
Commit 7dd96f9d authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

bgm does not work yet - don't pass the callback for now until it's fixed

parent 62314aa4
No related branches found
No related tags found
No related merge requests found
......@@ -26,23 +26,29 @@ extern "C" {
// This is a list of regions that are simply connected
HXTStatus hxtGmshMsgCallback(HXTMessage* msg){
HXTStatus hxtGmshMsgCallback(HXTMessage *msg)
{
if(msg) Msg::Info("%s", msg->string);
return HXT_STATUS_OK;
}
static double hxtMeshSizeGmshCallBack (double x, double y, double z, void *userData) {
static double hxtMeshSizeGmshCallBack(double x, double y, double z,
void *userData)
{
GRegion *gr = (GRegion *)userData;
double lc2 = BGM_MeshSize(gr, 0, 0, x, y, z);
return lc2;
}
static HXTStatus getAllFacesOfAllRegions (std::vector<GRegion *> &regions, HXTMesh *m, std::vector<GFace *> &allFaces){
static HXTStatus getAllFacesOfAllRegions(std::vector<GRegion *> &regions,
HXTMesh *m,
std::vector<GFace *> &allFaces)
{
std::set<GFace *, GEntityLessThan> allFacesSet;
if(m) {
m->brep.numVolumes = regions.size();
HXT_CHECK(
hxtAlignedMalloc(&m->brep.numSurfacesPerVolume, m->brep.numVolumes
* sizeof(uint32_t)));
HXT_CHECK(hxtAlignedMalloc(&m->brep.numSurfacesPerVolume,
m->brep.numVolumes * sizeof(uint32_t)));
}
uint32_t to_alloc = 0;
for(unsigned int i = 0; i < regions.size(); i++) {
......@@ -59,29 +65,33 @@ static HXTStatus getAllFacesOfAllRegions (std::vector<GRegion *> &regions, HXTMe
if(!m) return HXT_STATUS_OK;
HXT_CHECK(hxtAlignedMalloc(&m->brep.surfacesPerVolume, to_alloc* sizeof(uint32_t)));
HXT_CHECK(
hxtAlignedMalloc(&m->brep.surfacesPerVolume, to_alloc * sizeof(uint32_t)));
uint32_t counter = 0;
for(unsigned int i = 0; i < regions.size(); i++) {
std::vector<GFace *> const &f = regions[i]->faces();
std::vector<GFace *> const &f_e = regions[i]->embeddedFaces();
for (size_t j=0;j<f.size();j++)m->brep.surfacesPerVolume[counter++]=f[j]->tag();
for (size_t j=0;j<f_e.size();j++)m->brep.surfacesPerVolume[counter++]=f_e[j]->tag();
for(size_t j = 0; j < f.size(); j++)
m->brep.surfacesPerVolume[counter++] = f[j]->tag();
for(size_t j = 0; j < f_e.size(); j++)
m->brep.surfacesPerVolume[counter++] = f_e[j]->tag();
}
// printf("volume 0 has %d faces\n",m->brep.numSurfacesPerVolume[0]);
// for (int i=0;i<m->brep.numSurfacesPerVolume[0];i++)printf("%d ",m->brep.surfacesPerVolume[i]);
// printf("\n");
// for (int i=0;i<m->brep.numSurfacesPerVolume[0];i++)printf("%d
// ",m->brep.surfacesPerVolume[i]); printf("\n");
return HXT_STATUS_OK;
}
static HXTStatus getAllEdgesOfAllFaces (std::vector<GFace *> &faces, HXTMesh *m, std::vector<GEdge *> &allEdges){
static HXTStatus getAllEdgesOfAllFaces(std::vector<GFace *> &faces, HXTMesh *m,
std::vector<GEdge *> &allEdges)
{
if(m) {
m->brep.numSurfaces = faces.size();
HXT_CHECK(
hxtAlignedMalloc(&m->brep.numCurvesPerSurface, m->brep.numSurfaces
* sizeof(uint32_t)));
HXT_CHECK(hxtAlignedMalloc(&m->brep.numCurvesPerSurface,
m->brep.numSurfaces * sizeof(uint32_t)));
}
uint32_t to_alloc = 0;
......@@ -100,30 +110,35 @@ static HXTStatus getAllEdgesOfAllFaces (std::vector<GFace *> &faces, HXTMesh *m,
if(!m) return HXT_STATUS_OK;
HXT_CHECK(hxtAlignedMalloc(&m->brep.curvesPerSurface, to_alloc* sizeof(uint32_t)));
HXT_CHECK(
hxtAlignedMalloc(&m->brep.curvesPerSurface, to_alloc * sizeof(uint32_t)));
uint32_t counter = 0;
for(unsigned int i = 0; i < faces.size(); i++) {
std::vector<GEdge *> const &f = faces[i]->edges();
std::vector<GEdge *> const &f_e = faces[i]->embeddedEdges();
for (size_t j=0;j<f.size();j++)m->brep.curvesPerSurface[counter++]=f[j]->tag();
for (size_t j=0;j<f_e.size();j++)m->brep.curvesPerSurface[counter++]=f_e[j]->tag();
for(size_t j = 0; j < f.size(); j++)
m->brep.curvesPerSurface[counter++] = f[j]->tag();
for(size_t j = 0; j < f_e.size(); j++)
m->brep.curvesPerSurface[counter++] = f_e[j]->tag();
}
return HXT_STATUS_OK;
}
static HXTStatus Hxt2Gmsh(std::vector<GRegion *> &regions, HXTMesh *m,
std::map<MVertex *, int> &v2c,
std::vector<MVertex *> &c2v){
std::vector<MVertex *> &c2v)
{
std::vector<GFace *> allFaces;
std::vector<GEdge *> allEdges;
HXT_CHECK(getAllFacesOfAllRegions(regions, NULL, allFaces));
HXT_CHECK(getAllEdgesOfAllFaces(allFaces, NULL, allEdges));
std::map<int, GEdge *> i2e;
std::map<int, GFace *> i2f;
for (size_t i = 0;i<allFaces.size();i++)i2f[allFaces[i]->tag()] = allFaces[i];
for (size_t i = 0;i<allEdges.size();i++)i2e[allEdges[i]->tag()] = allEdges[i];
for(size_t i = 0; i < allFaces.size(); i++)
i2f[allFaces[i]->tag()] = allFaces[i];
for(size_t i = 0; i < allEdges.size(); i++)
i2e[allEdges[i]->tag()] = allEdges[i];
c2v.resize(m->vertices.num);
for(size_t i = c2v.size(); i < m->vertices.num; i++) {
......@@ -146,7 +161,6 @@ static HXTStatus Hxt2Gmsh(std::vector<GRegion *> &regions, HXTMesh *m,
gf->triangles.clear();
}
for(size_t i = 0; i < m->lines.num; i++) {
uint32_t i0 = m->lines.node[2 * i + 0];
uint32_t i1 = m->lines.node[2 * i + 1];
......@@ -219,7 +233,6 @@ static HXTStatus Hxt2Gmsh(std::vector<GRegion *> &regions, HXTMesh *m,
return HXT_STATUS_OK;
}
static HXTStatus Gmsh2Hxt(std::vector<GRegion *> &regions, HXTMesh *m,
std::map<MVertex *, int> &v2c,
std::vector<MVertex *> &c2v)
......@@ -274,10 +287,10 @@ static HXTStatus Gmsh2Hxt(std::vector<GRegion *> &regions, HXTMesh *m,
m->lines.num = m->lines.size = nedg;
uint64_t index = 0;
HXT_CHECK(hxtAlignedMalloc(&m->lines.node,
(m->lines.num) * 2 * sizeof(uint32_t)));
HXT_CHECK(hxtAlignedMalloc(&m->lines.colors,
(m->lines.num) * sizeof(uint16_t)));
HXT_CHECK(
hxtAlignedMalloc(&m->lines.node, (m->lines.num) * 2 * sizeof(uint32_t)));
HXT_CHECK(
hxtAlignedMalloc(&m->lines.colors, (m->lines.num) * sizeof(uint16_t)));
for(size_t j = 0; j < edges.size(); j++) {
GEdge *ge = edges[j];
......@@ -289,7 +302,6 @@ static HXTStatus Gmsh2Hxt(std::vector<GRegion *> &regions, HXTMesh *m,
}
}
m->triangles.num = m->triangles.size = ntri;
HXT_CHECK(hxtAlignedMalloc(&m->triangles.node,
(m->triangles.num) * 3 * sizeof(uint32_t)));
......@@ -332,17 +344,11 @@ static HXTStatus _meshGRegionHxt(std::vector<GRegion *> &regions)
Gmsh2Hxt(regions, mesh, v2c, c2v);
// Msg::Info("Entering hxtTetMesh3d using %d threads",nthreads);
HXT_CHECK(hxtTetMesh3d(mesh,
0,0,0,
reproducible,
verbosity,
stat,
refine,
optimize,
threshold,
hxt_boundary_recovery,
hxtMeshSizeGmshCallBack, regions[0]));
HXT_CHECK(
hxtTetMesh3d(mesh, 0, 0, 0, reproducible, verbosity, stat, refine, optimize,
threshold, hxt_boundary_recovery,
NULL, // hxtMeshSizeGmshCallBack, // FIXME does not work yet
regions[0]));
// HXT_CHECK(hxtMeshWriteGmsh(mesh, "hxt.msh"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment