Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/interface/nginterface.h
3206 views
1
#ifndef NGINTERFACE
2
#define NGINTERFACE
3
4
5
/**************************************************************************/
6
/* File: nginterface.h */
7
/* Author: Joachim Schoeberl */
8
/* Date: 20. Nov. 99 */
9
/**************************************************************************/
10
11
/*
12
Application program interface to Netgen
13
14
*/
15
16
17
18
// max number of nodes per element
19
#define NG_ELEMENT_MAXPOINTS 12
20
21
// max number of nodes per surface element
22
#define NG_SURFACE_ELEMENT_MAXPOINTS 8
23
24
25
26
// implemented element types:
27
enum NG_ELEMENT_TYPE {
28
NG_SEGM = 1, NG_SEGM3 = 2,
29
NG_TRIG = 10, NG_QUAD=11, NG_TRIG6 = 12, NG_QUAD6 = 13,
30
NG_TET = 20, NG_TET10 = 21,
31
NG_PYRAMID = 22, NG_PRISM = 23, NG_PRISM12 = 24,
32
NG_HEX = 25
33
};
34
35
typedef double NG_POINT[3]; // coordinates
36
typedef int NG_EDGE[2]; // initial point, end point
37
typedef int NG_FACE[4]; // points, last one is 0 for trig
38
39
40
#ifdef __cplusplus
41
extern "C" {
42
#endif
43
44
// load geomtry from file
45
void Ng_LoadGeometry (const char * filename);
46
47
// load netgen mesh
48
void Ng_LoadMesh (const char * filename);
49
50
// load netgen mesh
51
void Ng_LoadMeshFromString (const char * mesh_as_string);
52
53
// space dimension (2 or 3)
54
int Ng_GetDimension ();
55
56
// number of mesh points
57
int Ng_GetNP ();
58
59
// number of mesh vertices (differs from GetNP for 2nd order elements)
60
int Ng_GetNV ();
61
62
// number of mesh elements
63
int Ng_GetNE ();
64
65
// number of surface triangles
66
int Ng_GetNSE ();
67
68
// Get Point coordintes, index from 1 .. np
69
void Ng_GetPoint (int pi, double * p);
70
71
// Get Element Points
72
NG_ELEMENT_TYPE Ng_GetElement (int ei, int * epi, int * np = 0);
73
74
// Get Element Type
75
NG_ELEMENT_TYPE Ng_GetElementType (int ei);
76
77
// Get sub-domain of element ei
78
int Ng_GetElementIndex (int ei);
79
80
void Ng_SetElementIndex(const int ei, const int index);
81
82
// Get Material of element ei
83
char * Ng_GetElementMaterial (int ei);
84
85
// Get Material of domain dom
86
char * Ng_GetDomainMaterial (int dom);
87
88
// Get Surface Element Points
89
NG_ELEMENT_TYPE Ng_GetSurfaceElement (int ei, int * epi, int * np = 0);
90
91
// Get Surface Element Type
92
NG_ELEMENT_TYPE Ng_GetSurfaceElementType (int ei);
93
94
// Get Surface Element Index
95
int Ng_GetSurfaceElementIndex (int ei);
96
97
// Get Surface Element Surface Number
98
int Ng_GetSurfaceElementSurfaceNumber (int ei);
99
100
// Get Surface Element Number
101
int Ng_GetSurfaceElementFDNumber (int ei);
102
103
// Get BCName for Surface Element
104
char * Ng_GetSurfaceElementBCName (int ei);
105
//void Ng_GetSurfaceElementBCName (int ei, char * name);
106
107
// Get BCName for bc-number
108
char * Ng_GetBCNumBCName (int bcnr);
109
//void Ng_GetBCNumBCName (int bcnr, char * name);
110
111
// Get normal vector of surface element node
112
void Ng_GetNormalVector (int sei, int locpi, double * nv);
113
114
115
void Ng_SetPointSearchStartElement(int el);
116
117
// Find element of point, returns local coordinates
118
int Ng_FindElementOfPoint (double * p, double * lami,
119
int build_searchtrees = 0,
120
const int * const indices = NULL, const int numind = 0);
121
122
// Find surface element of point, returns local coordinates
123
int Ng_FindSurfaceElementOfPoint (double * p, double * lami,
124
int build_searchtrees = 0,
125
const int * const indices = NULL, const int numind = 0);
126
127
128
// is elment ei curved ?
129
int Ng_IsElementCurved (int ei);
130
// is elment sei curved ?
131
int Ng_IsSurfaceElementCurved (int sei);
132
133
/// Curved Elemens:
134
/// xi..local coordinates
135
/// x ..global coordinates
136
/// dxdxi...D x D Jacobian matrix (row major storage)
137
void Ng_GetElementTransformation (int ei, const double * xi,
138
double * x, double * dxdxi);
139
140
141
/// buffer must be at least 100 doubles, alignment of double
142
void Ng_GetBufferedElementTransformation (int ei, const double * xi,
143
double * x, double * dxdxi,
144
void * buffer, int buffervalid);
145
146
147
148
/// Curved Elemens:
149
/// xi..local coordinates
150
/// x ..global coordinates
151
/// dxdxi...D x D-1 Jacobian matrix (row major storage)
152
/// curved ...is element curved ?
153
void Ng_GetSurfaceElementTransformation (int sei, const double * xi,
154
double * x, double * dxdxi);
155
156
/// Curved Elemens:
157
/// xi..local coordinates
158
/// sxi..step xi
159
/// x ..global coordinates
160
/// dxdxi...D x D Jacobian matrix (row major storage)
161
void Ng_GetMultiElementTransformation (int ei, int n,
162
const double * xi, int sxi,
163
double * x, int sx,
164
double * dxdxi, int sdxdxi);
165
166
167
// Mark element for refinement
168
void Ng_SetRefinementFlag (int ei, int flag);
169
void Ng_SetSurfaceRefinementFlag (int sei, int flag);
170
171
// Do local refinement
172
enum NG_REFINEMENT_TYPE { NG_REFINE_H = 0, NG_REFINE_P = 1, NG_REFINE_HP = 2 };
173
void Ng_Refine (NG_REFINEMENT_TYPE reftype);
174
175
// Use second order elements
176
void Ng_SecondOrder ();
177
void Ng_HighOrder (int order, bool rational = false);
178
//void Ng_HPRefinement (int levels, double parameter = 0.125);
179
void Ng_HPRefinement (int levels, double parameter = 0.125,
180
bool setorders = true,bool ref_level = false);
181
// void Ng_HPRefinement (int levels);
182
// void Ng_HPRefinement (int levels, double parameter);
183
184
185
// Topology and coordinate information of master element:
186
187
int Ng_ME_GetNVertices (NG_ELEMENT_TYPE et);
188
int Ng_ME_GetNEdges (NG_ELEMENT_TYPE et);
189
int Ng_ME_GetNFaces (NG_ELEMENT_TYPE et);
190
191
const NG_POINT * Ng_ME_GetVertices (NG_ELEMENT_TYPE et);
192
const NG_EDGE * Ng_ME_GetEdges (NG_ELEMENT_TYPE et);
193
const NG_FACE * Ng_ME_GetFaces (NG_ELEMENT_TYPE et);
194
195
int Ng_GetNEdges();
196
int Ng_GetNFaces();
197
198
199
int Ng_GetElement_Edges (int elnr, int * edges, int * orient = 0);
200
int Ng_GetElement_Faces (int elnr, int * faces, int * orient = 0);
201
202
int Ng_GetSurfaceElement_Edges (int selnr, int * edges, int * orient = 0);
203
int Ng_GetSurfaceElement_Face (int selnr, int * orient = 0);
204
205
void Ng_GetSurfaceElementNeighbouringDomains(const int selnr, int & in, int & out);
206
207
int Ng_GetFace_Vertices (int fnr, int * vert);
208
void Ng_GetEdge_Vertices (int ednr, int * vert);
209
int Ng_GetFace_Edges (int fnr, int * edge);
210
211
int Ng_GetNVertexElements (int vnr);
212
void Ng_GetVertexElements (int vnr, int * els);
213
214
int Ng_GetElementOrder (int enr);
215
void Ng_GetElementOrders (int enr, int * ox, int * oy, int * oz);
216
217
void Ng_SetElementOrder (int enr, int order);
218
void Ng_SetElementOrders (int enr, int ox, int oy, int oz);
219
220
int Ng_GetSurfaceElementOrder (int enr);
221
void Ng_GetSurfaceElementOrders (int enr, int * ox, int * oy);
222
223
void Ng_SetSurfaceElementOrder (int enr, int order);
224
void Ng_SetSurfaceElementOrders (int enr, int ox, int oy);
225
226
// Multilevel functions:
227
228
// number of levels:
229
int Ng_GetNLevels ();
230
// get two parent nodes (indeed vertices !) of node ni
231
void Ng_GetParentNodes (int ni, int * parents);
232
233
// get parent element (first child has always same number)
234
int Ng_GetParentElement (int ei);
235
236
// get parent surface element (first child has always same number)
237
int Ng_GetParentSElement (int ei);
238
239
// representant of anisotropic cluster
240
int Ng_GetClusterRepVertex (int vi);
241
int Ng_GetClusterRepEdge (int edi);
242
int Ng_GetClusterRepFace (int fai);
243
int Ng_GetClusterRepElement (int eli);
244
245
246
void Ng_SurfaceElementTransformation (int eli, double x, double y,
247
double * p3d, double * jacobian);
248
249
#ifdef PARALLEL
250
// Is Element ei an element of this processor ??
251
bool Ng_IsGhostEl (int ei);
252
253
void Ng_SetGhostEl(const int ei, const bool aisghost );
254
255
bool Ng_IsGhostSEl (int ei);
256
257
void Ng_SetGhostSEl(const int ei, const bool aisghost );
258
259
bool Ng_IsGhostVert ( int pnum );
260
bool Ng_IsGhostEdge ( int ednum );
261
bool Ng_IsGhostFace ( int fanum );
262
263
bool Ng_IsExchangeEl ( int elnum );
264
bool Ng_IsExchangeSEl ( int selnr );
265
266
void Ng_UpdateOverlap ();
267
int Ng_Overlap();
268
/* void Ng_SetGhostVert ( const int pnum, const bool aisghost ); */
269
/* void Ng_SetGhostEdge ( const int ednum, const bool aisghost ); */
270
/* void Ng_SetGhostFace ( const int fanum, const bool aisghost ); */
271
272
#endif
273
274
namespace netgen {
275
#include "../visualization/soldata.hpp"
276
}
277
278
enum Ng_SolutionType
279
{ NG_SOLUTION_NODAL = 1,
280
NG_SOLUTION_ELEMENT = 2,
281
NG_SOLUTION_SURFACE_ELEMENT = 3,
282
NG_SOLUTION_NONCONTINUOUS = 4,
283
NG_SOLUTION_SURFACE_NONCONTINUOUS = 5,
284
NG_SOLUTION_VIRTUAL_FUNCTION = 6,
285
NG_SOLUTION_MARKED_ELEMENTS = 10,
286
NG_SOLUTION_ELEMENT_ORDER = 11
287
};
288
289
struct Ng_SolutionData
290
{
291
const char * name; // name of gridfunction
292
double * data; // solution values
293
int components; // relevant (double) components in solution vector
294
int dist; // # doubles per entry alignment!
295
int iscomplex; // complex vector ?
296
bool draw_surface;
297
bool draw_volume;
298
int order; // order of elements, only partially supported
299
Ng_SolutionType soltype; // type of solution function
300
netgen::SolutionData * solclass;
301
};
302
303
// initialize solution data with default arguments
304
void Ng_InitSolutionData (Ng_SolutionData * soldata);
305
// set solution data
306
void Ng_SetSolutionData (Ng_SolutionData * soldata);
307
/// delete gridfunctions
308
void Ng_ClearSolutionData();
309
// redraw
310
void Ng_Redraw();
311
//
312
void Ng_SetVisualizationParameter (const char * name,
313
const char * value);
314
315
316
// number of periodic vertices
317
int Ng_GetNPeriodicVertices (int idnr);
318
// pairs should be an integer array of 2*npairs
319
void Ng_GetPeriodicVertices (int idnr, int * pairs);
320
321
// number of periodic edges
322
int Ng_GetNPeriodicEdges (int idnr);
323
// pairs should be an integer array of 2*npairs
324
void Ng_GetPeriodicEdges (int idnr, int * pairs);
325
326
327
void Ng_PushStatus (const char * str);
328
void Ng_PopStatus ();
329
void Ng_SetThreadPercentage (double percent);
330
void Ng_GetStatus (char ** str, double & percent);
331
332
void Ng_SetTerminate(void);
333
void Ng_UnSetTerminate(void);
334
int Ng_ShouldTerminate(void);
335
336
337
//// added by Roman Stainko ....
338
int Ng_GetVertex_Elements( int vnr, int* elems);
339
int Ng_GetVertex_SurfaceElements( int vnr, int* elems );
340
int Ng_GetVertex_NElements( int vnr );
341
int Ng_GetVertex_NSurfaceElements( int vnr );
342
343
344
#ifdef SOCKETS
345
int Ng_SocketClientOpen( const int port, const char * host );
346
void Ng_SocketClientWrite( const char * write, char ** reply);
347
void Ng_SocketClientClose ( void );
348
void Ng_SocketClientGetServerHost ( const int number, char ** host );
349
void Ng_SocketClientGetServerPort ( const int number, int * port );
350
void Ng_SocketClientGetServerClientID ( const int number, int * id );
351
#endif
352
353
void Ng_InitPointCurve(double red, double green, double blue);
354
void Ng_AddPointCurvePoint(const double * point);
355
356
357
#ifdef PARALLEL
358
void Ng_SetElementPartition ( int elnr, int part );
359
int Ng_GetElementPartition ( int elnr );
360
#endif
361
362
void Ng_SaveMesh ( const char * meshfile );
363
void Ng_Bisect ( const char * refinementfile );
364
365
// if qualityloss is not equal to NULL at input, a (1-based) list of qualitylosses (due to projection)
366
// is saved in *qualityloss, its size is the return value
367
int Ng_Bisect_WithInfo ( const char * refinementfile, double ** qualityloss);
368
#ifdef __cplusplus
369
}
370
#endif
371
372
#endif
373
374
375
376
377
378
379
/*
380
The new node interface ...
381
it is 0-based !
382
*/
383
384
extern "C" {
385
386
/*
387
number of nodes of type nt
388
nt = 0 is Vertex
389
nt = 1 is Edge
390
nt = 2 is Face
391
nt = 3 is Cell
392
*/
393
int Ng_GetNNodes (int nt);
394
395
/*
396
closure nodes of node (nt, nodenr):
397
nodeset is bit-coded, bit 0 includes Vertices, bit 1 edges, etc
398
E.g., nodeset = 6 includes edge and face nodes
399
nodes consists of pairs of integers (nodetype, nodenr)
400
return value is number of nodes
401
*/
402
int Ng_GetClosureNodes (int nt, int nodenr, int nodeset, int * nodes);
403
404
405
/*
406
number of dim-dimensional elements
407
dim = 3 ... volume elements
408
dim = 2 ... surface elements
409
dim = 1 ... segments
410
dim = 0 ... not available
411
*/
412
int Ng_GetNElements (int dim);
413
414
/*
415
closure nodes of dim-dimensional element elmentnr:
416
nodeset is bit-coded, bit 0 includes Vertices, bit 1 edges, etc
417
E.g., nodeset = 6 includes edge and face nodes
418
nodes consists of pairs of integers (nodetype, nodenr)
419
return value is number of nodes
420
*/
421
int Ng_GetElementClosureNodes (int dim, int elementnr, int nodeset, int * nodes);
422
}
423
424