Skip to content
Snippets Groups Projects
Commit 908ef8c9 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

use C++ example in doc instead of C
parent f3eb1685
No related branches found
No related tags found
No related merge requests found
\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.
......
# $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
......
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.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;
......@@ -47,24 +45,25 @@ int main(int argc, char *argv[])
GmshClient client;
if(client.Connect(socket) < 0){
printf("Unable to connect to server\n");
printf("Unable to connect to Gmsh\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\"");
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);
sleep(1); // fake computation...
client.Info("Done computing curve");
FILE *file = fopen("andre.pos", "w");
FILE *file = fopen("solver.pos", "w");
if(!file)
client.Error("Unable to open output file");
else {
......@@ -78,12 +77,12 @@ int main(int argc, char *argv[])
fprintf(file, "View.Width = 350;\n");
fprintf(file, "View.Height = 350;\n");
fprintf(file, "Delete View[0];\n");
fprintf(file, "View \"test\"{\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("andre.pos");
client.View("solver.pos");
}
}
client.Info("Done!");
......@@ -92,4 +91,3 @@ int main(int argc, char *argv[])
client.Stop();
client.Disconnect();
}
}
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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment