Skip to content
Snippets Groups Projects
Commit d8cd2ffe authored by Francois Henrotte's avatar Francois Henrotte
Browse files

No commit message

No commit message
parent 0cabe2d1
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ SOURCES=myOS StringUtils mathex OnelabClients OnelabMessage OnelabParser metamod ...@@ -4,6 +4,7 @@ SOURCES=myOS StringUtils mathex OnelabClients OnelabMessage OnelabParser metamod
COMMON_DIR=$(GMSH_DIR)/Common COMMON_DIR=$(GMSH_DIR)/Common
ONELAB_DIR=$(GMSH_DIR)/contrib/onelab ONELAB_DIR=$(GMSH_DIR)/contrib/onelab
MATHEX_DIR=$(GMSH_DIR)/contrib/MathEx MATHEX_DIR=$(GMSH_DIR)/contrib/MathEx
CPPFLAGS+= $(shell python-config --includes) -fPIC
OBJDIR=objects OBJDIR=objects
...@@ -52,4 +53,9 @@ $(OBJDIR)/%.o : %.cpp $(ONELAB_DIR)/*.h ...@@ -52,4 +53,9 @@ $(OBJDIR)/%.o : %.cpp $(ONELAB_DIR)/*.h
clean : clean :
$(RM) $(TARGETS) $(OBJDIR)/*.o $(RM) $(TARGETS) $(OBJDIR)/*.o
onelab_wrap.cpp : onelab.i
swig -python -c++ -o $@ $<
_onelab.so : $(OBJECTS) $(OBJDIR)/onelab_wrap.o
$(CXX) -bundle -flat_namespace -undefined suppress $(OBJECTS) $(OBJDIR)/onelab_wrap.o -o _onelab.so
.PRECIOUS: $(OBJDIR)/%.o .PRECIOUS: $(OBJDIR)/%.o
...@@ -468,7 +468,7 @@ bool localSolverClient::buildRmCommand(std::string &cmd){ ...@@ -468,7 +468,7 @@ bool localSolverClient::buildRmCommand(std::string &cmd){
split = SplitOLFileName(choices[i]); split = SplitOLFileName(choices[i]);
cmd.append(split[1] + " "); cmd.append(split[1] + " ");
} }
return true; if(choices.size()) return true;
} }
return false; return false;
} }
...@@ -1206,6 +1206,7 @@ std::string ftoa(const double x){ ...@@ -1206,6 +1206,7 @@ std::string ftoa(const double x){
int mySystem(std::string commandLine){ int mySystem(std::string commandLine){
//Don't use OLMsg::Info here otherwise the message appears twice //Don't use OLMsg::Info here otherwise the message appears twice
//in the Gmsh message window. //in the Gmsh message window.
if(OLMsg::GetVerbosity())
std::cout << "Onelab: Calling <" << commandLine << ">" << std::endl; std::cout << "Onelab: Calling <" << commandLine << ">" << std::endl;
return SystemCall(commandLine.c_str(), true); return SystemCall(commandLine.c_str(), true);
} }
...@@ -1269,6 +1270,7 @@ std::string quote(const std::string &in){ ...@@ -1269,6 +1270,7 @@ std::string quote(const std::string &in){
} }
std::string unquote(const std::string &in) std::string unquote(const std::string &in)
{ {
if(in.empty()) return "";
size_t pos0=in.find_first_not_of(" "); size_t pos0=in.find_first_not_of(" ");
size_t pos=in.find_last_not_of(" "); size_t pos=in.find_last_not_of(" ");
if( (pos0 != std::string::npos) && (!in.compare(pos0,1,"\""))) if( (pos0 != std::string::npos) && (!in.compare(pos0,1,"\"")))
......
...@@ -107,7 +107,7 @@ void MetaModel::saveCommandLines(){ ...@@ -107,7 +107,7 @@ void MetaModel::saveCommandLines(){
} }
} }
else else
OLMsg::Error("The file <%s> cannot be opened",fileName.c_str()); OLMsg::Warning("The file <%s> cannot be opened",fileName.c_str());
infile.close(); infile.close();
//save client command lines //save client command lines
...@@ -623,9 +623,11 @@ void localSolverClient::parse_sentence(std::string line) { ...@@ -623,9 +623,11 @@ void localSolverClient::parse_sentence(std::string line) {
else else
OLMsg::Error("Wrong number of arguments for range <%s>", OLMsg::Error("Wrong number of arguments for range <%s>",
name.c_str()); name.c_str());
}
set(numbers[0]); set(numbers[0]);
} }
else
OLMsg::Error("The parameter <%s> does not exist",name.c_str());
}
} }
else if(!action.compare("withinRange")){ else if(!action.compare("withinRange")){
// ensure the value is in the prescribed range // ensure the value is in the prescribed range
...@@ -640,6 +642,8 @@ void localSolverClient::parse_sentence(std::string line) { ...@@ -640,6 +642,8 @@ void localSolverClient::parse_sentence(std::string line) {
numbers[0].setValue(numbers[0].getMax()); numbers[0].setValue(numbers[0].getMax());
set(numbers[0]); set(numbers[0]);
} }
else
OLMsg::Error("The parameter <%s> does not exist",name.c_str());
} }
else if(!action.compare("setValue")){ else if(!action.compare("setValue")){
// a set request together with a setReadOnly(1) forces // a set request together with a setReadOnly(1) forces
...@@ -662,11 +666,10 @@ void localSolverClient::parse_sentence(std::string line) { ...@@ -662,11 +666,10 @@ void localSolverClient::parse_sentence(std::string line) {
strings[0].setReadOnly(1); strings[0].setReadOnly(1);
set(strings[0]); set(strings[0]);
} }
else{ else
OLMsg::Error("The parameter <%s> does not exist",name.c_str()); OLMsg::Error("The parameter <%s> does not exist",name.c_str());
} }
} }
}
else if(!action.compare("resetChoices")){ else if(!action.compare("resetChoices")){
name.assign(longName(name)); name.assign(longName(name));
get(numbers,name); get(numbers,name);
...@@ -1586,6 +1589,7 @@ void MetaModel::client_sentence(const std::string &name, ...@@ -1586,6 +1589,7 @@ void MetaModel::client_sentence(const std::string &name,
bool changed = onelab::server::instance()->getChanged(c->getName()); bool changed = onelab::server::instance()->getChanged(c->getName());
bool started = isStarted(changed); bool started = isStarted(changed);
if(OLMsg::GetVerbosity())
std::cout << c->getName() << " active=" << c->getActive() << " changed=" << changed << " started=" << started << " errors=" << OLMsg::GetErrorCount() << std::endl; std::cout << c->getName() << " active=" << c->getActive() << " changed=" << changed << " started=" << started << " errors=" << OLMsg::GetErrorCount() << std::endl;
if(started) c->compute(); if(started) c->compute();
} }
...@@ -1638,7 +1642,7 @@ void MetaModel::client_sentence(const std::string &name, ...@@ -1638,7 +1642,7 @@ void MetaModel::client_sentence(const std::string &name,
} }
} }
else if(!action.compare("merge")){ else if(!action.compare("merge")){
if(isTodo(COMPUTE) && !OLMsg::GetErrorCount()){ if(isTodo(COMPUTE) && !OLMsg::GetErrorCount() && (OLMsg::hasGmsh)){
std::vector<std::string> choices; std::vector<std::string> choices;
for(unsigned int i = 0; i < arguments.size(); i++){ for(unsigned int i = 0; i < arguments.size(); i++){
choices.push_back(resolveGetVal(arguments[i])); choices.push_back(resolveGetVal(arguments[i]));
......
#include "StringUtils.h" #include "StringUtils.h"
//#include "onelabUtils.h"
#include "OnelabClients.h" #include "OnelabClients.h"
#include "metamodel.h" #include "metamodel.h"
#include <algorithm> #include <algorithm>
...@@ -141,24 +140,6 @@ std::string showClientStatus(){ ...@@ -141,24 +140,6 @@ std::string showClientStatus(){
return sstream.str(); return sstream.str();
} }
bool setParameter(const std::string &name, const std::string &value){
std::vector<onelab::number> numbers;
std::vector<onelab::string> strings;
onelab::server::instance()->get(numbers,name);
if (numbers.size()) {
numbers[0].setValue(atof(value.c_str()));
return onelab::server::instance()->set(numbers[0]);
}
else{
onelab::server::instance()->get(strings,name);
if (strings.size()) {
strings[0].setValue(value);
return onelab::server::instance()->set(strings[0]);
}
else
OLMsg::Error("The parameter <%s> does not exist", name.c_str());
}
}
bool menu() { bool menu() {
int choice, counter1=0, counter2=0; int choice, counter1=0, counter2=0;
......
#include "OnelabClients.h" #include "OnelabClients.h"
#include "metamodel.h" #include "metamodel.h"
/* PYTHON functions */
void modelName(const std::string &name, const std::string &wdir=""){
OLMsg::InitializeOnelab("onelab");
OLMsg::SetOnelabString("Arguments/FileName",name);
OLMsg::SetOnelabString("Arguments/WorkingDir",wdir);
OLMsg::SetVerbosity(0);
}
void setNumber(const std::string &name, const double value){
OLMsg::SetOnelabNumber(name, value);
}
void setString(const std::string &name, const std::string &value){
OLMsg::SetOnelabString(name, value);
}
double getNumber(const std::string &name){
return OLMsg::GetOnelabNumber(name);
}
std::string getString(const std::string &name){
return OLMsg::GetOnelabString(name);
}
/* Interface Gmsh - Metamodels */
void initializeMetamodel(const std::string &loaderName, onelab::client *olclient, void (*gui_wait_fct)(double time)) void initializeMetamodel(const std::string &loaderName, onelab::client *olclient, void (*gui_wait_fct)(double time))
{ {
......
...@@ -9,3 +9,11 @@ namespace onelab{ class client; } ...@@ -9,3 +9,11 @@ namespace onelab{ class client; }
int metamodel(const std::string &todo); int metamodel(const std::string &todo);
void initializeMetamodel(const std::string &, onelab::client *, void (*wait)(double time)); void initializeMetamodel(const std::string &, onelab::client *, void (*wait)(double time));
/* PYTHON functions */
void modelName(const std::string &name, const std::string &wdir);
void setNumber(const std::string &name, const double value);
void setString(const std::string &name, const std::string &value);
double getNumber(const std::string &name);
std::string getString(const std::string &name);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment