Commit d92413b8 authored by Christophe Geuzaine's avatar Christophe Geuzaine

fix compile witout gmsh

parent 88e69f41
Pipeline #1880 passed with stage
in 57 seconds
......@@ -6,13 +6,17 @@
#include <string.h>
#include <math.h>
#include <vector>
#include "GetDPConfig.h"
#include "GeoData.h"
#include "ProData.h"
#include "Pos_Search.h"
#include "MallocUtils.h"
#include "Message.h"
#include "OS.h"
#if defined(HAVE_GMSH)
#include "gmsh.h"
#endif
#define SQU(a) ((a)*(a))
......@@ -419,27 +423,28 @@ static std::string ExtractDoubleQuotedString(const char *str, int len)
static void Geo_ReadFileWithGmsh(struct GeoData * GeoData_P)
{
#if defined(HAVE_GMSH)
gmsh::open(name);
/* N O D E S */
struct Geo_Node Geo_Node ;
std::vector<int> nodeTags;
std::vector<double> coord;
std::vector<double> parametricCoord;
gmsh::model::mesh::getNodes(nodeTags, coord, parametricCoord, -1, -1);
if(GeoData_P->Nodes == NULL)
GeoData_P->Nodes = List_Create(nodeTags.size(), 1000, sizeof(struct Geo_Node)) ;
for(unsigned int i = 0; i < nodeTags.size(); i++){
Geo_Node.Num = nodeTags[i];
Geo_Node.x = coord[3*i + 0];
Geo_Node.y = coord[3*i + 1];
Geo_Node.z = coord[3*i + 2];
List_Add(GeoData_P->Nodes, &Geo_Node) ;
if(!i){
GeoData_P->Xmin = GeoData_P->Xmax = Geo_Node.x;
GeoData_P->Ymin = GeoData_P->Ymax = Geo_Node.y;
......@@ -454,7 +459,7 @@ static void Geo_ReadFileWithGmsh(struct GeoData * GeoData_P)
GeoData_P->Zmax = std::max(GeoData_P->Zmax, Geo_Node.z);
}
}
if(GeoData_P->Xmin != GeoData_P->Xmax &&
GeoData_P->Ymin != GeoData_P->Ymax &&
GeoData_P->Zmin != GeoData_P->Zmax)
......@@ -473,46 +478,48 @@ static void Geo_ReadFileWithGmsh(struct GeoData * GeoData_P)
GeoData_P->Dimension = _1D;
else
GeoData_P->Dimension = _0D;
GeoData_P->CharacteristicLength =
sqrt(SQU(GeoData_P->Xmax - GeoData_P->Xmin) +
SQU(GeoData_P->Ymax - GeoData_P->Ymin) +
SQU(GeoData_P->Zmax - GeoData_P->Zmin));
if(!GeoData_P->CharacteristicLength)
GeoData_P->CharacteristicLength = 1.;
coord.clear();
parametricCoord.clear();
/* E L E M E N T S */
struct Geo_Element Geo_Element ;
std::vector<int> elementTypes;
std::vector< std::vector<int> > elementTags;
std::vector< std::vector<int> > elementNodeTags;
gmsh::model::mesh::getElements(elementTypes, elementTags, elementNodeTags, -1, -1);
int nbr = 0;
for(unsigned int i = 0; i < elementTypes.size(); i++){
nbr += elementTags[i].size();
}
if (GeoData_P->Elements == NULL)
GeoData_P->Elements = List_Create(nbr, 1000, sizeof(struct Geo_Element)) ;
Geo_Element.NbrEdges = Geo_Element.NbrFacets = 0 ;
Geo_Element.NumEdges = Geo_Element.NumFacets = NULL ;
gmsh::vectorpair dimTags;
gmsh::model::getEntities(dimTags, -1);
for(unsigned int entity = 0; entity < dimTags.size(); entity++){
gmsh::model::mesh::getElements(elementTypes, elementTags, elementNodeTags, dimTags[entity].first, dimTags[entity].second);
gmsh::model::mesh::getElements(elementTypes, elementTags, elementNodeTags,
dimTags[entity].first, dimTags[entity].second);
std::vector<int> physicalsTags;
gmsh::model::getPhysicalGroupsForEntity(dimTags[entity].first, dimTags[entity].second, physicalsTags);
gmsh::model::getPhysicalGroupsForEntity(dimTags[entity].first,
dimTags[entity].second, physicalsTags);
if(physicalsTags.size() == 0) continue;
for(unsigned int i = 0; i < elementTypes.size(); i++){
Geo_Element.Type = Geo_GetElementType(FORMAT_GMSH, elementTypes[i]) ;
Geo_Element.NbrNodes = elementNodeTags[i].size()/elementTags[i].size();
......@@ -523,13 +530,17 @@ static void Geo_ReadFileWithGmsh(struct GeoData * GeoData_P)
Geo_Element.NumNodes = (int *)Malloc(Geo_Element.NbrNodes * sizeof(int)) ;
for (unsigned int k = 0; k < Geo_Element.NbrNodes; k++)
Geo_Element.NumNodes[k] = elementNodeTags[i][Geo_Element.NbrNodes*j + k];
List_Add(GeoData_P->Elements, &Geo_Element) ;
}
}
}
List_Sort(GeoData_P->Elements, fcmp_Elm) ;
#else
Message::Error("You need to compile GetDP with Gmsh support to open '%s'",
name);
#endif
}
void Geo_ReadFile(struct GeoData * GeoData_P)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment