You are on page 1of 52

MeshGems-Tetra HPC: The multithread or distributed

tetrahedral mesh generator of the MeshGems


R
Suite

API Manual
MeshGems-Tetra HPC Version: 2.10

Documentation Revision: 1

October 2019

Pantone Pantone
Process Blue 294 C

Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
API Manual MG-TETRA HPC
Release 2.10

Customer Service
Should you encounter any problem with MeshGems-Tetra HPC or the MeshGems
R
Suite, please contact
01
Pantone Pantone Pantone
the customer service by:
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Address: DISTENE S.A.S.
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

Customer Support Service


Campus Teratec
2, rue de la Piquetterie
91680 Bruyères-le-Chatel
FRANCE

Telephone: +33(0)970-650-219
Fax: +33(0)169-269-033
Electronic mail: support@distene.com

MeshGems
R
: a brand of DISTENE
Copyright
c Distene SAS 2019
Reproduction of this document is permitted except for resale and on condition its origin is specified. It may
not be changed in any way without the prior agreement of the authors.
1st edition edition, October 2019

TH-2
MG-TETRA HPC API Manual
Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

Information

This document is the api manual of the MeshGems-Tetra HPC software. It applies to all platforms running
the software.
The MeshGems-Tetra HPC software is the multithread or distributed tetrahedral mesh generator of the
MeshGems R
suite.

Important notice: In order to use MeshGems-Tetra HPC, you must first install the
tool and, if necessary, the license server. Please refer to the installation guide in the
delivered CD-ROM or in the installed distribution.

TH-3
API Manual MG-TETRA HPC
Release 2.10

Document History
Version Date Comment
01
Pantone
306 C
Pantone
Process Blue
Pantone
294 C 2.10-1 October 2019 1st edition
/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

TH-4
MG-TETRA HPC API Manual
Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

Foreword

The MeshGems R
Suite is a comprehensive set of meshing components, which aim at providing CAD/CAE
application developers with reliable, fast and high quality meshing technologies. These components ad-
dress all aspects of automatic meshing for real life industrial 3D numerical simulations, using very efficient
algorithms:

• surface meshing from analytical CAD, discrete CAD (tessellation) or hybrid CAD (mix of analytical
and discrete CAD definition),
• correction of data, whether geometrical or triangulated,

• volume mesh generation,


• remeshing,
• adaptation driven by user-given local criteria.

The MeshGems
R
Suite is designed to make integration and maintenance easy by third party developers.

R
The MeshGems Suite today includes:

• CADSurf for triangular/quadrilateral mesh generation


• Cleaner for mesh correction
• Tetra for tetrahedral volume mesh generation
• Tetra HPC for multithread or distributed tetrahedral volume mesh generation
• Hexa for hexahedral volume mesh generation
• Hybrid for multi-element volume mesh generation

• SurfOpt for surface remeshing and optimization


• Adapt for surface and/or volume mesh adaptation

All these components can be used independently or as a compatible whole thanks to the common core module
(MeshGems-Core) included in all the MeshGems R
Suite components.

See section 2.4 for more information about coupling MeshGems-Tetra HPC with the other MeshGems
R

Suite components.

TH-5
API Manual MG-TETRA HPC
Release 2.10

01
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

TH-6
MG-TETRA HPC API Manual
CONTENTS Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

Contents

Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1 Introduction 11

2 Getting started 13
2.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.1 Content of the distribution directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.2 Dynamic libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.3 Include files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.1 Supported platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.2 Disk Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.3 CPU time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.4 Memory usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 Errors and diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4 Coupling with other Distene tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.5 Integration within third party products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3 MeshGems-Tetra HPC’s integration 17


3.1 Short description of the Application Programming Interface . . . . . . . . . . . . . . . . . . . 17
3.1.1 API concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.2 The context object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.2.1 Construction/Destruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.2.2 Setting the message callback . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.3 The message object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.3.1 The message object type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.3.2 The message callback type . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

TH-7
API Manual MG-TETRA HPC
Release 2.10 CONTENTS

3.1.4 Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19


3.1.4.1 The error callback system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.1.4.2 Guided example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
01
Pantone
306 C

/04/2011
Pantone
Process Blue
Pantone
294 C
3.1.5 Stub system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
0401 Logo Mesh Gems 04

3.1.5.1 How it works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20


11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

3.1.5.2 How to use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20


3.1.6 Thread safety . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 MeshGems-Tetra HPC’s session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2.1 Construction/Destruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2.2 Setting parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2.3 Setting the message callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2.4 Setting the interrupt callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2.5 Setting the input mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2.6 Setting an optional sizemap callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2.7 Setting an optional tetrahedron quality callback . . . . . . . . . . . . . . . . . . . . . 23
3.2.8 Meshing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2.9 Getting the output mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.3 MeshGems-Tetra HPC’s parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3.1 List of MeshGems-Tetra HPC parameters . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3.2 Short description of various MeshGems-Tetra HPC parameters . . . . . . . . . . . . . 25
3.4 Sizemap structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.5 Sizemap creator structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.5.1 Construction/Destruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.5.2 Add a constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.5.3 Create a 3d sizemap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.6 Computing a quadratic volume mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.7 Mesh structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.7.1 The mesh object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.7.2 Accessing the output mesh structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.8 The subdomain description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.8.1 Getting the number of subdomains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.8.2 Getting the subdomain description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Appendices 41

A MeshGems-Tetra HPC’s integration template 41

TH-8
MG-TETRA HPC API Manual
CONTENTS Release 2.10

B MeshGems-Tetra HPC’s diagnostics 49


B.1 Possible causes of failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
B.2 Syntax of the diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
10401

B.3 List of MeshGems-Tetra HPC’s diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Pantone
306 C
Pantone
Process Blue
Pantone
294 C
50
Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

TH-9
API Manual MG-TETRA HPC
Release 2.10 CONTENTS

01
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

TH-10
MG-TETRA HPC API Manual
Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL

Chapter 1
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

Introduction

This user manual describes the main features of the API of MeshGems-Tetra HPC1 2.10 version.

1 Developed by the INRIA and Distene SAS

TH-11
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 1. INTRODUCTION

01
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

TH-12
MG-TETRA HPC API Manual
Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL

Chapter 2
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

Getting started

2.1 Installation

2.1.1 Content of the distribution directory

The MeshGems-Tetra HPC distribution directory is DISTENE/MeshGems-VERSION/Products (where VER-


SION is the release number of the MeshGems
R
Suite) and contains the following sub-directories:

Docs: mg-tetra hpc user manual.pdf the MeshGems-Tetra HPC user manual and mg-tetra hpc api manual.pdf
the API MeshGems-Tetra HPC user manual.

bin : the executable versions of MeshGems-Tetra HPC. They are organized by architecture in sub-directories.
See the MeshGems-Tetra HPC user manual for more information.

examples : some self-contained examples

include : the include files (C headers) associated to the dynamic libraries contained in the lib directory.

lib : the dynamic libraries of MeshGems-Tetra HPC. They are organized by architecture in sub-directories.

stubs : the source file of the stub system provided by the MeshGems
R
Suite API (see 3.1.5).

templates : templates that show how to use and integrate the component.

2.1.2 Dynamic libraries

Dynamic libraries are provided for various systems. Each sub-directory of the lib directory is dedicated to
a target architecture and contains :

• the files for the dynamic library (*.so or *.dll for example),

• a short text file readme.txt that describes the compiling environment or special options we used to
generate the dynamic library.

The dynamic libraries needed to use MeshGems-Tetra HPC are mg-tetra hpc.*, meshgems.* and meshgems stubs.*.
The name of a target architecture is self-explanatory. By default the target is a 32bit architecture while the
64 bit versions have the 64 suffix. For example Linux is the 32 bit target while Linux 64 is the 64 bit one.

TH-13
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 2. GETTING STARTED

2.1.3 Include files

The include files are gathered in the include/meshgems directory. This whole directory should be kept as
is.
01
Pantone
306 C
Pantone
Process Blue
Pantone
294 C
To compile a code with MeshGems-Tetra HPC you have to make sure that your compiler is able to find the
/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
include/meshgems directory and then you have to include the files meshgems/meshgems.h and meshgems/tetra hpc.h.
Please note that these include files are C include files. Hence if you include them in a C++ code, you have to
do it in the following way :

extern "C" {
#include <meshgems/meshgems.h>
#include <meshgems/tetra hpc.h>
}

2.1.4 Examples

Each example is provided under source form and may require some data. They produce a .mesh file.

2.2 Requirements

2.2.1 Supported platforms

MeshGems-Tetra HPC multithread version is currently available on Windows 7 and Linux architectures,
both 32 and 64 bits. MeshGems-Tetra HPC distributed version is on the other hand only available on Linux
architectures, both 32 and 64 bits.

2.2.2 Disk Space

The disk space requirement for this tool installation is about 15 MB per platform.

2.2.3 CPU time

The CPU time much depends on the input mesh. It can vary from less than a second to several minutes.

2.2.4 Memory usage

See MeshGems-Tetra HPC User Manual.

2.3 Errors and diagnostics


see 3.1.4

2.4 Coupling with other Distene tools


Tetra HPC in particular can be used efficiently with the following companion tools:

TH-14
MG-TETRA HPC API Manual
2.5. INTEGRATION WITHIN THIRD PARTY PRODUCTS Release 2.10

