gmsh-TingyuanDoc
0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
|
Go to the documentation of this file.
8 #include "GmshConfig.h"
9 #if !defined(HAVE_NO_STDINT_H)
11 #elif defined(HAVE_NO_INTPTR_T)
12 typedef unsigned long intptr_t;
26 #if defined(HAVE_MESH)
30 #if defined(HAVE_POPPLER)
34 #if defined(HAVE_PARSER)
39 #if defined(HAVE_MESH)
43 #if defined(HAVE_POST)
49 #if defined(HAVE_FLTK)
50 #include <FL/fl_ask.H>
52 #include "onelabGroup.h"
53 #include "graphicWindow.h"
62 #define SQU(a) ((a) * (a))
67 for(
int i = 0; i < 3; i++)
96 double l = sqrt(
SQU(range[1]) +
SQU(range[2]));
101 double l = sqrt(
SQU(range[0]) +
SQU(range[2]));
110 for(
int i = 0; i < 3; i++)
116 double zmin,
double zmax)
133 #if defined(HAVE_POST)
135 for(std::size_t i = 0; i <
PView::list.size(); i++)
137 if(!aroundVisible ||
PView::list[i]->getOptions()->visible)
177 int ParseFile(
const std::string &fileName,
bool close,
bool errorIfMissing)
179 #if !defined(HAVE_PARSER)
180 Msg::Error(
"Gmsh parser is not compiled in this version");
187 if(!(fp =
Fopen(fileName.c_str(),
"rb"))) {
189 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
212 Msg::Error(
"Too many errors: aborting parser...");
232 #if defined(HAVE_FLTK) && defined(HAVE_POST)
233 if(FlGui::available()) {
234 FlGui::instance()->updateViews(
true,
false);
243 const std::string &noExt)
245 std::ostringstream sstream;
246 sstream <<
"File '" << fileName <<
"' is in gzip format.\n\n"
247 <<
"Do you want to uncompress it?";
248 if(
Msg::GetAnswer(sstream.str().c_str(), 0,
"Cancel",
"Uncompress")) {
249 if(
SystemCall(std::string(
"gunzip -c ") + fileName +
" > " + noExt,
true))
251 "Potentially failed to uncompress `%s': check directory permissions",
261 if(str.empty())
return;
262 std::string fileName;
263 if(inCurrentModelDir)
268 FILE *fp =
Fopen(fileName.c_str(),
"w");
270 fprintf(fp,
"%s\n", str.c_str());
277 #if defined(HAVE_ONELAB)
278 static std::string GetSolverForExtension(
const std::string &ext)
287 static int DefineSolver(
const std::string &name)
298 int MergeFile(
const std::string &fileName,
bool errorIfMissing,
299 bool setBoundingBox,
bool importPhysicalsInOnelab,
304 FILE *fp =
Fopen(fileName.c_str(),
"rb");
307 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
312 if(!fgets(header,
sizeof(header), fp)) {
324 std::string noExt = split[0] + split[1], ext = split[2];
332 #if defined(HAVE_FLTK) && defined(HAVE_POST)
337 #if defined(HAVE_ONELAB)
338 std::string solver = GetSolverForExtension(ext);
340 int num = DefineSolver(solver);
353 else if(ext ==
".py" || ext ==
".PY" || ext ==
".m" || ext ==
".M" ||
354 ext ==
".exe" || ext ==
".EXE") {
355 int num = DefineSolver(split[1]);
368 if(ext ==
".stl" || ext ==
".STL") {
372 else if(ext ==
".brep" || ext ==
".rle" || ext ==
".brp" || ext ==
".BRP") {
375 else if(ext ==
".iges" || ext ==
".IGES" || ext ==
".igs" || ext ==
".IGS") {
378 else if(ext ==
".step" || ext ==
".STEP" || ext ==
".stp" || ext ==
".STP") {
382 else if(ext ==
".sat" || ext ==
".SAT") {
385 else if(ext ==
".x_t" || ext ==
".xmt_txt" ||
386 ext ==
".x_b" || ext ==
".xmt_bin") {
389 else if(ext ==
".unv" || ext ==
".UNV") {
393 else if(ext ==
".vtk" || ext ==
".VTK") {
396 else if(ext ==
".wrl" || ext ==
".WRL" || ext ==
".vrml" || ext ==
".VRML" ||
397 ext ==
".iv" || ext ==
".IV") {
400 else if(ext ==
".mesh" || ext ==
".MESH") {
403 else if(ext ==
".off" || ext ==
".OFF") {
406 else if(ext ==
".diff" || ext ==
".DIFF") {
409 else if(ext ==
".med" || ext ==
".MED" || ext ==
".mmed" || ext ==
".MMED" ||
410 ext ==
".rmed" || ext ==
".RMED") {
415 #if defined(HAVE_POST)
419 else if(ext ==
".bdf" || ext ==
".BDF" || ext ==
".nas" || ext ==
".NAS") {
422 else if(ext ==
".dat" || ext ==
".DAT") {
423 if(!strncmp(header,
"BEGIN ACTRAN", 12))
425 else if(!strncmp(header,
"!", 1) || !strncmp(header,
";ECHO", 5) ||
426 !strncmp(header,
".NOE", 4))
431 else if(ext ==
".p3d" || ext ==
".P3D") {
434 #if defined(HAVE_FLTK)
435 else if(ext ==
".pnm" || ext ==
".PNM" || ext ==
".pbm" || ext ==
".PBM" ||
436 ext ==
".pgm" || ext ==
".PGM" || ext ==
".ppm" || ext ==
".PPM") {
439 else if(ext ==
".bmp" || ext ==
".BMP") {
442 #if defined(HAVE_LIBJPEG)
443 else if(ext ==
".jpg" || ext ==
".JPG" || ext ==
".jpeg" || ext ==
".JPEG") {
447 #if defined(HAVE_LIBPNG)
448 else if(ext ==
".png" || ext ==
".PNG") {
453 else if(ext ==
".ply2" || ext ==
".PLY2") {
456 else if(ext ==
".ply" || ext ==
".PLY") {
459 else if(ext ==
".geom" || ext ==
".GEOM") {
462 #if defined(HAVE_LIBCGNS)
463 else if(ext ==
".cgns" || ext ==
".CGNS") {
464 std::vector<std::vector<MVertex *> > vertPerZone;
465 std::vector<std::vector<MElement *> > eltPerZone;
469 tmp->
readCGNS(fileName, vertPerZone, eltPerZone);
480 #if defined(HAVE_POST)
481 if((status > 1) && (
CTX::instance()->mesh.cgnsImportIgnoreSolution == 0)) {
488 else if(ext ==
".csv") {
489 status = readFile3M(fileName);
494 if(!strncmp(header,
"$PTS", 4) || !strncmp(header,
"$NO", 3) ||
495 !strncmp(header,
"$PARA", 5) || !strncmp(header,
"$ELM", 4) ||
496 !strncmp(header,
"$MeshFormat", 11) ||
497 !strncmp(header,
"$Comments", 9)) {
514 #if defined(HAVE_POST)
515 if(status > 1) status =
PView::readMSH(fileName, -1, partitionToRead);
518 #if defined(HAVE_POST)
519 else if(ext ==
".pch") {
522 else if(!strncmp(header,
"$PostFormat", 11) ||
523 !strncmp(header,
"$View", 5)) {
552 #if defined(HAVE_FLTK) && defined(HAVE_POST)
553 if(FlGui::available()) {
555 for(std::size_t i = numViewsBefore; i <
PView::list.size(); i++)
557 PView::list[i]->getData()->getFirstNonEmptyTimeStep(
559 FlGui::instance()->updateViews(numViewsBefore != (
int)
PView::list.size(),
564 if(!status)
Msg::Error(
"Error loading '%s'", fileName.c_str());
575 bool showLastStep,
bool errorIfMissing)
577 #if defined(HAVE_POST)
579 FILE *fp =
Fopen(fileName.c_str(),
"rb");
582 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
586 if(!fgets(header,
sizeof(header), fp)) {
590 bool haveMesh =
false;
591 if(!strncmp(header,
"$MeshFormat", 11)) {
592 while(!feof(fp) && fgets(header,
sizeof(header), fp)) {
593 if(!strncmp(header,
"$Nodes", 6)) {
597 else if(!strncmp(header,
"$NodeData", 9) ||
598 !strncmp(header,
"$ElementData", 12) ||
599 !strncmp(header,
"$ElementNodeData", 16)) {
608 std::vector<int> steps(n, 0);
610 for(std::size_t i = 0; i <
PView::list.size(); i++)
629 for(std::size_t i = 0; i <
PView::list.size(); i++) {
630 if(
PView::list[i]->getData()->getFileName().substr(0, 6) !=
"ONELAB" &&
631 PView::list[i]->getOptions()->attributes.find(
"AlwaysVisible") ==
636 else if(showViews == 2 && n <
PView::list.size()) {
639 for(std::size_t i = 0; i < n; i++) {
640 if(
PView::list[i]->getData()->getFileName().substr(0, 6) !=
"ONELAB" &&
641 PView::list[i]->getOptions()->attributes.find(
"AlwaysVisible") ==
651 for(std::size_t i = 0; i <
PView::list.size(); i++) {
653 if(step > steps[i] && steps[i] > 1)
666 #if defined(HAVE_POST)
674 #if defined(HAVE_PARSER)
699 Msg::Info(
"Clearing all models and views...");
701 Msg::Info(
"Done clearing all models and views");
707 #if defined(HAVE_FLTK)
708 if(FlGui::available()) {
709 FlGui::instance()->resetVisibility();
710 FlGui::instance()->updateViews(
true,
true);
711 FlGui::instance()->updateFields();
718 void OpenProject(
const std::string &fileName,
bool errorIfMissing)
721 Msg::Info(
"I'm busy! Ask me that later...");
742 #if defined(HAVE_PARSER)
746 for(
auto it = cln.begin();
747 it != cln.end(); it++)
750 for(
auto it = cls.begin();
751 it != cls.end(); it++)
768 for(std::size_t i = 0; i < tmp.size(); i++) {
772 #if defined(HAVE_FLTK)
773 if(FlGui::available()) FlGui::instance()->graph[0]->fillRecentHistoryMenu();
788 #if defined(HAVE_FLTK)
789 if(FlGui::available()) {
790 file_watch_cb(
nullptr,
nullptr);
791 FlGui::instance()->resetVisibility();
792 FlGui::instance()->updateViews(
true,
false);
793 FlGui::instance()->updateFields();
801 if(!fileName)
return;
802 std::string name(fileName);
804 Msg::Debug(
"Ignoring macOS file open callback, as the given file name "
805 "is the executable name '%s'", name.c_str());
808 #if defined(HAVE_FLTK)
809 if(!FlGui::available() || !FlGui::getFinishedProcessingCommandLine()) {
811 FlGui::setOpenedThroughMacFinder(name);
818 solver_cb(
nullptr, (
void *)(intptr_t)
CTX::instance()->launchSolverAtStartup);
std::string opt_solver_name(OPT_ARGS_STR)
void setVisibility(char val)
int SystemCall(const std::string &command, bool blocking)
std::vector< std::string > SplitFileName(const std::string &fileName)
int readParasolidXMT(const std::string &name)
static std::map< std::string, std::string > & GetCommandLineStrings()
int MergeFile(const std::string &fileName, bool errorIfMissing, bool setBoundingBox, bool importPhysicalsInOnelab, int partitionToRead)
int readUNV(const std::string &name, bool readGroupsOfElements=true)
int read_pnm(std::string fileName)
static void Info(const char *fmt,...)
void setMaxTag(int dim, int val)
double matchMeshScaleFactor
bool addAutomaticExtrusionConstraints(const std::vector< int > &numElements, const std::vector< double > &heights, const bool recombine, const std::vector< int > ®ionTag)
static void Debug(const char *fmt,...)
void DeleteAllModelsAndViews()
static GeomMeshMatcher * instance()
static void Warning(const char *fmt,...)
static void Error(const char *fmt,...)
static void StatusBar(bool log, const char *fmt,...)
static FunctionManager * Instance()
int readGEOM(const std::string &name)
int readOCCSTEP(const std::string &name)
static bool readPOS(const std::string &fileName, int fileIndex=-1)
static void ImportPhysicalGroupsInOnelab()
NameSpaces gmsh_yynamespaces
std::string opt_solver_extension(OPT_ARGS_STR)
int UnlinkFile(const std::string &fileName)
int readDIFF(const std::string &name)
void SetBoundingBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
static void AddOnelabStringChoice(const std::string &name, const std::string &kind, const std::string &value, bool updateValue=true, bool readOnly=false, bool visible=true)
static drawContextGlobal * global()
void getBoundingBox(int dim, List_T *in, List_T *out)
FILE * Fopen(const char *f, const char *mode)
int readMSH(const std::string &name)
static SBoundingBox3d temp_bb
virtual void draw(bool rateLimited=true)
void ParseString(const std::string &str, bool inCurrentModelDir)
double opt_view_nb_timestep(OPT_ARGS_NUM)
static void SetOnelabString(const std::string &name, const std::string &val, bool visible=true, bool persistent=false, bool readOnly=false, int changedValue=3, const std::string &kind="")
int readCGNS(const std::string &name, std::vector< std::vector< MVertex * > > &vertPerZone, std::vector< std::vector< MElement * > > &eltPerZone)
int MergePostProcessingFile(const std::string &fileName, int showViews, bool showLastStep, bool errorIfMissing)
static int readMED(const std::string &name)
static bool DoSystemUncompress(const std::string &fileName, const std::string &noExt)
int readVTK(const std::string &name, bool bigEndian=false)
int readSTL(const std::string &name, double tolerance=1.e-3)
SBoundingBox3d bounds(bool aroundVisible=false)
std::string FixRelativePath(const std::string &reference, const std::string &in)
void scaleMesh(double factor)
void setName(const std::string &name)
void setFileName(const std::string &fileName)
int read_bmp(std::string fileName)
std::map< std::string, gmsh_yysymbol > gmsh_yysymbols
void OpenProject(const std::string &fileName, bool errorIfMissing)
int readVRML(const std::string &name)
static bool readCGNS(const std::vector< std::vector< MVertex * > > &vertPerZone, const std::vector< std::vector< MElement * > > &eltPerZone, const std::string &fileName)
int readP3D(const std::string &name)
static void SetOnelabChanged(int value, const std::string &client="Gmsh")
static void removeAllInterpolationSchemes()
int readPLY2(const std::string &name)
void AddToTemporaryBoundingBox(double x, double y, double z)
int read_png(std::string fileName)
void destroy(bool keepName=false)
int read_jpeg(std::string fileName)
static std::vector< GModel * > list
double opt_view_timestep(OPT_ARGS_NUM)
int readPLY(const std::string &name)
int readBDF(const std::string &name)
contextGeometryOptions geom
int readACTRAN(const std::string &name)
int readOFF(const std::string &name)
int StatFile(const std::string &fileName)
static int readGEO(const std::string &name)
int readACISSAT(const std::string &name)
static int setCurrent(GModel *m)
static int GetNumOnelabClients()
static void ResetErrorCounter()
std::vector< std::string > recentFiles
static std::map< std::string, std::vector< double > > & GetCommandLineNumbers()
int readSAMCEF(const std::string &name)
int readOCCBREP(const std::string &name)
static bool readMED(const std::string &fileName, int fileIndex=-1)
static int GetAnswer(const char *question, int defaultval, const char *zero, const char *one, const char *two=nullptr)
static bool readMSH(const std::string &fileName, int fileIndex=-1, int partitionToRead=-1)
static bool readPCH(const std::string &fileName, int fileIndex=-1)
std::map< std::string, std::vector< std::string > > gmsh_yystringsymbols
void ResetTemporaryBoundingBox()
int readMESH(const std::string &name)
int launchSolverAtStartup
int readOCCIGES(const std::string &name)
static void FinishUpBoundingBox()
static void setGlobalTag(int tag)
std::string gmsh_yyfactory
static std::vector< PView * > list
int match(GModel *geom, GModel *mesh)
void setSelection(int val)
GEO_Internals * getGEOInternals()
int ParseFile(const std::string &fileName, bool close, bool errorIfMissing)
static std::string GetOnelabString(const std::string &name, const std::string &defaultValue="", bool errorIfMissing=false)
static std::vector< FILE * > openedFiles
static std::string GetExecutableName()
static GModel * current(int index=-1)
std::string opt_solver_executable(OPT_ARGS_STR)
void OpenProjectMacFinder(const char *fileName)