diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index caaa02b8e7e1e0b51266dcb03a00004f2555b36a..a462d974986d75b509f61c421cdcf615c279afc1 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -684,13 +684,23 @@ void Msg::SetOnelabString(std::string name, std::string val, bool visible) class localGmsh : public onelab::localClient { public: localGmsh() : onelab::localClient("Gmsh") {} + // redefinition of virtual onelab_client::sendMergeFileRequest void sendMergeFileRequest(const std::string &name) { - MergePostProcessingFile(name, CTX::instance()->solver.autoShowLastStep, - CTX::instance()->solver.autoHideNewViews, true); if(name.find(".geo")!= std::string::npos){ + MergePostProcessingFile(name, CTX::instance()->solver.autoShowLastStep, + CTX::instance()->solver.autoHideNewViews, true); GModel::current()->setFileName(name); } + else if((name.find(".opt")!= std::string::npos)){ + MergeFile(name); + } + else if((name.find(".macro")!= std::string::npos)){ + MergeFile(name); + } + else + MergePostProcessingFile(name, CTX::instance()->solver.autoShowLastStep, + CTX::instance()->solver.autoHideNewViews, true); } void sendInfo(const std::string &msg){ Msg::Info("%s", msg.c_str()); } void sendWarning(const std::string &msg){ Msg::Warning("%s", msg.c_str()); } diff --git a/contrib/onelab/OnelabClients.h b/contrib/onelab/OnelabClients.h index 32507689b472b920d097509b1e2a7b2f3719b13a..08db4637870fa0d859477a363a0378aea88a2fc3 100644 --- a/contrib/onelab/OnelabClients.h +++ b/contrib/onelab/OnelabClients.h @@ -63,7 +63,6 @@ std::string extractExpandPattern(const std::string& str); typedef std::vector <std::vector <double> > array; array read_array(std::string fileName, char sep); double find_in_array(int i, int j, const std::vector <std::vector <double> > &data); -//std::vector<double> extract_column(const int j, array data); static std::string getShortName(const std::string &name) { std::string s = name; diff --git a/contrib/onelab/OnelabMessage.cpp b/contrib/onelab/OnelabMessage.cpp index d55610d5a8e0301d9c83110814b8d886bc7e3109..524100baa4c93b261a7bb5ce6414c2ca34739f77 100644 --- a/contrib/onelab/OnelabMessage.cpp +++ b/contrib/onelab/OnelabMessage.cpp @@ -408,10 +408,8 @@ std::string OLMsg::obtainFullName(const std::string &name){ } void OLMsg::MergeFile(const std::string &name){ - //This routine allows sending input files (geo, pos, msh) to Gmsh - //The parameter Gmsh/MergedGeo ensures that only one geometry - //is sent to Gmsh. It is reloaded afted each metamodel execution - // + //Sends files (geo, pos, msh) to Gmsh + //The parameter Gmsh/MergedGeo ensures that the geometry is sent once. if(_onelabClient){ if(name.find(".geo") != std::string::npos){ if(GetOnelabString("Gmsh/MergedGeo").empty()){ @@ -421,7 +419,7 @@ void OLMsg::MergeFile(const std::string &name){ } } else{ - Info("Merge a geometry <%s> to Gmsh", name.c_str()); + Info("Merge <%s> to Gmsh", name.c_str()); _onelabClient->sendMergeFileRequest(name); } } diff --git a/contrib/onelab/OnelabMessage.h b/contrib/onelab/OnelabMessage.h index 17c1f938675377d69f6ded10dba3167157300669..5219dc3cd8884f2806c68475a9e749597bf8328b 100644 --- a/contrib/onelab/OnelabMessage.h +++ b/contrib/onelab/OnelabMessage.h @@ -1,4 +1,4 @@ -// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle +// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, F. Henrotte // // See the LICENSE.txt file for license information. Please report all // bugs and problems to <gmsh@geuz.org>. diff --git a/contrib/onelab/OnelabParser.cpp b/contrib/onelab/OnelabParser.cpp index eb344b5bb2798224512ac3ff6fd28e47169be721..89647adf39d0543c16e0f12622f8fd0d2f5ba80d 100644 --- a/contrib/onelab/OnelabParser.cpp +++ b/contrib/onelab/OnelabParser.cpp @@ -11,7 +11,6 @@ namespace olkey{ static std::string begin(label+"block"); static std::string end(label+"endblock"); static std::string include(label+"include"); - static std::string loader(label+"loaderName"); static std::string message(label+"msg"); static std::string showParam(label+"show"); static std::string showGmsh(label+"merge"); @@ -280,8 +279,10 @@ std::string localSolverClient::resolveString(const std::string &line) { } std::string localSolverClient::resolveGetVal(std::string line) { - //looks for OL.get() statements, substitute the value from server - //then ealuate the resulting string with mathex. + //looks for OL.get() statements, substitute values from server + //then evaluate the resulting string with mathex. + //OL.get(name + // {, {choices|range}.{size|comp|expand|index}|attributes.get(args)}) std::vector<onelab::number> numbers; std::vector<onelab::string> strings; std::vector<std::string> arguments; @@ -375,6 +376,11 @@ std::string localSolverClient::resolveGetVal(std::string line) { OLMsg::Error("Unknown action <%s> in %s statement", action.c_str(),olkey::getValue.c_str()); } + else if(!name.compare(0,6,"attrib")) { + if(!action.compare("get")) { + buff.assign(numbers[0].getAttribute(args[0])); + } + } } } else{ @@ -840,7 +846,6 @@ void localSolverClient::modify_tags(const std::string lab, const std::string com olkey::begin.assign(olkey::label+"block"); olkey::end.assign(olkey::label+"endblock"); olkey::include.assign(olkey::label+"include"); - olkey::loader.assign(olkey::label+"loaderName"); olkey::message.assign(olkey::label+"msg"); olkey::showParam.assign(olkey::label+"show"); olkey::showGmsh.assign(olkey::label+"merge"); @@ -975,17 +980,6 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { OLMsg::Info("%s",msg.c_str()); } } - else if ( (pos=line.find(olkey::loader)) != std::string::npos) { - // onelab.loaderName - cursor = pos+olkey::loader.length(); - if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Error("Misformed <%s> statement: (%s)", - olkey::loader.c_str(),line.c_str()); - else{ - std::string msg = resolveGetVal(arguments[0]); - OLMsg::Info("%s",msg.c_str()); - } - } else if ( (pos=line.find(olkey::showParam)) != std::string::npos) { // onelab.showParam cursor = pos+olkey::showParam.length(); @@ -1019,7 +1013,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { olkey::showGmsh.c_str(),line.c_str()); else{ std::string fileName=resolveGetVal(arguments[0]); - OLMsg::MergeFile(fileName); + OLMsg::MergeFile(getWorkingDir() + fileName); } } else if ( (pos=line.find(olkey::dump)) != std::string::npos) { @@ -1605,20 +1599,20 @@ void MetaModel::client_sentence(const std::string &name, if(arguments.size()%4==0){ if(isTodo(REGISTER)){ // predefine the parameters to upload - for(unsigned int i = 0; i < arguments.size(); i++){ - if(i%4==3){ - std::string str=resolveGetVal(arguments[i]); - OLMsg::recordFullName(str); - std::vector<onelab::number> numbers; - get(numbers, str); - if(numbers.empty()){ - numbers.resize(1); - numbers[0].setName(str); - numbers[0].setValue(0); - set(numbers[0]); - } - } - } + // for(unsigned int i = 0; i < arguments.size(); i++){ + // if(i%4==3){ + // std::string str=resolveGetVal(arguments[i]); + // OLMsg::recordFullName(str); + // std::vector<onelab::number> numbers; + // get(numbers, str); + // if(numbers.empty()){ + // numbers.resize(1); + // numbers[0].setName(str); + // numbers[0].setValue(0); + // set(numbers[0]); + // } + // } + // } } else if(isTodo(COMPUTE) && !OLMsg::GetErrorCount()){ std::vector<std::string> choices; diff --git a/contrib/onelab/metamodel.h b/contrib/onelab/metamodel.h index 981c351076719517b9a756a407e3b9238ca6b31e..b98354e5f14258093021d289f70ef24caaa97bd4 100644 --- a/contrib/onelab/metamodel.h +++ b/contrib/onelab/metamodel.h @@ -1,3 +1,8 @@ +// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, F. Henrotte +// +// See the LICENSE.txt file for license information. Please report all +// bugs and problems to <gmsh@geuz.org>. + #include <string> namespace onelab{ class client; }