• CADSurf for the generation of the surface meshes needed by Tetra HPC
• Cleaner for the correction of the input surface meshes, if they contain errors preventing Tetra HPC
from getting a correct input mesh
10401

• SurfOpt for surface enrichment, optimisation or coarsening prior to volume meshing


Pantone
306 C
Pantone
Process Blue
Pantone
294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

• Adapt for the local control and remeshing of meshes produced by Tetra HPC 11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

2.5 Integration within third party products


MeshGems-Tetra HPC is delivered as an executable and meshes come in and out of MeshGems-Tetra HPC
as files (see the user manual of MeshGems-Tetra HPC), or as a library using the MeshGems
R
Suite common
API.
Integration templates are provided in the MeshGems-Tetra HPC distribution.

TH-15
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 2. GETTING STARTED

01
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

TH-16
MG-TETRA HPC API Manual
Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL

Chapter 3
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

MeshGems-Tetra HPC’s integration

To communicate with the user environment, MeshGems-Tetra HPC uses the general MeshGems
R
API.
The meshing and processing functions can then be accessed through a MeshGems-Tetra HPC session object
(see 3.1.2) that was associated to these inputs.
As output, a MeshGems-Tetra HPC session generates a mesh which is stored in an abstract structure de-
scribed in section 3.7.

3.1 Short description of the Application Programming Interface

3.1.1 API concepts

The API is fully written in C language, following an object oriented approach. For the sake of compatibility
and code safety, the only way to manipulate an API object is through its given functions. Every object
provides at least a constructor and a destructor (with respectively a new and delete suffix).
Each function, except constructors and destructors, returns a status code of type status t. In case of
success, the returned value is STATUS OK.
Every object is attached to a parent one at construction time. The root object being the global context of
type context t.
All the MeshGems R
functions, types, macros and constants are prefixed with meshgems . The equivalent
short names (i.e. without the meshgems prefix) are also automatically defined in the MeshGems R
headers
using #define macros.
We will either use the long or the short names in this documentation.
All the symbols exported by the MeshGems
R
dynamic libraries are prefixed with meshgems .

3.1.2 The context object

The root of all the objects in the MeshGems


R
API is the global context of type context t.

3.1.2.1 Construction/Destruction

The constructor and destructor for these objects are respectively:

TH-17
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

context_t *context_new(void)
void context_delete(context_t *ctx)

01 3.1.2.2 Setting the message callback


Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
Any MeshGems R
API function call can generate messages. When such a function generates a message,
it sends it to the user through a message callback function of type message callback t (see 3.1.3). By
default this message callback prints the message to standard output but one can override this behaviour by
providing the context a new message callback, with the following function :

status_t context_set_message_callback(context_t *context,


message_callback_t callback,
void *user_data)

where

• context (input) is the working context.


• callback (input) is the new message callback to use.
• user data (input) is a user pointer the callback function will be given as last parameter when called.

3.1.3 The message object

3.1.3.1 The message object type

A message object (of type message t) is an abstract object representing a message from MeshGems-
Tetra HPC to the user. It contains :

• a number: an integer which is negative for an error, positive for a warning/information and null for
an unstructured text message.
• a description: a char* string containing the text describing the message.

Such an object is always constructed and destructed by MeshGems-Tetra HPC itself. The user is provided
with functions to interrogate it. The following functions extract respectively the number (codenumber) and
the description (desc) of a given message :

status_t message_get_number(message_t *msg, integer *codenumber)


status_t message_get_description(message_t *msg, char **desc)

Note : The char * set by message get description shall not be freed by the user.

3.1.3.2 The message callback type

status_t (*message_callback_t)(message_t *message, void *user_data)

where

• message (input) is a pointer to a message object.


• user data (input) is the generic user pointer associated to the working message callback.

TH-18
MG-TETRA HPC API Manual
3.1. SHORT DESCRIPTION OF THE APPLICATION PROGRAMMING INTERFACE Release 2.10

3.1.4 Error management

3.1.4.1 The error callback system

Any MeshGems R 10401


API function call can generate messages. When such a function generates a message,
Pantone
306 C
Pantone
Process Blue
Pantone
294 C

it sends it to the user through a message callback function of type message callback t (see 3.1.3.2). By
Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

default this message callback prints the message to standard output but one can override this behaviour by
11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

providing the context a new message callback, with the following function:

status_t context_set_message_callback(context_t *context,


message_callback_t callback,
void *user_data)

More details on this function are available in 3.1.2.2.


A MeshGems R
module will transmit error or warning/information to the defined callback. One can examine
these errors or warnings/information messages by consulting their code number, and then perform the
appropriate treatment.
This number can be decipher with the MESHGEMS TETRA HPC CODE macro in order to get the corre-
spondance with the errors of the standard documentation. See the standard documentation for a complete
list of errors and warnings/information.

3.1.4.2 Guided example

We provide here is an example of message callback to parse the warning/error messages generated by
MeshGems-Tetra HPC :

status_t my_message_cb(message_t * msg, void *user_data)


{
char *desc;
FILE *my_file = (FILE*)user_data;
integer code, ibuff[6];
real rbuff[3];

/* Get the error number */


message_get_number(msg, &code);
if (code == MESHGEMS_TETRA_HPC_CODE(-8423)) {
/* This is the error 8423, related to a face that cannot
* be inserted.
* Get the associated integer data [1..3]
*/
message_get_integer_data(msg, 1, 3, ibuff);
...
}else if(..) {
...
} else {
/* No specific handler for this message. Just print its description */
message_get_description(msg, &desc);
fprintf(my_file, "Tetra_HPC message : %s", desc);
}

return STATUS_OK;
}

TH-19
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

A complete description is provided in the template included in this distribution.

01
3.1.5 Stub system
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


The MeshGems R
API provides a stub system that allows the integrator to override some functions of the
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

standard C library with its own functions.


For the moment, only the memory management functions (malloc, calloc, realloc and free) can be replaced,
but this system will be extended to other standard functions in the future.

3.1.5.1 How it works

All functions that can be overriden are called by MeshGems


R
libraries through a wrapper function prefixed
R
with ”meshgems ”. For example, the MeshGems code does not call ”malloc()” but ”meshgems malloc()”.
These functions are provided by a separate dynamic library (libmeshgems stubs.so on Linux platforms and
meshgems stubs.dll on Windows platforms) for which we provide the source code, so that the integrator can
redefine them.

3.1.5.2 How to use

The file stubs/meshgems stubs.c defines the implementation of the functions that can be replaced.
The integrator can modify this meshgems stubs.c file for his needs. This file has then to be recompiled into
a dynamic stubs implementation library 1 .
This dynamic library shall replace the existing one provided with MeshGems
R
dynamic libraries.

3.1.6 Thread safety

The MeshGems-Tetra HPC library is thread safe and can be called in a multi-threaded environment. However
some limitations still exist in the MeshGems
R
Suite for the moment :

• The context t object is not fully thread safe. It is thus recommended to create one context t object
per calling thread.

• The DLIM license management system (using .key files or a license server) is not thread safe. If you
want to work in a multi-threaded calling environment, please use the OEM license management system.

• The routines mesh write mesh() and mesh new read mesh() designed to handle the .mesh[b] files
are not thread safe and should only be used sequentially.

3.2 MeshGems-Tetra HPC’s session

A MeshGems-Tetra HPC session object (of type meshgems tetra hpc session t) is an object describing a
MeshGems-Tetra HPC run. It makes the link between the input mesh and parameters, the meshing process
and the resulting mesh recovery.
1 see the Readme stubs.txt in the stubs directory

TH-20
MG-TETRA HPC API Manual
3.2. MESHGEMS-TETRA HPC’S SESSION Release 2.10

3.2.1 Construction/Destruction

The following constructor creates a new meshgems tetra hpc session t object associated to the given
context:
10401
Pantone Pantone Pantone
306 C Process Blue 294 C

meshgems tetra hpc_session_t *meshgems tetra hpc_session_new(context_t *context)


Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

A meshgems tetra hpc session t object shall be destructed by a call to its destructor:

void meshgems tetra hpc_session_delete(meshgems tetra hpc_session_t *ts)

3.2.2 Setting parameters

In a session, parameters can be set with the function

status_t meshgems tetra hpc_set_param(meshgems tetra hpc_session_t *ts, const char *option_name,
const char *option_value)

where

• ts (input) is the working meshgems tetra hpc session.


• option name (input) is the option name (for example components).
• option value (input) is the option value (for example 1.32) option name should be set to.

3.2.3 Setting the message callback

In a session, the message callback provided by the associated context (see 3.1.2.2) can be overridden through
the following call :

status_t meshgems tetra hpc_set_message_callback(meshgems tetra hpc_session_t *ts,


message_callback_t callback,
void *user_data)

where

• ts (input) is the working meshgems tetra hpc session.


• callback (input) is the new message callback to use.
• user data (input) is a user pointer the callback function will be given as last parameter when called.

3.2.4 Setting the interrupt callback

While the MeshGems-Tetra HPC session is generating a mesh or doing a complex operation, the user might
want to stop the computation. For this purpose MeshGems-Tetra HPC regularly interrogates a user provided
interrupt callback.
The prototype of an interrupt callback is given by the type :

status_t (*interrupt_callback_t)(integer *interrupt_status, void *user_data)

TH-21
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

where

• interrupt status (input/output) is a pointer to an integer the user has to set to either INTERRUPT STOP
01
(stop the current computation) or INTERRUPT CONTINUE (continue the current computation).
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04
• user data (input) is the generic user pointer associated to the working interrupt callback.
11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

By default, an interrupt callback that never asks to stop the computation is provided, but one can override
it with the following call :

status_t meshgems tetra hpc_set_interrupt_callback(meshgems tetra hpc_session_t *ts,


interrupt_callback_t callback,
void *user_data)

where

• ts (input) is the working meshgems tetra hpc session.

• callback (input) is the new interrupt callback to use.

• user data (input) is a user pointer the callback function will be given as last parameter when called.

3.2.5 Setting the input mesh

The input mesh of a session can be set with the following function:

status_t meshgems tetra hpc_set_input_mesh(meshgems tetra hpc_session_t *ts, mesh_t *m)

where

• ts (input) is the working meshgems tetra hpc session.

• m (input) is the given input mesh (see 3.7 for the mesh t structure). It can be a surface mesh (made
of vertices, edges and triangles) or a volume mesh (made of vertices, edges, triangles and tetrahedra).

3.2.6 Setting an optional sizemap callback

An optional continous size specification callback can be given to a session with the following function:

status_t meshgems tetra hpc_set_sizemap(meshgems tetra hpc_session_t *ts, sizemap_t *s)

where

• ts (input) is the working meshgems tetra hpc session.

• s (input) is the given sizemap (see 3.4 for information on the sizemap t structure).

Please note that this functionality may require an optional license feature.

TH-22
MG-TETRA HPC API Manual
3.2. MESHGEMS-TETRA HPC’S SESSION Release 2.10

3.2.7 Setting an optional tetrahedron quality callback

An optional tetrahedron quality callback can be given to a session with the following function:
10401

status_t tetra_hpc_set_tetrahedron_quality_callback(tetra_hpc_session_t *ts, Pantone


306 C
Pantone
Process Blue
Pantone
294 C

Date : 14/04/2011

tetra_hpc_tetrahedron_quality_callback_t quality_cb, void *user_data);Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

where

• ts (input) is the working meshgems tetra hpc session.


• quality cb (input) is the tetrahedron quality callback to use.
• user data (input) is a user pointer the quality cb function will be given as last parameter when
called.

The quality callback function must respect the following prototype :

/**
* Type for a user callback function for computing the quality of a
* tetrahedron, given the coordinates of its vertices and a metric.
*
* For an oriented tetrahedron given by the coordinates of its
* vertices xyz1, xyz2, xyz3 and xyz4, this function returns
* its quality in the metric given by metric. The resulting quality is
* a real number between 0. (worst quality) and 1. (perfect quality)
*
* @param[in] xyz1 : a real[3] array with the coordinates of the 1st tetrahedron vertex
* @param[in] xyz2 : a real[3] array with the coordinates of the 2nd tetrahedron vertex
* @param[in] xyz3 : a real[3] array with the coordinates of the 3rd tetrahedron vertex
* @param[in] xyz4 : a real[3] array with the coordinates of the 4th tetrahedron vertex
* @param[in] metric : a real[6] array with the metric to be considered. If NULL,
* there is no metric to consider (we are in an isotropic situation).
* @param[in] volume : a real containing the (already known) volume of the tetrahedron
* in the metric
* @param[in] user_data : a user pointer.
*
* @retval the computed quality between 0. (worst quality) and 1. (perfect quality).
*/
typedef real (tetra_hpc_tetrahedron_quality_callback_t)(real xyz1[3], real xyz2[3],
real xyz3[3], real xyz4[3],
real metric[6], real volume,
void *user_data);

For example, one can be defined like the following one:

real quality_cb(real xyz1[3], real xyz2[3],


real xyz3[3], real xyz4[3],
real metric[6], real volume,
void *udata){
integer i, j, k;
real*xyz[4];
real q, v, h;

TH-23
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

static const real alpha = 12.0 * 6.0 * SQRT3;


xyz[0] = xyz1;
xyz[1] = xyz2;
01
Pantone
306 C
Pantone
Process Blue
Pantone
294 C
xyz[2] = xyz3;
/04/2011
0401 Logo Mesh Gems 04
xyz[3] = xyz4;
11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

/* sum of the 6 edges of a tetra*/


h = 0;
if(!metric) {
/* Isotropic situation */
for (i = 0; i < 4; i++) {
for (j = i + 1; j < 4; j++) {
for (k = 0; k < 3; k++)
h += sqr(xyz[i][k] - xyz[j][k]);
}
}
} else {
/* Anisotropic situation */
}
h = pow(h, 1.5);
q = alpha * v / h;

return q;
}

It is guaranteed that the quality (as defined by the user provided tetrahedron quality callback) of the
generated volume mesh will be equal or better than the one which would have been generated if the callback
had not been provided.

3.2.8 Meshing

When all the input parameters are set in the session, the mesh can be generated by calling the following
function:

status_t meshgems tetra hpc_compute_mesh(meshgems tetra hpc_session_t *ts)

where

• ts (input) is the working meshgems tetra hpc session.

3.2.9 Getting the output mesh

The mesh structure resulting from the previous meshing step can be recovered with :

status_t meshgems tetra hpc_get_mesh(meshgems tetra hpc_session_t *ts, mesh_t **msh)

where

• ts (input) is the working meshgems tetra hpc session.


• msh (output) is set to point to the resulting mesh by this function.

TH-24
MG-TETRA HPC API Manual
3.3. MESHGEMS-TETRA HPC’S PARAMETERS Release 2.10

The section 3.7 explains how to extract the mesh elements from this abstract structure. It shall be released
by the user and given back to the session afterward with :

status_t meshgems tetra hpc_regain_mesh(meshgems tetra hpc_session_t *ts, mesh_t *msh)


10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

3.3 MeshGems-Tetra HPC’s parameters 11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

3.3.1 List of MeshGems-Tetra HPC parameters

The array 3.1 gives a list of all MeshGems-Tetra HPC parameters, with their name, type, default value and
where they are described in this document. The most significant and important ones are indicated by a
diamond-shaped sign (♦).
In this array, diag is the length of the diagonal of the box bounding the object.

♦ Name Type Default value Reference


components string ”all” 3.3.2
♦ gradation real ”1.05” 3.3.2
internal points boolean ”yes” 3.3.2
max number of threads integer ”4” 3.3.2
♦ max edge length real ”0” 3.3.2
♦ max size real ”0” 3.3.2
metric string ”isotropic” 3.3.2
♦ min edge length real ”0” 3.3.2
♦ min size real ”0” 3.3.2
number of subdomains integer ”0” 3.3.2
optimisation boolean ”yes” 3.3.2
optimisation level string ”standard” 3.3.2
parallel strategy string ”reproducible given max number of threads” 3.3.2
split overconstrained edges boolean ”no” 3.3.2
split overconstrained elements boolean ”no” 3.3.2
split overconstrained tetrahedra boolean ”no” 3.3.2
verbose integer ”3” 3.3.2
volume proximity layers real ”0” 3.3.2

Figure 3.1: List of MeshGems-Tetra HPC parameters

3.3.2 Short description of various MeshGems-Tetra HPC parameters

• components: Sets the desired set of components to be meshed. Possible values are:
– all: all the volume components will be meshed.
– outside components: only the outermost components will be meshed.
Default value is all.
• gradation: Sets the desired maximum ratio between 2 adjacent tetrahedra edges. The closer it is to
”1”, the more uniform the mesh will be. Default value is ”1.05”
• internal points: Sets whether to insert internal vertices inside the volume or not. Default value is
yes.

TH-25
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

• max number of threads: Sets the maximum number of computing threads to launch for the meshing
process. Default value is ”4”.

• max edge length: Sets the maximum edge length for the generated volume mesh. Default value is
01 ”0”, meaning that there is no maximum edge length.
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
• max size: Sets the desired maximum cell size for the generated volume mesh. This will drive the
maximum edge length but does imply that all volume edges will respect this maximum size (see also
3.3.2). Default value is ”0”, meaning that there is no maximum size.

• metric: Sets the type of metric governing the mesh generation. Possible values are :

– isotropic : the metric induces the same size in all directions.


– anisotropic : the metric induces different sizes depending on the directions.

Default value is isotropic.

• min edge length: Sets the minimum edge length for the generated volume mesh. Default value is ”0”,
meaning that there is no minimum edge length.
item min size: Sets the desired minimum cell size for the generated volume mesh. This will drive the
minimum edge length but does imply that all volume edges will respect this minimum size (see also
3.3.2). Default value is ”0”, meaning that there is no minimum size.

• number of subdomains: Sets the desired number of parallel subdomains. This parameter only exists
for the shared memory version. Default value is ”0”, meaning that this value will be automatically
determined.

• optimisation: Sets whether to optimise mesh quality or not. Default value is ”yes”, meaning that
some time will be spent to optimise the resulting volume mesh quality.

• optimisation level: Sets the desired optimisation level regarding mesh quality. Possible values are,
in increasing order of quality versus speed ratio :

– light
– standard
– strong

The default value is standard. The optimisation levels are strictly incremental. It means that for a
given input mesh, increasing the optimisation level can only lead to equal or better quality for the
generated output mesh.

• parallel strategy: Sets the desired parallel strategy, influencing the level of reproducibility of the
result and the potential performances. Possible values for strategy are (in decreasing order for
reproducibility and increasing order for performances):

– reproducible: result is entirely reproducible but performances may not be optimal.


– reproducible given max number of threads: result is reproducible for a given number of al-
lowed threads.
– aggressive: result may not be reproducible but all parallel optimizations are allowed.

Default value is reproducible given max number of threads.

• split overconstrained edges: Sets whether to split over-constrained edges or not. An edge is
considered as overconstrained when it connects two surface vertices but does not belong to the surface.
Default value is no.

TH-26
MG-TETRA HPC API Manual
3.4. SIZEMAP STRUCTURE Release 2.10

• split overconstrained elements: Sets whether to split over-constrained elements or not. An ele-
ment is considered as overconstrained when at least two of its faces belong to the surface or when
at least one of its edges connects two surface vertices but does not belong to the surface. Default
value is no. Activating this option is equivalent to activating both split overconstrained edges
10401
and split overconstrained tetrahedra. Pantone
306 C
Pantone
Process Blue
Pantone
294 C

Date : 14/04/2011

• split overconstrained tetrahedra: Sets whether to split over-constrained tetrahedra or not. A


Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

tetrahedra is considered as overconstrained when at least two of its faces belong to the surface. Default
value is no.

• verbose: This parameter changes the verbosity level of MeshGems-Tetra HPC, between 0 and 10.
The higher it is, the more messages MeshGems-Tetra HPC will send through the message callback.
Default is 3.

• volume proximity layers: This parameter sets the desired minimum number of tetrahedra layers
inside the volume. Default is 0 (no minimum).

3.4 Sizemap structure


After defining a sizemap function following one of the function types

• sizemap iso 3d t,

• sizemap aniso 3d t

a structured sizemap object on the XYZ space can be created using the following constructor:

sizemap t * s = sizemap new(context t *ctx, meshgems_sizemap_type_t type,


void *fun, (void*)your user data);

where :

• ctx is the current context.

• type is the type of the sizemap. It can be

– meshgems sizemap type iso 3d,


– meshgems sizemap type aniso 3d,

• fun is the sizing function defined by the user.

• user data is a user pointer the corresponding size function will be given as last parameter when called.

After defining a sizemap function following one of the function types

• sizemap iso mesh vertex t,

• sizemap aniso mesh vertex t

a structured sizemap object on mesh vertices can be created using the following constructor:

sizemap t * s = sizemap new(mesh t * m, meshgems_sizemap_type_t type,


void *fun, (void*)your user data);

TH-27
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

where :

• m is the current mesh object.


01
Pantone Pantone Pantone
• type is the type of the sizemap. It can be
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
– meshgems sizemap type iso mesh vertex,
– meshgems sizemap type aniso mesh vertex,

• fun is the sizing function defined by the user.

• user data is a user pointer the corresponding size function will be given as last parameter when called.

For instance, an isotropic continuous sizemap object for MeshGems-Tetra HPC can be created with the
following call:

sizemap t * s = sizemap new(context t *ctx, meshgems sizemap type iso 3d,


sizemap iso fun, (void*)your user data);

with a continuous sizemap callback of the following form:

status t sizemap iso fun(real *xyz, real *size, void *user data){
your user data type your user data = (your user data type) user_data;

if(xyz[1] <= 50 )
*size = 5;
else
*size = 40;

return STATUS OK;


}

where:

• xyz (input) is a real[3] array containing the coordinates of the point for which the size is being requested.

• size (output) is a real representing the size we request for the given xyz.

• user data (input) is the pointer you choose to provide as last paramter in the sizemap new() call.

One can also request an anisotropic mesh by setting the “metric” parameter to “anisotropic” and using a
sizemap aniso 3d t callback function.
An anisotropic metric at a point P is defined by a matrix (M ) 3x3 symmetric and positive-definite. The six
reals array metric to be filled in the sizemap aniso 3d t is defined by :

• metric[0] = M11

• metric[1] = M12

• metric[2] = M22

• metric[3] = M13

• metric[4] = M23

TH-28
MG-TETRA HPC API Manual
3.5. SIZEMAP CREATOR STRUCTURE Release 2.10

• metric[5] = M33

This anisotropic metric is used to determine the desired element size in all directions. MeshGems-Tetra HPC
(and all the components of the MeshGems Suite) assumes that the eigen values of this matrix give the square
10401

inverse of the desired lengths and the eigen vectors give the directions. Pantone
306 C
Pantone
Process Blue
Pantone
294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

For example if one wants the edges around a node to be : 11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

• of length 2 along the X axis,

• of length 10 along the Y and Z axis,

then the user should write the following data for the desired point P in the callback of the anisotropic sizemap
1 1 1
: 2×2 , 0, 10×10 , 0, 0, 10×10 .

3.5 Sizemap creator structure


The MeshGems API provides an intuitive way to easily create some specific 3d sizemaps, using an object of
type sizemap creator t. We describe below how to use it.

3.5.1 Construction/Destruction

The following constructor creates a new sizemap creator t object :

sizemap_creator_t *sizemap_creator_new(void *parent,


meshgems_sizemap_creator_type_t stype, real xyz_min[3], real xyz_max[3])

Where:

• parent (input) is the associated parent object the sizemap creator is made for : only a context t for
now.

• stype (input) is the type of the sizemap creator to create. It can be :

– meshgems sizemap creator type iso 3d to create an isotropic 3d sizemap using the sizemap
creator.
– meshgems sizemap creator type aniso 3d to create an anisotropic 3d sizemap using the sizemap
creator.

• xyz min[3] (input) are the coordinates of the minimum point of the bounding box of the geometry.

• xyz max[3] (input) are the coordinates of the maximum point of the bounding box of the geometry.

• Returns the created sizemap creator t, or NULL in case of error.

A sizemap creator t object can be destroyed by a call to its destructor :

void sizemap_creator_delete(sizemap_creator_t *sc)

TH-29
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

3.5.2 Add a constraint

Once created, one can add some constraints in the sizemap creator. We list below all the constraints currently
available in the sizemap creator object.
01
Pantone
306 C
Pantone
Process Blue
Pantone
294 C
The first constraint is related to the default size to be used. This size will be used for each point which does
/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
not belong to any constraint. We give here its prototype :

status_t sizemap_creator_add_constraint_default(sizemap_creator_t *sc, real size)

Where:

• sc (input) is the working sizemap creator object


• size (input) is the default size, to be used outside of the other constraints

The call of this function is mandatory.

The second constraint can be used to specify a gradation in the resulting 3d sizemap. We give here its
prototype :

status_t sizemap_creator_add_constraint_default_gradation(sizemap_creator_t *sc, real gradation)

Where:

• sc (input) is the working sizemap creator object


• gradation (input) is the default gradation

By default, no gradation is used.

A size at a given point coordinates can be specified using the following constraint function :

status_t sizemap_creator_add_constraint_on_point(sizemap_creator_t *sc, real P[3], real size)

Where:

• sc (input) is the working sizemap creator object


• P[3] (input) are the coordinates of point on which one want to specify the size
• size (input) is the size to be used on the point

One have to specify a default gradation in order to correctly take into


account the constraints on points.

It is also possible to specify a size inside a sphere using the following constraint function :

TH-30
MG-TETRA HPC API Manual
3.5. SIZEMAP CREATOR STRUCTURE Release 2.10

status_t sizemap_creator_add_constraint_on_sphere(sizemap_creator_t *sc, real center[3],


real radius, real size)

Where:
10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011

• sc (input) is the working sizemap creator object Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

• center[3] (input) are the coordinates of the center of the sphere

• radius (input) are the radius of the sphere

• size (input) is the size to be used inside the sphere

It is also possible to specify a size inside a non twisted hexahedron. This can be done by calling the following
function :

status_t sizemap_creator_add_constraint_on_hexahedron(sizemap_creator_t *sc, real v1[3],


real v2[3], real v3[3], real v4[3],
real v5[3], real v6[3], real v7[3],
real v8[3], real size)

Where:

• sc (input) is the working sizemap creator object

• v1 (input) are the coordinates of the first vertex of the hexahedron

• v2 (input) are the coordinates of the second vertex of the hexahedron

• v3 (input) are the coordinates of the third vertex of the hexahedron

• v4 (input) are the coordinates of the fourth vertex of the hexahedron

• v5 (input) are the coordinates of the fifth vertex of the hexahedron

• v6 (input) are the coordinates of the sixth vertex of the hexahedron

• v7 (input) are the coordinates of the seventh vertex of the hexahedron

• v8 (input) are the coordinates of the heighth vertex of the hexahedron

• size (input) is the size to be used inside the hexahedron

The numbering of a hexahedron in the same as the convention in


MeshGems.

Last, one can specify a size inside a cylinder using the following function :

status_t sizemap_creator_add_constraint_on_cylinder(sizemap_creator_t *sc,


real p1[3], real p2[3], real radius, real size)

Where:

TH-31
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

• sc (input) is the working sizemap creator object


• p1[3] (input) are the coordinates of the first point of the cylinder axis

01
• p2[3] (input) are the coordinates of the second point of the cylinder axis
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04
• radius (input) is the radius of the cylinder
11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

• size (input) is the size to be used inside the cylinder

All these constraints (expect the default size setting) can be added several times.

3.5.3 Create a 3d sizemap

Once all the constraints specified, the associated 3d sizemap t can be created using the following function :

sizemap_t *sizemap_creator_generate_sizemap(sizemap_creator_t *sc)

Where:

• sc (input) is the working sizemap creator object.


• Returns the 3d sizemap corresponding to all the specified constraints.

The type of the created sizemap will be meshgems sizemap type iso 3d.
The resulting sizemap respects the following properties :

• For each point outside of each constraint, the returned size is the default one.
• If a point belongs to several constraints, the associated size is defined by the minimum size on each of
these constraints.
• It’s destruction is on the responsibility of the user, using the function sizemap delete.

3.6 Computing a quadratic volume mesh


If the input surface mesh is quadratic, MeshGems-Tetra HPC is then automatically able to produce quadratic
elements with extra nodes at the edges. The quadratic elements generation is a post-treatment to the
MeshGems-Tetra HPC meshing process which inserts the extra nodes on the linear mesh. Following the
initial insertion, MeshGems-Tetra HPC is eventually able to perform modifications of the mesh (including
modifications of the input surface mesh) to ensure the positivity of the jacobian of the volume elements.
Finally, a specific optimization is done for the quadratic volume mesh.
Once the quadratic mesh has been generated by MeshGems-Tetra HPC, one can access the high order nodes
through the call of the following functions (depending of the mesh entity type):

status t mesh get tetrahedron extra vertices(mesh t *msh, integer itetra, integer *type,
integer *evtetra);

where

• msh (input) is the resulting mesh.

TH-32
MG-TETRA HPC API Manual
3.7. MESH STRUCTURE Release 2.10

• itetra (input) is the index of the tetra in the mesh msh.

• type (output) integer containing the type of the tetrahedron.


10401
• evtetra (output) integer[] array containing the extra vertices of the tetrahedron.
Pantone
306 C
Pantone
Process Blue
Pantone
294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

The same function exists for triangles :

status t mesh get triangle extra vertices(mesh t *msh, integer itri, integer *typetri,
integer *evtri);

The user can leave to the API the responsibility to allocate and free a buffer that will be able to hold the
extra nodes for any kind of element generated by MeshGems-Tetra HPC:

void *mesh calloc generic buffer(mesh t *m);


void mesh free generic buffer(void *v);

The order used by MeshGems-Tetra HPC to enumerate the extra vertices for a triangle or a tetrahedra is
presented on the figure 3.2.

Figure 3.2: Triangle P2 (left), Tetrahedron P2 (right).

3.7 Mesh structure


Most of our components deal with a mesh which may be quite a big data structure. This is why a common
type mesh t has been designed to hold meshes from the user or from our components. A mesh can be:

• exported from our components;

• provided by the user;

• an accessor to the component or the user code structures;

• a file reader; or

• a memory repository.

Depending on the case at hand (see above), a mesh t object simply keeps track of which method implemen-
tation should be called for each of the available mesh methods.

TH-33
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

3.7.1 The mesh object

A mesh is described by an object of type mesh t. The basic functions to manipulate this object are:
01
Pantone
306 C
Pantone
Process Blue
Pantone
294 C • mesh t *mesh new(context t *ctx) : constructs a mesh object and associates it to the given context
/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


ctx.
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

• void mesh delete(mesh t *cad) : destroys the mesh object.

A template describing the creation of a mesh can be found in the appendix A.

3.7.2 Accessing the output mesh structure

Let’s assume that we have an abstract mesh object pointer

mesh_t *msh;

which comes, for example from a call like

tetra_hpc_get_mesh(meshgems tetra hpc session t, &msh);

One can access the mesh vertices, edges, triangles and tetrahedra through the following functions:

status_t mesh_get_vertex_count(mesh_t *m, integer *n)


status_t mesh_get_vertex_coordinates(mesh_t *m, integer i, real *xyz)
status_t mesh_get_vertex_tag(mesh_t *m, integer i, integer *tag)
status_t mesh_get_edge_count(mesh_t *m, integer *n)
status_t mesh_get_edge_vertices(mesh_t *m, integer i, integer *v)
status_t mesh_get_edge_tag(mesh_t *m, integer i, integer *tag)
status_t mesh_get_triangle_count(mesh_t *m, integer *n)
status_t mesh_get_triangle_vertices(mesh_t *m, integer i, integer *v)
status_t mesh_get_triangle_tag(mesh_t *m, integer i, integer *tag)
status_t mesh_get_tetrahedron_count(mesh_t *m, integer *n)
status_t mesh_get_tetrahedron_vertices(mesh_t *m, integer i, integer *v)
status_t mesh_get_tetrahedron_tag(mesh_t *m, integer i, integer *tag)

If the generated mesh has high order elements, one can access them through the following functions:

status_t mesh_get_edge_extra_vertices(mesh_t *m, integer i, integer *type, integer *extra_v)


status_t mesh_get_triangle_extra_vertices(mesh_t *m, integer i, integer *type, integer *extra_v)
status_t mesh_get_tetrahedron_extra_vertices(mesh_t *m, integer i, integer *type, integer *extra_v)

The subdomain definition for the generated tetrahedra can be accessed through the following functions (more
details on this topic can be found in 3.8):

status_t mesh_get_subdomain_count(mesh_t *m, integer *nbsub)


status_t mesh_get_subdomain_description(mesh_t *m, integer isd,
integer *subdomain_tag, integer *seed_type,
integer *seed_idx, integer *seed_orientation)

Here is a simple example that illustrates how to use these functions :

TH-34
MG-TETRA HPC API Manual
3.7. MESH STRUCTURE Release 2.10

integer i, nv, nt, nq;


real x[3];
integer v[4], tag, per id;
integer *buff = (integer*)mesh_calloc_generic_buffer(msh);
10401
integer *evedg, *evtri, type; Pantone
306 C
Pantone
Process Blue
Pantone
294 C

integer nsub, subdomain_tag, seed_type, seed_idx, seed_orientation;


Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

mesh_get_vertex_count(msh, &nv);
cout << "There are "<< nv << " vertices in the mesh" << endl;
for (i=1;i<=nv;i++){
mesh_get_vertex_coordinates(msh, i, x);
mesh_get_vertex_tag(msh, i, &tag);

cout << "vertex "<< i << "coordinates are : "


<< x[0] << "," << x[1] << "," << x[2] << endl;
cout << "Vertex "<< i << " tag is : " << tag << endl;
}

evedg = (integer *)mesh calloc generic buffer(msh);


mesh_get_edge_count(msh, &ne);
cout << "There are "<< ne << " edges in the mesh" << endl;
for(i=1;i<=ne;i++){
mesh_get_edge_tag(msh, i, &tag);
mesh_get_edge_vertices(msh, i, v);
mesh get edge extra vertices(msh, i, &type, evedg);

cout << "Edge "<< i << "vertices are : "


<< v[0] << "," << v[1] << endl;

if(type == MESHGEMS MESH ELEMENT TYPE EDGE3){


/* This is a quadratic edge
* evedg is filled with the quadratic nodes index
*/
cout << "Edge "<< i << "quadratic extra vertex is : "
<< evedg[0] << endl;
}
}
mesh free generic buffer(evedg);

evtri = (integer *)mesh calloc generic buffer(msh);


mesh_get_triangle_count(msh, &nt);
cout << "There are "<< nt << " triangles in the mesh" << endl;
for (i=1;i<=nt;i++) {
mesh_get_triangle_vertices(msh, i, v);
mesh get triangle extra vertices(msh, i, &type, evtri);
mesh_get_triangle_tag(msh, i, &tag);
cout << "Triangle "<< i << "vertices are : "
<< v[0] << "," << v[1] << "," << v[2] << endl;
cout << "Triangle "<< i << "tag (color) is : " << tag << endl;

if(type == MESHGEMS MESH ELEMENT TYPE TRIA6){


/* This is a quadratic triangle

TH-35
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

* evtri is filled with the quadratic nodes indices


*/
cout << "Triangle "<< i << "quadratic extra vertices are : "
<< evtri[0] << "," << evtri[1] << "," << evtri[2] << endl;
01
Pantone
306 C
Pantone
Process Blue
Pantone
294 C
}
/04/2011
0401 Logo Mesh Gems 04
}
11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
mesh free generic buffer(evtri);

evtetra = (integer *)mesh calloc generic buffer(msh);


mesh_get_tetrahedron_count(msh, &nt);
cout << "There are "<< nq << " tetrahedra in the mesh" << endl;
for (i=1;i<=nt;i++) {
mesh_get_tetrahedron_vertices(msh, i, v);
mesh get tetrahedron extra vertices(msh, i, &type, evtetra);
mesh_get_tetrahedron_tag(msh, i, &tag);
cout << "Tetrahedron "<< i << "vertices are : "
<< v[0] << "," << v[1] << "," << v[2] << "," << v[3] << endl;
cout << "Tetrahedron "<< i << "tag (color) is : " << tag << endl;

if(type == MESHGEMS MESH ELEMENT TYPE TETRA10){


/* This is a quadratic tetrahedron
* evquad is filled with the quadratic nodes index
*/
cout << "Tetrahedron "<< i << "quadratic extra vertices are : "
<< evtetra[0] << "," << evtetra[1] << "," << evtetra[2] << ","
<< evtetra[3] << "," << evtetra[4] << evtetra[5] <<endl;
}
}
mesh free generic buffer(evtetra);

mesh_get_subdomain_count(msh, &nsub);
cout << "There are "<< nsub << " subdomains in the mesh" << endl;

for (i=1;i<=nsub;i++) {
mesh_get_subdomain_description(msh, i, &subdomain_tag, &seed_type,
&seed_idx, &seed_orientation);
cout << "Subdomain "<< i << " tag is : " << subdomain_tag << endl;
cout << "Subdomain "<< i << " seed type is : " << seed_type << endl;
cout << "Subdomain "<< i << " seed index is : " << seed_idx << endl;
cout << "Subdomain "<< i << " seed orientation is : " << seed_orientation << endl;
}

