From 908ef8c97481af2a9a88b8f4e5ffd8779556bb31 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 14 Jan 2005 17:54:01 +0000
Subject: [PATCH] use C++ example in doc instead of C

---
 doc/texinfo/gmsh.texi                       | 20 +++--
 utils/solvers/c++/Makefile                  |  6 +-
 utils/solvers/c++/andre.cpp                 | 95 ---------------------
 utils/solvers/c++/solver.cpp                | 93 ++++++++++++++++++++
 utils/solvers/c++/{andre.opt => solver.opt} |  7 +-
 5 files changed, 111 insertions(+), 110 deletions(-)
 delete mode 100644 utils/solvers/c++/andre.cpp
 create mode 100644 utils/solvers/c++/solver.cpp
 rename utils/solvers/c++/{andre.opt => solver.opt} (56%)

diff --git a/doc/texinfo/gmsh.texi b/doc/texinfo/gmsh.texi
index 9f43a21f00..e556d48bdb 100644
--- a/doc/texinfo/gmsh.texi
+++ b/doc/texinfo/gmsh.texi
@@ -1,5 +1,5 @@
 \input texinfo.tex @c -*-texinfo-*-
-@c $Id: gmsh.texi,v 1.166 2005-01-13 05:45:46 geuzaine Exp $
+@c $Id: gmsh.texi,v 1.167 2005-01-14 17:54:01 geuzaine Exp $
 @c
 @c Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 @c
@@ -2210,24 +2210,24 @@ available on @value{GMSH-WEB}.
 @cindex Solver example
 @cindex Example, solver
 
-Here is a small example of how to interface a C solver with Gmsh. The
-following listing reproduces the @file{utils/solvers/mysolver.c} file from
-the Gmsh source distribution.
+Here is a small example of how to interface a C++ solver with Gmsh. The
+following listing reproduces the @file{utils/solvers/c++/solver.cpp} file
+from the Gmsh source distribution (C and Perl examples are also available).
 
 @sp 1
 
-@verbatiminclude ../../utils/solvers/mysolver.c
+@verbatiminclude ../../utils/solvers/c++/solver.cpp
 
 @sp 1
 
-To define the above solver as the second external solver in Gmsh, you should
-define the following solver options (either merge them in your Gmsh option
+To define the above solver as the second external solver in Gmsh, you then
+need to define the following options (either merge them in your Gmsh option
 file, or use the @code{-option} command-line option---see @ref{Command-line
 options}):
 
 @sp 1
 
-@verbatiminclude ../../utils/solvers/mysolver.opt
+@verbatiminclude ../../utils/solvers/c++/solver.opt
 
 @c =========================================================================
 @c Post-processing module
@@ -2322,6 +2322,10 @@ different display options), but you cannot afford to store all copies in
 memory. If what you really want is multiple physical copies of the data,
 just merge the file containing the post-processing view multiple times.
 
+@item AliasWithOptions View[@var{expression}];
+Creates an alias of the @var{expression}-th post-processing view and copies
+all the options of the @var{expression}-th view to the new aliased view.
+
 @item Combine TimeSteps;
 Combines the data from all the post-processing views having the same name
 into new multi-time-step views.
diff --git a/utils/solvers/c++/Makefile b/utils/solvers/c++/Makefile
index aa1b85424a..4d60902530 100644
--- a/utils/solvers/c++/Makefile
+++ b/utils/solvers/c++/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.2 2005-01-14 02:27:01 geuzaine Exp $
+# $Id: Makefile,v 1.3 2005-01-14 17:54:01 geuzaine Exp $
 #
 # Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 #
@@ -21,8 +21,8 @@
 
 include ../../../variables
 
-andre: andre.cpp
-	${CXX} ${FLAGS} ${OPTIM} -o andre.exe andre.cpp
+solver: solver.cpp
+	${CXX} ${FLAGS} ${OPTIM} -o solver.exe solver.cpp
 
 clean:
 	rm -f *.o *.exe *.pos
diff --git a/utils/solvers/c++/andre.cpp b/utils/solvers/c++/andre.cpp
deleted file mode 100644
index 8ab24cc414..0000000000
--- a/utils/solvers/c++/andre.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <math.h>
-#include "GmshClient.h"
-
-typedef enum { send_options, run_code } action;
-
-int main(int argc, char *argv[])
-{
-  action what_to_do = run_code;
-  char *name = NULL, *option = NULL, *socket = NULL;
-
-  // 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 server\n");
-    exit(1);
-  }
-  else{
-    client.Start(getpid());
-    if(what_to_do == send_options) {
-      // send the available options for this computation
-      client.Option(1, "FormulationH");
-      client.Option(1, "\"Convergence Test\"");
-      client.Option(1, "\"Blabla blblablabli\"");
-    }
-    else if(what_to_do == run_code){
-      // do the computation and merge some views
-      for(int i = 0; i < 10; i++){
-	client.Info("Computing curve...");
-	sleep(1);
-	client.Info("Done computing curve");
-	FILE *file = fopen("andre.pos", "w");
-	if(!file)
-	  client.Error("Unable to open output file");
-	else {
-	  fprintf(file, "General.GraphicsWidth = 500;\n");
-	  fprintf(file, "General.GraphicsHeight = 450;\n");
-	  fprintf(file, "General.SmallAxes = 0;\n");
-	  fprintf(file, "View.Type = 2;\n");
-	  fprintf(file, "View.AutoPosition = 0;\n");
-	  fprintf(file, "View.PositionX = 100;\n");
-	  fprintf(file, "View.PositionY = 50;\n");
-	  fprintf(file, "View.Width = 350;\n");
-	  fprintf(file, "View.Height = 350;\n");
-	  fprintf(file, "Delete View[0];\n");
-	  fprintf(file, "View \"test\"{\n");
-	  for(int j = 0; j < 100; j++)
-	    fprintf(file, "SP(%d,0,0){%g};\n", j,sin(j*i*M_PI/10.));
-	  fprintf(file, "};\n");
-	  fclose(file);
-	  client.View("andre.pos");
-	}
-      }
-      client.Info("Done!");
-    }
-
-    client.Stop();
-    client.Disconnect();
-  }
-}
diff --git a/utils/solvers/c++/solver.cpp b/utils/solvers/c++/solver.cpp
new file mode 100644
index 0000000000..5d61838f22
--- /dev/null
+++ b/utils/solvers/c++/solver.cpp
@@ -0,0 +1,93 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "GmshClient.h"
+
+typedef enum { send_options, run_code } action;
+
+int main(int argc, char *argv[])
+{
+  action what_to_do = run_code;
+  char *name = NULL, *option = NULL, *socket = NULL;
+
+  // 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(getpid());
+
+  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++){
+      client.Info("Computing curve...");
+      sleep(1); // fake computation...
+      client.Info("Done computing curve");
+      FILE *file = fopen("solver.pos", "w");
+      if(!file)
+	client.Error("Unable to open output file");
+      else {
+	fprintf(file, "General.GraphicsWidth = 500;\n");
+	fprintf(file, "General.GraphicsHeight = 450;\n");
+	fprintf(file, "General.SmallAxes = 0;\n");
+	fprintf(file, "View.Type = 2;\n");
+	fprintf(file, "View.AutoPosition = 0;\n");
+	fprintf(file, "View.PositionX = 100;\n");
+	fprintf(file, "View.PositionY = 50;\n");
+	fprintf(file, "View.Width = 350;\n");
+	fprintf(file, "View.Height = 350;\n");
+	fprintf(file, "Delete View[0];\n");
+	fprintf(file, "View \"%s\"{\n", option);
+	for(int j = 0; j < 100; j++)
+	  fprintf(file, "SP(%d,0,0){%g};\n", j,sin(j*i*M_PI/10.));
+	fprintf(file, "};\n");
+	fclose(file);
+	client.View("solver.pos");
+      }
+    }
+    client.Info("Done!");
+  }
+
+  client.Stop();
+  client.Disconnect();
+}
diff --git a/utils/solvers/c++/andre.opt b/utils/solvers/c++/solver.opt
similarity index 56%
rename from utils/solvers/c++/andre.opt
rename to utils/solvers/c++/solver.opt
index 399b6b8eea..c8e38486d2 100644
--- a/utils/solvers/c++/andre.opt
+++ b/utils/solvers/c++/solver.opt
@@ -1,8 +1,7 @@
-Solver.Name1 = "Solveur Andre";
-Solver.Help1 = "Mon petit solveur";
-Solver.Executable1 = "./andre.exe";
+Solver.Name1 = "My C++ Solver";
+Solver.Executable1 = "./solver.exe";
 Solver.OptionCommand1 = "-options";
-Solver.FirstOption1 = "Mes options";
+Solver.FirstOption1 = "My options";
 Solver.FirstButton1 = "Run !";
 Solver.FirstButtonCommand1 = "-run %s";
 Solver.ClientServer1 = 1;
-- 
GitLab