Skip to content
Snippets Groups Projects
Select Git revision
  • d8cd2ffe86b8c1bd9b77183c9746cf89adec2d90
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

metamodel.cpp

Blame
  • Forked from gmsh / gmsh
    11861 commits behind the upstream repository.
    user avatar
    Francois Henrotte authored
    No commit message
    d8cd2ffe
    History
    metamodel.cpp 2.98 KiB
    #include "OnelabClients.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))
    {
      //called by  "metamodel_cb"
      //copies the Msg::_onelabClient to  OLMsg::_onelabClient
      //This pointer refers to an object of class localGmsh() (cf GmshMessage.cpp)
      //which is a onelab::client with sone Gmsh features (merge and messages).
      //Initilizes also the wait function the Gmsh Gui
      //so that Gmsh windows may remain active during client computations.
      OLMsg::SetOnelabClient(olclient);
      OLMsg::SetOnelabString("LoaderPathName",loaderName,false);
      OLMsg::SetGuiWaitFunction(gui_wait_fct);
    }
    
    int metamodel(const std::string &action){
      int errors;
    
      OLMsg::Info("Start metamodel");
      OLMsg::hasGmsh = OLMsg::GetOnelabNumber("IsMetamodel");
      OLMsg::ResetErrorCounter();
    
      parseMode todo;
      if(action == "compute")
        todo = COMPUTE;
      else{
        todo = ANALYZE;
      }
    
      std::string modelName = OLMsg::GetOnelabString("Arguments/FileName");
      std::string workingDir = OLMsg::GetOnelabString("Arguments/WorkingDir");
      std::string clientName = "meta";
    
      MetaModel *myModel =
        new MetaModel("meta", workingDir, "meta", modelName);
      myModel->setTodo(todo);
    
      if(OLMsg::GetOnelabNumber("LOGFILES")){
        std::string mystdout = FixWindowsQuotes(workingDir + "stdout.txt");
        std::string mystderr = FixWindowsQuotes(workingDir + "stderr.txt");
        OLMsg::Info("Redirecting stdout into <%s>",mystdout.c_str());
        OLMsg::Info("Redirecting stderr into <%s>",mystderr.c_str());
        freopen(mystdout.c_str(),"w",stdout);
        freopen(mystderr.c_str(),"w",stderr);
      }
    
      if(OLMsg::GetErrorCount()) myModel->setTodo(EXIT);
    
      if( myModel->isTodo(ANALYZE)){
        myModel->analyze();
      }
      else if( myModel->isTodo(COMPUTE)){
        myModel->compute();
      }
      else if( myModel->isTodo(EXIT)){
      }
      else
        OLMsg::Error("Main: Unknown Action <%d>", todo);
      delete myModel;
    
      if((errors=OLMsg::GetErrorCount())){
        OLMsg::Error("Leave metamodel - %d errors",errors);
        OLMsg::Info("=====  O  N  E  L  A  B  =====");
        return 0;
      }
    
      int reload=OLMsg::GetOnelabNumber("Gmsh/NeedReloadGeom");
      OLMsg::SetOnelabNumber("Gmsh/NeedReloadGeom",0,false);
    
      OLMsg::Info("Leave metamodel - need reload=%d", reload);
      OLMsg::Info("=====  O  N  E  L  A  B  =====");
      return reload;
    }