3.8 The subdomain description

The mesh object can contain a description of the volume subdomains. This description links for each
subdomain a tag of volume elements to a volume subdomain defined by a seed face.
For exemple, in a mesh m generated by MeshGems-Tetra HPC, the subdomain description will provide the
information that the tetrahedra with a tag equal to t fill the volume defined by the i-th triangle of the mesh
(which can be accessed through the mesh get triangle vertices(m,i,...) function) considered either in

TH-36
MG-TETRA HPC API Manual
3.8. THE SUBDOMAIN DESCRIPTION Release 2.10

its forward or reversed orientation.


Some generic code illustrating this feature can be found in the template provided in A.

10401

3.8.1 Getting the number of subdomains Pantone


306 C
Pantone
Process Blue
Pantone
294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

The number of subdomains in a mesh can be retrieved with the following function :

status_t mesh_get_subdomain_count(mesh_t *m, integer *nsub);

where

• m (input) is the working mesh.


• nsub (output) is the number of (volume) subdomain in the mesh.

3.8.2 Getting the subdomain description

After retrieving the number of subdomains in the mesh, it is possible to retrieve the description of each
subdomain with the following function :

status_t mesh_get_subdomain_description(mesh_t *m, integer isd,


integer *tag, integer *seed_type,
integer *seed_idx, integer *seed_orientation);

where

• m (input) is the working mesh.


• isd (input) is the the index of the subdomain (from 1 to nsub).
• tag (output) is the tag of the elements in the subdomain.

• seed type (output) is the subdomain seed element type : MESH ELEMENT TYPE TRIA3 for a
triangle.
• seed idx (output) is the index of the seed element for the subdomain in the table of the elements of
type seed type.
• seed orientation (output) is the orientation of the subdomain seed : the normal is assumed to
point toward the outside of the subdomain. Value can be MESH ORIENTATION FORWARD or
MESH ORIENTATION REVERSE.

TH-37
API Manual MG-TETRA HPC
Release 2.10 CHAPTER 3. MESHGEMS-TETRA HPC’S INTEGRATION

01
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

TH-38
MG-TETRA HPC API Manual
3.8. THE SUBDOMAIN DESCRIPTION Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

Appendices

TH-39
MG-TETRA HPC API Manual
Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL

Appendix A
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

MeshGems-Tetra HPC’s integration


template

1 # include < stdio .h >


2 # include < malloc .h >
3 # include < stdlib .h >
4 # include < string .h >
5
6 # include < meshgems / meshgems .h >
7 # include < meshgems / tetra_hpc .h >
8
9 /* FOR OEM customers only , uncomment the following */
10 /* # include < me shge ms_k ey_x xx .h > */
11
12 /**
13 * Let ’ s assume that the following structure holds data that
14 * represents the input surface mesh on client side . It could be a
15 * database handle or anything else containing surface mesh data . We
16 * will build the mesh_t object that accesses it . See the file
17 * meshgems / mesh . h for more detailed information .
18 */
19
20 struct y o u r _ i n t e r n a l _ d a t a _ t _ {
21 /* _your_data ; */
22 };
23
24 typedef struct y o u r _ i n t e r n a l _ d a t a _ t _ y o u r _ i n t e r n a l _ d a t a _ t ;
25
26 /**
27 * Implementation of how the number of vertices in the mesh is obtained .
28 * @param [ out ] nbvtx : the number of vertices
29 * @param [ in ] user_data : a user pointer .
30 * @return error code
31 */
32
33 status_t m g t m _ g e t _ v e r t e x _ c o u n t ( integer * nbvtx , void * user_data ) {
34 y o u r _ i n t e r n a l _ d a t a _ t * mm = ( y o u r _ i n t e r n a l _ d a t a _ t *) user_data ;
35
36 * nbvtx = 0; /* the number of vertices in your mesh */
37
38 return STATUS_OK ;
39 }
40
41 /**
42 * Implementation of how the coordinates of a mesh vertex are obtained .
43 * @param [ in ] ivtx : index of the desired vertex coordinates from 1 to nbvtx
44 * @param [ out ] xyz : real [3] array containing the coordinates of the vertex

TH-41
API Manual MG-TETRA HPC
Release 2.10 APPENDIX A. MESHGEMS-TETRA HPC’S INTEGRATION TEMPLATE

45 * @param [ in ] user_data : a user pointer .


46 * @return error code
47 */
48 status_t m g t m _ g e t _ v e r t e x _ c o o r d i n a t e s ( integer ivtx , real * xyz , void * user_data ) {
49 int j ;
01
Pantone Pantone Pantone
50 y o u r _ i n t e r n a l _ d a t a _ t * mm = ( y o u r _ i n t e r n a l _ d a t a _ t *) user_data ;
306 C Process Blue 294 C

/04/2011
51
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
52 for ( j = 0; j < 3; j ++)
53 xyz [ j ] = 0.0; /* j ’ th coordinate of the ivtx ’ th vertex */
54
55 return STATUS_OK ;
56 }
57
58 /**
59 * Implementation of how the number of edges in the mesh is obtained .
60 * @param [ out ] nbedg : the number of edges
61 * @param [ in ] user_data : a user pointer .
62 * @return error code
63 */
64 status_t m g t m _ g e t _ e d g e _ c o u n t ( integer * nbedge , void * user_data ) {
65 y o u r _ i n t e r n a l _ d a t a _ t * mm = ( y o u r _ i n t e r n a l _ d a t a _ t *) user_data ;
66
67 * nbedge = 0; /* the number of edges in your mesh */
68
69 return STATUS_OK ;
70 }
71
72 /**
73 * Implementation of how the vertices of a mesh edge are obtained .
74 * @param [ in ] iedge : index of the desired edge from 1 to nbedge
75 * @param [ out ] vedge : integer [2] array containing the vertices of the edge
76 * @param [ in ] user_data : a user pointer .
77 * @return error code
78 */
79 status_t m g t m _ g e t _ e d g e _ v e r t i c e s ( integer iedge , integer * vedge , void * user_data ) {
80 int j ;
81 y o u r _ i n t e r n a l _ d a t a _ t * mm = ( y o u r _ i n t e r n a l _ d a t a _ t *) user_data ;
82
83 for ( j = 0; j < 2; j ++)
84 vedge [ j ] = 0; /* the j ’ th vertex index of the iedge ’ th edge */
85
86 return STATUS_OK ;
87 }
88
89 /**
90 * Implementation of how the number of triangles in the mesh is obtained .
91 * @param [ out ] nbtri : the number of triangles
92 * @param user_data : a user pointer .
93 * @return error code
94 */
95 status_t m g t m _ g e t _ t r i a n g l e _ c o u n t ( integer * nbtri , void * user_data ) {
96 y o u r _ i n t e r n a l _ d a t a _ t * mm = ( y o u r _ i n t e r n a l _ d a t a _ t *) user_data ;
97
98 * nbtri = 0; /* the number of triangles in your mesh */
99
100 return STATUS_OK ;
101 }
102
103 /**
104 * Implementation of how the vertices of a mesh triangle are obtained .
105 * @param [ in ] itri : index of the desired triangle from 1 to nbtri
106 * @param [ out ] vtri : integer [3] array containing the vertices of the triangle
107 * @param [ in ] user_data : a user pointer .
108 * @return error code
109 */
110 status_t m g t m _ g e t _ t r i a n g l e _ v e r t i c e s ( integer itri , integer * vtri ,
111 void * user_data ) {

TH-42
MG-TETRA HPC API Manual
Release 2.10

112 int j ;
113 y o u r _ i n t e r n a l _ d a t a _ t * mm = ( y o u r _ i n t e r n a l _ d a t a _ t *) user_data ;
114
115 for ( j = 0; j < 3; j ++)
116 vtri [ j ] = 0; /* the j ’ th vertex index of the itri ’ th triangle */
10401
117 Pantone Pantone Pantone
306 C Process Blue 294 C

118 return STATUS_OK ; Date : 14/04/2011

119 } Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

