Newer
Older
// Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
Nicolas Kowalski
committed
#include <iostream>
#include "GmshConfig.h"
#include "GmshDefines.h"
#include "GmshVersion.h"
#include "GmshMessage.h"
#include "OpenFile.h"
#include "CommandLine.h"
#include "Context.h"
#include "Options.h"
#include "GModel.h"
#include "CreateFile.h"
#include "OS.h"

Christophe Geuzaine
committed
#if defined(HAVE_FLTK)
#include <FL/Fl.H>

Christophe Geuzaine
committed
#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION >= 3)

Christophe Geuzaine
committed
#error "Gmsh requires FLTK >= 1.3"

Christophe Geuzaine
committed
#endif
#endif
#if defined(HAVE_PETSC)
#include "petsc.h"
#endif

Christophe Geuzaine
committed
#include "PView.h"
#endif

Christophe Geuzaine
committed
#if defined(HAVE_PARSER)
#include "Parser.h"
#endif
int GetGmshMajorVersion(){ return GMSH_MAJOR_VERSION; }
int GetGmshMinorVersion(){ return GMSH_MINOR_VERSION; }
int GetGmshPatchVersion(){ return GMSH_PATCH_VERSION; }
const char *GetGmshExtraVersion(){ return GMSH_EXTRA_VERSION; }
const char *GetGmshVersion(){ return GMSH_VERSION; }
const char *GetGmshBuildDate(){ return GMSH_DATE; }
const char *GetGmshBuildHost(){ return GMSH_HOST; }
const char *GetGmshPackager(){ return GMSH_PACKAGER; }
const char *GetGmshBuildOS(){ return GMSH_OS; }
const char *GetGmshShortLicense(){ return GMSH_SHORT_LICENSE; }
const char *GetGmshBuildOptions(){ return GMSH_CONFIG_OPTIONS; }
typedef std::pair<std::string, std::string> mp;
std::vector<mp> s;
s.push_back(mp("Geometry options:", ""));
s.push_back(mp("-tol float", "Set geometrical tolerance"));
s.push_back(mp("-match", "Match geometries and meshes"));
s.push_back(mp("Mesh options:", ""));
s.push_back(mp("-1, -2, -3", "Perform 1D, 2D or 3D mesh generation, then exit"));
s.push_back(mp("-format string", "Select output mesh format (auto (default), msh, "
"msh1, msh2, unv, vrml, ply2, stl, mesh, bdf, cgns, "
"p3d, diff, med, ...)"));
s.push_back(mp("-bin", "Use binary format when available"));
s.push_back(mp("-refine", "Perform uniform mesh refinement, then exit"));
s.push_back(mp("-part int", "Partition after batch mesh generation"));
s.push_back(mp("-partWeight tri|quad|tet|prism|hex int", "Weight of a triangle/quad/etc. "
"during partitioning"));
s.push_back(mp("-saveall", "Save all elements (discard physical group definitions)"));
s.push_back(mp("-parametric", "Save vertices with their parametric coordinates"));
s.push_back(mp("-algo string", "Select mesh algorithm (meshadapt, del2d, front2d, "
"delquad, del3d, front3d, mmg3d, pack)"));
s.push_back(mp("-smooth int", "Set number of mesh smoothing steps"));
s.push_back(mp("-order int", "Set mesh order (1, ..., 5)"));
s.push_back(mp("-optimize[_netgen]", "Optimize quality of tetrahedral elements"));
s.push_back(mp("-optimize_ho", "Optimize high order meshes"));
s.push_back(mp("-ho_[min,max,nlayers]", "High-order optimization parameters"));
s.push_back(mp("-optimize_lloyd", "Optimize 2D meshes using Lloyd algorithm"));
s.push_back(mp("-clscale float", "Set global mesh element size scaling factor"));
s.push_back(mp("-clmin float", "Set minimum mesh element size"));
s.push_back(mp("-clmax float", "Set maximum mesh element size"));
s.push_back(mp("-anisoMax float", "Set maximum anisotropy (only used in bamg for now)"));
s.push_back(mp("-smoothRatio float", "Set smoothing ration between mesh sizes at nodes of "
"a same edge (only used in bamg)"));
s.push_back(mp("-clcurv", "Automatically compute element sizes from curvatures"));
s.push_back(mp("-epslc1d", "Set accuracy of evaluation of LCFIELD for 1D mesh"));
s.push_back(mp("-swapangle", "Set the threshold angle (in degree) between two adjacent"
" faces below which a swap is allowed"));
s.push_back(mp("-rand float", "Set random perturbation factor"));
s.push_back(mp("-bgm file", "Load background mesh from file"));
s.push_back(mp("-check", "Perform various consistency checks on mesh"));
s.push_back(mp("-mpass int", "Do several passes on the mesh for complex background fields"));
s.push_back(mp("-ignorePartBound", "Ignore partitions boundaries"));
s.push_back(mp("Post-processing options:", ""));
s.push_back(mp("-link int", "Select link mode between views (0, 1, 2, 3, 4)"));
s.push_back(mp("-combine", "Combine views having identical names into "
"multi-time-step views"));
s.push_back(mp("Solver options:", ""));
s.push_back(mp("-listen", "Always listen to incoming connection requests"));
s.push_back(mp("-minterpreter string", "Name of Octave interpreter"));
s.push_back(mp("-pyinterpreter string", "Name of Python interpreter"));
s.push_back(mp("Display options:", ""));
s.push_back(mp("-n", "Hide all meshes and post-processing views on startup"));
s.push_back(mp("-nodb", "Disable double buffering"));
s.push_back(mp("-numsubedges", "Set num of subdivisions for high order element display"));
s.push_back(mp("-fontsize int", "Specify the font size for the GUI"));
s.push_back(mp("-theme string", "Specify FLTK GUI theme"));
s.push_back(mp("-display string", "Specify display"));
s.push_back(mp("-camera", "Use camera mode view;"));
s.push_back(mp("-stereo", "OpenGL quad-buffered stereo rendering (requires "
"special graphic card)"));
s.push_back(mp("-gamepad", "Use gamepad controller if available"));
s.push_back(mp("Other options:", ""));
s.push_back(mp("-, -parse_and_exit", "Parse input files, then exit"));

Christophe Geuzaine
committed
s.push_back(mp("-new", "Create new model before merge next file"));
s.push_back(mp("-merge", "Merge next files"));
s.push_back(mp("-open", "Open next files"));
s.push_back(mp("-a, -g, -m, -s, -p", "Start in automatic, geometry, mesh, solver or "
"post-processing mode"));
s.push_back(mp("-pid", "Print process id on stdout"));
s.push_back(mp("-watch pattern", "Pattern of files to merge as they become available"));
s.push_back(mp("-bg file", "Load background (image or PDF) file"));
s.push_back(mp("-v int", "Set verbosity level"));
s.push_back(mp("-nopopup", "Don't popup dialog windows in scripts"));

Christophe Geuzaine
committed
s.push_back(mp("-string \"string\"", "Parse command string at startup"));
s.push_back(mp("-setnumber name value", "Set constant number name=value"));
s.push_back(mp("-setstring name value", "Set constant string name=value"));
s.push_back(mp("-option file", "Parse option file at startup"));
s.push_back(mp("-convert files", "Convert files into latest binary formats, then exit"));
s.push_back(mp("-version", "Show version number"));
s.push_back(mp("-info", "Show detailed version information"));
s.push_back(mp("-help", "Show command line usage"));
std::vector<std::pair<std::string, std::string> > GetShortcutsUsage(const std::string &ctrl)
typedef std::pair<std::string, std::string> mp;
std::vector<mp> s;
s.push_back(mp("Left arrow", "Go to previous time step"));
s.push_back(mp("Right arrow", "Go to next time step"));
s.push_back(mp("Up arrow", "Make previous view visible"));
s.push_back(mp("Down arrow", "Make next view visible"));
s.push_back(mp("0", "Reload project file"));
s.push_back(mp("1 or F1", "Mesh lines"));
s.push_back(mp("2 or F2", "Mesh surfaces"));
s.push_back(mp("3 or F3", "Mesh volumes"));
s.push_back(mp("Escape", "Cancel lasso zoom/selection, toggle mouse selection ON/OFF"));
s.push_back(mp("g", "Go to geometry module"));
s.push_back(mp("m", "Go to mesh module"));
s.push_back(mp("p", "Go to post-processing module"));
s.push_back(mp("s", "Go to solver module"));
s.push_back(mp("Shift+a", "Bring all windows to front"));
s.push_back(mp("Shift+g", "Show geometry options"));
s.push_back(mp("Shift+m", "Show mesh options"));
s.push_back(mp("Shift+o", "Show general options"));
s.push_back(mp("Shift+p", "Show post-processing options"));
s.push_back(mp("Shift+s", "Show solver options"));
s.push_back(mp("Shift+u", "Show post-processing view plugins"));
s.push_back(mp("Shift+w", "Show post-processing view options"));
s.push_back(mp("Shift+Escape", "Enable full mouse selection"));
s.push_back(mp(cc + "d", "Attach/detach menu"));

Christophe Geuzaine
committed
s.push_back(mp(cc + "i", "Show statistics window"));
s.push_back(mp(cc + "j", "Save model options"));
s.push_back(mp(cc + "l", "Show message console"));
s.push_back(mp(cc + "m", "Minimize window"));
s.push_back(mp(cc + "n", "Create new project file"));
s.push_back(mp(cc + "o", "Open project file"));
s.push_back(mp(cc + "q", "Quit"));
s.push_back(mp(cc + "r", "Rename project file"));
s.push_back(mp(cc + "s", "Save file as"));
s.push_back(mp("Shift+" + cc + "c", "Show clipping plane window"));
s.push_back(mp("Shift+" + cc + "h", "Show current options and workspace window"));

Christophe Geuzaine
committed
s.push_back(mp("Shift+" + cc + "j", "Save options as default"));
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
s.push_back(mp("Shift+" + cc + "m", "Show manipulator window"));
s.push_back(mp("Shift+" + cc + "n", "Show option window"));
s.push_back(mp("Shift+" + cc + "o", "Merge file(s)"));
s.push_back(mp("Shift+" + cc + "s", "Save mesh in default format"));
s.push_back(mp("Shift+" + cc + "u", "Show plugin window"));
s.push_back(mp("Shift+" + cc + "v", "Show visibility window"));
s.push_back(mp("Alt+a", "Loop through axes modes"));
s.push_back(mp("Alt+b", "Hide/show bounding boxes"));
s.push_back(mp("Alt+c", "Loop through predefined color schemes"));
s.push_back(mp("Alt+e", "Hide/Show element outlines for visible post-pro views"));
s.push_back(mp("Alt+f", "Change redraw mode (fast/full)"));
s.push_back(mp("Alt+h", "Hide/show all post-processing views"));
s.push_back(mp("Alt+i", "Hide/show all post-processing view scales"));
s.push_back(mp("Alt+l", "Hide/show geometry lines"));
s.push_back(mp("Alt+m", "Toggle visibility of all mesh entities"));
s.push_back(mp("Alt+n", "Hide/show all post-processing view annotations"));
s.push_back(mp("Alt+o", "Change projection mode (orthographic/perspective)"));
s.push_back(mp("Alt+p", "Hide/show geometry points"));
s.push_back(mp("Alt+r", "Loop through range modes for visible post-pro views"));
s.push_back(mp("Alt+s", "Hide/show geometry surfaces"));
s.push_back(mp("Alt+t", "Loop through interval modes for visible post-pro views"));
s.push_back(mp("Alt+v", "Hide/show geometry volumes"));
s.push_back(mp("Alt+w", "Enable/disable all lighting"));
s.push_back(mp("Alt+x", "Set X view"));
s.push_back(mp("Alt+y", "Set Y view"));
s.push_back(mp("Alt+z", "Set Z view"));
s.push_back(mp("Alt+Shift+a", "Hide/show small axes"));
s.push_back(mp("Alt+Shift+b", "Hide/show mesh volume faces"));
s.push_back(mp("Alt+Shift+d", "Hide/show mesh surface faces"));
s.push_back(mp("Alt+Shift+l", "Hide/show mesh lines"));
s.push_back(mp("Alt+Shift+p", "Hide/show mesh points"));
s.push_back(mp("Alt+Shift+s", "Hide/show mesh surface edges"));
s.push_back(mp("Alt+Shift+v", "Hide/show mesh volume edges"));
s.push_back(mp("Alt+Shift+w", "Reverse all mesh normals"));
s.push_back(mp("Alt+Shift+x", "Set -X view"));
s.push_back(mp("Alt+Shift+y", "Set -Y view"));
s.push_back(mp("Alt+Shift+z", "Set -Z view"));
std::vector<std::pair<std::string, std::string> > GetMouseUsage()
typedef std::pair<std::string, std::string> mp;
std::vector<mp> s;
s.push_back(mp("Move", "- Highlight the entity under the mouse pointer and display its properties"));
s.push_back(mp("", "- Resize a lasso zoom or a lasso (un)selection"));
s.push_back(mp("Left button", "- Rotate"));
s.push_back(mp("", "- Select an entity"));
s.push_back(mp("", "- Accept a lasso zoom or a lasso selection"));
s.push_back(mp("Ctrl+Left button", "Start a lasso zoom or a lasso (un)selection"));
s.push_back(mp("Middle button", "- Zoom"));
s.push_back(mp("", "- Unselect an entity"));
s.push_back(mp("", "- Accept a lasso zoom or a lasso unselection"));
s.push_back(mp("Ctrl+Middle button", "Orthogonalize display"));
s.push_back(mp("Right button", "- Pan"));
s.push_back(mp("", "- Cancel a lasso zoom or a lasso (un)selection"));
s.push_back(mp("", "- Pop-up menu on post-processing view button"));
s.push_back(mp("Ctrl+Right button", "Reset to default viewpoint"));
return s;
}
void PrintUsage(const std::string &name)
{
Msg::Direct("Usage: %s [options] [files]", name.c_str());
std::vector<std::pair<std::string, std::string> > s = GetUsage();
for(unsigned int i = 0; i < s.size(); i++){
std::string a = s[i].first, b = s[i].second;
if(b.empty()){
Msg::Direct("%s", a.c_str());
}
else{
if(a.size() < 20) a.resize(20, ' ');
Msg::Direct(" %s %s", a.c_str(), b.c_str());
}
}
void GetOptions(int argc, char *argv[])
// print messages on terminal
int terminal = CTX::instance()->terminal;

Christophe Geuzaine
committed
if(argc && argv){
// parse session and option file (if argc/argv is not provided skip this
// step: this is usually what is expected when using Gmsh as a library)
ParseFile(CTX::instance()->homeDir + CTX::instance()->sessionFileName, true);
ParseFile(CTX::instance()->homeDir + CTX::instance()->optionsFileName, true);
}

Christophe Geuzaine
committed
// get command line options
if(!strcmp(argv[i] + 1, "") ||
!strcmp(argv[i] + 1, "parse_and_exit")) {

Christophe Geuzaine
committed
CTX::instance()->batch = -99;
i++;
}
else if(!strcmp(argv[i] + 1, "onelab")) {
if(argv[i] && argv[i + 1] && argv[i + 1][0] != '-'){
Msg::InitializeOnelab(argv[i], argv[i + 1]);
i += 2;
}
Msg::Fatal("Missing client name and/or address of ONELAB server");

Christophe Geuzaine
committed
else if(!strcmp(argv[i] + 1, "socket")) {

Christophe Geuzaine
committed
Msg::InitializeOnelab("GmshRemote", argv[i++]);
Msg::Fatal("Missing string");
CTX::instance()->batch = -3;

Christophe Geuzaine
committed
else if(!strcmp(argv[i] + 1, "check")) {
CTX::instance()->batch = -2;
i++;
}
else if(!strcmp(argv[i] + 1, "0")) {
CTX::instance()->batch = -1;
i++;
}
else if(!strcmp(argv[i] + 1, "1")) {
CTX::instance()->batch = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "2")) {
CTX::instance()->batch = 2;
i++;
}
else if(!strcmp(argv[i] + 1, "3")) {
CTX::instance()->batch = 3;
CTX::instance()->batch = 4;
else if(!strcmp(argv[i] + 1, "refine")) {
CTX::instance()->batch = 5;
else if(!strcmp(argv[i] + 1, "renumber")) {
CTX::instance()->batchAfterMesh = 1;
opt_mesh_partition_num(0, GMSH_SET, atoi(argv[i++]));
}
else
Msg::Fatal("Missing number");

Koen Hillewaert
committed
else if (!strcmp(argv[i] + 1,"partWeight")) {
i++;
bool check = true;

Christophe Geuzaine
committed
opt_mesh_partition_partitioner(0, GMSH_SET, 2); // Metis partitioner
opt_mesh_partition_metis_algorithm(0, GMSH_SET, 3); // partGraphKWay w/ weights

Koen Hillewaert
committed
while (check) {
if (argv[i]) {
Axel Modave
committed
if (!strcmp(argv[i],"tri") || !strcmp(argv[i],"triangle")) {

Koen Hillewaert
committed
i++;
opt_mesh_partition_tri_weight(0,GMSH_SET,atoi(argv[i]));
}
else if (!strcmp(argv[i],"quad")) {
i++;
opt_mesh_partition_qua_weight(0,GMSH_SET,atoi(argv[i]));
}
else if (!strcmp(argv[i],"tet")) {
i++;
opt_mesh_partition_tet_weight(0,GMSH_SET,atoi(argv[i]));
}
else if (!strcmp(argv[i],"prism")) {
i++;
opt_mesh_partition_pri_weight(0,GMSH_SET,atoi(argv[i]));
}
else if (!strcmp(argv[i],"pyramid")) {
i++;
opt_mesh_partition_pyr_weight(0,GMSH_SET,atoi(argv[i]));
}
else if (!strcmp(argv[i],"hex")) {
i++;
opt_mesh_partition_hex_weight(0,GMSH_SET,atoi(argv[i]));
}
Axel Modave
committed
else {
Msg::Error("Bad argument for 'partWeight' (%s)", argv[i]);
check = false;
}

Koen Hillewaert
committed
i++;
}
else check = false;
}
}
else if(!strcmp(argv[i] + 1, "new")) {
CTX::instance()->files.push_back("-new");

Christophe Geuzaine
committed
else if(!strcmp(argv[i] + 1, "open")) {
CTX::instance()->files.push_back("-open");
i++;
}
else if(!strcmp(argv[i] + 1, "merge")) {
CTX::instance()->files.push_back("-merge");
i++;
}
CTX::instance()->initialContext = 0;
CTX::instance()->initialContext = 1;
CTX::instance()->initialContext = 2;
CTX::instance()->initialContext = 3;
CTX::instance()->initialContext = 4;
CTX::instance()->mesh.saveAll = 1;
Bastien Gorissen
committed
else if(!strcmp(argv[i] + 1, "switch_tags")) {
CTX::instance()->mesh.switchElementTags = 1;
i++;
}
CTX::instance()->mesh.optimize = 1;
else if(!strcmp(argv[i] + 1, "optimize_netgen")) {
CTX::instance()->mesh.optimizeNetgen = 1;
else if(!strcmp(argv[i] + 1, "optimize_ho") ||
!strcmp(argv[i] + 1, "hoOptimize")) {

Christophe Geuzaine
committed
i++;

Christophe Geuzaine
committed
}
else if(!strcmp(argv[i] + 1, "ho_min")) {
Bastien Gorissen
committed
i++;
opt_mesh_ho_threshold_min(0, GMSH_SET, atof(argv[i++]));
else
Msg::Fatal("Missing number");
}
else if(!strcmp(argv[i] + 1, "ho_max")) {
i++;
if(argv[i])
opt_mesh_ho_threshold_max(0, GMSH_SET, atof(argv[i++]));
else
Msg::Fatal("Missing number");
}
else if(!strcmp(argv[i] + 1, "ho_nlayers")) {
i++;
if(argv[i])
opt_mesh_ho_nlayers(0, GMSH_SET, atoi(argv[i++]));
else
Msg::Fatal("Missing number");
Bastien Gorissen
committed
}

Christophe Geuzaine
committed
else if(!strcmp(argv[i] + 1, "optimize_lloyd")) {
i++;
if(argv[i])
CTX::instance()->mesh.optimizeLloyd = atoi(argv[i++]);
else
Msg::Fatal("Missing number of lloyd iterations");
else if(!strcmp(argv[i] + 1, "bunin")) {
i++;
if(argv[i])
CTX::instance()->mesh.bunin = atoi(argv[i++]);
else
Msg::Fatal("Missing cavity size in bunin optimization");
}
#if defined(HAVE_MESH)
else if(!strcmp(argv[i] + 1, "microstructure")) {
i++;
int j;
int radical;
double max;
Nicolas Kowalski
committed
double xMax;
double yMax;
double zMax;
std::vector<double> properties;
if(argv[i]){
std::ifstream file(argv[i++]);
file >> max;
file >> radical;
Nicolas Kowalski
committed
file >> xMax;
file >> yMax;
file >> zMax;
properties.clear();
properties.resize(4*max);
for(j=0;j<max;j++){
file >> properties[4*j];
file >> properties[4*j+1];
file >> properties[4*j+2];
file >> properties[4*j+3];
}
voroMetal3D vm1;
Nicolas Kowalski
committed
vm1.execute(properties,radical,0.1,xMax,yMax,zMax);
GModel::current()->load("MicrostructurePolycrystal3D.geo");
voroMetal3D vm2;
Nicolas Kowalski
committed
vm2.correspondance(0.00001,xMax,yMax,zMax);
Nicolas Kowalski
committed
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
else if(!strcmp(argv[i] + 1, "computeBestSeeds")) {
i++;
int j;
int radical;
double max;
double xMax;
double yMax;
double zMax;
std::vector<double> properties;
std::cout<<"entree dans computeBestSeeds"<<std::endl;
if(argv[i]){
std::ifstream file(argv[i++]);
file >> max;
file >> radical;
file >> xMax;
file >> yMax;
file >> zMax;
properties.clear();
properties.resize(4*max);
for(j=0;j<max;j++){
file >> properties[4*j];
file >> properties[4*j+1];
file >> properties[4*j+2];
file >> properties[4*j+3];
}
std::cout<<"Before count"<<std::endl;
std::vector<double> listDistances;
listDistances.clear();
int nbOfCount = 17;
listDistances.resize(nbOfCount);
Nicolas Kowalski
committed
for (int Count = 0; Count < nbOfCount; Count++){
Nicolas Kowalski
committed
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
std::cout<<"Count"<<Count<<std::endl;
double distMinGlobal = 0.0;
int jMinGlobal = 0;
int xORyORz = 0;
int posORneg = 0;
for(j=0;j<max;j++){
std::cout<<"j "<<j<<std::endl;
std::vector<double> propertiesModified;
propertiesModified.clear();
propertiesModified.resize(4*max);
std::cout<<"before assign propModif"<<std::endl;
for(unsigned int k=0;k < properties.size();k++){
propertiesModified[k] = properties[k];
}
std::cout<<"after assign propModif"<<std::endl;
propertiesModified[4*j] += 0.01;
voroMetal3D vm1;
std::cout<<"before execute"<<std::endl;
//std::remove("MicrostructurePolycrystal3D.geo");
vm1.execute(propertiesModified,radical,0.1,xMax,yMax,zMax);
//GModel::current()->destroy();
GModel *m = new GModel();
//GModel::current()->load("MicrostructurePolycrystal3D.geo");
m->load("MicrostructurePolycrystal3D.geo");
double distMinTmp = 1000.0;
//GModel *m = GModel::current();
for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){
GEdge* eTmp = (*ite);
GVertex* vTmp1 = eTmp->getBeginVertex();
GVertex* vTmp2 = eTmp->getEndVertex();
double distTmp = sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z()));
if (distTmp < distMinTmp){
distMinTmp = distTmp;
}
}
if (distMinTmp > distMinGlobal){
distMinGlobal = distMinTmp;
jMinGlobal = j;
xORyORz = 1;
posORneg = 1;
}
delete m;
}
for(j=0;j<max;j++){
std::cout<<"j "<<j<<std::endl;
std::vector<double> propertiesModified;
propertiesModified.clear();
propertiesModified.resize(4*max);
std::cout<<"before assign propModif"<<std::endl;
for(unsigned int k=0;k < properties.size();k++){
propertiesModified[k] = properties[k];
}
std::cout<<"after assign propModif"<<std::endl;
propertiesModified[4*j + 1] += 0.01;
voroMetal3D vm1;
std::cout<<"before execute"<<std::endl;
//std::remove("MicrostructurePolycrystal3D.geo");
vm1.execute(propertiesModified,radical,0.1,xMax,yMax,zMax);
//GModel::current()->destroy();
GModel *m = new GModel();
//GModel::current()->load("MicrostructurePolycrystal3D.geo");
m->load("MicrostructurePolycrystal3D.geo");
double distMinTmp = 1000.0;
//GModel *m = GModel::current();
for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){
GEdge* eTmp = (*ite);
GVertex* vTmp1 = eTmp->getBeginVertex();
GVertex* vTmp2 = eTmp->getEndVertex();
double distTmp = sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z()));
if (distTmp < distMinTmp){
distMinTmp = distTmp;
}
}
if (distMinTmp > distMinGlobal){
distMinGlobal = distMinTmp;
jMinGlobal = j;
xORyORz = 2;
posORneg = 1;
}
delete m;
}
for(j=0;j<max;j++){
std::cout<<"j "<<j<<std::endl;
std::vector<double> propertiesModified;
propertiesModified.clear();
propertiesModified.resize(4*max);
std::cout<<"before assign propModif"<<std::endl;
for(unsigned int k=0;k < properties.size();k++){
propertiesModified[k] = properties[k];
}
std::cout<<"after assign propModif"<<std::endl;
propertiesModified[4*j + 2] += 0.01;
voroMetal3D vm1;
std::cout<<"before execute"<<std::endl;
//std::remove("MicrostructurePolycrystal3D.geo");
vm1.execute(propertiesModified,radical,0.1,xMax,yMax,zMax);
//GModel::current()->destroy();
GModel *m = new GModel();
//GModel::current()->load("MicrostructurePolycrystal3D.geo");
m->load("MicrostructurePolycrystal3D.geo");
double distMinTmp = 1000.0;
//GModel *m = GModel::current();
for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){
GEdge* eTmp = (*ite);
GVertex* vTmp1 = eTmp->getBeginVertex();
GVertex* vTmp2 = eTmp->getEndVertex();
double distTmp = sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z()));
if (distTmp < distMinTmp){
distMinTmp = distTmp;
}
}
if (distMinTmp > distMinGlobal){
distMinGlobal = distMinTmp;
jMinGlobal = j;
xORyORz = 3;
posORneg = 1;
}
delete m;
}
for(j=0;j<max;j++){
std::cout<<"j "<<j<<std::endl;
std::vector<double> propertiesModified;
propertiesModified.clear();
propertiesModified.resize(4*max);
std::cout<<"before assign propModif"<<std::endl;
for(unsigned int k=0;k < properties.size();k++){
propertiesModified[k] = properties[k];
}
std::cout<<"after assign propModif"<<std::endl;
propertiesModified[4*j] -= 0.01;
voroMetal3D vm1;
std::cout<<"before execute"<<std::endl;
//std::remove("MicrostructurePolycrystal3D.geo");
vm1.execute(propertiesModified,radical,0.1,xMax,yMax,zMax);
//GModel::current()->destroy();
GModel *m = new GModel();
//GModel::current()->load("MicrostructurePolycrystal3D.geo");
m->load("MicrostructurePolycrystal3D.geo");
double distMinTmp = 1000.0;
//GModel *m = GModel::current();
for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){
GEdge* eTmp = (*ite);
GVertex* vTmp1 = eTmp->getBeginVertex();
GVertex* vTmp2 = eTmp->getEndVertex();
double distTmp = sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z()));
if (distTmp < distMinTmp){
distMinTmp = distTmp;
}
}
if (distMinTmp > distMinGlobal){
distMinGlobal = distMinTmp;
jMinGlobal = j;
xORyORz = 1;
posORneg = 2;
}
delete m;
}
for(j=0;j<max;j++){
std::cout<<"j "<<j<<std::endl;
std::vector<double> propertiesModified;
propertiesModified.clear();
propertiesModified.resize(4*max);
std::cout<<"before assign propModif"<<std::endl;
for(unsigned int k=0;k < properties.size();k++){
propertiesModified[k] = properties[k];
}
std::cout<<"after assign propModif"<<std::endl;
propertiesModified[4*j + 1] -= 0.01;
voroMetal3D vm1;
std::cout<<"before execute"<<std::endl;
//std::remove("MicrostructurePolycrystal3D.geo");
vm1.execute(propertiesModified,radical,0.1,xMax,yMax,zMax);
//GModel::current()->destroy();
GModel *m = new GModel();
//GModel::current()->load("MicrostructurePolycrystal3D.geo");
m->load("MicrostructurePolycrystal3D.geo");
double distMinTmp = 1000.0;
//GModel *m = GModel::current();
for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){
GEdge* eTmp = (*ite);
GVertex* vTmp1 = eTmp->getBeginVertex();
GVertex* vTmp2 = eTmp->getEndVertex();
double distTmp = sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z()));
if (distTmp < distMinTmp){
distMinTmp = distTmp;
}
}
if (distMinTmp > distMinGlobal){
distMinGlobal = distMinTmp;
jMinGlobal = j;
xORyORz = 2;
posORneg = 2;
}
delete m;
}
for(j=0;j<max;j++){
std::cout<<"j "<<j<<std::endl;
std::vector<double> propertiesModified;
propertiesModified.clear();
propertiesModified.resize(4*max);
std::cout<<"before assign propModif"<<std::endl;
for(unsigned int k=0;k < properties.size();k++){
propertiesModified[k] = properties[k];
}
std::cout<<"after assign propModif"<<std::endl;
propertiesModified[4*j + 2] -= 0.01;
voroMetal3D vm1;
std::cout<<"before execute"<<std::endl;
//std::remove("MicrostructurePolycrystal3D.geo");
vm1.execute(propertiesModified,radical,0.1,xMax,yMax,zMax);
//GModel::current()->destroy();
GModel *m = new GModel();
//GModel::current()->load("MicrostructurePolycrystal3D.geo");
m->load("MicrostructurePolycrystal3D.geo");
double distMinTmp = 1000.0;
//GModel *m = GModel::current();
for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){
GEdge* eTmp = (*ite);
GVertex* vTmp1 = eTmp->getBeginVertex();
GVertex* vTmp2 = eTmp->getEndVertex();
double distTmp = sqrt((vTmp1->x() - vTmp2->x()) * (vTmp1->x() - vTmp2->x()) + (vTmp1->y() - vTmp2->y()) * (vTmp1->y() - vTmp2->y()) + (vTmp1->z() - vTmp2->z()) * (vTmp1->z() - vTmp2->z()));
if (distTmp < distMinTmp){
distMinTmp = distTmp;
}
}
if (distMinTmp > distMinGlobal){
distMinGlobal = distMinTmp;
jMinGlobal = j;
xORyORz = 3;
posORneg = 2;
}
delete m;
}
std::cout<<"distance minimale de "<<distMinGlobal<<std::endl;
listDistances[Count] = distMinGlobal;
if (xORyORz == 1){
if (posORneg == 1){
properties[4*jMinGlobal] += 0.01;
} else if (posORneg == 2){
properties[4*jMinGlobal] -= 0.01;
}
} else if (xORyORz == 2){
if (posORneg == 1){
properties[4*jMinGlobal + 1] += 0.01;
} else if (posORneg == 2){
properties[4*jMinGlobal + 1] -= 0.01;
}
} else if (xORyORz == 3){
if (posORneg == 1){
properties[4*jMinGlobal + 2] += 0.01;
} else if (posORneg == 2){
properties[4*jMinGlobal + 2] -= 0.01;
}
}
}
voroMetal3D vm1;
vm1.execute(properties,radical,0.1,xMax,yMax,zMax);
GModel::current()->load("MicrostructurePolycrystal3D.geo");
voroMetal3D vm2;
vm2.correspondance(0.00001,xMax,yMax,zMax);
for (unsigned int iTmp = 0; iTmp < listDistances.size();iTmp++){
std::cout<<"distMinGlobal "<<iTmp<<" egale a "<<listDistances[iTmp]<<std::endl;
}
std::cout<<"liste des nouveaux seeds :"<<std::endl;
for(unsigned int iTmp = 0; iTmp < max;iTmp++){
std::cout<<properties[4*iTmp]<<" "<<properties[4*iTmp + 1]<<" "<<properties[4*iTmp + 2]<<" "<<properties[4*iTmp + 3]<<std::endl;
}
}
}
CTX::instance()->noPopup = 1;

