Skip to content
Snippets Groups Projects
Select Git revision
  • 1f1c7695cfcbe25b7f40f12c505ffa1c72f34136
  • 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

solver.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    solver.cpp 2.50 KiB
    // This is a dummy C++ client solver for Gmsh: it does not solve
    // anything, but shows how to program your own solver to interact with
    // the Gmsh solver module.
    //
    // To compile this solver, type something like:
    //
    // g++ solver.cpp -o solver.exe
    //
    // To run it, merge the contents of the file solver.opt into your
    // default Gmsh option file, or launch Gmsh with the command:
    //
    // gmsh -option solver.opt 
    //
    // You will then see a new button labeled "My C++ solver" in Gmsh's
    // solver menu.
    
    #include <math.h>
    #include "GmshSocket.h"
    
    typedef enum { send_options, run_code } action;
    
    int main(int argc, char *argv[])
    {
      action what_to_do = run_code;
      char *name = 0, *option = 0, *socket = 0;
    
      // parse command line
      int i = 0;
      while(i < argc) {
        if(argv[i][0] == '-') {
          if(!strcmp(argv[i] + 1, "socket")) {
            i++; 
            if(argv[i]) socket = argv[i++];
          }
          else if(!strcmp(argv[i] + 1, "options")) {
            i++;
            what_to_do = send_options;
          }
          else if(!strcmp(argv[i] + 1, "run")) {
            i++;
            what_to_do = run_code;
            if(argv[i]) option = argv[i++];
          }
        }
        else
          name = argv[i++];
      }
    
      if(!socket) {
        printf("No socket specified: running non-interactively...\n");
        exit(1);
      }
    
      // connect to Gmsh
      GmshClient client;
      if(client.Connect(socket) < 0){
        printf("Unable to connect to Gmsh\n");
        exit(1);
      }
      client.Start();
    
      if(what_to_do == send_options) {
        // send the available options for this computation
        client.Option(1, "FormulationH");
        client.Option(1, "ConvTest");
        client.Option(1, "Blablabli");
      }
      else if(what_to_do == run_code){
        // do the computation and merge some views
        for(int i = 0; i < 10; i++){