The Higher Education and Research forge

Home My Page Projects Code Snippets Project Openings MMD
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

eca12e4053b8127a505f03a23802ee7f58295b83
1 /*---------------------------------------------------------------------------*\
2     \o/\o/\o/
3     MMD
4     Version : 0.0.3
5     Web : https://github.com/alainbastide/MMD
6 -------------------------------------------------------------------------------
7 License
9     MMD is free software: you can redistribute it and/or modify it
10     under the terms of the GNU General Public License as published by the
11     Free Software Foundation, either version 3 of the License, or (at your
12     option) any later version.
14     MMD is distributed in the hope that it will be useful, but
15     WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17     General Public License for more details.
19     You should have received a copy of the GNU General Public License
20     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
22 Application
23     explain
25 Description
26     explain
28 Author
29     Alain Bastide, Université de La Réunion, FRANCE.  All rights reserved
31 \*---------------------------------------------------------------------------*/
33 #ifndef MMD_H
34 #define MMD_H
36 #include <signal.h>
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <stdbool.h>
40 #include <string.h>
42 #include <math.h>
43 //#include <quadmath.h>
45 #include <malloc.h>
47 #include <time.h>
48 #include <ctype.h>
50 #include <vtkCellType.h>
52 #ifdef _OPENMP
53 #include <omp.h>
54 #endif
56 #define NBAFFICHE 10
58 #define DIM3D 3
61 //typedef __float128 dataType; // attention aux opérations
62 #ifdef QUADPRECISION
63 typedef long double dataType;
64 #else
65 #ifdef DOUBLEPRECISION
66 typedef double dataType;
67 #else
68 #ifdef SIMPLEPRECISION
69 typedef float dataType;
70 #else //default
71 typedef double dataType;
72 #endif
73 #endif
74 #endif
76 typedef u_char connectivity_short;
77 typedef u_int64_t connectivity_int;
78 typedef u_int64_t count_int;
80 static dataType SMALL   = 1.0E-16;
81 static dataType VSMALL  = 1.0E-30;
84 #define ZEROVECTOR  {0.0, 0.0, 0.0}
85 #define ZEROSCALAR    0.0
88 #define HEXAHEDRON 8
89 #define HEXAHEDRON_FACES 6
90 #define HEXAHEDRON_DUAL_FACE_POINT 4
91 #define HEXAHEDRON_SEGMENTS 12
92 #define QUAD 4
93 #define SEGMENTVERTEX 2
94 #define MAXSIZECONNECTIVITYVECTOR 1024
96 //extern connectivity_int  hexaedron_localNodeList[HEXAHEDRON_FACES][QUAD];
98 //extern connectivity_int  hexaedron_localNodeListNumbers[HEXAHEDRON_FACES];
100 //extern connectivity_int  hexaedron_localSegmentList[HEXAHEDRON_SEGMENTS][SEGMENTVERTEX];
102 //extern connectivity_int  hexaedron_localSegmentsListNumbers[HEXAHEDRON_SEGMENTS];
104 #define PT1 0
105 #define PT2 1
106 #define PT3 2
107 #define PT4 3
108 #define CELL1 0
109 #define CELL2 1
111 struct dualMesh {
113   connectivity_int    internalDualFacesNumber;
114   dataType         ***internalDualFaces;
115   dataType          **internalDualFaceCentres;
116   dataType          **internalDualFaceArea;
117   
118   connectivity_int ** segmentToInternalDualFace;
119   connectivity_short *  segmentToInternalDualFaceNumber;
120   
121   
122 };
124 struct primalMesh {
127     // structrured Mesh
128     connectivity_int M; dataType L;
129     connectivity_int N; dataType l;
130     connectivity_int P; dataType H;
132     // Element Number
133     connectivity_int vertexNumber;  // vertex number
134     connectivity_int segmentNumber;  // segment number
135     connectivity_int faceNumber; //surface number
136     connectivity_int cellNumber;  // cell number
137     connectivity_int faceBoundaryNumber;
139     // Cells
140     connectivity_int            **         cellToCells; // done
141     connectivity_int             *         cellToCellsNumbers; // done
144     // Vertex
145     dataType                    **         vertex;
146     connectivity_int            **         cellToVertex; // done
147     connectivity_int            **         vertexToCells;
148     connectivity_short          *          vertexToCellNumber;
150     connectivity_int            **         vertexToSegments; // done
151     connectivity_short          *          vertexToSegmentNumber; // done
152     connectivity_short          *          cellToVertexNumber; // done
156     // Segments
157 //    connectivity_int **     segmentToVertex;
158     connectivity_int **     faceToSegment;
160     connectivity_int **     segments;
163     // Surfaces
164     connectivity_int **     faces;
165     connectivity_int **     cellToFaces;
166     connectivity_short      cellToFacesNumber;
167     connectivity_int **     cellToFacesOwner;
168     connectivity_int **     cellToFacesNeighbour;
169     connectivity_short *    cellToFacesOwnerNumber;
170     connectivity_short *    cellToFacesNeighbourNumber;
171     connectivity_int **     cellToSegmentOwner;
172     connectivity_short *    cellToSegmentOwnerNumber;
173     connectivity_int **     cellToSegmentNeighbour;
174     connectivity_short *    cellToSegmentNeighbourNumber;
175     
176     connectivity_int **     vertexToFaces;
177     connectivity_short *    vertexToFacesNumber;
178     connectivity_int **     vertexToSegmentOwner;
179     connectivity_short *    vertexToSegmentOwnerNumber;
180     connectivity_int **     vertexToSegmentNeighbour;
181     connectivity_short *    vertexToSegmentNeighbourNumber;
183     connectivity_int **     segmentToFaceOwner;
184     connectivity_short *    segmentToFaceOwnerNumber;
185     connectivity_int **     segmentToFaceNeighbour;
186     connectivity_short *    segmentToFaceNeighbourNumber;
187     dataType       **       segmentCentres;
190     connectivity_short *    faceToVertexNumber; // done
191     connectivity_short *    faceToCellsNumber; // done
192     connectivity_int **     faceToVertex; // vertexToFaces -> facesTo
193     connectivity_int **     faceToSegments;
194     connectivity_int **     faceToCells;
195     dataType       **       faceCentres;
196     dataType       **       faceAreas;
197     connectivity_int  *     faceBoundary;
200     dataType       **   volumeCentroid;
201     dataType        *   volume;
203     // boundaries
205 };
210 struct simulationData {
212     char *      simulationName;
213     connectivity_int    iteration;
214     double      time;
215     int         dimension;
216 };
219 struct readWriteVTK {
220     char *      fileName;
221     FILE *      handle;
222     int         binary;
223     char *      dataName;
225     struct simulationData * mySimulationData;
227 };
233 #ifdef DEBUG
234 #define DEBUG_TEST 1
235 #else
236 #define DEBUG_TEST 0
237 #endif // DEBUG
240 // MY ASSERT
241 //#ifdef NDEBUG
242 //#define ASSERT(expr) (void)0
243 //#else
245 // https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
246 #define P_BLINK "\033[25m"
247 #define P_RED "\033[0;31m"
248 #define P_YELLOW "\033[0;33m"
249 #define P_RESET "\033[0;0m"
251 #define P_BACK_RED "\033[1;37;41m"
252 #define P_BACK_YELLOW "\033[0;43m"
253 #define P_BACK_RESET "\033[0;0m"
256 #define affiche(...) \
257  do {  printf( __VA_ARGS__); } while (0)
260 #define warning(...) \
261  printf(P_BACK_RESET);do {  printf(P_BACK_RED); printf(__VA_ARGS__);printf(P_BACK_RESET); } while (0); printf(P_BACK_RESET);printf("\n")
264 #define warning_debug(...) \
265  if (DEBUG_TEST) { fprintf(stderr,P_BACK_RESET);do {  fprintf(stderr,P_BACK_RED); fprintf(stderr,__VA_ARGS__);fprintf(stderr,P_BACK_RESET); } while (0); fprintf(stderr,P_BACK_RESET);fprintf(stderr,"\n"); }
268 #define debug_print(...) \
269     do { if (DEBUG_TEST) fprintf(stderr, __VA_ARGS__); } while (0) 
271   
272 #define release_print(...) \
273     do {  printf( __VA_ARGS__); } while (0)
275  
276 #define ASSERT(expr) \
277   printf("%sASSERT%s -> FILE:%s LINE:%d EXPRESSION EVALUATED: \"%s\"\n",P_BACK_RED,P_BACK_RESET,__FILE__, __LINE__, #expr);
278  
280 #define ERROR_TEST(x) \
281 { \
282     do { \
283     if (!x) { \
284     fprintf(stderr, "%sInternal error ERROR_TEST: FILE %s at LINE %d in FUNCTION %s : " x "%s\n",P_BACK_RED, __FILE__, __LINE__, __FUNCTION__,P_BACK_RESET); \
285     exit(1);\
286     } \
287     } while (0)
291 clock_t startFunction(const char * functionName);
293 void endFunction(const char * functionName, clock_t t);
295 void todo(void) ;
297 void setHandler(void (*handler)(int,siginfo_t *,void *));
299 void fault_handler(int signo, siginfo_t *info, void *extra) ;
301 #endif // MMD_H