Christophe Geuzaine
committed
if(argv[i]){
std::string tmp = argv[i++];
if(tmp.size() > 2 && tmp[0] == '"' && tmp[tmp.size() - 1] == '"')
CTX::instance()->watchFilePattern = tmp.substr(1, tmp.size() - 2);
else
CTX::instance()->watchFilePattern = tmp;
}
else
Msg::Fatal("Missing string");

Christophe Geuzaine
committed
#if defined(HAVE_PARSER)
else if(!strcmp(argv[i] + 1, "setstring")) {
i++;
if (i + 1 < argc && argv[i][0] != '-' && argv[i + 1][0] != '-') {
gmsh_yystringsymbols[argv[i]] = argv[i + 1];
i += 2;
}
else
Msg::Fatal("Missing name and/or value for string definition");
}
else if (!strcmp(argv[i]+1, "setnumber")) {
i++;
if (i + 1 < argc && argv[i][0] != '-' && argv[i + 1][0] != '-') {
std::vector<double> val(1, atof(argv[i + 1]));
gmsh_yysymbols[argv[i]].value = val;
i += 2;
}
else
Msg::Error("Missing name and/or value for number definition");
}
#endif
ParseFile(argv[i++], true);
else
Msg::Fatal("Missing file name");
CTX::instance()->outputFileName = argv[i++];
else
Msg::Fatal("Missing file name");
else if(!strcmp(argv[i] + 1, "anisoMax")) {
i++;
if(argv[i])
CTX::instance()->mesh.anisoMax = atof(argv[i++]);
else
Msg::Fatal("Missing anisotropy ratio");
}
else if(!strcmp(argv[i] + 1, "smoothRatio")) {
i++;
if(argv[i])
CTX::instance()->mesh.smoothRatio = atof(argv[i++]);
else
Msg::Fatal("Missing smooth ratio");
}
CTX::instance()->bgmFileName = argv[i++];
else
Msg::Fatal("Missing file name");
else if(!strcmp(argv[i] + 1, "nw")) {
i++;
CTX::instance()->numWindows = atoi(argv[i++]);
else
Msg::Fatal("Missing number");
}
else if(!strcmp(argv[i] + 1, "nt")) {
i++;
CTX::instance()->numTiles = atoi(argv[i++]);
Msg::Fatal("Missing number");
else if(!strcmp(argv[i] + 1, "vmsh")) {
i++;
if(argv[i]){
CTX::instance()->mesh.mshFileVersion = atof(argv[i++]);
}
else
Msg::Fatal("Missing number");
}
CTX::instance()->batch = 1;
std::string fileName = std::string(argv[i]) + "_new";

Christophe Geuzaine
committed
#endif
PView::list[j]->write(fileName, 1, (j == n) ? false : true);

Christophe Geuzaine
committed
#endif
// convert mesh to latest binary format
if(GModel::current()->getMeshStatus() > 0){
CTX::instance()->mesh.mshFileVersion = 2.0;
CTX::instance()->mesh.binary = 1;
Msg::Exit(0);
CTX::instance()->geom.tolerance = atof(argv[i++]);
else
Msg::Fatal("Missing number");

Jean-François Remacle
committed
else if(!strcmp(argv[i] + 1, "match")) {
CTX::instance()->geom.matchGeomAndMesh = 1;

Jean-François Remacle
committed
}
CTX::instance()->geom.scalingFactor = atof(argv[i++]);
else
Msg::Fatal("Missing number");
CTX::instance()->mesh.scalingFactor = atof(argv[i++]);
else
Msg::Fatal("Missing number");
CTX::instance()->mesh.randFactor = atof(argv[i++]);
else
Msg::Fatal("Missing number");
CTX::instance()->mesh.lcFactor = atof(argv[i++]);
if(CTX::instance()->mesh.lcFactor <= 0.0)

Christophe Geuzaine
committed
Msg::Fatal("Mesh element size factor must be > 0");
else
Msg::Fatal("Missing number");
}
else if(!strcmp(argv[i] + 1, "clmin")) {