[Gmsh] Mesh Code/Source for Heat Transfer

Geordie McBain gdmcbain at freeshell.org
Tue Apr 5 01:50:34 CEST 2011


> I am currently working on a project which is about the ground-coupled heat exchanger model. The model is used to simulate the heat transfer process of surrounding soil of the circular pipe, where heat is extracted or generated within the circular pipe. I will need to write a code (in C++) to simulate the transient heat transfer for the pipe (i.e. circular cylindrical) within soil (i.e. rectangular domain model).

While you can write a code in C++ for this, you don't really need to;
several serviceable C++ codes for the solving the heat equation, are
freely available.  Try GetDP, FreeFem++, OpenFOAM, or libMesh, for
example; the first of these enjoys close links with Gmsh.

> (1) After the mesh has been generated, can I read or view the mesh code/source coordinate data?

Yes.  The 110404_Model in msh.msh file you generated and included in
the zip-archive is in an ASCII format, so you can read it yourself in
a text-editor (e.g. Emacs or vi) or parse it fairly easily in any
programming language.  The format is simple and is described in the
manual:

   http://geuz.org/gmsh/doc/texinfo/gmsh.html#MSH-ASCII-file-format

> (2) Once I have got the mesh code/source coordinate data, how would I be able to transfer or link these data into my C++ program?

If you do decide to go this way, you'll find an example of reading a
Gmsh geometry .geo file, meshing it, and processing the resulting mesh
in utils/api_demos/mainSimple.cpp in the Gmsh source distribution.

> As mentioned, I will be using transient heat transfer equation in cylindrical polar coordinate system to determine the heat transfer effect of the circular pipe. The equation shows as below:

You may well be better off working with the equation in the Cartesian
coordinate system, despite the circular pipe.  It's much easier to
generate an unstructured mesh than a structured one which respects the
coordinate system, and once you've done that, I think you've lost
whatever advantages a special coordinate system might have.

> Another thing is that, I have downloaded the Gmsh 2.5.0 Source Code from your website, and I am wondering how I shall read this source code, and whether I can link/use one of the codes into my simulation model (or mesh model) from the Source Code?

You probably don't need to read the Gmsh source code, except out of
curiosity or if you find later you need to fix or bug or extend the
program, but Gmsh is already in a sufficiently mature state that you
shouldn't need to for solving the heat equation in a reasonably
well-defined geometry.  But don't let me discourage you: see the other
examples in utils/api_demos.