120
121 /**
122 * Implementation of how the required status of a mesh vertex is obtained .
123 * @param [ in ] ivtx : index of the desired vertex from 1 to nbvtx
124 * @param [ out ] rvtx : integer [1] containing the required status (0 or 1) of the
vertex
125 * @param [ in ] user_data : a user pointer .
126 * @return error code
127 */
128 status_t m g t m _ g e t _ v e r t e x _ r e q u i r e d _ p r o p e r t y ( integer ivtx , integer * rvtx ,
129 void * user_data ) {
130 y o u r _ i n t e r n a l _ d a t a _ t * mm = ( y o u r _ i n t e r n a l _ d a t a _ t *) user_data ;
131
132 * rvtx = 0; /* the ivtx ’ th vertex required property : 1 if the vertex is required or
0 if it is not */
133
134 return STATUS_OK ;
135 }
136
137 /**
138 * This is the message callback function that Tetra_HPC will call when
139 * it wants to send a message to the caller
140 * see meshgems / message . h for more details .
141 *
142 * @param [ in ] msg : the message
143 * @param [ in ] user_data : a user pointer .
144 * @return an error code
145 */
146 status_t my_message_cb ( message_t * msg , void * user_data ) {
147 char * desc ;
148 integer e , ibuff [6];
149 real rbuff [3];
150
151 m e s s a g e _ g e t _ d e s c r i p t i o n ( msg , & desc ) ;
152 m e s s a g e _g e t _ n u m b e r ( msg , & e ) ;
153
154 if ( e == M E S H G E M S _ T E T R A _ H P C _ C O D E ( -8411) ) {
155 /* This is the error 8411 related to unrecovered
156 * required vertex .
157 * Get the associated integer data
158 */
159 m e s s a g e _ g e t _ i n t e g e r _ d a t a ( msg , 1 , 1 , ibuff ) ;
160 printf (" Missing required vertex : % i \ n " , ibuff [0]) ;
161 } else if ( e == M E S H G E M S _ T E T R A _ H P C _ C O D E ( -8441) ) {
162 /* This is the error 8441 related to unrecovered edges .
163 * Get the associated integer data [1..2]
164 */
165 m e s s a g e _ g e t _ i n t e g e r _ d a t a ( msg , 1 , 2 , ibuff ) ;
166 printf (" Missing required edge : % i % i \ n " , ibuff [0] , ibuff [1]) ;
167 } else if ( e == M E S H G E M S _ T E T R A _ H P C _ C O D E ( -8423) ) {
168 /* This is the error 8423 related to unrecovered faces .
169 * Get the associated integer data [1..3]
170 */
171 m e s s a g e _ g e t _ i n t e g e r _ d a t a ( msg , 1 , 3 , ibuff ) ;
172 printf (" Missing required face : % i % i % i \ n " , ibuff [0] , ibuff [1] , ibuff [2]) ;
173 } else {
174 /* No specific handler for this message . Just print its description */
175 printf (" Message (% i ) : % s " , e , desc ) ;
176 }

TH-43
API Manual MG-TETRA HPC
Release 2.10 APPENDIX A. MESHGEMS-TETRA HPC’S INTEGRATION TEMPLATE

177
178 return STATUS_OK ;
179 }
180
181 status_t s e t _ t e t r a _ h p c _ p a r a m e t e r s ( t e t r a _ h p c _ s e s s i o n _ t * ts ) {
01
Pantone Pantone Pantone
182 status_t ret ;
306 C Process Blue 294 C

/04/2011
183
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
184 /* You can here specify the Tetra_HPC options , using the API function
185 * t e t r a _ h p c _ s e t _ p a r a m () .
186 * For example :
187 */
188
189 /* This option changes the verbosity level of Tetra_HPC , between 0 and
190 * 10. The higher it is , the more messages Tetra_HPC will send
191 * through the message callback . Default is 3.
192 */
193 ret = t e t r a _ h p c _ s e t _ p a r a m ( ts , " verbose " , "3") ;
194 if ( ret != STATUS_OK )
195 return ret ;
196
197 /* Set the desired maximum ratio between 2 adjacent tetrahedra
198 * edges . The closer it is to "1" , the more uniform the mesh will be
199 * Default value is "1.05"
200 */
201 ret = t e t r a _ h p c _ s e t _ p a r a m ( ts , " gradation " , "1.05") ;
202 if ( ret != STATUS_OK )
203 return ret ;
204
205 /* Number of computing thread to launch */
206 ret = t e t r a _ h p c _ s e t _ p a r a m ( ts , " m a x _ n u m b e r _ o f _ t h r e a d s " , "6") ;
207 if ( ret != STATUS_OK )
208 return ret ;
209
210 return ret ;
211 }
212
213 /* A macro we will call to cleanly return from the function in case of
214 * failure .
215 */
216 # define R E T U R N _ W I T H _ M E S S A G E ( _ret , _msg ) do { \
217 fprintf ( stderr ,"% s \ n " , _msg ) ; \
218 if ( input_mesh ) mesh_delete ( input_mesh ) ;\
219 if ( ts ) t e t r a _ h p c _ s e s s i o n _ d e l e t e ( ts ) ; \
220 if ( ctx ) context_delete ( ctx ) ; \
221 return _ret ; \
222 } while (0) ;
223
224 status_t g e n e r a t e _ t e t r a _ m e s h ( y o u r _ i n t e r n a l _ d a t a _ t * y o u r _ i n t e r n a l _ d a t a ) {
225 status_t ret ;
226 context_t * ctx ;
227 mesh_t * input_mesh , * output_mesh ;
228 t e t r a _ h p c _ s e s s i o n _ t * ts ;
229
230 integer i , nvm , ntm ;
231 integer nsd ;
232 real q , qmin , qmax ;
233
234 ctx = 0;
235 input_mesh = 0;
236 output_mesh = 0;
237 ts = 0;
238
239 /*
240 * Create the meshgems working context
241 */
242 ctx = context_new () ;
243 if (! ctx )

TH-44
MG-TETRA HPC API Manual
Release 2.10

244 R E T U R N _ W I T H _ M E S S A G E ( STATUS_NOMEM , " unable to create a new context ") ;


245
246 /*
247 * Set the message callback for our context .
248 */
249 ret = c o n t e x t _ s e t _ m e s s a g e _ c a l l b a c k ( ctx , my_message_cb , 0)10401
; Pantone Pantone Pantone
306 C Process Blue 294 C

250 if ( ret != STATUS_OK ) Date : 14/04/2011

251 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ; Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

252
253 /*
254 * Create the mesh_t structure holding the callbacks giving acces to your mesh data
in
255 * y ou r _ i n t e r n a l _ d at a
256 */
257 input_mesh = mesh_new ( ctx ) ;
258 if (! input_mesh )
259 R E T U R N _ W I T H _ M E S S A G E ( STATUS_NOMEM , " unable to create a new mesh ") ;
260
261 /*
262 * Set the mesh_t callback functions that will query y o u r _ i n t e r n a l _ d a t a structure :
263 * see meshgems / mesh . h for detailed function prototypes .
264 */
265
266 ret = m e s h _ s e t _ g e t _ v e r t e x _ c o u n t ( input_mesh , mgtm_get_vertex_count ,
267 your_internal_data );
268 if ( ret != STATUS_OK )
269 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ;
270
271 ret = m e s h _ s e t _ g e t _ v e r t e x _ c o o r d i n a t e s ( input_mesh , m gtm_ge t_ver tex_c oordi nates ,
272 your_internal_data );
273 if ( ret != STATUS_OK )
274 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ;
275
276 ret = m e s h _ s e t _ g e t _ v e r t e x _ r e q u i r e d _ p r o p e r t y ( input_mesh ,
277 mgtm_get_vertex_required_property ,
278 your_internal_data );
279 if ( ret != STATUS_OK )
280 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ;
281
282 ret = m e s h _ s e t _ g e t _ e d g e _ c o u n t ( input_mesh , mgtm_get_edge_count ,
283 your_internal_data );
284 if ( ret != STATUS_OK )
285 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ;
286
287 ret = m e s h _ s e t _ g e t _ e d g e _ v e r t i c e s ( input_mesh , mgtm_get_edge_vertices ,
288 your_internal_data );
289 if ( ret != STATUS_OK )
290 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ;
291
292 ret = m e s h _ s e t _ g e t _ t r i a n g l e _ c o u n t ( input_mesh , mgtm_get_triangle_count ,
293 your_internal_data );
294 if ( ret != STATUS_OK )
295 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ;
296
297 ret = m e s h _ s e t _ g e t _ t r i a n g l e _ v e r t i c e s ( input_mesh , mgtm_get_triangle_vertices ,
298 your_internal_data );
299 if ( ret != STATUS_OK )
300 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ;
301
302 if (0) {
303 /*
304 * Display some statistics about the surface mesh .
305 * The data is sent formated to the context message callback
306 * For debugging purposes
307 */
308 m e s h _ c o m p u t e _ s t a t i s t i c s ( input_mesh ) ;
309 }

TH-45
API Manual MG-TETRA HPC
Release 2.10 APPENDIX A. MESHGEMS-TETRA HPC’S INTEGRATION TEMPLATE

310 # ifdef _ _ M E S H G E M S _ P R I V K E Y _ H _ _
311 /* If you are an OEM customer for Tetra_HPC , this will sign the mesh object with
312 * your private key ( else Tetra_HPC would reject it ) */
313 ret = sign_mesh ( input_mesh ) ;
314 if ( ret != STATUS_OK )
01
Pantone Pantone Pantone
315 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to sign input mesh ") ;
306 C Process Blue 294 C

/04/2011
316 # endif
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
317
318 /*
319 * Create a tetra_hpc session
320 */
321 ts = t e t r a _ h p c _ s e s s i o n _ n e w ( ctx ) ;
322 if (! ts )
323 R E T U R N _ W I T H _ M E S S A G E ( STATUS_NOMEM ,
324 " unable to create a new tetra_hpc session ") ;
325
326 /*
327 * Set the input working surface mesh for this tetra_hpc session
328 */
329 ret = t e t r a _ h p c _ s e t _ i n p u t _ m e s h ( ts , input_mesh ) ;
330 if ( ret != STATUS_OK )
331 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to set surface mesh ") ;
332
333 ret = s e t _ t e t r a _ h p c _ p a r a m e t e r s ( ts ) ;
334 if ( ret != STATUS_OK )
335 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to set tetra_hpc paramters ") ;
336
337 /*
338 * The mesh generation process .
339 * See the meshgems / tetra_hpc . h file for more details
340 */
341 ret = tetra_hpc_mesh ( ts ) ;
342 if ( ret != STATUS_OK )
343 R E T U R N _ W I T H _ M E S S A G E ( ret , " Unable to generate volume mesh ") ;
344
345 /*
346 * Mesh generation is completed . Get the generated volume
347 * mesh . This output mesh belongs to the t e t r a _ h p c _ s e s s i o n . Thus the
348 * user does not have to delete it afterwards .
349 */
350 ret = t e t r a _ h pc _ g e t _ m e s h ( ts , & output_mesh ) ;
351 if ( ret != STATUS_OK )
352 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to get resulting mesh ") ;
353
354 /*
355 * Read the output mesh data . See meshgems / mesh . h for more detailed
356 * prototypes .
357 */
358
359 /* First get all the vertices */
360 ret = m e s h _ g e t _ v e r t e x _ c o u n t ( output_mesh , & nvm ) ;
361 if ( ret != STATUS_OK )
362 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to get resulting vertex count ") ;
363
364 ret = m e s h _ g e t _ t e t r a h e d r o n _ c o u n t ( output_mesh , & ntm ) ;
365 if ( ret != STATUS_OK )
366 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to get resulting tetrahedron count ") ;
367
368 for ( i = 1; i <= nvm ; i ++) {
369 real coo [3];
370 ret = m e s h _ g e t _ v e r t e x _ c o o r d i n a t e s ( output_mesh , i , coo ) ;
371 if ( ret != STATUS_OK )
372 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to get resulting vertices ") ;
373 if (0) {
374 fprintf ( stdout , " vertex % d coordinates are : % e % e % e \ n " , i , coo [0] ,
375 coo [1] , coo [2]) ;
376 }

TH-46
MG-TETRA HPC API Manual
Release 2.10

377 }
378
379 /* Then get all the tetrahedra and compute some statistics on their aspect ratio */
380
381 qmin = REAL_INFINITY ;
10401
382 qmax = - REAL_INFINITY ; Pantone Pantone Pantone
306 C Process Blue 294 C

383 Date : 14/04/2011

384 for ( i = 1; i <= ntm ; i ++) { Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

385 integer vtx [4] , tag ;


386 ret = m e s h _ g e t _ t e t r a h e d r o n _ v e r t i c e s ( output_mesh , i , vtx ) ;
387 if ( ret != STATUS_OK )
388 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to get resulting tetrahedra vertices ") ;
389 if (0) {
390 fprintf ( stdout , " tetra % d vertices are : % d % d % d % d \ n " , i , vtx [0] ,
391 vtx [1] , vtx [2] , vtx [3]) ;
392 }
393 ret = m e s h _ g e t _ t e t r a h e d r o n _ t a g ( output_mesh , i , & tag ) ;
394 if ( ret != STATUS_OK )
395 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to get resulting tetrahedra tags ") ;
396 if (0) {
397 fprintf ( stdout , " tetra % d is in subdomain % d \ n " , i , tag ) ;
398 }
399 ret = m e s h _ g e t _ t e t r a h e d r o n _ a s p e c t _ r a t i o ( output_mesh , i , & q ) ;
400 if ( ret != STATUS_OK )
401 R E T U R N _ W I T H _ M E S S A G E ( ret , " internal error ") ;
402 if ( q > qmax )
403 qmax = q ;
404 if ( q < qmin )
405 qmin = q ;
406 }
407
408 fprintf ( stdout , "\ nGenerated % d vertices and % d tetrahedra \ n " , nvm , ntm ) ;
409 fprintf ( stdout , " with a quality within [% f ,% f ]\ n " , qmin , qmax ) ;
410
411 /*
412 * Read the subdomain identifi cat io n information .
413 * See tetra_hpc documentation for more information .
414 */
415 ret = m e s h _ g e t _ s u b d o m a i n _ c o u n t ( output_mesh , & nsd ) ;
416 if ( ret != STATUS_OK )
417 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to get resulting subdomain count ") ;
418
419 fprintf ( stdout , " Identified subdomains : % d \ n " , nsd ) ;
420 if ( nsd > 1) {
421 for ( i = 1; i <= nsd ; i ++) {
422 integer subdomain_tag , seed_type , seed_idx , s e e d _ o r i e n t a t i o n ;
423 char * seed_type_str ;
424 ret = m e s h _ g e t _ s u b d o m a i n _ d e s c r i p t i o n ( output_mesh , i , & subdomain_tag ,
425 & seed_type , & seed_idx ,
426 & seed_orientation );
427 if ( ret != STATUS_OK )
428 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to get a subdomain seed ") ;
429
430 if ( seed_type == M E S H G E M S _ M E S H _ E L E M E N T _ T Y P E _ T R I A 3 ) {
431 seed_type_str = " triangle ";
432 } else {
433 /* The only seed type generated by MeshGems - Tetra_HPC is the triangle */
434 seed_type_str = " unknown error ";
435 }
436
437 fprintf (
438 stdout ,
439 " subdomain % d description is : tag =% d type =% s facet =% d orientation =% d \ n " ,
440 i , subdomain_tag , seed_type_str , seed_idx , s e e d _ o r i e n t a t i o n ) ;
441 }
442 }
443

TH-47
API Manual MG-TETRA HPC
Release 2.10 APPENDIX A. MESHGEMS-TETRA HPC’S INTEGRATION TEMPLATE

444 /*
445 * We can also directly write a . mesh formated file and a . sol formated file for the
sizemap :
446 */
447
01
Pantone Pantone Pantone
448 fprintf ( stdout , " Writing volume mesh in tetra_hpc . mesh file \ n ") ;
306 C Process Blue 294 C

/04/2011
449 ret = mesh_write_mesh ( output_mesh , " tetra_hpc . mesh ") ;
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
450 if ( ret != STATUS_OK )
451 R E T U R N _ W I T H _ M E S S A G E ( ret , " unable to write a . mesh file ") ;
452
453 if (0) {
454 /*
455 * Display some statistics about the output mesh .
456 * The data is sent formated to the context message callback
457 * for debugging purposes .
458 */
459 m e s h _ c o m p u t e _ s t a t i s t i c s ( output_mesh ) ;
460 }
461
462 /*
463 * We are done , give the volume mesh and sizemap back to the session and clean up
everything .
464 */
465 t e t r a _ h p c _ r e g a i n _ m e s h ( ts , output_mesh ) ;
466 t e t r a _ h p c _ s e s s i o n _ d e l e t e ( ts ) ;
467
468 mesh_delete ( input_mesh ) ;
469
470 context_delete ( ctx ) ;
471
472 return STATUS_OK ;
473 }

TH-48
MG-TETRA HPC API Manual
Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL

Appendix B
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

MeshGems-Tetra HPC’s diagnostics

B.1 Possible causes of failure


The reasons for which the algorithm may fail can be divided into several categories, as follows:

• there are wrong data (for example the surface mesh contains elements other than edge and triangle),

• the surface is self-intersecting (at least, a surface edge intersects a surface face, an edge intersects
another edge or a face intersects another face),

• the surface mesh contains hole(s) so that the domain is not watertight and therefore the volume is not
properly defined,

• two given points at least are identical or considered as being too close to one another,

• the memory size is not sufficient,

• the boundary regeneration was not performed (most of the time because the surface quality is too poor
or because incompatible face sizes occur for two faces that are very close to one another).

Remark: Most of the failures of the mesh generation algorithm are due to very poor quality surface meshes
(in terms of element aspect ratios). To prevent this type of failure, it is advised to input good quality surface
meshes to MeshGems-Tetra HPC.

B.2 Syntax of the diagnostics


During an execution of MeshGems-Tetra HPC, some messages may be sent to the message callback. Each
message is composed of a code number, a description and sometimes attached data (typically a list of CAD
or mesh entities: vertices, edges...). For more information about how to get these components, please refer
to 3.1.3.
The messages are classified into three groups :

• the error messages with a negative code number,

• the warning/information messages with a positive code number,

• the unstructured text messages with a null code number,

TH-49
API Manual MG-TETRA HPC
Release 2.10 APPENDIX B. MESHGEMS-TETRA HPC’S DIAGNOSTICS

A non null message code number can be written as follows : code = ±(1000000 × q + r),
where 0 ≤ r < 1000000
Where q identifies the module and r identifies the diagnostic independently of the module and defines the
01
base number of the message. For a diagnostic comming from MeshGems-Tetra HPC q is equal to 9.
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04
For example, let’s consider a message with a code number equal to -9005100. This is an error message (the
11, rue des Grandes Cultures - 93100 MONTREUIL
Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr
code is negative). It comes from MeshGems-Tetra HPC (q is 1), and the base number is 5100.

B.3 List of MeshGems-Tetra HPC’s diagnostics


The complete list of MeshGems-Tetra HPC’s diagnostics is included in the MeshGems-Tetra HPC’s user
manual (mg-tetra hpc user manual.pdf).

TH-50
MG-TETRA HPC API Manual
LIST OF FIGURES Release 2.10

10401
Pantone Pantone Pantone
306 C Process Blue 294 C

Date : 14/04/2011
Name : 10401 Logo Mesh Gems 04

List of Figures 11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

3.1 List of MeshGems-Tetra HPC parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25


3.2 Triangle P2 (left), Tetrahedron P2 (right). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

TH-51
API Manual MG-TETRA HPC
Release 2.10 LIST OF FIGURES

01
Pantone Pantone Pantone
306 C Process Blue 294 C

/04/2011
0401 Logo Mesh Gems 04

11, rue des Grandes Cultures - 93100 MONTREUIL


Tél. : 01 48 51 05 78 - Fax : 01 48 51 10 35 - www.ckube.fr

TH-52

You might also like