"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Kernel/MainKernel.cpp" between
getdp-3.4.0-source.tgz and getdp-3.5.0-source.tgz

About: GetDP is a general finite element solver using mixed elements to discretize de Rham-type complexes in one, two and three dimensions.

MainKernel.cpp  (getdp-3.4.0-source.tgz):MainKernel.cpp  (getdp-3.5.0-source.tgz)
// GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege // GetDP - Copyright (C) 1997-2022 P. Dular and C. Geuzaine, University of Liege
// //
// See the LICENSE.txt file for license information. Please report all // See the LICENSE.txt file for license information. Please report all
// issues on https://gitlab.onelab.info/getdp/getdp/issues. // issues on https://gitlab.onelab.info/getdp/getdp/issues.
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include <string> #include <string>
#include <string.h> #include <string.h>
#include "GetDPConfig.h" #include "GetDPConfig.h"
#include "GetDPVersion.h" #include "GetDPVersion.h"
skipping to change at line 30 skipping to change at line 30
#if defined(HAVE_GMSH) #if defined(HAVE_GMSH)
#include <gmsh.h> #include <gmsh.h>
// these will disappear // these will disappear
#include <gmsh/GmshGlobal.h> #include <gmsh/GmshGlobal.h>
#include <gmsh/GmshVersion.h> #include <gmsh/GmshVersion.h>
#include <gmsh/GmshConfig.h> #include <gmsh/GmshConfig.h>
#include <gmsh/PView.h> #include <gmsh/PView.h>
#endif #endif
int Flag_PRE = 0, Flag_CAL = 0, Flag_POS = 0, Flag_RESTART = 0; int Flag_PRE = 0, Flag_CAL = 0, Flag_POS = 0, Flag_RESTART = 0;
int Flag_XDATA = 0, Flag_BIN = 0, Flag_SPLIT = 0, Flag_GMSH_VERSION = 1; int Flag_XDATA = 0, Flag_BIN = 0, Flag_SPLIT = 0, Flag_GMSH_VERSION = 1;
int Flag_NETWORK_CACHE = 0, Flag_CALLED_WITH_ONELAB_SERVER = 0; int Flag_NETWORK_CACHE = 0, Flag_CALLED_WITH_ONELAB_SERVER = 0;
int Flag_SLEPC = 0; int Flag_SLEPC = 0;
double Flag_ORDER = -1., Flag_MSH_SCALING = 1.; double Flag_ORDER = -1., Flag_MSH_SCALING = 1.;
char *Name_Generic = 0, *Name_Path = 0; char *Name_Generic = 0, *Name_Path = 0;
char *Name_Resolution = 0; char *Name_Resolution = 0;
char *Name_MshFile = 0, *Name_AdaptFile = 0; char *Name_MshFile = 0, *Name_AdaptFile = 0;
char *Name_PostOperation[NBR_MAX_POS] = {0}; char *Name_PostOperation[NBR_MAX_POS] = {0};
char *Name_ResFile[NBR_MAX_RES] = {0}; char *Name_ResFile[NBR_MAX_RES] = {0};
char *Name_GmshReadFile[NBR_MAX_RES] = {0}; char *Name_GmshReadFile[NBR_MAX_RES] = {0};
int Tag_GmshReadFile[NBR_MAX_RES] = {-1}; int Tag_GmshReadFile[NBR_MAX_RES] = {-1};
static void Info(int level, char *arg0) static void Info(int level, char *arg0)
{ {
switch(level){ switch(level) {
case 0 : case 0:
fprintf(stderr, fprintf(
"GetDP, a General environment for the treatment of Discrete Problems\ stderr,
n" "GetDP, a General environment for the treatment of Discrete Problems\n"
"Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Lieg "Copyright (C) 1997-2022 P. Dular and C. Geuzaine, University of Liege\n"
e\n" "Usage: %s [file] [options]\n"
"Usage: %s [file] [options]\n" "Processing options:\n"
"Processing options:\n" " -pre 'Resolution' pre-processing\n"
" -pre 'Resolution' pre-processing\n" " -cal processing\n"
" -cal processing\n" " -pos 'PostOperation(s)' post-processing\n"
" -pos 'PostOperation(s)' post-processing\n" " -msh file read mesh (in msh format) from file\n"
" -msh file read mesh (in msh format) from file\n" " -msh_scaling value scale the input mesh by the given value\n"
" -msh_scaling value scale the input mesh by the given value " -gmshread file(s) read gmsh data (same as GmshRead in "
\n" "resolution)\n"
" -gmshread file(s) read gmsh data (same as GmshRead in res " -gmshtag tag(s) tag(s) associated to GmshRead data\n"
olution)\n" " -restart resume processing from where it stopped\n"
" -gmshtag tag(s) tag(s) associated to GmshRead data\n" " -solve 'Resolution' same as -pre 'Resolution' -cal\n"
" -restart resume processing from where it stopped\ " -split save processing results in separate files\n"
n" " -res file(s) load processing results from file(s)\n"
" -solve 'Resolution' same as -pre 'Resolution' -cal\n" " -name string use string as generic file name\n"
" -split save processing results in separate file " -adapt file read adaptation constraints from file\n"
s\n" " -order num restrict maximum interpolation order\n"
" -res file(s) load processing results from file(s)\n" " -cache cache network computations to disk\n"
" -name string use string as generic file name\n" "Linear solver options:\n"
" -adapt file read adaptation constraints from file\n"
" -order num restrict maximum interpolation order\n"
" -cache cache network computations to disk\n"
"Linear solver options:\n"
#if defined(HAVE_PETSC) #if defined(HAVE_PETSC)
" -solver file specify parameter file (default: .petscr " -solver file specify parameter file (default: .petscrc)\n"
c)\n" " [PETsc options] PETSc options (must be listed after "
" [PETsc options] PETSc options (must be listed after [fil "[file])\n"
e])\n"
#endif #endif
#if defined(HAVE_SLEPC) #if defined(HAVE_SLEPC)
" -slepc use SLEPc instead of Arpack as eigensolv er\n" " -slepc use SLEPc instead of Arpack as eigensolver\n"
#endif #endif
#if defined(HAVE_SPARSKIT) #if defined(HAVE_SPARSKIT)
" -solver file specify parameter file (default: solver. " -solver file specify parameter file (default: "
par)\n" "solver.par)\n"
" -'Parameter' num override value of solver parameter 'Para " -'Parameter' num override value of solver parameter "
meter'\n" "'Parameter'\n"
#endif #endif
"Output options:\n" "Output options:\n"
" -bin create binary output files\n" " -bin create binary output files\n"
" -v2 create mesh-based Gmsh output files when " -v2 create mesh-based Gmsh output files when "
possible\n" "possible\n"
"Other options:\n" "Other options:\n"
" -check interactive check of problem structure\n " -check interactive check of problem structure\n"
" " -v num set verbosity level (default: 5)\n"
" -v num set verbosity level (default: 5)\n" " -cpu report CPU times for all operations\n"
" -cpu report CPU times for all operations\n" " -p num set progress indicator update (default: "
" -p num set progress indicator update (default: "10)\n"
10)\n" " -onelab name [address] communicate with ONELAB (file or server "
" -onelab name [address] communicate with ONELAB (file or server "address)\n"
address)\n" " -setnumber name value set constant number name=value (or -sn)\n"
" -setnumber name value set constant number name=value (or -sn) " -setstring name value set constant string name=value (or -ss)\n"
\n" " -version show version number\n"
" -setstring name value set constant string name=value (or -ss) " -info show detailed version information\n"
\n" " -help show this message\n",
" -version show version number\n" arg0);
" -info show detailed version information\n"
" -help show this message\n", arg0);
break;
case 1:
fprintf(stderr, "%s\n", GETDP_VERSION);
break; break;
case 1: fprintf(stderr, "%s\n", GETDP_VERSION); break;
case 2: case 2:
fprintf(stderr, "Version : %s\n", GETDP_VERSION); fprintf(stderr, "Version : %s\n", GETDP_VERSION);
fprintf(stderr, "License : %s\n", GETDP_SHORT_LICENSE); fprintf(stderr, "License : %s\n", GETDP_SHORT_LICENSE);
fprintf(stderr, "Build OS : %s\n", GETDP_OS); fprintf(stderr, "Build OS : %s\n", GETDP_OS);
fprintf(stderr, "Build date : %s\n", GETDP_DATE); fprintf(stderr, "Build date : %s\n", GETDP_DATE);
fprintf(stderr, "Build host : %s\n", GETDP_HOST); fprintf(stderr, "Build host : %s\n", GETDP_HOST);
fprintf(stderr, "Build options :%s\n", GETDP_CONFIG_OPTIONS); fprintf(stderr, "Build options :%s\n", GETDP_CONFIG_OPTIONS);
#if defined(HAVE_PETSC) #if defined(HAVE_PETSC)
fprintf(stderr, "PETSc version : %d.%d.%d (%s arithmetic)\n", PETSC_VERSI fprintf(stderr, "PETSc version : %d.%d.%d (%s arithmetic)\n",
ON_MAJOR, PETSC_VERSION_MAJOR, PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR,
PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR,
#if defined(PETSC_USE_COMPLEX) #if defined(PETSC_USE_COMPLEX)
"complex" "complex"
#else #else
"real" "real"
#endif #endif
); );
#endif #endif
#if defined(HAVE_GMSH) #if defined(HAVE_GMSH)
fprintf(stderr, "Gmsh lib version : %s%s (%s)\n", fprintf(stderr, "Gmsh lib version : %s%s (%s)\n", GMSH_VERSION,
GMSH_VERSION, GMSH_EXTRA_VERSION, GMSH_DATE); GMSH_EXTRA_VERSION, GMSH_DATE);
fprintf(stderr, "Gmsh lib options :%s\n", GMSH_CONFIG_OPTIONS); fprintf(stderr, "Gmsh lib options :%s\n", GMSH_CONFIG_OPTIONS);
#endif #endif
fprintf(stderr, "Packaged by : %s\n", GETDP_PACKAGER); fprintf(stderr, "Packaged by : %s\n", GETDP_PACKAGER);
fprintf(stderr, "Web site : http://getdp.info\n"); fprintf(stderr, "Web site : http://getdp.info\n");
fprintf(stderr, "Issue tracker : https://gitlab.onelab.info/getdp/getdp/i fprintf(
ssues\n"); stderr,
"Issue tracker : https://gitlab.onelab.info/getdp/getdp/issues\n");
break; break;
} }
Message::Exit(0); Message::Exit(0);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* G e t _ O p t i o n s */ /* G e t _ O p t i o n s */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static void Get_Options(int argc, char *argv[], int *sargc, char **sargv, char * static void Get_Options(int argc, char *argv[], int *sargc, char **sargv,
pro, char *pro, int *lres, int *lpos, int *check)
int *lres, int *lpos, int *check)
{ {
strcpy(pro, ""); strcpy(pro, "");
int i = *sargc = 1, j = 0; int i = *sargc = 1, j = 0;
while (i < argc) { while(i < argc) {
if(argv[i][0] == '-') {
if (argv[i][0] == '-') { if(!strcmp(argv[i] + 1, "cal")) {
Flag_CAL = 1;
if (!strcmp(argv[i]+1, "cal")) { Flag_CAL = 1; i++; } i++;
else if (!strcmp(argv[i]+1, "check")) { *check = 1; i++; } }
else if (!strcmp(argv[i]+1, "xdata")) { Flag_XDATA = 1; i++; } else if(!strcmp(argv[i] + 1, "check")) {
else if (!strcmp(argv[i]+1, "cache")) { Flag_NETWORK_CACHE = 1; i++; } *check = 1;
else if (!strcmp(argv[i]+1, "bin")) { Flag_BIN = 1; i++; } i++;
else if (!strcmp(argv[i]+1, "v2")) { Flag_GMSH_VERSION = 2; i++; } }
else if (!strcmp(argv[i]+1, "ascii")) { Flag_BIN = 0; i++; } else if(!strcmp(argv[i] + 1, "xdata")) {
else if (!strcmp(argv[i]+1, "split")) { Flag_SPLIT = 1; i++; } Flag_XDATA = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "cache")) {
Flag_NETWORK_CACHE = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "bin")) {
Flag_BIN = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "v2")) {
Flag_GMSH_VERSION = 2;
i++;
}
else if(!strcmp(argv[i] + 1, "ascii")) {
Flag_BIN = 0;
i++;
}
else if(!strcmp(argv[i] + 1, "split")) {
Flag_SPLIT = 1;
i++;
}
else if (!strcmp(argv[i]+1, "socket")) { else if(!strcmp(argv[i] + 1, "socket")) {
i++; i++;
if (i < argc && argv[i][0] != '-') { if(i < argc && argv[i][0] != '-') {
Message::InitializeSocket(argv[i]); i++; Message::InitializeSocket(argv[i]);
i++;
} }
else { else {
Message::Error("Missing socket name"); Message::Error("Missing socket name");
} }
} }
else if (!strcmp(argv[i]+1, "onelab")) { else if(!strcmp(argv[i] + 1, "onelab")) {
i++; i++;
if (i + 1 < argc && argv[i][0] != '-' && argv[i + 1][0] != '-') { if(i + 1 < argc && argv[i][0] != '-' && argv[i + 1][0] != '-') {
Message::InitializeOnelab(argv[i], argv[i + 1]); Message::InitializeOnelab(argv[i], argv[i + 1]);
i += 2; i += 2;
} }
else if (i < argc && argv[i][0] != '-') { else if(i < argc && argv[i][0] != '-') {
Message::InitializeOnelab(argv[i], ""); Message::InitializeOnelab(argv[i], "");
i += 1; i += 1;
} }
else { else {
Message::Error("Missing client name and/or address of ONELAB server"); Message::Error("Missing client name and/or address of ONELAB server");
} }
} }
else if (!strcmp(argv[i]+1, "setnumber") || else if(!strcmp(argv[i] + 1, "setnumber") || !strcmp(argv[i] + 1, "sn")) {
!strcmp(argv[i]+1, "sn")) {
i++; i++;
if (i + 1 < argc && argv[i][0] != '-') { if(i + 1 < argc && argv[i][0] != '-') {
CommandLineNumbers[argv[i]] = std::vector<double>(1, atof(argv[i + 1]) CommandLineNumbers[argv[i]] =
); std::vector<double>(1, atof(argv[i + 1]));
i += 2; i += 2;
} }
else{ else {
Message::Error("Missing name and/or value for number definition"); Message::Error("Missing name and/or value for number definition");
} }
} }
else if (!strcmp(argv[i]+1, "setstring") || else if(!strcmp(argv[i] + 1, "setstring") || !strcmp(argv[i] + 1, "ss")) {
!strcmp(argv[i]+1, "ss")) {
i++; i++;
if (i + 1 < argc && argv[i][0] != '-' && argv[i + 1][0] != '-') { if(i + 1 < argc && argv[i][0] != '-' && argv[i + 1][0] != '-') {
CommandLineStrings[argv[i]] = std::vector<std::string>(1, argv[i + 1]) CommandLineStrings[argv[i]] =
; std::vector<std::string>(1, argv[i + 1]);
i += 2; i += 2;
} }
else{ else {
Message::Error("Missing name and/or value for string definition"); Message::Error("Missing name and/or value for string definition");
} }
} }
else if (!strcmp(argv[i]+1, "setlist") || else if(!strcmp(argv[i] + 1, "setlist") ||
!strcmp(argv[i]+1, "setlistofnumbers")) { !strcmp(argv[i] + 1, "setlistofnumbers")) {
i++; i++;
if (i + 1 < argc && argv[i][0] != '-') { if(i + 1 < argc && argv[i][0] != '-') {
std::string n(argv[i]); std::string n(argv[i]);
std::vector<double> v; std::vector<double> v;
int s = atoi(argv[i + 1]), j = 0; int s = atoi(argv[i + 1]), j = 0;
i += 2; i += 2;
while(j < s && i < argc){ while(j < s && i < argc) {
v.push_back(atof(argv[i])); v.push_back(atof(argv[i]));
i++; j++; i++;
j++;
} }
if(j < s) if(j < s)
Message::Error("Missing values in list (got %d instead of %d)", j, s Message::Error("Missing values in list (got %d instead of %d)", j,
); s);
CommandLineNumbers[n] = v; CommandLineNumbers[n] = v;
} }
else{ else {
Message::Error("Missing name and/or value for definition of list of nu Message::Error(
mbers"); "Missing name and/or value for definition of list of numbers");
} }
} }
else if (!strcmp(argv[i]+1, "restart")){ else if(!strcmp(argv[i] + 1, "restart")) {
Flag_CAL = Flag_RESTART = 1; i++; Flag_CAL = Flag_RESTART = 1;
i++;
} }
else if (!strcmp(argv[i]+1, "verbose") || else if(!strcmp(argv[i] + 1, "verbose") || !strcmp(argv[i] + 1, "v")) {
!strcmp(argv[i]+1, "v")) { i++;
i++; if(i < argc && argv[i][0] != '-') {
if (i < argc && argv[i][0] != '-') { Message::SetVerbosity(atoi(argv[i]));
Message::SetVerbosity(atoi(argv[i])); i++; i++;
} }
else { else {
Message::Error("Missing number"); Message::Error("Missing number");
} }
} }
else if (!strcmp(argv[i]+1, "cpu")) { else if(!strcmp(argv[i] + 1, "cpu")) {
Message::SetInfoCpu(true); i++; Message::SetInfoCpu(true);
i++;
} }
else if(!strcmp(argv[i] + 1, "nt")) { else if(!strcmp(argv[i] + 1, "nt")) {
i++; i++;
if(argv[i]) if(argv[i])
Message::SetNumThreads(atoi(argv[i++])); Message::SetNumThreads(atoi(argv[i++]));
else else
Message::Error("Missing number"); Message::Error("Missing number");
} }
else if (!strcmp(argv[i]+1, "help") || !strcmp(argv[i]+1, "h") || else if(!strcmp(argv[i] + 1, "help") || !strcmp(argv[i] + 1, "h") ||
!strcmp(argv[i]+1, "-help") || !strcmp(argv[i]+1, "-h")) { !strcmp(argv[i] + 1, "-help") || !strcmp(argv[i] + 1, "-h")) {
Info(0, argv[0]); Info(0, argv[0]);
} }
else if (!strcmp(argv[i]+1, "version") || else if(!strcmp(argv[i] + 1, "version") ||
!strcmp(argv[i]+1, "-version")) { !strcmp(argv[i] + 1, "-version")) {
Info(1, argv[0]); Info(1, argv[0]);
} }
else if (!strcmp(argv[i]+1, "info") || else if(!strcmp(argv[i] + 1, "info") || !strcmp(argv[i] + 1, "-info")) {
!strcmp(argv[i]+1, "-info")) {
Info(2, argv[0]); Info(2, argv[0]);
} }
else if (!strcmp(argv[i]+1, "progress") || else if(!strcmp(argv[i] + 1, "progress") || !strcmp(argv[i] + 1, "p")) {
!strcmp(argv[i]+1, "p")) { i++;
i++; if(i < argc && argv[i][0] != '-') {
if (i < argc && argv[i][0] != '-') { Message::SetProgressMeterStep(atoi(argv[i]));
Message::SetProgressMeterStep(atoi(argv[i])); i++; i++;
} }
else { else {
Message::Error("Missing number"); Message::Error("Missing number");
} }
} }
else if (!strcmp(argv[i]+1, "pre")) { else if(!strcmp(argv[i] + 1, "pre")) {
i++; i++;
if (i < argc && argv[i][0] == '#') { if(i < argc && argv[i][0] == '#') {
Flag_PRE = 1; *lres = -atoi(argv[i]+1); i++; Flag_PRE = 1;
} *lres = -atoi(argv[i] + 1);
else if (i < argc && argv[i][0] != '-') { i++;
Flag_PRE = 1; Name_Resolution = strSave(argv[i]); i++; }
} else if(i < argc && argv[i][0] != '-') {
else { Flag_PRE = 1;
Flag_PRE = *lres = 1; Name_Resolution = strSave(argv[i]);
} i++;
} }
else {
else if (!strcmp(argv[i]+1, "order") || Flag_PRE = *lres = 1;
!strcmp(argv[i]+1, "ord")) { }
i++;
if (i < argc && argv[i][0] != '-') {
Flag_ORDER = atof(argv[i]); i++;
}
else {
Message::Error("Missing interpolation order");
}
} }
else if (!strcmp(argv[i]+1, "solver")) { else if(!strcmp(argv[i] + 1, "order") || !strcmp(argv[i] + 1, "ord")) {
i++;
if(i < argc && argv[i][0] != '-') {
Flag_ORDER = atof(argv[i]);
i++;
}
else {
Message::Error("Missing interpolation order");
}
}
else if(!strcmp(argv[i] + 1, "solver")) {
// fix when calling getdp from gmsh (since the GUI forces us // fix when calling getdp from gmsh (since the GUI forces us
// to put the -solver option before the .pro file!) // to put the -solver option before the .pro file!)
sargv[(*sargc)++] = argv[i++]; sargv[(*sargc)++] = argv[i++];
if (i < argc && argv[i][0] != '-') { if(i < argc && argv[i][0] != '-') { sargv[(*sargc)++] = argv[i++]; }
sargv[(*sargc)++] = argv[i++]; else {
} Message::Error("Missing solver option file name");
else { }
Message::Error("Missing solver option file name"); }
}
} else if(!strcmp(argv[i] + 1, "slepc")) {
Flag_SLEPC = 1;
else if (!strcmp(argv[i]+1, "slepc")) { i++;
Flag_SLEPC = 1; i++; }
}
else if(!strcmp(argv[i] + 1, "solve") || !strcmp(argv[i] + 1, "sol")) {
else if (!strcmp(argv[i]+1, "solve") || i++;
!strcmp(argv[i]+1, "sol")) { if(i < argc && argv[i][0] == '#') {
i++; Flag_PRE = Flag_CAL = 1;
if (i < argc && argv[i][0] == '#') { *lres = -atoi(argv[i] + 1);
Flag_PRE = Flag_CAL = 1; *lres = -atoi(argv[i]+1); i++; i++;
} }
else if (i < argc && argv[i][0] != '-') { else if(i < argc && argv[i][0] != '-') {
Flag_PRE = Flag_CAL = 1; Name_Resolution = strSave(argv[i]); i++; Flag_PRE = Flag_CAL = 1;
} Name_Resolution = strSave(argv[i]);
else { i++;
Flag_PRE = Flag_CAL = *lres = 1; }
} else {
} Flag_PRE = Flag_CAL = *lres = 1;
}
else if (!strcmp(argv[i]+1, "post") || }
!strcmp(argv[i]+1, "pos")) {
i++; j = 0; else if(!strcmp(argv[i] + 1, "post") || !strcmp(argv[i] + 1, "pos")) {
if (i < argc && argv[i][0] == '#') { i++;
Flag_POS = 1; *lpos = -atoi(argv[i]+1); i++; j = 0;
} /* Only one numbered (#) PostOperation allowed */ if(i < argc && argv[i][0] == '#') {
else { Flag_POS = 1;
while (i < argc && argv[i][0] != '-') { *lpos = -atoi(argv[i] + 1);
Name_PostOperation[j] = strSave(argv[i]); i++; j++; i++;
if(j == NBR_MAX_POS){ } /* Only one numbered (#) PostOperation allowed */
Message::Error("Too many PostOperations"); else {
while(i < argc && argv[i][0] != '-') {
Name_PostOperation[j] = strSave(argv[i]);
i++;
j++;
if(j == NBR_MAX_POS) {
Message::Error("Too many PostOperations");
break; break;
} }
} }
if(!j){ if(!j) { Flag_POS = *lpos = 1; }
Flag_POS = *lpos = 1; else {
} Flag_POS = 1;
else{ Name_PostOperation[j] = NULL;
Flag_POS = 1; }
Name_PostOperation[j] = NULL; }
} }
}
} else if(!strcmp(argv[i] + 1, "mesh") || !strcmp(argv[i] + 1, "msh") ||
!strcmp(argv[i] + 1, "m")) {
else if (!strcmp(argv[i]+1, "mesh") || i++;
!strcmp(argv[i]+1, "msh") || if(i < argc && argv[i][0] != '-') {
!strcmp(argv[i]+1, "m")) { Name_MshFile = strSave(argv[i]);
i++; i++;
if (i < argc && argv[i][0] != '-') { }
Name_MshFile = strSave(argv[i]); i++; else {
} Message::Error("Missing file name");
else { }
Message::Error("Missing file name"); }
}
} else if(!strcmp(argv[i] + 1, "msh_scaling")) {
i++;
else if (!strcmp(argv[i]+1, "msh_scaling")) { if(i < argc && argv[i][0] != '-') {
i++; Flag_MSH_SCALING = atof(argv[i]);
if (i < argc && argv[i][0] != '-') { i++;
Flag_MSH_SCALING = atof(argv[i]); i++; }
} else {
else { Message::Error("Missing scaling value");
Message::Error("Missing scaling value"); }
} }
}
else if(!strcmp(argv[i] + 1, "adapt") || !strcmp(argv[i] + 1, "adap") ||
else if (!strcmp(argv[i]+1, "adapt") || !strcmp(argv[i] + 1, "ada")) {
!strcmp(argv[i]+1, "adap") || i++;
!strcmp(argv[i]+1, "ada")) { if(i < argc && argv[i][0] != '-') {
i++; Name_AdaptFile = strSave(argv[i]);
if (i < argc && argv[i][0] != '-') { i++;
Name_AdaptFile = strSave(argv[i]); i++; }
} else {
else { Message::Error("Missing file name");
Message::Error("Missing file name"); }
} }
}
else if(!strcmp(argv[i] + 1, "res")) {
else if (!strcmp(argv[i]+1, "res")) { i++;
i++; j = 0; j = 0;
while (i < argc && argv[i][0] != '-') { while(i < argc && argv[i][0] != '-') {
Name_ResFile[j] = strSave(argv[i]); i++; j++; Name_ResFile[j] = strSave(argv[i]);
if(j == NBR_MAX_RES){ i++;
Message::Error("Too many '.res' files"); j++;
if(j == NBR_MAX_RES) {
Message::Error("Too many '.res' files");
break; break;
} }
} }
if(!j) if(!j)
Message::Error("Missing file name"); Message::Error("Missing file name");
else{ else {
Name_ResFile[j] = NULL; Name_ResFile[j] = NULL;
} }
} }
else if (!strcmp(argv[i]+1, "gmshread")) { else if(!strcmp(argv[i] + 1, "gmshread")) {
for(int k = 0; k < NBR_MAX_RES; k++) Tag_GmshReadFile[k] = -1; for(int k = 0; k < NBR_MAX_RES; k++) Tag_GmshReadFile[k] = -1;
i++; j = 0; i++;
while (i < argc && argv[i][0] != '-') { j = 0;
Name_GmshReadFile[j] = strSave(argv[i]); i++; j++; while(i < argc && argv[i][0] != '-') {
if(j == NBR_MAX_RES){ Name_GmshReadFile[j] = strSave(argv[i]);
Message::Error("Too many GmshRead files"); i++;
j++;
if(j == NBR_MAX_RES) {
Message::Error("Too many GmshRead files");
break; break;
} }
} }
if(!j) if(!j)
Message::Error("Missing file name"); Message::Error("Missing file name");
else{ else {
Name_GmshReadFile[j] = NULL; Name_GmshReadFile[j] = NULL;
} }
} }
else if (!strcmp(argv[i]+1, "gmshtag")) { else if(!strcmp(argv[i] + 1, "gmshtag")) {
for(int k = 0; k < NBR_MAX_RES; k++) Tag_GmshReadFile[k] = -1; for(int k = 0; k < NBR_MAX_RES; k++) Tag_GmshReadFile[k] = -1;
i++; j = 0; i++;
while (i < argc && argv[i][0] != '-') { j = 0;
Tag_GmshReadFile[j] = atoi(argv[i]); i++; j++; while(i < argc && argv[i][0] != '-') {
if(j == NBR_MAX_RES){ Tag_GmshReadFile[j] = atoi(argv[i]);
Message::Error("Too many tags"); i++;
j++;
if(j == NBR_MAX_RES) {
Message::Error("Too many tags");
break; break;
} }
} }
if(!j) if(!j) Message::Error("Missing tag");
Message::Error("Missing tag");
}
else if (!strcmp(argv[i]+1, "name")) {
i++;
if (i < argc && argv[i][0] != '-') {
Name_Generic = strSave(argv[i]); i++;
}
else {
Message::Error("Missing string");
}
}
else if (!strcmp(argv[i]+1, "petscinfo") ||
!strcmp(argv[i]+1, "-petscinfo")) {
sargv[(*sargc)++] = (char*)"-info";
i++;
} }
else { else if(!strcmp(argv[i] + 1, "name")) {
sargv[(*sargc)++] = argv[i++]; i++;
if(i < argc && argv[i][0] != '-') {
Name_Generic = strSave(argv[i]);
i++;
}
else {
Message::Error("Missing string");
}
} }
else if(!strcmp(argv[i] + 1, "petscinfo") ||
!strcmp(argv[i] + 1, "-petscinfo")) {
sargv[(*sargc)++] = (char *)"-info";
i++;
}
else {
sargv[(*sargc)++] = argv[i++];
}
} }
else{ else {
if (!strlen(pro)) { if(!strlen(pro)) {
sargv[0] = argv[i]; sargv[0] = argv[i];
strcpy(pro, argv[i++]); strcpy(pro, argv[i++]);
} }
else{ else {
sargv[(*sargc)++] = argv[i++]; sargv[(*sargc)++] = argv[i++];
} }
} }
} }
if(!strlen(pro)){ if(!strlen(pro)) {
Message::Error("Missing input file name"); Message::Error("Missing input file name");
Name_Generic = strSave(""); Name_Generic = strSave("");
*sargc = 0; *sargc = 0;
} }
else{ else {
if(!Name_Generic){ if(!Name_Generic) {
Name_Generic = strSave(pro); Name_Generic = strSave(pro);
if(strcmp(pro+(strlen(pro)-4), ".pro") && if(strcmp(pro + (strlen(pro) - 4), ".pro") &&
strcmp(pro+(strlen(pro)-4), ".PRO")) strcmp(pro + (strlen(pro) - 4), ".PRO"))
strcat(pro,".pro"); strcat(pro, ".pro");
else else
Name_Generic[strlen(pro)-4] = '\0'; Name_Generic[strlen(pro) - 4] = '\0';
} }
else{ else {
std::string fix = Fix_RelativePath(Name_Generic, pro); std::string fix = Fix_RelativePath(Name_Generic, pro);
Free(Name_Generic); Free(Name_Generic);
Name_Generic = strSave(fix.c_str()); Name_Generic = strSave(fix.c_str());
if(strcmp(pro+(strlen(pro)-4), ".pro") && if(strcmp(pro + (strlen(pro) - 4), ".pro") &&
strcmp(pro+(strlen(pro)-4), ".PRO")) strcmp(pro + (strlen(pro) - 4), ".PRO"))
strcat(pro,".pro"); strcat(pro, ".pro");
} }
Name_Path = strSave(Name_Generic); Name_Path = strSave(Name_Generic);
i = strlen(Name_Path)-1; i = strlen(Name_Path) - 1;
while(i >= 0 && Name_Path[i] != '/' && Name_Path[i] != '\\') i--; while(i >= 0 && Name_Path[i] != '/' && Name_Path[i] != '\\') i--;
Name_Path[i+1] = '\0'; Name_Path[i + 1] = '\0';
} }
} }
#if defined(HAVE_GMSH) #if defined(HAVE_GMSH)
class GmshMsg : public GmshMessage{ class GmshMsg : public GmshMessage {
public: public:
void operator()(std::string level, std::string msg) void operator()(std::string level, std::string msg)
{ {
if(level == "Fatal") if(level == "Fatal")
Message::Fatal("%s", msg.c_str()); Message::Fatal("%s", msg.c_str());
else if(level == "Error") else if(level == "Error")
Message::Error("%s", msg.c_str()); Message::Error("%s", msg.c_str());
else if(level == "Warning") else if(level == "Warning")
Message::Warning("%s", msg.c_str()); Message::Warning("%s", msg.c_str());
else if(level == "Progress"){ else if(level == "Progress") {
} }
else else
Message::Info("%s", msg.c_str()); Message::Info("%s", msg.c_str());
} }
}; };
#endif #endif
static void Free_GlobalVariables() static void Free_GlobalVariables()
{ {
Flag_PRE = 0; Flag_CAL = 0; Flag_POS = 0; Flag_RESTART = 0; Flag_PRE = 0;
Flag_XDATA = 0; Flag_BIN = 0; Flag_SPLIT = 0; Flag_GMSH_VERSION = 1; Flag_CAL = 0;
Flag_POS = 0;
Flag_RESTART = 0;
Flag_XDATA = 0;
Flag_BIN = 0;
Flag_SPLIT = 0;
Flag_GMSH_VERSION = 1;
Flag_NETWORK_CACHE = 0; Flag_NETWORK_CACHE = 0;
Flag_ORDER = -1.; Flag_ORDER = -1.;
Free(Name_Generic); Name_Generic = 0; Free(Name_Generic);
Free(Name_Path); Name_Path = 0; Name_Generic = 0;
Free(Name_Resolution); Name_Resolution = 0; Free(Name_Path);
Free(Name_MshFile); Name_MshFile = 0; Name_Path = 0;
Free(Name_AdaptFile); Name_AdaptFile = 0; Free(Name_Resolution);
Name_Resolution = 0;
Free(Name_MshFile);
Name_MshFile = 0;
Free(Name_AdaptFile);
Name_AdaptFile = 0;
int i = 0; int i = 0;
while(Name_PostOperation[i]){ while(Name_PostOperation[i]) {
Free(Name_PostOperation[i]); Name_PostOperation[i] = 0; i++; Free(Name_PostOperation[i]);
Name_PostOperation[i] = 0;
i++;
} }
i = 0; i = 0;
while(Name_ResFile[i]){ while(Name_ResFile[i]) {
Free(Name_ResFile[i]); Name_ResFile[i] = 0; i++; Free(Name_ResFile[i]);
Name_ResFile[i] = 0;
i++;
} }
i = 0; i = 0;
while(Name_GmshReadFile[i]){ while(Name_GmshReadFile[i]) {
Free(Name_GmshReadFile[i]); Name_GmshReadFile[i] = 0; i++; Free(Name_GmshReadFile[i]);
Name_GmshReadFile[i] = 0;
i++;
} }
Free_ProblemStructure(); Free_ProblemStructure();
Free_ParserVariables(); Free_ParserVariables();
} }
void getdpPrintNumbers() void getdpPrintNumbers()
{ {
for(std::map<std::string, std::vector<double> >::iterator for(std::map<std::string, std::vector<double> >::iterator it =
it = GetDPNumbers.begin(); it != GetDPNumbers.end(); it++){ GetDPNumbers.begin();
it != GetDPNumbers.end(); it++) {
printf("%s() = {", it->first.c_str()); printf("%s() = {", it->first.c_str());
for(unsigned int i = 0; i < it->second.size(); i++){ for(unsigned int i = 0; i < it->second.size(); i++) {
if(i) printf(", "); if(i) printf(", ");
printf("%g", it->second[i]); printf("%g", it->second[i]);
} }
printf("};\n"); printf("};\n");
} }
} }
void getdpPrintStrings() void getdpPrintStrings()
{ {
for(std::map<std::string, std::vector<std::string> >::iterator for(std::map<std::string, std::vector<std::string> >::iterator it =
it = GetDPStrings.begin(); it != GetDPStrings.end(); it++){ GetDPStrings.begin();
it != GetDPStrings.end(); it++) {
printf("%s() = {", it->first.c_str()); printf("%s() = {", it->first.c_str());
for(unsigned int i = 0; i < it->second.size(); i++){ for(unsigned int i = 0; i < it->second.size(); i++) {
if(i) printf(", "); if(i) printf(", ");
printf("%s", it->second[i].c_str()); printf("%s", it->second[i].c_str());
} }
printf("};\n"); printf("};\n");
} }
} }
void getdpClearNumbers() void getdpClearNumbers() { GetDPNumbers.clear(); }
{
GetDPNumbers.clear();
}
void getdpSetNumber(const std::string &name, double value) void getdpSetNumber(const std::string &name, double value)
{ {
GetDPNumbers[name] = std::vector<double>(1, value); GetDPNumbers[name] = std::vector<double>(1, value);
CommandLineNumbers[name] = std::vector<double>(1, value); CommandLineNumbers[name] = std::vector<double>(1, value);
} }
void getdpSetNumber(const std::string &name, const std::vector<double> &value) void getdpSetNumber(const std::string &name, const std::vector<double> &value)
{ {
GetDPNumbers[name] = value; GetDPNumbers[name] = value;
CommandLineNumbers[name] = value; CommandLineNumbers[name] = value;
} }
std::vector<double> &getdpGetNumber(const std::string &name) std::vector<double> &getdpGetNumber(const std::string &name)
{ {
return GetDPNumbers[name]; return GetDPNumbers[name];
} }
void getdpClearStrings() void getdpClearStrings() { GetDPStrings.clear(); }
{
GetDPStrings.clear();
}
void getdpSetString(const std::string &name, const std::string &value) void getdpSetString(const std::string &name, const std::string &value)
{ {
GetDPStrings[name] = std::vector<std::string>(1, value); GetDPStrings[name] = std::vector<std::string>(1, value);
CommandLineStrings[name] = std::vector<std::string>(1, value); CommandLineStrings[name] = std::vector<std::string>(1, value);
} }
void getdpSetString(const std::string &name, const std::vector<std::string> &val void getdpSetString(const std::string &name,
ue) const std::vector<std::string> &value)
{ {
GetDPStrings[name] = value; GetDPStrings[name] = value;
CommandLineStrings[name] = value; CommandLineStrings[name] = value;
} }
std::vector<std::string> &getdpGetString(const std::string &name) std::vector<std::string> &getdpGetString(const std::string &name)
{ {
return GetDPStrings[name]; return GetDPStrings[name];
} }
int MainKernel(int argc, char *argv[]) int MainKernel(int argc, char *argv[])
{ {
if(argc < 2) Info(0, argv[0]); if(argc < 2) Info(0, argv[0]);
std::string cmdline(""); std::string cmdline("");
for(int i = 0; i < argc; i++){ for(int i = 0; i < argc; i++) {
if(i) cmdline += " "; if(i) cmdline += " ";
cmdline += argv[i]; cmdline += argv[i];
} }
Message::Initialize(argc, argv); Message::Initialize(argc, argv);
char pro[256]; char pro[256];
char **sargv = (char**)Malloc(256 * sizeof(char*)); char **sargv = (char **)Malloc(256 * sizeof(char *));
int sargc, lres = 0, lpos = 0, check = 0; int sargc, lres = 0, lpos = 0, check = 0;
Get_Options(argc, argv, &sargc, sargv, pro, &lres, &lpos, &check); Get_Options(argc, argv, &sargc, sargv, pro, &lres, &lpos, &check);
if(Message::GetErrorCount()){ if(Message::GetErrorCount()) {
Message::Finalize(); Message::Finalize();
return Message::GetErrorCount(); return Message::GetErrorCount();
} }
Message::Info("Running '%s' [GetDP %s, %d node%s, max. %d thread%s]", Message::Info("Running '%s' [GetDP %s, %d node%s, max. %d thread%s]",
cmdline.c_str(), GETDP_VERSION, cmdline.c_str(), GETDP_VERSION, Message::GetCommSize(),
Message::GetCommSize(), Message::GetCommSize() > 1 ? "s" : "", Message::GetCommSize() > 1 ? "s" : "", Message::GetMaxThreads(),
Message::GetMaxThreads(), Message::GetMaxThreads() > 1 ? "s" : " Message::GetMaxThreads() > 1 ? "s" : "");
");
Message::Cpu(3, true, true, true, true, true, "Started"); Message::Cpu(3, true, true, true, true, true, "Started");
if(sargc > 1){ if(sargc > 1) {
std::string solveropt(""); std::string solveropt("");
for(int i = 1; i < sargc; i++){ for(int i = 1; i < sargc; i++) {
if(i > 1) solveropt += " "; if(i > 1) solveropt += " ";
solveropt += sargv[i]; solveropt += sargv[i];
} }
Message::Debug("Passing unused options to solver: '%s'", solveropt.c_str()); Message::Debug("Passing unused options to solver: '%s'", solveropt.c_str());
} }
if(!Name_ResFile[0]){ if(!Name_ResFile[0]) {
Name_ResFile[0] = (char*)Malloc((strlen(Name_Generic)+5)*sizeof(char)); Name_ResFile[0] = (char *)Malloc((strlen(Name_Generic) + 5) * sizeof(char));
strcpy(Name_ResFile[0], Name_Generic); strcpy(Name_ResFile[0], Name_Generic);
strcat(Name_ResFile[0], ".res"); strcat(Name_ResFile[0], ".res");
Name_ResFile[1] = 0; Name_ResFile[1] = 0;
} }
if(!Name_MshFile){ if(!Name_MshFile) {
std::string name = Message::GetOnelabString("Gmsh/MshFileName"); std::string name = Message::GetOnelabString("Gmsh/MshFileName");
if(name.size()){ if(name.size()) {
Name_MshFile = strSave(name.c_str()); Name_MshFile = strSave(name.c_str());
Message::Info("Got mesh name from Onelab: '%s'", Name_MshFile); Message::Info("Got mesh name from Onelab: '%s'", Name_MshFile);
} }
} }
if(!Name_MshFile){ if(!Name_MshFile) {
Name_MshFile = (char*)Malloc((strlen(Name_Generic)+5)*sizeof(char)); Name_MshFile = (char *)Malloc((strlen(Name_Generic) + 5) * sizeof(char));
strcpy(Name_MshFile, Name_Generic); strcpy(Name_MshFile, Name_Generic);
strcat(Name_MshFile, ".msh"); strcat(Name_MshFile, ".msh");
} }
#if defined(HAVE_GMSH) #if defined(HAVE_GMSH)
Message::Info("Initializing Gmsh"); Message::Info("Initializing Gmsh");
gmsh::initialize(); gmsh::initialize();
gmsh::option::setNumber("General.Terminal", 0); gmsh::option::setNumber("General.Terminal", 0);
GmshMsg *msg = 0; GmshMsg *msg = 0;
if(!GmshGetMessageHandler() && !Flag_CALLED_WITH_ONELAB_SERVER){ if(!GmshGetMessageHandler() && !Flag_CALLED_WITH_ONELAB_SERVER) {
// do not set msg handler if one is provided (e.g. on Android/iOS) // do not set msg handler if one is provided (e.g. on Android/iOS)
msg = new GmshMsg; msg = new GmshMsg;
GmshSetMessageHandler(msg); GmshSetMessageHandler(msg);
} }
int j = 0; int j = 0;
while(Name_GmshReadFile[j]){ while(Name_GmshReadFile[j]) {
if(Tag_GmshReadFile[j] >= 0){ if(Tag_GmshReadFile[j] >= 0) {
PView::setGlobalTag(Tag_GmshReadFile[j]); PView::setGlobalTag(Tag_GmshReadFile[j]);
Message::Info("GmshRead[%s] -> View[%d]", Name_GmshReadFile[j], Tag_GmshRe Message::Info("GmshRead[%s] -> View[%d]", Name_GmshReadFile[j],
adFile[j]); Tag_GmshReadFile[j]);
} }
else{ else {
Message::Info("GmshRead[%s]", Name_GmshReadFile[j]); Message::Info("GmshRead[%s]", Name_GmshReadFile[j]);
} }
GmshMergePostProcessingFile(Name_GmshReadFile[j]); GmshMergePostProcessingFile(Name_GmshReadFile[j]);
j++; j++;
} }
#endif #endif
IncreaseStackSize(); IncreaseStackSize();
LinAlg_InitializeSolver(&sargc, &sargv); LinAlg_InitializeSolver(&sargc, &sargv);
Init_ProblemStructure(); Init_ProblemStructure();
Read_ProblemPreamble(); Read_ProblemPreamble();
Read_ProblemStructure(pro); Read_ProblemStructure(pro);
Finalize_ProblemStructure(); Finalize_ProblemStructure();
int choose = 1; int choose = 1;
if (!Flag_PRE && !Flag_CAL && !Flag_POS && !check){ if(!Flag_PRE && !Flag_CAL && !Flag_POS && !check) {
lres = lpos = 1; lres = lpos = 1;
choose = 0; choose = 0;
} }
if(lres) if(lres) Print_ListResolution(choose, lres, &Name_Resolution);
Print_ListResolution(choose, lres, &Name_Resolution);
if(lpos) if(lpos) Print_ListPostOperation(choose, lpos, Name_PostOperation);
Print_ListPostOperation(choose, lpos, Name_PostOperation);
if(check){ if(check) { Print_ProblemStructure(); }
Print_ProblemStructure(); else {
} check =
else{ Message::GetOnelabNumber(Message::GetOnelabClientName() + "/}ModelCheck");
check = Message::GetOnelabNumber
(Message::GetOnelabClientName() + "/}ModelCheck");
if(check) Print_Object(check - 1); if(check) Print_Object(check - 1);
} }
if(Flag_PRE || Flag_CAL || Flag_POS) if(Flag_PRE || Flag_CAL || Flag_POS) SolvingAnalyse();
SolvingAnalyse();
// PETSc cannot be finalized if it will be re-initialized again in the same // PETSc cannot be finalized if it will be re-initialized again in the same
// process - so just don't finalize it if we use getdp as a library with a // process - so just don't finalize it if we use getdp as a library with a
// provided onelab server (e.g. for the mobile apps) // provided onelab server (e.g. for the mobile apps)
if(!Flag_CALLED_WITH_ONELAB_SERVER) if(!Flag_CALLED_WITH_ONELAB_SERVER) LinAlg_FinalizeSolver();
LinAlg_FinalizeSolver();
Message::PrintErrorCounter("Run"); Message::PrintErrorCounter("Run");
Message::Cpu(3, true, true, true, true, true, "Stopped"); Message::Cpu(3, true, true, true, true, true, "Stopped");
if(Message::GetVerbosity() == 99){ // debug if(Message::GetVerbosity() == 99) { // debug
getdpPrintNumbers(); getdpPrintNumbers();
getdpPrintStrings(); getdpPrintStrings();
} }
#if defined(HAVE_GMSH) #if defined(HAVE_GMSH)
if(!Flag_CALLED_WITH_ONELAB_SERVER) GmshFinalize(); if(!Flag_CALLED_WITH_ONELAB_SERVER) GmshFinalize();
if(msg) delete msg; if(msg) delete msg;
#endif #endif
Free_GlobalVariables(); Free_GlobalVariables();
Free(sargv); Free(sargv);
Message::Finalize(); Message::Finalize();
return Message::GetErrorCount(); return Message::GetErrorCount();
} }
int getdp(const std::vector<std::string> &args, void *ptr) int getdp(const std::vector<std::string> &args, void *ptr)
{ {
onelab::server *onelabServer = (onelab::server*) ptr; onelab::server *onelabServer = (onelab::server *)ptr;
if(onelabServer != NULL){ if(onelabServer != NULL) {
onelab::server::setInstance(onelabServer); onelab::server::setInstance(onelabServer);
Flag_CALLED_WITH_ONELAB_SERVER = 1; Flag_CALLED_WITH_ONELAB_SERVER = 1;
Message::SetExitOnError(2); // throw exception on error Message::SetExitOnError(2); // throw exception on error
} }
int argc = args.size(); int argc = args.size();
std::vector<char*> argv(argc + 1, (char*)0); std::vector<char *> argv(argc + 1, (char *)0);
for(int i = 0; i < argc; i++) argv[i] = (char*)args[i].c_str(); for(int i = 0; i < argc; i++) argv[i] = (char *)args[i].c_str();
return MainKernel(argc, &argv[0]); return MainKernel(argc, &argv[0]);
} }
 End of changes. 98 change blocks. 
409 lines changed or deleted 444 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)