Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
API_functions_3d.c
Go to the documentation of this file.
1/* =============================================================================
2** This file is part of the mmg software package for the tetrahedral
3** mesh modification.
4** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004-
5**
6** mmg is free software: you can redistribute it and/or modify it
7** under the terms of the GNU Lesser General Public License as published
8** by the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** mmg is distributed in the hope that it will be useful, but WITHOUT
12** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14** License for more details.
15**
16** You should have received a copy of the GNU Lesser General Public
17** License and of the GNU General Public License along with mmg (in
18** files COPYING.LESSER and COPYING). If not, see
19** <http://www.gnu.org/licenses/>. Please read their terms carefully and
20** use this copy of the mmg distribution only if you accept them.
21** =============================================================================
22*/
23
41#include "libmmg3d.h"
42#include "libmmg3d_private.h"
44#include "PRoctree_3d_private.h"
45
46int MMG3D_Init_mesh(const int starter,...) {
47 va_list argptr;
48 int ier;
49
51
53
55
56 return ier;
57}
59 ) {
60
62 return;
63}
64
66
68}
69
71 return MMG5_Set_inputSolName(mesh,sol,solin);
72}
73
74int MMG3D_Set_outputMeshName(MMG5_pMesh mesh, const char* meshout) {
75
76 return MMG5_Set_outputMeshName(mesh,meshout);
77}
78
80 return MMG5_Set_outputSolName(mesh,sol,solout);
81}
82
84
85 /* Init common parameters for mmgs and mmg3d. */
87
88 /* default values for integers */
93 /* [0/1] ,avoid/allow surface modifications */
95#ifdef USE_SCOTCH
96 /* [1/0] , Turn on/off the renumbering using SCOTCH */
98#else
99 /* [0] , Turn on/off the renumbering using SCOTCH */
101#endif
102
103 /* default values for doubles */
104 /* level set value */
105 mesh->info.ls = MMG5_LS;
106
107#ifndef MMG_PATTERN
109#endif
110}
111
112int MMG3D_Set_solSize(MMG5_pMesh mesh, MMG5_pSol sol, int typEntity, MMG5_int np, int typSol) {
113
114 if ( ( (mesh->info.imprim > 5) || mesh->info.ddebug ) && sol->m )
115 fprintf(stderr,"\n ## Warning: %s: old solution deletion.\n",__func__);
116
117 if ( typEntity != MMG5_Vertex ) {
118 fprintf(stderr,"\n ## Error: %s: mmg3d need a solution imposed on vertices.\n",
119 __func__);
120 return 0;
121 }
122
123 sol->type = typSol;
124
125 if ( typSol == MMG5_Scalar ) {
126 sol->size = 1;
127 }
128 else if ( typSol == MMG5_Vector ) {
129 sol->size = 3;
130 }
131 else if ( typSol == MMG5_Tensor ) {
132 sol->size = 6;
133 /* User will provide its own metric: classical storage at ridges */
134 mesh->info.metRidTyp = 0;
135 }
136 else {
137 fprintf(stderr,"\n ## Error: %s: type of solution not yet implemented.\n",
138 __func__);
139 return 0;
140 }
141
142 sol->dim = 3;
143 if ( np ) {
144 sol->np = np;
145 sol->npi = np;
146 if ( sol->m )
148
149 sol->npmax = mesh->npmax;
150 MMG5_ADD_MEM(mesh,(sol->size*(sol->npmax+1))*sizeof(double),"initial solution",
151 return 0);
152 MMG5_SAFE_CALLOC(sol->m,(sol->size*(sol->npmax+1)),double,return 0);
153 }
154 return 1;
155}
156
158 MMG5_int nentities, int *typSol) {
159 MMG5_pSol psl;
160 char data[18];
161 int j;
162
163 if ( ( (mesh->info.imprim > 5) || mesh->info.ddebug ) && mesh->nsols ) {
164 if ( *sol ) {
165 fprintf(stderr,"\n ## Warning: %s: old solutions array deletion.\n",
166 __func__);
168 }
169 }
170
172 mesh->nsols = nsols;
173
174 MMG5_ADD_MEM(mesh,nsols*sizeof(MMG5_Sol),"solutions array",
175 return 0);
176 MMG5_SAFE_CALLOC(*sol,nsols,MMG5_Sol,return 0);
177
178 for ( j=0; j<nsols; ++j ) {
179 psl = *sol + j;
180 psl->ver = 2;
181
182 /* Give an arbitrary name to the solution */
183 sprintf(data,"sol_%d",j);
184 if ( !MMG3D_Set_inputSolName(mesh,psl,data) ) {
185 return 0;
186 }
187 /* Give an arbitrary name to the solution */
188 sprintf(data,"sol_%d.o",j);
189 if ( !MMG3D_Set_outputSolName(mesh,psl,data) ) {
190 return 0;
191 }
192
193 if ( !MMG3D_Set_solSize(mesh,psl,MMG5_Vertex,mesh->np,typSol[j]) ) {
194 fprintf(stderr,"\n ## Error: %s: unable to set the size of the"
195 " solution num %d.\n",__func__,j);
196 return 0;
197 }
198 }
199 return 1;
200}
201
216int MMG3D_setMeshSize_initData(MMG5_pMesh mesh, MMG5_int np, MMG5_int ne, MMG5_int nprism,
217 MMG5_int nt, MMG5_int nquad, MMG5_int na ) {
218
219 if ( ( (mesh->info.imprim > 5) || mesh->info.ddebug ) &&
220 ( mesh->point || mesh->tria || mesh->tetra || mesh->edge) )
221 fprintf(stderr,"\n ## Warning: %s: old mesh deletion.\n",__func__);
222
223 if ( !np ) {
224 fprintf(stderr," ** MISSING DATA:\n");
225 fprintf(stderr," Your mesh must contains at least points.\n");
226 return 0;
227 }
228 if ( !ne && (mesh->info.imprim > 4 || mesh->info.ddebug) ) {
229 fprintf(stderr," ** WARNING:\n");
230 fprintf(stderr," Your mesh don't contains tetrahedra.\n");
231 }
232 if ( mesh->point )
234 if ( mesh->tetra )
236 if ( mesh->prism )
238 if ( mesh->tria )
240 if ( mesh->quadra )
242 if ( mesh->edge )
244
245 mesh->np = np;
246 mesh->ne = ne;
247 mesh->nt = nt;
248 mesh->na = na;
249 mesh->nprism = nprism;
250 mesh->nquad = nquad;
251
252 mesh->npi = mesh->np;
253 mesh->nei = mesh->ne;
254 mesh->nti = mesh->nt;
255 mesh->nai = mesh->na;
256
257 return 1;
258}
259
260int MMG3D_Set_meshSize(MMG5_pMesh mesh, MMG5_int np, MMG5_int ne, MMG5_int nprism,
261 MMG5_int nt, MMG5_int nquad, MMG5_int na ) {
262
263 /* Check input data and set mesh->ne/na/np/nt to the suitable values */
264 if ( !MMG3D_setMeshSize_initData(mesh,np,ne,nprism,nt,nquad,na) )
265 return 0;
266
267 /* Check the -m option */
268 if( mesh->info.mem > 0) {
269 if((mesh->npmax < mesh->np || mesh->ntmax < mesh->nt || mesh->nemax < mesh->ne)) {
270 if ( !MMG3D_memOption(mesh) ) return 0;
271 } else if(mesh->info.mem < 39) {
272 fprintf(stderr,"\n ## Error: %s: not enough memory %d\n",__func__,
273 mesh->info.mem);
274 return 0;
275 }
276 } else {
277 if ( !MMG3D_memOption(mesh) ) return 0;
278 }
279
280 /* Mesh allocation and linkage */
281 if ( !MMG3D_setMeshSize_alloc( mesh ) ) return 0;
282
283 return 1;
284}
285
286int MMG3D_Get_solSize(MMG5_pMesh mesh, MMG5_pSol sol, int* typEntity, MMG5_int* np, int* typSol) {
287
288 if ( typEntity != NULL )
289 *typEntity = MMG5_Vertex;
290
291 if ( typSol != NULL ) {
292 if ( sol->size == 1 )
293 *typSol = MMG5_Scalar;
294 else if ( sol->size == 3 )
295 *typSol = MMG5_Vector;
296 else if ( sol->size == 6 )
297 *typSol = MMG5_Tensor;
298 else
299 *typSol = MMG5_Notype;
300 }
301
302 assert( (!sol->np) || (sol->np == mesh->np));
303
304 if ( np != NULL )
305 *np = sol->np;
306
307 return 1;
308}
309
311 MMG5_int* np, int* typSol) {
312 MMG5_pSol psl;
313 MMG5_int j;
314
315 if ( !mesh ) {
316 fprintf(stderr,"\n ## Error: %s: your mesh structure must be allocated"
317 " and filled\n",__func__);
318 return 0;
319 }
320
321 if ( nsols != NULL )
322 *nsols = mesh->nsols;
323
324 for ( j=0; j<mesh->nsols; ++j ) {
325 psl = *sol + j;
326
327 if ( typSol != NULL ) {
328 typSol[j] = psl->type;
329 }
330
331 assert( (!psl->np) || (psl->np == mesh->np));
332 }
333 if ( np != NULL )
334 *np = mesh->np;
335
336 return 1;
337}
338
339int MMG3D_Get_meshSize(MMG5_pMesh mesh, MMG5_int* np, MMG5_int* ne, MMG5_int* nprism,
340 MMG5_int* nt, MMG5_int * nquad, MMG5_int* na) {
341
342 if ( np != NULL )
343 *np = mesh->np;
344 if ( ne != NULL )
345 *ne = mesh->ne;
346 if ( nprism != NULL )
347 *nprism = mesh->nprism;
348 if ( nt != NULL )
349 *nt = mesh->nt;
350 if ( nquad != NULL )
351 *nquad = mesh->nquad;
352 if ( na != NULL )
353 *na = mesh->na;
354
355 return 1;
356}
357
358int MMG3D_Set_vertex(MMG5_pMesh mesh, double c0, double c1, double c2, MMG5_int ref, MMG5_int pos) {
359
360 if ( !mesh->np ) {
361 fprintf(stderr,"\n ## Error: %s: you must set the number of points with the",
362 __func__);
363 fprintf(stderr," MMG3D_Set_meshSize function before setting vertices in mesh.\n");
364 return 0;
365 }
366
367 if ( pos > mesh->npmax ) {
368 fprintf(stderr,"\n ## Error: %s: unable to allocate a new point.\n",__func__);
369 fprintf(stderr," max number of points: %" MMG5_PRId "\n",mesh->npmax);
371 return 0;
372 }
373
374 if ( pos > mesh->np ) {
375 fprintf(stderr,"\n ## Error: %s: attempt to set new vertex at position %" MMG5_PRId ".",
376 __func__,pos);
377 fprintf(stderr," Overflow of the given number of vertices: %" MMG5_PRId "\n",mesh->np);
378 fprintf(stderr,"\n ## Check the mesh size, its compactness or the position");
379 fprintf(stderr," of the vertex.\n");
380 return 0;
381 }
382
383 mesh->point[pos].c[0] = c0;
384 mesh->point[pos].c[1] = c1;
385 mesh->point[pos].c[2] = c2;
386 mesh->point[pos].ref = ref;
387 mesh->point[pos].tag = MG_NUL;
388 mesh->point[pos].flag = 0;
389 mesh->point[pos].tmp = 0;
390
391 return 1;
392}
393
394int MMG3D_Get_vertex(MMG5_pMesh mesh, double* c0, double* c1, double* c2, MMG5_int* ref,
395 int* isCorner, int* isRequired) {
396
397 if ( mesh->npi == mesh->np ) {
398 mesh->npi = 0;
399 if ( mesh->info.ddebug ) {
400 fprintf(stderr,"\n ## Warning: %s: reset the internal counter of points.\n",
401 __func__);
402 fprintf(stderr," You must pass here exactly one time (the first time ");
403 fprintf(stderr,"you call the MMG3D_Get_vertex function).\n");
404 fprintf(stderr," If not, the number of call of this function");
405 fprintf(stderr," exceed the number of points: %" MMG5_PRId "\n ",mesh->np);
406 }
407 }
408
409 mesh->npi++;
410
411 if ( mesh->npi > mesh->np ) {
412 fprintf(stderr,"\n ## Error: %s: unable to get point.\n",__func__);
413 fprintf(stderr," The number of call of MMG3D_Get_vertex function");
414 fprintf(stderr," can not exceed the number of points: %" MMG5_PRId "\n ",mesh->np);
415 return 0;
416 }
417
418 return MMG3D_GetByIdx_vertex( mesh,c0,c1,c2,ref,isCorner,isRequired,mesh->npi);
419}
420
421int MMG3D_GetByIdx_vertex(MMG5_pMesh mesh, double* c0, double* c1, double* c2, MMG5_int* ref,
422 int* isCorner, int* isRequired, MMG5_int idx) {
423
424 if ( idx < 1 || idx > mesh->np ) {
425 fprintf(stderr,"\n ## Error: %s: unable to get point at position %" MMG5_PRId ".\n",
426 __func__,idx);
427 fprintf(stderr," Your vertices numbering goes from 1 to %" MMG5_PRId "\n",mesh->np);
428 return 0;
429 }
430
431 *c0 = mesh->point[idx].c[0];
432 *c1 = mesh->point[idx].c[1];
433 *c2 = mesh->point[idx].c[2];
434 if ( ref != NULL )
435 *ref = mesh->point[idx].ref;
436
437 if ( isCorner != NULL ) {
438 if ( mesh->point[idx].tag & MG_CRN )
439 *isCorner = 1;
440 else
441 *isCorner = 0;
442 }
443
444 if ( isRequired != NULL ) {
445 if ( mesh->point[idx].tag & MG_REQ )
446 *isRequired = 1;
447 else
448 *isRequired = 0;
449 }
450
451 return 1;
452}
453
454int MMG3D_Set_vertices(MMG5_pMesh mesh, double *vertices,MMG5_int *refs) {
455
456 MMG5_pPoint ppt;
457 MMG5_int i,j;
458
459 /*coordinates vertices*/
460 for (i=1;i<=mesh->np;i++)
461 {
462 ppt = &mesh->point[i];
463
464 j = (i-1)*3;
465 ppt->c[0] = vertices[j];
466 ppt->c[1] = vertices[j+1];
467 ppt->c[2] = vertices[j+2];
468
469 ppt->tag = MG_NUL;
470 ppt->flag = 0;
471 ppt->tmp = 0;
472
473 if ( refs != NULL )
474 ppt->ref = refs[i-1];
475 }
476
477 return 1;
478}
479
480
481int MMG3D_Get_vertices(MMG5_pMesh mesh, double* vertices, MMG5_int* refs,
482 int* areCorners, int* areRequired) {
483 MMG5_pPoint ppt;
484 MMG5_int i,j;
485
486 for (i=1;i<=mesh->np;i++)
487 {
488 ppt = &mesh->point[i];
489
490 j = (i-1)*3;
491 vertices[j] = ppt->c[0];
492 vertices[j+1] = ppt->c[1];
493 vertices[j+2] = ppt->c[2];
494
495 j = i-1;
496 if ( refs != NULL )
497 refs[j] = ppt->ref;
498
499 if ( areCorners !=NULL ) {
500 if ( ppt->tag & MG_CRN )
501 areCorners[j] = 1;
502 else
503 areCorners[j] = 0;
504 }
505
506 if ( areRequired != NULL ) {
507 if ( ppt->tag & MG_REQ )
508 areRequired[j] = 1;
509 else
510 areRequired[j] = 0;
511 }
512 }
513
514 return 1;
515}
516
517int MMG3D_Set_tetrahedron(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int v3, MMG5_int ref, MMG5_int pos) {
518 MMG5_pTetra pt;
519 MMG5_pPoint ppt;
520 double vol;
521 MMG5_int aux;
522 int j,ip;
523
524 if ( !mesh->ne ) {
525 fprintf(stderr,"\n ## Error: %s: You must set the number of elements with the",
526 __func__);
527 fprintf(stderr," MMG3D_Set_meshSize function before setting elements in mesh\n");
528 return 0;
529 }
530
531 if ( pos > mesh->nemax ) {
532 fprintf(stderr,"\n ## Error: %s: unable to allocate a new element.\n",
533 __func__);
534 fprintf(stderr," max number of element: %" MMG5_PRId "\n",mesh->nemax);
536 return 0;
537 }
538
539 if ( pos > mesh->ne ) {
540 fprintf(stderr,"\n ## Error: %s: attempt to set new tetrahedron at position %" MMG5_PRId ".",
541 __func__,pos);
542 fprintf(stderr," Overflow of the given number of tetrahedron: %" MMG5_PRId "\n",mesh->ne);
543 fprintf(stderr,"\n ## Check the mesh size, its compactness or the position");
544 fprintf(stderr," of the tetrahedron.\n");
545 return 0;
546 }
547
548 pt = &mesh->tetra[pos];
549 pt->v[0] = v0;
550 pt->v[1] = v1;
551 pt->v[2] = v2;
552 pt->v[3] = v3;
553 pt->ref = MMG5_abs(ref);
554
555 mesh->point[pt->v[0]].tag &= ~MG_NUL;
556 mesh->point[pt->v[1]].tag &= ~MG_NUL;
557 mesh->point[pt->v[2]].tag &= ~MG_NUL;
558 mesh->point[pt->v[3]].tag &= ~MG_NUL;
559
560 vol = MMG5_orvol(mesh->point,pt->v);
561 if ( fabs(vol) <= MMG5_EPSD2 ) {
562 fprintf(stderr,"\n ## Error: %s: tetrahedron %" MMG5_PRId " has volume null.\n",
563 __func__,pos);
564 for ( ip=0; ip<4; ip++ ) {
565 ppt = &mesh->point[pt->v[ip]];
566 for ( j=0; j<3; j++ ) {
567 if ( fabs(ppt->c[j])>0. ) {
568 fprintf(stderr," Check that you don't have a sliver tetrahedron.\n");
569 return 0;
570 }
571 }
572 }
573 fprintf(stderr," All vertices have zero coordinates.");
574 fprintf(stderr," Check that you have set the vertices before the tetrahedra.\n");
575 return 0;
576 }
577 else if ( vol < 0.0 ) {
578 /* Possibly switch 2 vertices number so that each tet is positively oriented */
579 aux = pt->v[2];
580 pt->v[2] = pt->v[3];
581 pt->v[3] = aux;
582 /* mesh->xt temporary used to count reoriented tetra */
583 mesh->xt++;
584 }
585
586 return 1;
587}
588
589int MMG3D_Get_tetrahedron(MMG5_pMesh mesh, MMG5_int* v0, MMG5_int* v1, MMG5_int* v2, MMG5_int* v3,
590 MMG5_int* ref, int* isRequired) {
591
592 if ( mesh->nei == mesh->ne ) {
593 mesh->nei = 0;
594 if ( mesh->info.ddebug ) {
595 fprintf(stderr,"\n ## Warning: %s: reset the internal counter of"
596 " tetrahedra.\n",__func__);
597 fprintf(stderr," You must pass here exactly one time (the first time ");
598 fprintf(stderr,"you call the MMG3D_Get_tetrahedron function).\n");
599 fprintf(stderr," If not, the number of call of this function");
600 fprintf(stderr," exceed the number of tetrahedron: %" MMG5_PRId "\n ",mesh->ne);
601 }
602 }
603
604 mesh->nei++;
605
606 if ( mesh->nei > mesh->ne ) {
607 fprintf(stderr,"\n ## Error: %s: unable to get tetra.\n",__func__);
608 fprintf(stderr," The number of call of MMG3D_Get_tetrahedron function");
609 fprintf(stderr," can not exceed the number of tetra: %" MMG5_PRId "\n ",mesh->ne);
610 return 0;
611 }
612
613 *v0 = mesh->tetra[mesh->nei].v[0];
614 *v1 = mesh->tetra[mesh->nei].v[1];
615 *v2 = mesh->tetra[mesh->nei].v[2];
616 *v3 = mesh->tetra[mesh->nei].v[3];
617 if ( ref != NULL ) {
618 *ref = mesh->tetra[mesh->nei].ref;
619 }
620
621 if ( isRequired != NULL ) {
622 if ( mesh->tetra[mesh->nei].tag & MG_REQ )
623 *isRequired = 1;
624 else
625 *isRequired = 0;
626 }
627
628 return 1;
629}
630
631int MMG3D_Set_tetrahedra(MMG5_pMesh mesh, MMG5_int *tetra, MMG5_int *refs) {
632 MMG5_pPoint ppt;
633 MMG5_pTetra pt;
634 double vol;
635 int ip;
636 MMG5_int aux,i,j;
637
638 mesh->xp = 0;
639 for (i=1;i<=mesh->ne;i++)
640 {
641 j = (i-1)*4;
642 pt = &mesh->tetra[i];
643 pt->v[0] = tetra[j];
644 pt->v[1] = tetra[j+1];
645 pt->v[2] = tetra[j+2];
646 pt->v[3] = tetra[j+3];
647
648 if ( refs != NULL )
649 pt->ref = MMG5_abs(refs[i-1]);
650
651 mesh->point[pt->v[0]].tag &= ~MG_NUL;
652 mesh->point[pt->v[1]].tag &= ~MG_NUL;
653 mesh->point[pt->v[2]].tag &= ~MG_NUL;
654 mesh->point[pt->v[3]].tag &= ~MG_NUL;
655
656 vol = MMG5_orvol(mesh->point,pt->v);
657
658 if ( fabs(vol) <= MMG5_EPSD2 ) {
659 fprintf(stderr,"\n ## Error: %s: tetrahedron %" MMG5_PRId " has volume null.\n",
660 __func__,i);
661
662 for ( ip=0; ip<4; ip++ ) {
663 ppt = &mesh->point[pt->v[ip]];
664 for ( j=0; j<3; j++ ) {
665 if ( fabs(ppt->c[j])>0. ) {
666 fprintf(stderr," Check that you don't have a sliver tetrahedron.\n");
667 return 0;
668 }
669 }
670 }
671
672 fprintf(stderr," All vertices have zero coordinates.");
673 fprintf(stderr," Check that you have set the vertices before the tetrahedra.\n");
674 return 0;
675 }
676 else if ( vol < 0.0 ) {
677 /* Possibly switch 2 vertices number so that each tet is positively oriented */
678 aux = pt->v[2];
679 pt->v[2] = pt->v[3];
680 pt->v[3] = aux;
681
682 ++mesh->xp;
683 }
684 }
685
686 return 1;
687}
688
689int MMG3D_Get_tetrahedra(MMG5_pMesh mesh, MMG5_int *tetra, MMG5_int *refs, int * areRequired) {
690 MMG5_pTetra pt;
691 MMG5_int i, j;
692
693 for (i=1;i<=mesh->ne;i++)
694 {
695 j = (i-1)*4;
696 pt = &mesh->tetra[i];
697 tetra[j] = pt->v[0];
698 tetra[j+1] = pt->v[1];
699 tetra[j+2] = pt->v[2];
700 tetra[j+3] = pt->v[3];
701 if ( refs!=NULL )
702 refs[i-1] = pt->ref ;
703 if ( areRequired != NULL ) {
704 if ( pt->tag & MG_REQ )
705 areRequired[i-1] = 1;
706 else
707 areRequired[i-1] = 0;
708 }
709 }
710 return 1;
711}
712
713int MMG3D_Set_prism(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2,
714 MMG5_int v3, MMG5_int v4, MMG5_int v5, MMG5_int ref, MMG5_int pos) {
715 MMG5_pPrism pp;
716
717 if ( !mesh->nprism ) {
718 fprintf(stderr,"\n ## Error: %s: You must set the number of prisms with the",
719 __func__);
720 fprintf(stderr," MMG3D_Set_meshSize function before setting elements in mesh\n");
721 return 0;
722 }
723
724 if ( pos > mesh->nprism ) {
725 fprintf(stderr,"\n ## Error: %s: attempt to set new prism at position %" MMG5_PRId ".",
726 __func__,pos);
727 fprintf(stderr," Overflow of the given number of prism: %" MMG5_PRId "\n",mesh->nprism);
728 fprintf(stderr,"\n ## Check the mesh size, its compactness or the position");
729 fprintf(stderr," of the prism.\n");
730 return 0;
731 }
732
733 pp = &mesh->prism[pos];
734 pp->v[0] = v0;
735 pp->v[1] = v1;
736 pp->v[2] = v2;
737 pp->v[3] = v3;
738 pp->v[4] = v4;
739 pp->v[5] = v5;
740 pp->ref = ref;
741
742 mesh->point[pp->v[0]].tag &= ~MG_NUL;
743 mesh->point[pp->v[1]].tag &= ~MG_NUL;
744 mesh->point[pp->v[2]].tag &= ~MG_NUL;
745 mesh->point[pp->v[3]].tag &= ~MG_NUL;
746 mesh->point[pp->v[4]].tag &= ~MG_NUL;
747 mesh->point[pp->v[5]].tag &= ~MG_NUL;
748
749
750 return 1;
751}
752
753int MMG3D_Get_prism(MMG5_pMesh mesh, MMG5_int* v0, MMG5_int* v1, MMG5_int* v2, MMG5_int* v3,
754 MMG5_int* v4, MMG5_int* v5, MMG5_int* ref, int* isRequired) {
755 static MMG5_int npri = 0;
756
757 if ( npri == mesh->nprism ) {
758 npri = 0;
759 if ( mesh->info.ddebug ) {
760 fprintf(stderr,"\n ## Warning: %s: reset the internal counter of prisms.\n",
761 __func__);
762 fprintf(stderr," You must pass here exactly one time (the first time ");
763 fprintf(stderr,"you call the MMG3D_Get_prism function).\n");
764 fprintf(stderr," If not, the number of call of this function");
765 fprintf(stderr," exceed the number of prisms: %" MMG5_PRId "\n ",mesh->nprism);
766 }
767 }
768
769 ++npri;
770
771 if ( npri > mesh->nprism ) {
772 fprintf(stderr,"\n ## Error: %s: unable to get prism.\n",__func__);
773 fprintf(stderr," The number of call of MMG3D_Get_prism function");
774 fprintf(stderr," can not exceed the number of prism: %" MMG5_PRId "\n ",mesh->nprism);
775 return 0;
776 }
777
778 *v0 = mesh->prism[npri].v[0];
779 *v1 = mesh->prism[npri].v[1];
780 *v2 = mesh->prism[npri].v[2];
781 *v3 = mesh->prism[npri].v[3];
782 *v4 = mesh->prism[npri].v[4];
783 *v5 = mesh->prism[npri].v[5];
784
785 if ( ref != NULL ) {
786 *ref = mesh->prism[npri].ref;
787 }
788
789 if ( isRequired != NULL ) {
790 if ( mesh->prism[npri].tag & MG_REQ )
791 *isRequired = 1;
792 else
793 *isRequired = 0;
794 }
795
796 return 1;
797}
798
799int MMG3D_Set_prisms(MMG5_pMesh mesh, MMG5_int *prisms, MMG5_int *refs) {
800 MMG5_pPrism pp;
801 MMG5_int j,i;
802
803 for (i=1;i<=mesh->nprism;i++)
804 {
805 j = (i-1)*6;
806 pp = &mesh->prism[i];
807 pp->v[0] = prisms[j];
808 pp->v[1] = prisms[j+1];
809 pp->v[2] = prisms[j+2];
810 pp->v[3] = prisms[j+3];
811 pp->v[4] = prisms[j+4];
812 pp->v[5] = prisms[j+5];
813
814 if ( refs != NULL )
815 pp->ref = refs[i-1];
816
817 mesh->point[pp->v[0]].tag &= ~MG_NUL;
818 mesh->point[pp->v[1]].tag &= ~MG_NUL;
819 mesh->point[pp->v[2]].tag &= ~MG_NUL;
820 mesh->point[pp->v[3]].tag &= ~MG_NUL;
821 mesh->point[pp->v[4]].tag &= ~MG_NUL;
822 mesh->point[pp->v[5]].tag &= ~MG_NUL;
823
824 }
825
826 return 1;
827}
828
829int MMG3D_Get_prisms(MMG5_pMesh mesh, MMG5_int *prisms, MMG5_int *refs, int * areRequired) {
830 MMG5_pPrism pp;
831 MMG5_int j,i;
832
833 for (i=1;i<=mesh->nprism;i++)
834 {
835 j = (i-1)*6;
836 pp = &mesh->prism[i];
837 prisms[j] = pp->v[0];
838 prisms[j+2] = pp->v[1];
839 prisms[j+1] = pp->v[2];
840 prisms[j+3] = pp->v[3];
841 prisms[j+4] = pp->v[4];
842 prisms[j+5] = pp->v[5];
843
844 if ( refs!=NULL )
845 refs[i-1] = pp->ref ;
846 if ( areRequired != NULL ) {
847 if ( pp->tag & MG_REQ )
848 areRequired[i-1] = 1;
849 else
850 areRequired[i-1] = 0;
851 }
852 }
853 return 1;
854}
855
856
857
858int MMG3D_Set_triangle(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int ref,MMG5_int pos) {
859
860 if ( !mesh->nt ) {
861 fprintf(stderr,"\n ## Error: %s: You must set the number of triangles"
862 " with the",__func__);
863 fprintf(stderr," MMG3D_Set_meshSize function before setting triangles in mesh\n");
864 return 0;
865 }
866
867 if ( pos > mesh->ntmax ) {
868 fprintf(stderr,"\n ## Error: %s: unable to allocate a new triangle.\n",
869 __func__);
870 fprintf(stderr," max number of triangle: %" MMG5_PRId "\n",mesh->ntmax);
872 return 0;
873 }
874
875 if ( pos > mesh->nt ) {
876 fprintf(stderr,"\n ## Error: %s: attempt to set new triangle at"
877 " position %" MMG5_PRId ".",__func__,pos);
878 fprintf(stderr," Overflow of the given number of triangles: %" MMG5_PRId "\n",mesh->nt);
879 fprintf(stderr,"\n ## Check the mesh size, its compactness or the position");
880 fprintf(stderr," of the triangle.\n");
881 return 0;
882 }
883
884 mesh->tria[pos].v[0] = v0;
885 mesh->tria[pos].v[1] = v1;
886 mesh->tria[pos].v[2] = v2;
887 mesh->tria[pos].ref = ref;
888
889 return 1;
890}
891
892int MMG3D_Get_triangle(MMG5_pMesh mesh, MMG5_int* v0, MMG5_int* v1, MMG5_int* v2, MMG5_int* ref
893 ,int* isRequired) {
894 MMG5_pTria ptt;
895
896 if ( mesh->nti == mesh->nt ) {
897 mesh->nti = 0;
898 if ( mesh->info.ddebug ) {
899 fprintf(stderr,"\n ## Warning: %s: reset the internal counter of"
900 " triangles.\n",__func__);
901 fprintf(stderr," You must pass here exactly one time (the first time ");
902 fprintf(stderr,"you call the MMG3D_Get_triangle function).\n");
903 fprintf(stderr," If not, the number of call of this function");
904 fprintf(stderr," exceed the number of triangles: %" MMG5_PRId "\n ",mesh->nt);
905 }
906 }
907
908 mesh->nti++;
909
910 if ( mesh->nti > mesh->nt ) {
911 fprintf(stderr,"\n ## Error: %s: unable to get triangle.\n",__func__);
912 fprintf(stderr," The number of call of MMG3D_Get_triangle function");
913 fprintf(stderr," can not exceed the number of triangles: %" MMG5_PRId "\n ",mesh->nt);
914 return 0;
915 }
916
917 ptt = &mesh->tria[mesh->nti];
918 *v0 = ptt->v[0];
919 *v1 = ptt->v[1];
920 *v2 = ptt->v[2];
921 if ( ref != NULL )
922 *ref = ptt->ref;
923
924 if ( isRequired != NULL ) {
925 if ( (ptt->tag[0] & MG_REQ) && (ptt->tag[1] & MG_REQ) &&
926 (ptt->tag[2] & MG_REQ) )
927 *isRequired = 1;
928 else
929 *isRequired = 0;
930 }
931
932 return 1;
933}
934int MMG3D_Set_triangles(MMG5_pMesh mesh, MMG5_int *tria, MMG5_int *refs) {
935
936 MMG5_pTria ptt;
937 MMG5_int i, j;
938
939 for (i=1;i<=mesh->nt;i++)
940 {
941 j = (i-1)*3;
942 ptt = &mesh->tria[i];
943 ptt->v[0] = tria[j] ;
944 ptt->v[1] = tria[j+2];
945 ptt->v[2] = tria[j+1];
946 if ( refs != NULL )
947 ptt->ref = refs[i-1];
948 }
949 return 1;
950}
951
952int MMG3D_Get_triangles(MMG5_pMesh mesh, MMG5_int *tria, MMG5_int *refs, int *areRequired) {
953 MMG5_pTria ptt;
954 MMG5_int i, j;
955
956 for (i=1;i<=mesh->nt;i++)
957 {
958 j = (i-1)*3;
959 ptt = &mesh->tria[i];
960 tria[j] = ptt->v[0];
961 tria[j+1] = ptt->v[1];
962 tria[j+2] = ptt->v[2];
963
964 if ( refs!=NULL )
965 refs[i-1] = ptt->ref ;
966 if ( areRequired != NULL ) {
967 if ( (ptt->tag[0] & MG_REQ) && (ptt->tag[1] & MG_REQ) &&
968 (ptt->tag[2] & MG_REQ) )
969 areRequired[i-1] = 1;
970 else
971 areRequired[i-1] = 0;
972 }
973 }
974 return 1;
975}
976
977int MMG3D_Set_quadrilateral(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int v3,
978 MMG5_int ref,MMG5_int pos) {
979
980 if ( !mesh->nquad ) {
981 fprintf(stderr,"\n ## Error: %s: You must set the number of quadrilaterals"
982 " with the",__func__);
983 fprintf(stderr," MMG3D_Set_meshSize function before setting quadrilaterals in mesh\n");
984 return 0;
985 }
986
987 if ( pos > mesh->nquad ) {
988 fprintf(stderr,"\n ## Error: %s: attempt to set new quadrilateral"
989 " at position %" MMG5_PRId ".",__func__,pos);
990 fprintf(stderr," Overflow of the given number of quadrilaterals: %" MMG5_PRId "\n",mesh->nquad);
991 fprintf(stderr,"\n ## Check the mesh size, its compactness or the position");
992 fprintf(stderr," of the quadrilateral.\n");
993 return 0;
994 }
995
996 mesh->quadra[pos].v[0] = v0;
997 mesh->quadra[pos].v[1] = v1;
998 mesh->quadra[pos].v[2] = v2;
999 mesh->quadra[pos].v[3] = v3;
1000 mesh->quadra[pos].ref = ref;
1001
1002 return 1;
1003}
1004
1005int MMG3D_Get_quadrilateral(MMG5_pMesh mesh, MMG5_int* v0, MMG5_int* v1, MMG5_int* v2, MMG5_int* v3,
1006 MMG5_int* ref,int* isRequired) {
1007 MMG5_pQuad pq;
1008 static MMG5_int nqi = 0;
1009
1010 if ( nqi == mesh->nquad ) {
1011 nqi = 0;
1012 if ( mesh->info.ddebug ) {
1013 fprintf(stderr,"\n ## Warning: %s: reset the internal counter"
1014 " of quadrilaterals.\n",__func__);
1015 fprintf(stderr," You must pass here exactly one time (the first time ");
1016 fprintf(stderr,"you call the MMG3D_Get_quadrilateral function).\n");
1017 fprintf(stderr," If not, the number of call of this function");
1018 fprintf(stderr," exceed the number of quadrilaterals: %" MMG5_PRId "\n ",mesh->nquad);
1019 }
1020 }
1021
1022 nqi++;
1023
1024 if ( nqi > mesh->nquad ) {
1025 fprintf(stderr,"\n ## Error: %s: unable to get quadrilateral.\n",__func__);
1026 fprintf(stderr," The number of call of MMG3D_Get_quadrilateral function");
1027 fprintf(stderr," can not exceed the number of quadrilaterals: %" MMG5_PRId "\n ",mesh->nquad);
1028 return 0;
1029 }
1030
1031 pq = &mesh->quadra[nqi];
1032 *v0 = pq->v[0];
1033 *v1 = pq->v[1];
1034 *v2 = pq->v[2];
1035 *v3 = pq->v[3];
1036 if ( ref != NULL )
1037 *ref = pq->ref;
1038
1039 if ( isRequired != NULL ) {
1040 if ( (pq->tag[0] & MG_REQ) && (pq->tag[1] & MG_REQ) &&
1041 (pq->tag[2] & MG_REQ) && (pq->tag[3] & MG_REQ))
1042 *isRequired = 1;
1043 else
1044 *isRequired = 0;
1045 }
1046
1047 return 1;
1048}
1049
1050int MMG3D_Set_quadrilaterals(MMG5_pMesh mesh, MMG5_int *quads, MMG5_int *refs) {
1051 MMG5_pQuad pq;
1052 MMG5_int j,i;
1053
1054 for (i=1;i<=mesh->nquad;i++)
1055 {
1056 j = (i-1)*4;
1057 pq = &mesh->quadra[i];
1058 pq->v[0] = quads[j] ;
1059 pq->v[1] = quads[j+1];
1060 pq->v[2] = quads[j+2];
1061 pq->v[3] = quads[j+3];
1062 if ( refs != NULL )
1063 pq->ref = refs[i-1];
1064 }
1065 return 1;
1066}
1067
1068int MMG3D_Get_quadrilaterals(MMG5_pMesh mesh, MMG5_int *quads, MMG5_int *refs, int *areRequired) {
1069 MMG5_pQuad pq;
1070 MMG5_int j,i;
1071
1072 for (i=1;i<=mesh->nquad;i++)
1073 {
1074 j = (i-1)*4;
1075 pq = &mesh->quadra[i];
1076 quads[j] = pq->v[0];
1077 quads[j+1] = pq->v[1];
1078 quads[j+2] = pq->v[2];
1079 quads[j+3] = pq->v[3];
1080
1081 if ( refs!=NULL )
1082 refs[i-1] = pq->ref ;
1083 if ( areRequired != NULL ) {
1084 if ( (pq->tag[0] & MG_REQ) && (pq->tag[1] & MG_REQ) &&
1085 (pq->tag[2] & MG_REQ) && (pq->tag[3] & MG_REQ) )
1086 areRequired[i-1] = 1;
1087 else
1088 areRequired[i-1] = 0;
1089 }
1090 }
1091 return 1;
1092}
1093
1094int MMG3D_Set_edge(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int ref, MMG5_int pos) {
1095
1096 if ( !mesh->na ) {
1097 fprintf(stderr,"\n ## Error: %s: You must set the number of edges with"
1098 " the",__func__);
1099 fprintf(stderr," MMG3D_Set_meshSize function before setting edges in mesh\n");
1100 return 0;
1101 }
1102 if ( pos > mesh->namax ) {
1103 fprintf(stderr,"\n ## Error: %s: unable to allocate a new edge.\n",
1104 __func__);
1105 fprintf(stderr," max number of edge: %" MMG5_PRId "\n",mesh->namax);
1107 return 0;
1108 }
1109 if ( pos > mesh->na ) {
1110 fprintf(stderr,"\n ## Error: %s: attempt to set new edge at position %" MMG5_PRId ".",
1111 __func__,pos);
1112 fprintf(stderr," Overflow of the given number of edges: %" MMG5_PRId "\n",mesh->na);
1113 fprintf(stderr,"\n ## Check the mesh size, its compactness or the position");
1114 fprintf(stderr," of the edge.\n");
1115 return 0;
1116 }
1117
1118 mesh->edge[pos].a = v0;
1119 mesh->edge[pos].b = v1;
1120 mesh->edge[pos].ref = ref;
1121 mesh->edge[pos].tag |= MG_REF;
1122
1123 return 1;
1124}
1125
1126int MMG3D_Get_edge(MMG5_pMesh mesh, MMG5_int* e0, MMG5_int* e1, MMG5_int* ref
1127 ,int* isRidge, int* isRequired) {
1128
1129 if ( mesh->nai == mesh->na ) {
1130 mesh->nai = 0;
1131 if ( mesh->info.ddebug ) {
1132 fprintf(stderr,"\n ## Warning: %s: reset the internal counter of edges.\n",
1133 __func__);
1134 fprintf(stderr," You must pass here exactly one time (the first time ");
1135 fprintf(stderr,"you call the MMG3D_Get_edge function).\n");
1136 fprintf(stderr," If not, the number of call of this function");
1137 fprintf(stderr," exceed the number of edges: %" MMG5_PRId "\n ",mesh->na);
1138 }
1139 }
1140
1141 mesh->nai++;
1142
1143 if ( mesh->nai > mesh->na ) {
1144 fprintf(stderr,"\n ## Error: %s: unable to get edge.\n",__func__);
1145 fprintf(stderr," The number of call of MMG3D_Get_edge function");
1146 fprintf(stderr," can not exceed the number of edges: %" MMG5_PRId "\n ",mesh->na);
1147 return 0;
1148 }
1149
1150 *e0 = mesh->edge[mesh->nai].a;
1151 *e1 = mesh->edge[mesh->nai].b;
1152 if ( ref!=NULL )
1153 *ref = mesh->edge[mesh->nai].ref;
1154
1155 if ( isRidge != NULL ) {
1156 if ( mesh->edge[mesh->nai].tag & MG_GEO )
1157 *isRidge = 1;
1158 else
1159 *isRidge = 0;
1160 }
1161
1162 if ( isRequired != NULL ) {
1163 if ( mesh->edge[mesh->nai].tag & MG_REQ )
1164 *isRequired = 1;
1165 else
1166 *isRequired = 0;
1167 }
1168
1169 return 1;
1170}
1171
1172int MMG3D_Set_edges(MMG5_pMesh mesh, MMG5_int *edges, MMG5_int *refs) {
1173 MMG5_int i,j;
1174
1175 for (i=1;i<=mesh->na;i++)
1176 {
1177 j = (i-1)*2;
1178
1179 mesh->edge[i].a = edges[j];
1180 mesh->edge[i].b = edges[j+1];
1181 if ( refs != NULL )
1182 mesh->edge[i].ref = refs[i-1];
1183 mesh->edge[i].tag |= MG_REF;
1184 }
1185
1186 return 1;
1187}
1188
1189int MMG3D_Get_edges(MMG5_pMesh mesh, MMG5_int* edges,MMG5_int *refs,int* areRidges,int* areRequired) {
1190 MMG5_int i,j;
1191
1192 for (i=1;i<=mesh->na;i++)
1193 {
1194 j = (i-1)*2;
1195 edges[j] = mesh->edge[i].a;
1196 edges[j+1] = mesh->edge[i].b;
1197
1198 if ( refs!=NULL )
1199 refs[i-1] = mesh->edge[i].ref;
1200
1201 if ( areRidges != NULL ) {
1202 if ( mesh->edge[i].tag & MG_GEO )
1203 areRidges[i-1] = 1;
1204 else
1205 areRidges[i-1] = 0;
1206 }
1207
1208 if ( areRequired != NULL ) {
1209 if ( mesh->edge[i].tag & MG_REQ )
1210 areRequired[i-1] = 1;
1211 else
1212 areRequired[i-1] = 0;
1213 }
1214 }
1215
1216 return 1;
1217}
1218
1220 assert ( k <= mesh->np );
1221 mesh->point[k].tag |= MG_CRN;
1222 return 1;
1223}
1224
1226 assert ( k <= mesh->np );
1227 mesh->point[k].tag &= ~MG_CRN;
1228 return 1;
1229}
1230
1232 assert ( k <= mesh->np );
1233 mesh->point[k].tag |= MG_REQ;
1234 mesh->point[k].tag &= ~MG_NUL;
1235 return 1;
1236}
1237
1239 assert ( k <= mesh->np );
1240 mesh->point[k].tag &= ~MG_REQ;
1241 return 1;
1242}
1243
1245 assert ( k <= mesh->ne );
1246 mesh->tetra[k].tag |= MG_REQ;
1247 return 1;
1248}
1249
1251 assert ( k <= mesh->ne );
1252 mesh->tetra[k].tag &= ~MG_REQ;
1253 return 1;
1254}
1255
1256int MMG3D_Set_requiredTetrahedra(MMG5_pMesh mesh, MMG5_int *reqIdx, MMG5_int nreq) {
1257 MMG5_int k;
1258
1259 for ( k=0; k<nreq; ++k ){
1260 mesh->tetra[reqIdx[k]].tag |= MG_REQ;
1261 }
1262
1263 return 1;
1264}
1265
1266int MMG3D_Unset_requiredTetrahedra(MMG5_pMesh mesh, MMG5_int *reqIdx, MMG5_int nreq) {
1267 MMG5_int k;
1268
1269 for ( k=0; k<nreq; ++k ){
1270 mesh->tetra[reqIdx[k]].tag &= ~MG_REQ;
1271 }
1272
1273 return 1;
1274}
1275
1277 assert ( k <= mesh->nt );
1278 mesh->tria[k].tag[0] |= MG_REQ;
1279 mesh->tria[k].tag[1] |= MG_REQ;
1280 mesh->tria[k].tag[2] |= MG_REQ;
1281 return 1;
1282}
1283
1285 assert ( k <= mesh->nt );
1286 mesh->tria[k].tag[0] &= ~MG_REQ;
1287 mesh->tria[k].tag[1] &= ~MG_REQ;
1288 mesh->tria[k].tag[2] &= ~MG_REQ;
1289 return 1;
1290}
1291
1292int MMG3D_Set_requiredTriangles(MMG5_pMesh mesh, MMG5_int* reqIdx, MMG5_int nreq) {
1293 MMG5_int k;
1294
1295 for ( k=0; k<nreq; ++k ){
1296 mesh->tria[reqIdx[k]].tag[0] |= MG_REQ;
1297 mesh->tria[reqIdx[k]].tag[1] |= MG_REQ;
1298 mesh->tria[reqIdx[k]].tag[2] |= MG_REQ;
1299 }
1300 return 1;
1301}
1302
1303int MMG3D_Unset_requiredTriangles(MMG5_pMesh mesh, MMG5_int* reqIdx, MMG5_int nreq) {
1304 MMG5_int k;
1305
1306 for ( k=0; k<nreq; ++k ){
1307 mesh->tria[reqIdx[k]].tag[0] &= ~MG_REQ;
1308 mesh->tria[reqIdx[k]].tag[1] &= ~MG_REQ;
1309 mesh->tria[reqIdx[k]].tag[2] &= ~MG_REQ;
1310 }
1311 return 1;
1312}
1313
1315 assert ( k <= mesh->nt );
1316 mesh->tria[k].tag[0] |= MG_PARBDY;
1317 mesh->tria[k].tag[1] |= MG_PARBDY;
1318 mesh->tria[k].tag[2] |= MG_PARBDY;
1319 return 1;
1320}
1321
1323 assert ( k <= mesh->nt );
1324 mesh->tria[k].tag[0] &= ~MG_PARBDY;
1325 mesh->tria[k].tag[1] &= ~MG_PARBDY;
1326 mesh->tria[k].tag[2] &= ~MG_PARBDY;
1327 return 1;
1328}
1329
1330int MMG3D_Set_parallelTriangles(MMG5_pMesh mesh, MMG5_int* parIdx, MMG5_int npar) {
1331 MMG5_int k;
1332
1333 for ( k=0; k<npar; ++k ){
1334 mesh->tria[parIdx[k]].tag[0] |= MG_PARBDY;
1335 mesh->tria[parIdx[k]].tag[1] |= MG_PARBDY;
1336 mesh->tria[parIdx[k]].tag[2] |= MG_PARBDY;
1337 }
1338 return 1;
1339}
1340
1341int MMG3D_Unset_parallelTriangles(MMG5_pMesh mesh, MMG5_int* parIdx, MMG5_int npar) {
1342 MMG5_int k;
1343
1344 for ( k=0; k<npar; ++k ){
1345 mesh->tria[parIdx[k]].tag[0] &= ~MG_PARBDY;
1346 mesh->tria[parIdx[k]].tag[1] &= ~MG_PARBDY;
1347 mesh->tria[parIdx[k]].tag[2] &= ~MG_PARBDY;
1348 }
1349 return 1;
1350}
1351
1353 assert ( k <= mesh->na );
1354 mesh->edge[k].tag |= MG_GEO;
1355 return 1;
1356}
1357
1359 assert ( k <= mesh->na );
1360 mesh->edge[k].tag &= ~MG_GEO;
1361 return 1;
1362}
1363
1365 assert ( k <= mesh->na );
1366 mesh->edge[k].tag |= MG_REQ;
1367 return 1;
1368}
1369
1371 assert ( k <= mesh->na );
1372 mesh->edge[k].tag &= ~MG_REQ;
1373 return 1;
1374}
1375
1376int MMG3D_Set_normalAtVertex(MMG5_pMesh mesh, MMG5_int k, double n0, double n1, double n2) {
1377
1378 assert ( k <= mesh->np );
1379 mesh->point[k].n[0] = n0;
1380 mesh->point[k].n[1] = n1;
1381 mesh->point[k].n[2] = n2;
1382
1383 ++mesh->nc1;
1384
1385 return 1;
1386}
1387
1388int MMG3D_Get_normalAtVertex(MMG5_pMesh mesh, MMG5_int k, double *n0, double *n1, double *n2) {
1389
1390 assert ( k <= mesh->np );
1391 (*n0) = mesh->point[k].n[0];
1392 (*n1) = mesh->point[k].n[1];
1393 (*n2) = mesh->point[k].n[2];
1394
1395 return 1;
1396}
1397
1399 double qual = 0.;
1400 MMG5_pTetra pt;
1401
1402 if ( k < 1 || k > mesh->ne ) {
1403 fprintf(stderr,"\n ## Error: %s: unable to access to tetra %" MMG5_PRId ".\n",
1404 __func__,k);
1405 fprintf(stderr," Tetra numbering goes from 1 to %" MMG5_PRId "\n",mesh->ne);
1406 return 0.;
1407 }
1408 pt = &mesh->tetra[k];
1409 assert ( MG_EOK(pt) );
1410
1411 if ( (!met) || (!met->m) || met->size==1 ) {
1412 if ( mesh->info.optimLES) {
1413 /* Skewness */
1414 qual = MMG3D_ALPHAD * MMG3D_caltetLES_iso(mesh,met,pt);
1415 } else {
1416 /* iso quality */
1417 qual = MMG3D_ALPHAD * MMG5_caltet_iso(mesh,NULL,pt);
1418 }
1419 }
1420 else if ( !mesh->info.metRidTyp ) {
1421 qual = MMG3D_ALPHAD * MMG5_caltet33_ani(mesh,met,pt);
1422 }
1423 else {
1424 qual = MMG3D_ALPHAD * MMG5_caltet_ani(mesh,met,pt);
1425 }
1426
1427 return qual;
1428}
1429
1430int MMG3D_Set_scalarSol(MMG5_pSol met, double s, MMG5_int pos) {
1431
1432 if ( !met->np ) {
1433 fprintf(stderr,"\n ## Error: %s: You must set the number of"
1434 " solution with the",__func__);
1435 fprintf(stderr," MMG3D_Set_solSize function before setting values");
1436 fprintf(stderr," in solution structure \n");
1437 return 0;
1438 }
1439 if ( pos < 1 ) {
1440 fprintf(stderr,"\n ## Error: %s: unable to set a new solution.\n",__func__);
1441 fprintf(stderr," Minimal index of the solution position must be 1.\n");
1442 return 0;
1443 }
1444 if ( pos >= met->npmax ) {
1445 fprintf(stderr,"\n ## Error: %s: unable to set a new solution.\n",__func__);
1446 fprintf(stderr," max number of solutions: %" MMG5_PRId "\n",met->npmax);
1447 return 0;
1448 }
1449
1450 if ( pos > met->np ) {
1451 fprintf(stderr,"\n ## Error: %s: attempt to set new solution at"
1452 " position %" MMG5_PRId ".",__func__,pos);
1453 fprintf(stderr," Overflow of the given number of solutions: %" MMG5_PRId "\n",met->np);
1454 fprintf(stderr,"\n ## Check the solution size, its compactness or the position");
1455 fprintf(stderr," of the solution.\n");
1456 return 0;
1457 }
1458
1459 met->m[pos] = s;
1460 return 1;
1461}
1462
1463
1464int MMG3D_Get_scalarSol(MMG5_pSol met, double* s) {
1465
1466 int ddebug = 0;
1467
1468 if ( met->npi == met->np ) {
1469 met->npi = 0;
1470 if ( ddebug ) {
1471 fprintf(stderr,"\n ## Warning: %s: reset the internal counter of points.\n",
1472 __func__);
1473 fprintf(stderr," You must pass here exactly one time (the first time ");
1474 fprintf(stderr,"you call the MMG3D_Get_scalarSol function).\n");
1475 fprintf(stderr," If not, the number of call of this function");
1476 fprintf(stderr," exceed the number of points: %" MMG5_PRId "\n ",met->np);
1477 }
1478 }
1479
1480 met->npi++;
1481
1482 if ( met->npi > met->np ) {
1483 fprintf(stderr,"\n ## Error: %s: unable to get solution.\n",__func__);
1484 fprintf(stderr," The number of call of MMG3D_Get_scalarSol function");
1485 fprintf(stderr," can not exceed the number of points: %" MMG5_PRId "\n ",met->np);
1486 return 0;
1487 }
1488
1489 *s = met->m[met->npi];
1490
1491 return 1;
1492}
1493
1494int MMG3D_Set_scalarSols(MMG5_pSol met, double *s ) {
1495 MMG5_int k;
1496
1497 if ( !met->np ) {
1498 fprintf(stderr,"\n ## Error: %s: You must set the number of solution"
1499 " with the",__func__);
1500 fprintf(stderr," MMG3D_Set_solSize function before setting values");
1501 fprintf(stderr," in solution structure \n");
1502 return 0;
1503 }
1504
1505 for ( k=0; k<met->np; ++k )
1506 met->m[k+1] = s[k];
1507
1508 return 1;
1509}
1510
1511int MMG3D_Get_scalarSols(MMG5_pSol met, double* s) {
1512 MMG5_int k;
1513
1514 for ( k=0; k<met->np; ++k )
1515 s[k] = met->m[k+1];
1516
1517 return 1;
1518}
1519
1520int MMG3D_Set_vectorSol(MMG5_pSol met, double vx,double vy, double vz, MMG5_int pos) {
1521
1522 if ( !met->np ) {
1523 fprintf(stderr,"\n ## Error: %s: You must set the number of solution"
1524 " with the",__func__);
1525 fprintf(stderr," MMG3D_Set_solSize function before setting values");
1526 fprintf(stderr," in solution structure \n");
1527 return 0;
1528 }
1529 if ( pos < 1 ) {
1530 fprintf(stderr,"\n ## Error: %s: unable to set a new solution.\n",__func__);
1531 fprintf(stderr," Minimal index of the solution position must be 1.\n");
1532 return 0;
1533 }
1534 if ( pos >= met->npmax ) {
1535 fprintf(stderr,"\n ## Error: %s: unable to set a new solution.\n",__func__);
1536 fprintf(stderr," max number of solutions: %" MMG5_PRId "\n",met->npmax);
1537 return 0;
1538 }
1539
1540 if ( pos > met->np ) {
1541 fprintf(stderr,"\n ## Error: %s: attempt to set new solution at"
1542 " position %" MMG5_PRId ".",__func__,pos);
1543 fprintf(stderr," Overflow of the given number of solutions: %" MMG5_PRId "\n",met->np);
1544 fprintf(stderr,"\n ## Check the solution size, its compactness or the position");
1545 fprintf(stderr," of the solution.\n");
1546 return 0;
1547 }
1548
1549 met->m[3*pos] = vx;
1550 met->m[3*pos+1] = vy;
1551 met->m[3*pos+2] = vz;
1552
1553 return 1;
1554}
1555
1556
1557int MMG3D_Get_vectorSol(MMG5_pSol met, double* vx, double* vy, double* vz) {
1558
1559 int ddebug = 0;
1560
1561 if ( met->npi == met->np ) {
1562 met->npi = 0;
1563 if ( ddebug ) {
1564 fprintf(stderr,"\n ## Warning: %s: reset the internal counter of points.\n",
1565 __func__);
1566 fprintf(stderr," You must pass here exactly one time (the first time ");
1567 fprintf(stderr,"you call the MMG3D_Get_vectorSol function).\n");
1568 fprintf(stderr," If not, the number of call of this function");
1569 fprintf(stderr," exceed the number of points: %" MMG5_PRId "\n ",met->np);
1570 }
1571 }
1572
1573 met->npi++;
1574
1575 if ( met->npi > met->np ) {
1576 fprintf(stderr,"\n ## Error: %s: unable to get solution.\n",__func__);
1577 fprintf(stderr," The number of call of MMG3D_Get_vectorSol function");
1578 fprintf(stderr," can not exceed the number of points: %" MMG5_PRId "\n ",met->np);
1579 return 0;
1580 }
1581
1582 *vx = met->m[3*met->npi];
1583 *vy = met->m[3*met->npi+1];
1584 *vz = met->m[3*met->npi+2];
1585
1586 return 1;
1587}
1588
1589int MMG3D_Set_vectorSols(MMG5_pSol met, double *sols) {
1590 double *m;
1591 MMG5_int k,j;
1592
1593 if ( !met->np ) {
1594 fprintf(stderr,"\n ## Error: %s: You must set the number of solution"
1595 " with the",__func__);
1596 fprintf(stderr," MMG3D_Set_solSize function before setting values");
1597 fprintf(stderr," in solution structure \n");
1598 return 0;
1599 }
1600
1601 for ( k=0; k<met->np; ++k ) {
1602 j = 3*k;
1603 m = &met->m[j+3];
1604 m[0] = sols[j];
1605 m[1] = sols[j+1];
1606 m[2] = sols[j+2];
1607 }
1608
1609 return 1;
1610}
1611
1612int MMG3D_Get_vectorSols(MMG5_pSol met, double* sols) {
1613 double *m;
1614 MMG5_int k, j;
1615
1616 for ( k=0; k<met->np; ++k ) {
1617 j = 3*k;
1618 m = &met->m[j+3];
1619 sols[j] = m[0];
1620 sols[j+1] = m[1];
1621 sols[j+2] = m[2];
1622 }
1623
1624 return 1;
1625}
1626
1627int MMG3D_Set_tensorSol(MMG5_pSol met, double m11,double m12, double m13,
1628 double m22,double m23, double m33, MMG5_int pos) {
1629
1630 if ( !met->np ) {
1631 fprintf(stderr,"\n ## Error: %s: You must set the number of solution"
1632 " with the",__func__);
1633 fprintf(stderr," MMG3D_Set_solSize function before setting values");
1634 fprintf(stderr," in solution structure \n");
1635 return 0;
1636 }
1637 if ( pos < 1 ) {
1638 fprintf(stderr,"\n ## Error: %s: unable to set a new solution.\n",
1639 __func__);
1640 fprintf(stderr," Minimal index of the solution position must be 1.\n");
1641 return 0;
1642 }
1643 if ( pos >= met->npmax ) {
1644 fprintf(stderr,"\n ## Error: %s: unable to set a new solution.\n",__func__);
1645 fprintf(stderr," max number of solutions: %" MMG5_PRId "\n",met->npmax);
1646 return 0;
1647 }
1648
1649 if ( pos > met->np ) {
1650 fprintf(stderr,"\n ## Error: %s: attempt to set new solution at "
1651 "position %" MMG5_PRId ".",__func__,pos);
1652 fprintf(stderr," Overflow of the given number of solutions: %" MMG5_PRId "\n",met->np);
1653 fprintf(stderr,"\n ## Check the solution size, its compactness or the position");
1654 fprintf(stderr," of the solution.\n");
1655 return 0;
1656 }
1657
1658 met->m[6*pos] = m11;
1659 met->m[6*pos+1] = m12;
1660 met->m[6*pos+2] = m13;
1661 met->m[6*pos+3] = m22;
1662 met->m[6*pos+4] = m23;
1663 met->m[6*pos+5] = m33;
1664
1665 return 1;
1666}
1667
1668
1669int MMG3D_Get_tensorSol(MMG5_pSol met, double *m11,double *m12, double *m13,
1670 double *m22,double *m23, double *m33) {
1671
1672 int ddebug = 0;
1673
1674 if ( met->npi == met->np ) {
1675 met->npi = 0;
1676 if ( ddebug ) {
1677 fprintf(stderr,"\n ## Warning: %s: reset the internal counter of points.\n",
1678 __func__);
1679 fprintf(stderr," You must pass here exactly one time (the first time ");
1680 fprintf(stderr,"you call the MMG3D_Get_tensorSol function).\n");
1681 fprintf(stderr," If not, the number of call of this function");
1682 fprintf(stderr," exceed the number of points: %" MMG5_PRId "\n ",met->np);
1683 }
1684 }
1685
1686 met->npi++;
1687
1688 if ( met->npi > met->np ) {
1689 fprintf(stderr,"\n ## Error: %s: unable to get solution.\n",__func__);
1690 fprintf(stderr," The number of call of MMG3D_Get_tensorSol function");
1691 fprintf(stderr," can not exceed the number of points: %" MMG5_PRId "\n ",met->np);
1692 return 0;
1693 }
1694
1695 *m11 = met->m[6*met->npi];
1696 *m12 = met->m[6*met->npi+1];
1697 *m13 = met->m[6*met->npi+2];
1698 *m22 = met->m[6*met->npi+3];
1699 *m23 = met->m[6*met->npi+4];
1700 *m33 = met->m[6*met->npi+5];
1701
1702 return 1;
1703}
1704
1705int MMG3D_Set_tensorSols(MMG5_pSol met, double *sols) {
1706 double *m;
1707 MMG5_int k,j;
1708
1709 if ( !met->np ) {
1710 fprintf(stderr,"\n ## Error: %s: You must set the number of"
1711 " solution with the",__func__);
1712 fprintf(stderr," MMG3D_Set_solSize function before setting values");
1713 fprintf(stderr," in solution structure \n");
1714 return 0;
1715 }
1716
1717 for ( k=0; k<met->np; ++k ) {
1718 j = 6*k;
1719 m = &met->m[j+6];
1720
1721 m[0] = sols[j];
1722 m[1] = sols[j+1];
1723 m[2] = sols[j+2];
1724 m[3] = sols[j+3];
1725 m[4] = sols[j+4];
1726 m[5] = sols[j+5];
1727 }
1728 return 1;
1729}
1730
1731int MMG3D_Get_tensorSols(MMG5_pSol met, double *sols) {
1732 double *m;
1733 MMG5_int k,j;
1734
1735 for ( k=0; k<met->np; ++k ) {
1736 j = 6*k;
1737 m = &met->m[j+6];
1738
1739 sols[j] = m[0];
1740 sols[j+1] = m[1];
1741 sols[j+2] = m[2];
1742 sols[j+3] = m[3];
1743 sols[j+4] = m[4];
1744 sols[j+5] = m[5];
1745 }
1746
1747 return 1;
1748}
1749
1750int MMG3D_Set_ithSol_inSolsAtVertices(MMG5_pSol sol,int i, double* s,MMG5_int pos) {
1751 MMG5_pSol psl;
1752
1753 /* Warning: users give indices from 1 to nsols */
1754 psl = sol + (i-1);
1755
1756 switch ( psl->type ) {
1757 case MMG5_Scalar:
1758 return MMG3D_Set_scalarSol(psl,s[0],pos);
1759 break;
1760
1761 case MMG5_Vector:
1762 MMG3D_Set_vectorSol(psl,s[0],s[1],s[2],pos);
1763 break;
1764
1765 case MMG5_Tensor:
1766 MMG3D_Set_tensorSol(psl,s[0],s[1],s[2],s[3],s[4],s[5],pos);
1767 break;
1768
1769 default:
1770 fprintf(stderr,"\n ## Error: %s: unexpected type of solution: %s.\n",
1771 __func__,MMG5_Get_typeName(psl->type));
1772 return 0;
1773 }
1774 return 1;
1775}
1776
1777int MMG3D_Get_ithSol_inSolsAtVertices(MMG5_pSol sol,int i, double *s,MMG5_int pos) {
1778 MMG5_pSol psl;
1779
1780 /* Warning: users give indices from 1 to nsols */
1781 psl = sol + (i-1);
1782
1783 psl->npi = pos-1;
1784
1785 switch ( psl->type ) {
1786 case MMG5_Scalar:
1787 return MMG3D_Get_scalarSol(psl,&s[0]);
1788 break;
1789
1790 case MMG5_Vector:
1791 MMG3D_Get_vectorSol(psl,&s[0],&s[1],&s[2]);
1792 break;
1793
1794 case MMG5_Tensor:
1795 MMG3D_Get_tensorSol(psl,&s[0],&s[1],&s[2],&s[3],&s[4],&s[5]);
1796 break;
1797
1798 default:
1799 fprintf(stderr,"\n ## Error: %s: unexpected type of solution: %s\n",
1800 __func__,MMG5_Get_typeName(psl->type));
1801 return 0;
1802 }
1803
1804 return 1;
1805}
1806
1808 MMG5_pSol psl;
1809
1810 /* Warning: users give indices from 1 to nsols */
1811 psl = sol + (i-1);
1812
1813 switch ( psl->type ) {
1814 case MMG5_Scalar:
1815 return MMG3D_Set_scalarSols(psl,s);
1816 break;
1817
1818 case MMG5_Vector:
1819 MMG3D_Set_vectorSols(psl,s);
1820 break;
1821
1822 case MMG5_Tensor:
1823 MMG3D_Set_tensorSols(psl,s);
1824 break;
1825
1826 default:
1827 fprintf(stderr,"\n ## Error: %s: unexpected type of solution: %s.\n",
1828 __func__,MMG5_Get_typeName(psl->type));
1829 return 0;
1830 }
1831
1832 return 1;
1833}
1834
1836 MMG5_pSol psl;
1837
1838 /* Warning: users give indices from 1 to nsols */
1839 psl = sol + (i-1);
1840
1841 switch ( psl->type ) {
1842 case MMG5_Scalar:
1843 return MMG3D_Get_scalarSols(psl,s);
1844 break;
1845
1846 case MMG5_Vector:
1847 MMG3D_Get_vectorSols(psl,s);
1848 break;
1849
1850 case MMG5_Tensor:
1851 MMG3D_Get_tensorSols(psl,s);
1852 break;
1853
1854 default:
1855 fprintf(stderr,"\n ## Error: %s: unexpected type of solution: %s\n",
1856 __func__,MMG5_Get_typeName(psl->type));
1857 return 0;
1858 }
1859
1860 return 1;
1861}
1862
1864 MMG5_int k, aux;
1865
1866 /* Possibly switch 2 vertices number so that each tet is positively oriented */
1867 for (k=1; k<=mesh->ne; k++) {
1868 if ( MMG5_orvol(mesh->point,mesh->tetra[k].v) < 0.0 ) {
1869 /* mesh->xt temporary used to count reoriented tetra */
1870 mesh->xt++;
1871 aux = mesh->tetra[k].v[2];
1872 mesh->tetra[k].v[2] = mesh->tetra[k].v[3];
1873 mesh->tetra[k].v[3] = aux;
1874 }
1875 }
1876 return;
1877}
1878
1880
1881 if ( (mesh->npi != mesh->np) || (mesh->nei != mesh->ne) ) {
1882 fprintf(stderr,"\n ## Error: %s: if you don't use the MMG3D_loadMesh"
1883 " function,",__func__);
1884 fprintf(stderr," you must call the MMG3D_Set_meshSize function to have a");
1885 fprintf(stderr," valid mesh.\n");
1886 fprintf(stderr," Missing datas.\n");
1887 return 0;
1888 }
1889
1890 if ( met->npi != met->np ) {
1891 fprintf(stderr,"\n ## Error: %s: if you don't use the MMG3D_loadSol"
1892 " function,",__func__);
1893 fprintf(stderr," you must call the MMG3D_Set_solSize function to have a");
1894 fprintf(stderr," valid solution.\n");
1895 fprintf(stderr," Missing datas.\n");
1896 return 0;
1897 }
1898
1899 /* Check mesh data */
1900 if ( mesh->info.ddebug ) {
1901 if ( (!mesh->np) || (!mesh->point) ||
1902 (!mesh->ne) || (!mesh->tetra) ) {
1903 fprintf(stderr," ** MISSING DATA.\n");
1904 fprintf(stderr," Check that your mesh contains points and tetrahedra.\n");
1905 fprintf(stderr," Exit program.\n");
1906 return 0;
1907 }
1908 }
1909
1910 if ( mesh->dim != 3 ) {
1911 fprintf(stderr," ** 3 DIMENSIONAL MESH NEEDED. Exit program.\n");
1912 return 0;
1913 }
1914 if ( met->dim != 3 ) {
1915 fprintf(stderr," ** WRONG DIMENSION FOR METRIC. Exit program.\n");
1916 return 0;
1917 }
1918 if ( !mesh->ver ) mesh->ver = 2;
1919 if ( !met ->ver ) met ->ver = 2;
1920
1921 return 1;
1922}
1923
1924static inline
1926 MMG5_pTria ptt,ptt1;
1927 MMG5_pEdge pa,pa1;
1928 MMG5_int k;
1929
1930 if ( (mesh->info.imprim > 5) || mesh->info.ddebug )
1931 fprintf(stderr,"\n ## Warning: %s: skip of all entites with %"MMG5_PRId
1932 " reference.\n",__func__,mesh->info.isoref);
1933
1934 /* Skip triangles with mesh->info.isoref refs */
1935 k = 1;
1936 do {
1937 ptt = &mesh->tria[k];
1938 if ( MMG5_abs(ptt->ref) != mesh->info.isoref ) continue;
1939 /* here ptt is the first tri of mesh->tria that we want to delete */
1940 do {
1941 ptt1 = &mesh->tria[mesh->nti];
1942 }
1943 while( (MMG5_abs(ptt1->ref) == mesh->info.isoref) && (k <= --mesh->nti) );
1944
1945 if ( MMG5_abs(ptt1->ref) != mesh->info.isoref )
1946 /* ptt1 is the last tri of mesh->tria that we want to keep */
1947 memcpy(ptt,ptt1,sizeof(MMG5_Tria));
1948 } while( ++k <= mesh->nti );
1949
1950 if ( mesh->nti < mesh->nt ) {
1951 if( !mesh->nti )
1953 else {
1954 MMG5_ADD_MEM(mesh,mesh->nti-mesh->nt,"triangles",return 0);
1956 "triangles",return 0);
1957 }
1958 mesh->nt = mesh->nti;
1959 }
1960
1961 /* Skip edges with mesh->info.isoref refs */
1962 if ( mesh->na ) {
1963 k = 1;
1964 do {
1965 pa = &mesh->edge[k];
1966 if ( MMG5_abs(pa->ref) != mesh->info.isoref ) {
1967 pa->ref = MMG5_abs(pa->ref);
1968 continue;
1969 }
1970 /* here pa is the first edge of mesh->edge that we want to delete */
1971 do {
1972 pa1 = &mesh->edge[mesh->nai];
1973 }
1974 while( (MMG5_abs(pa1->ref) == mesh->info.isoref) && (k <= --mesh->nai) );
1975
1976 if ( MMG5_abs(pa1->ref) != mesh->info.isoref ) {
1977 /* pa1 is the last edge of mesh->edge that we want to keep */
1978 memcpy(pa,pa1,sizeof(MMG5_Edge));
1979 pa1->ref = MMG5_abs(pa1->ref);
1980 }
1981 } while( ++k <= mesh->nai );
1982
1983 if ( mesh->nai < mesh->na ) {
1984 if( !mesh->nai )
1986 else {
1987 MMG5_ADD_MEM(mesh,mesh->nai-mesh->na,"Edges",return 0);
1989 "edges",return 0);
1990 }
1991 mesh->na = mesh->nai;
1992 }
1993 }
1994 assert ( mesh->nai == mesh->na );
1995
1996 /* delete tetrahedra references */
1997 for (k=1; k<=mesh->ne; k++) {
1998 mesh->tetra[k].ref = 0;
1999 }
2000 return 1;
2001}
2002
2003int MMG3D_Add_tetrahedron(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int v3, MMG5_int ref) {
2004 MMG5_pTetra pt;
2005 MMG5_pPoint ppt;
2006 double vol;
2007 int j,ip;
2008 MMG5_int aux,vv[4],iel;
2009
2010 vv[0] = v0;
2011 vv[1] = v1;
2012 vv[2] = v2;
2013 vv[3] = v3;
2014
2015 for ( j=0; j<4; ++j ) {
2016 if ( vv[j] > mesh->np ) {
2017 fprintf(stderr,"\n ## Error: %s: vertex %" MMG5_PRId " doesn't exist in the mesh.\n",
2018 __func__,vv[j]);
2019 fprintf(stderr," Use the MMG3D_Add_vertex function to add it.\n");
2020 return 0;
2021 }
2022 }
2023
2024 iel = MMG3D_newElt(mesh);
2025 if ( !iel ) {
2027 fprintf(stderr,"\n ## Error: %s: unable to allocate"
2028 " a new element.\n",__func__);
2030 fprintf(stderr," Exit program.\n");
2031 return 0);
2032 }
2033
2034 pt = &mesh->tetra[iel];
2035 pt->v[0] = v0;
2036 pt->v[1] = v1;
2037 pt->v[2] = v2;
2038 pt->v[3] = v3;
2039 pt->ref = MMG5_abs(ref);
2040
2041 mesh->point[pt->v[0]].tag &= ~MG_NUL;
2042 mesh->point[pt->v[1]].tag &= ~MG_NUL;
2043 mesh->point[pt->v[2]].tag &= ~MG_NUL;
2044 mesh->point[pt->v[3]].tag &= ~MG_NUL;
2045
2046 vol = MMG5_orvol(mesh->point,pt->v);
2047 if ( fabs(vol) <= MMG5_EPSD2 ) {
2048 fprintf(stderr,"\n ## Error: %s: tetrahedron %" MMG5_PRId ": null volume.\n",
2049 __func__,iel);
2050 for ( ip=0; ip<4; ip++ ) {
2051 ppt = &mesh->point[pt->v[ip]];
2052 for ( j=0; j<3; j++ ) {
2053 if ( fabs(ppt->c[j])>0. ) {
2054 fprintf(stderr," Check that you don't have a sliver tetrahedron.\n");
2055 return -iel;
2056 }
2057 }
2058 }
2059 fprintf(stderr," All vertices have zero coordinates.");
2060 fprintf(stderr," Check that you have set the vertices before the tetrahedra.\n");
2061 return -iel;
2062 }
2063 else if ( vol < 0.0 ) {
2064 /* Possibly switch 2 vertices number so that each tet is positively oriented */
2065 aux = pt->v[2];
2066 pt->v[2] = pt->v[3];
2067 pt->v[3] = aux;
2068 /* mesh->xt temporary used to count reoriented tetra */
2069 mesh->xt++;
2070
2071 return -iel;
2072 }
2073
2074 return iel;
2075}
2076
2077MMG5_int MMG3D_Add_vertex(MMG5_pMesh mesh,double c0,double c1,double c2,MMG5_int ref) {
2078 double c[3];
2079 MMG5_int ip,klink;
2080
2081 c[0] = c0;
2082 c[1] = c1;
2083 c[2] = c2;
2084
2085 ip = MMG3D_newPt(mesh,c,0,1);
2086 if ( !ip ) {
2088 "larger point table",
2089 fprintf(stderr,"\n ## Error: %s: unable to allocate"
2090 " a new point\n",__func__);
2091 MMG5_INCREASE_MEM_MESSAGE();return 0);
2092
2093 mesh->npnil = mesh->np+1;
2094 for (klink=mesh->npnil; klink<mesh->npmax-1; klink++)
2095 mesh->point[klink].tmp = klink+1;
2096
2097 /* We try again to add the point */
2098 ip = MMG3D_newPt(mesh,c,0,1);
2099 if ( !ip ) {
2100 fprintf(stderr,"\n ## Error: %s: unable to allocate"
2101 " a new point\n",__func__);
2103 return 0;
2104 }
2105 }
2106 return ip;
2107}
2108
2109int MMG3D_Set_iparameter(MMG5_pMesh mesh, MMG5_pSol sol, int iparam,MMG5_int val){
2110 int k;
2111
2112 switch ( iparam ) {
2113 /* Integer parameters */
2115 mesh->info.imprim = val;
2116 break;
2117 case MMG3D_IPARAM_mem :
2118 if ( val <= 0 ) {
2119 fprintf(stderr,"\n ## Warning: %s: maximal memory authorized must be"
2120 " strictly positive.\n",__func__);
2121 fprintf(stderr," Reset to default value.\n");
2122 }
2123 else
2124 mesh->info.mem = val;
2125 if ( !MMG3D_memOption(mesh) ) return 0;
2126 break;
2127#ifndef MMG_PATTERN
2128 case MMG3D_IPARAM_octree :
2129 mesh->info.PROctree = val;
2130 break;
2131#endif
2132 case MMG3D_IPARAM_debug :
2133 mesh->info.ddebug = val;
2134 break;
2135 case MMG3D_IPARAM_angle :
2136 /* free table that may contains old ridges */
2137 if ( mesh->htab.geom )
2139 if ( mesh->xpoint )
2141 if ( mesh->xtetra )
2143 if ( !val )
2144 mesh->info.dhd = -1.;
2145 else {
2146 if ( (mesh->info.imprim > 5) || mesh->info.ddebug )
2147 fprintf(stderr,"\n ## Warning: %s: angle detection parameter set"
2148 " to default value\n",__func__);
2150 }
2151 break;
2152 case MMG3D_IPARAM_nofem :
2153 mesh->info.setfem = (val==1)? 0 : 1;
2154 break;
2155 case MMG3D_IPARAM_opnbdy :
2156 mesh->info.opnbdy = val;
2157 break;
2158 case MMG3D_IPARAM_iso :
2159 mesh->info.iso = val;
2160 if ( mesh->info.iso )
2161 if ( mesh->nt && !MMG3D_skipIso(mesh) )
2162 return 0;
2163 break;
2164 case MMG3D_IPARAM_isoref :
2165 mesh->info.isoref = val;
2166 break;
2168 mesh->info.isosurf = val;
2169 break;
2170 case MMG3D_IPARAM_lag :
2171#ifdef USE_ELAS
2172 if ( val < 0 || val > 2 )
2173 return 0;
2174 mesh->info.lag = val;
2175 /* No connectivity changes unless lag >= 2 */
2176 if ( val < 2 ) {
2178 return 0;
2179 }
2180#else
2181 fprintf(stderr,"\n ## Error: %s"
2182 " \"lagrangian motion\" option unavailable (-lag):\n"
2183 " set the USE_ELAS CMake's flag to ON when compiling the mmg3d"
2184 " library to enable this feature.\n",__func__);
2185 return 0;
2186#endif
2187 break;
2189 mesh->info.nsd = val;
2190 break;
2191 case MMG3D_IPARAM_optim :
2192 mesh->info.optim = val;
2193 break;
2195 mesh->info.optimLES = val;
2196 break;
2198 mesh->info.noinsert = val;
2199 break;
2200 case MMG3D_IPARAM_noswap :
2201 mesh->info.noswap = val;
2202 break;
2203 case MMG3D_IPARAM_nomove :
2204 mesh->info.nomove = val;
2205 break;
2206 case MMG3D_IPARAM_nosurf :
2207 mesh->info.nosurf = val;
2208 break;
2209 case MMG3D_IPARAM_nreg :
2210 mesh->info.nreg = val;
2211 break;
2212 case MMG3D_IPARAM_xreg :
2213 mesh->info.xreg = val;
2214 break;
2216 mesh->info.nosizreq = val;
2217 break;
2219 if ( mesh->info.par ) {
2221 if ( (mesh->info.imprim > 5) || mesh->info.ddebug )
2222 fprintf(stderr,"\n ## Warning: %s: new local parameter values\n",__func__);
2223 }
2224 mesh->info.npar = val;
2225 mesh->info.npari = 0;
2226 mesh->info.parTyp = 0;
2227
2228 MMG5_ADD_MEM(mesh,mesh->info.npar*sizeof(MMG5_Par),"parameters",
2229 printf(" Exit program.\n");
2230 return 0);
2232
2233 for (k=0; k<mesh->info.npar; k++) {
2235 mesh->info.par[k].ref = INT_MAX;
2236 mesh->info.par[k].hausd = mesh->info.hausd;
2237 mesh->info.par[k].hmin = mesh->info.hmin;
2238 mesh->info.par[k].hmax = mesh->info.hmax;
2239 }
2240
2241 break;
2243 mesh->info.nbr = val;
2244 MMG5_ADD_MEM(mesh,mesh->info.nbr*sizeof(int),"References",
2245 printf(" Exit program.\n");
2246 return 0);
2247 MMG5_SAFE_CALLOC(mesh->info.br,mesh->info.nbr,MMG5_int,return 0);
2248
2249 for (k=0; k<mesh->info.nbr; k++)
2250 mesh->info.br[k] = 0;
2251
2252 break;
2253
2255 if ( mesh->info.mat ) {
2257 if ( (mesh->info.imprim > 5) || mesh->info.ddebug )
2258 fprintf(stderr,"\n ## Warning: %s: new multi materials values\n",__func__);
2259 }
2260 mesh->info.nmat = val;
2261 mesh->info.nmati = 0;
2262
2263 MMG5_ADD_MEM(mesh,(mesh->info.nmat)*sizeof(MMG5_Mat),"multi material",
2264 printf(" Exit program.\n");
2265 return 0);
2267 for (k=0; k<mesh->info.nmat; k++) {
2268 mesh->info.mat[k].ref = 0;
2269 }
2270
2271 break;
2272
2273#ifdef USE_SCOTCH
2274 case MMG3D_IPARAM_renum :
2275 mesh->info.renum = val;
2276 break;
2277#endif
2279 mesh->info.ani = val;
2280 break;
2281 default :
2282 fprintf(stderr,"\n ## Error: %s: unknown type of parameter\n",__func__);
2283 return 0;
2284 }
2285 /* other options */
2286
2287 return 1;
2288}
2289
2290int MMG3D_Get_iparameter(MMG5_pMesh mesh, MMG5_int iparam) {
2291
2292 switch ( iparam ) {
2293 /* Integer parameters */
2295 return mesh->info.imprim;
2296 break;
2297 case MMG3D_IPARAM_mem :
2298 return mesh->info.mem;
2299 break;
2300#ifndef MMG_PATTERN
2301 case MMG3D_IPARAM_octree :
2302 return mesh->info.PROctree;
2303 break;
2304#endif
2305 case MMG3D_IPARAM_debug :
2306 return mesh->info.ddebug;
2307 break;
2308 case MMG3D_IPARAM_angle :
2309 if ( mesh->info.dhd <= 0. ) {
2310 return 0;
2311 }
2312 else {
2313 return 1;
2314 }
2315 break;
2316 case MMG3D_IPARAM_iso :
2317 return mesh->info.iso;
2318 break;
2319 case MMG3D_IPARAM_lag :
2320 return mesh->info.lag;
2321 break;
2323 return mesh->info.noinsert;
2324 break;
2325 case MMG3D_IPARAM_noswap :
2326 return mesh->info.noswap;
2327 break;
2328 case MMG3D_IPARAM_nomove :
2329 return mesh->info.nomove;
2330 break;
2331 case MMG3D_IPARAM_nosurf :
2332 return mesh->info.nosurf;
2333 break;
2334 case MMG3D_IPARAM_nreg :
2335 return mesh->info.nreg;
2336 break;
2337 case MMG3D_IPARAM_xreg :
2338 return mesh->info.xreg;
2339 break;
2341 return mesh->info.npar;
2342 break;
2344 return mesh->info.nmat;
2345 break;
2346#ifdef USE_SCOTCH
2347 case MMG3D_IPARAM_renum :
2348 return mesh->info.renum;
2349 break;
2350#endif
2351 default :
2352 fprintf(stderr,"\n ## Error: %s: unknown type of parameter\n",__func__);
2353 return 0;
2354 }
2355}
2356
2357int MMG3D_Set_dparameter(MMG5_pMesh mesh, MMG5_pSol sol, int dparam, double val){
2358
2359 switch ( dparam ) {
2360 /* double parameters */
2362 mesh->info.dhd = val;
2363 mesh->info.dhd = MG_MAX(0.0, MG_MIN(180.0,mesh->info.dhd));
2364 mesh->info.dhd = cos(mesh->info.dhd*M_PI/180.0);
2365 break;
2366 case MMG3D_DPARAM_hmin :
2367 mesh->info.sethmin = 1;
2368 mesh->info.hmin = val;
2369 if ( mesh->info.sethmax && ( mesh->info.hmin >= mesh->info.hmax ) ) {
2370 fprintf(stderr,"\n ## Warning: hmin value must be strictly lower than hmax one"
2371 " (hmin = %lf hmax = %lf ).\n",mesh->info.hmin, mesh->info.hmax);
2372 }
2373
2374 break;
2375 case MMG3D_DPARAM_hmax :
2376 mesh->info.sethmax = 1;
2377 mesh->info.hmax = val;
2378 if ( mesh->info.sethmin && ( mesh->info.hmin >= mesh->info.hmax ) ) {
2379 fprintf(stderr,"\n ## Warning: hmin value must be strictly lower than hmax one"
2380 " (hmin = %lf hmax = %lf ).\n",mesh->info.hmin, mesh->info.hmax);
2381 }
2382
2383 break;
2384 case MMG3D_DPARAM_hsiz :
2385 mesh->info.hsiz = val;
2386 break;
2387 case MMG3D_DPARAM_hgrad :
2388 mesh->info.hgrad = val;
2389 if ( mesh->info.hgrad <= 0.0 )
2390 mesh->info.hgrad = -1.0;
2391 else
2392 mesh->info.hgrad = log(mesh->info.hgrad);
2393 break;
2395 mesh->info.hgradreq = val;
2396 if ( mesh->info.hgradreq <= 0.0 )
2397 mesh->info.hgradreq = -1.0;
2398 else
2400 break;
2401 case MMG3D_DPARAM_hausd :
2402 if ( val <=0 ) {
2403 fprintf(stderr,"\n ## Error: %s: hausdorff number must be strictly"
2404 " positive.\n",__func__);
2405 return 0;
2406 }
2407 else
2408 mesh->info.hausd = val;
2409 break;
2410 case MMG3D_DPARAM_ls :
2411 mesh->info.ls = val;
2412 break;
2413 case MMG3D_DPARAM_rmc :
2414 if ( !val ) {
2415 /* Default value */
2417 }
2418 else {
2419 /* User customized value */
2420 mesh->info.rmc = val;
2421 }
2422 break;
2423 default :
2424 fprintf(stderr,"\n ## Error: %s: unknown type of parameter\n", __func__);
2425 return 0;
2426 }
2427 return 1;
2428}
2429
2431 double hmin,double hmax,double hausd){
2432 MMG5_pPar par;
2433 int k;
2434
2435 if ( !mesh->info.npar ) {
2436 fprintf(stderr,"\n ## Error: %s: You must set the number of local"
2437 " parameters",__func__);
2438 fprintf(stderr," with the MMG3D_Set_iparameters function before setting");
2439 fprintf(stderr," values in local parameters structure. \n");
2440 return 0;
2441 }
2442 if ( mesh->info.npari >= mesh->info.npar ) {
2443 fprintf(stderr,"\n ## Error: %s: unable to set a new local parameter.\n",
2444 __func__);
2445 fprintf(stderr," max number of local parameters: %d\n",mesh->info.npar);
2446 return 0;
2447 }
2448 if ( typ != MMG5_Triangle && typ != MMG5_Tetrahedron ) {
2449 fprintf(stderr,"\n ## Warning: %s: you must apply your local parameters",
2450 __func__);
2451 fprintf(stderr," on triangles (MMG5_Triangle or %d) or tetrahedron"
2452 " (MMG5_Tetrahedron or %d).\n",MMG5_Triangle,MMG5_Tetrahedron);
2453 fprintf(stderr,"\n ## Unknown type of entity: ignored.\n");
2454 return 0;
2455 }
2456 if ( ref < 0 ) {
2457 fprintf(stderr,"\n ## Error: %s: negative references are not allowed.\n",
2458 __func__);
2459 return 0;
2460 }
2461
2462 if ( hmin <= 0 ) {
2463 fprintf(stderr,"\n ## Error: %s: negative hmin value is not allowed.\n",
2464 __func__);
2465 return 0;
2466 }
2467 if ( hmax <= 0 ) {
2468 fprintf(stderr,"\n ## Error: %s: negative hmax value is not allowed.\n",
2469 __func__);
2470 return 0;
2471 }
2472 if ( hausd <= 0 ) {
2473 fprintf(stderr,"\n ## Error: %s: negative hausd value is not allowed.\n",
2474 __func__);
2475 return 0;
2476 }
2477
2478 for (k=0; k<mesh->info.npari; k++) {
2479 par = &mesh->info.par[k];
2480
2481 if ( par->elt == typ && par->ref == ref ) {
2482 par->hausd = hausd;
2483 par->hmin = hmin;
2484 par->hmax = hmax;
2485 if ( (mesh->info.imprim > 5) || mesh->info.ddebug ) {
2486 fprintf(stderr,"\n ## Warning: %s: new parameters (hausd, hmin and hmax)",
2487 __func__);
2488 fprintf(stderr," for entities of type %d and of ref %" MMG5_PRId "\n",typ,ref);
2489 }
2490 return 1;
2491 }
2492 }
2493
2494 mesh->info.par[mesh->info.npari].elt = typ;
2495 mesh->info.par[mesh->info.npari].ref = ref;
2496 mesh->info.par[mesh->info.npari].hmin = hmin;
2497 mesh->info.par[mesh->info.npari].hmax = hmax;
2498 mesh->info.par[mesh->info.npari].hausd = hausd;
2499
2500 switch ( typ )
2501 {
2502 case ( MMG5_Triangle ):
2503 mesh->info.parTyp |= MG_Tria;
2504 break;
2505 case ( MMG5_Tetrahedron ):
2507 break;
2508 default:
2509 fprintf(stderr,"\n ## Error: %s: unexpected entity type: %s.\n",
2510 __func__,MMG5_Get_entitiesName(typ));
2511 return 0;
2512 }
2513
2514 mesh->info.npari++;
2515
2516 return 1;
2517}
2518
2519int MMG3D_Set_multiMat(MMG5_pMesh mesh,MMG5_pSol sol,MMG5_int ref,int split,MMG5_int rin,MMG5_int rout) {
2520 return MMG5_Set_multiMat(mesh,sol,ref,split,rin,rout);
2521}
2522
2525}
2526
2527
2529
2530 return MMG5_Free_allSols(mesh,sol);
2531}
2532
2533int MMG3D_Free_all(const int starter,...)
2534{
2535 va_list argptr;
2536 int ier;
2537
2539
2541
2542 va_end(argptr);
2543
2544 return ier;
2545}
2546
2548{
2549 va_list argptr;
2550 int ier;
2551
2553
2555
2556 va_end(argptr);
2557
2558 return ier;
2559}
2560
2561int MMG3D_Free_names(const int starter,...)
2562{
2563 va_list argptr;
2564 int ier;
2565
2567
2569
2570 va_end(argptr);
2571
2572 return ier;
2573}
const char * MMG5_Get_typeName(enum MMG5_type typ)
int MMG5_Set_outputMeshName(MMG5_pMesh mesh, const char *meshout)
int MMG5_Set_inputSolName(MMG5_pMesh mesh, MMG5_pSol sol, const char *solin)
int MMG5_Free_allSols(MMG5_pMesh mesh, MMG5_pSol *sol)
int MMG5_Set_inputMeshName(MMG5_pMesh mesh, const char *meshin)
void MMG5_Init_parameters(MMG5_pMesh mesh)
Definition: API_functions.c:51
const char * MMG5_Get_entitiesName(enum MMG5_entities ent)
void MMG5_Init_fileNames(MMG5_pMesh mesh, MMG5_pSol sol)
int MMG5_Set_outputSolName(MMG5_pMesh mesh, MMG5_pSol sol, const char *solout)
int MMG3D_Init_mesh(const int starter,...)
int MMG3D_Set_vectorSol(MMG5_pSol met, double vx, double vy, double vz, MMG5_int pos)
int MMG3D_Unset_requiredEdge(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_GetByIdx_vertex(MMG5_pMesh mesh, double *c0, double *c1, double *c2, MMG5_int *ref, int *isCorner, int *isRequired, MMG5_int idx)
int MMG3D_Get_vectorSol(MMG5_pSol met, double *vx, double *vy, double *vz)
int MMG3D_Get_vertices(MMG5_pMesh mesh, double *vertices, MMG5_int *refs, int *areCorners, int *areRequired)
int MMG3D_Get_prism(MMG5_pMesh mesh, MMG5_int *v0, MMG5_int *v1, MMG5_int *v2, MMG5_int *v3, MMG5_int *v4, MMG5_int *v5, MMG5_int *ref, int *isRequired)
int MMG3D_Set_multiMat(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int ref, int split, MMG5_int rin, MMG5_int rout)
int MMG3D_Get_normalAtVertex(MMG5_pMesh mesh, MMG5_int k, double *n0, double *n1, double *n2)
int MMG3D_Set_triangles(MMG5_pMesh mesh, MMG5_int *tria, MMG5_int *refs)
int MMG3D_Unset_corner(MMG5_pMesh mesh, MMG5_int k)
void MMG3D_Init_fileNames(MMG5_pMesh mesh, MMG5_pSol sol)
int MMG3D_Set_quadrilateral(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int v3, MMG5_int ref, MMG5_int pos)
int MMG3D_Unset_ridge(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Set_corner(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Get_edge(MMG5_pMesh mesh, MMG5_int *e0, MMG5_int *e1, MMG5_int *ref, int *isRidge, int *isRequired)
int MMG3D_Set_inputMeshName(MMG5_pMesh mesh, const char *meshin)
int MMG3D_Set_ithSols_inSolsAtVertices(MMG5_pSol sol, int i, double *s)
int MMG3D_Get_prisms(MMG5_pMesh mesh, MMG5_int *prisms, MMG5_int *refs, int *areRequired)
int MMG3D_Set_edges(MMG5_pMesh mesh, MMG5_int *edges, MMG5_int *refs)
int MMG3D_Set_tensorSols(MMG5_pSol met, double *sols)
int MMG3D_Set_requiredTetrahedron(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Get_triangle(MMG5_pMesh mesh, MMG5_int *v0, MMG5_int *v1, MMG5_int *v2, MMG5_int *ref, int *isRequired)
double MMG3D_Get_tetrahedronQuality(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k)
int MMG3D_Set_dparameter(MMG5_pMesh mesh, MMG5_pSol sol, int dparam, double val)
int MMG3D_Get_tensorSol(MMG5_pSol met, double *m11, double *m12, double *m13, double *m22, double *m23, double *m33)
int MMG3D_Set_localParameter(MMG5_pMesh mesh, MMG5_pSol sol, int typ, MMG5_int ref, double hmin, double hmax, double hausd)
int MMG3D_Set_tetrahedron(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int v3, MMG5_int ref, MMG5_int pos)
int MMG3D_Set_triangle(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int ref, MMG5_int pos)
int MMG3D_Get_tetrahedron(MMG5_pMesh mesh, MMG5_int *v0, MMG5_int *v1, MMG5_int *v2, MMG5_int *v3, MMG5_int *ref, int *isRequired)
int MMG3D_Set_scalarSols(MMG5_pSol met, double *s)
int MMG3D_Get_quadrilaterals(MMG5_pMesh mesh, MMG5_int *quads, MMG5_int *refs, int *areRequired)
int MMG3D_Get_solSize(MMG5_pMesh mesh, MMG5_pSol sol, int *typEntity, MMG5_int *np, int *typSol)
int MMG3D_Set_edge(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int ref, MMG5_int pos)
int MMG3D_Get_ithSol_inSolsAtVertices(MMG5_pSol sol, int i, double *s, MMG5_int pos)
int MMG3D_Set_scalarSol(MMG5_pSol met, double s, MMG5_int pos)
int MMG3D_Free_allSols(MMG5_pMesh mesh, MMG5_pSol *sol)
int MMG3D_Get_vectorSols(MMG5_pSol met, double *sols)
int MMG3D_Set_quadrilaterals(MMG5_pMesh mesh, MMG5_int *quads, MMG5_int *refs)
int MMG3D_Get_vertex(MMG5_pMesh mesh, double *c0, double *c1, double *c2, MMG5_int *ref, int *isCorner, int *isRequired)
int MMG3D_Set_ithSol_inSolsAtVertices(MMG5_pSol sol, int i, double *s, MMG5_int pos)
int MMG3D_Get_edges(MMG5_pMesh mesh, MMG5_int *edges, MMG5_int *refs, int *areRidges, int *areRequired)
int MMG3D_Get_tensorSols(MMG5_pSol met, double *sols)
int MMG3D_Set_lsBaseReference(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int br)
int MMG3D_Set_parallelTriangles(MMG5_pMesh mesh, MMG5_int *parIdx, MMG5_int npar)
int MMG3D_Set_vectorSols(MMG5_pSol met, double *sols)
void MMG3D_Set_handGivenMesh(MMG5_pMesh mesh)
int MMG3D_Set_requiredVertex(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Set_inputSolName(MMG5_pMesh mesh, MMG5_pSol sol, const char *solin)
int MMG3D_Unset_requiredTriangles(MMG5_pMesh mesh, MMG5_int *reqIdx, MMG5_int nreq)
int MMG3D_Unset_requiredTetrahedra(MMG5_pMesh mesh, MMG5_int *reqIdx, MMG5_int nreq)
int MMG3D_Set_requiredTriangle(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Set_vertices(MMG5_pMesh mesh, double *vertices, MMG5_int *refs)
int MMG3D_Free_structures(const int starter,...)
int MMG3D_Add_tetrahedron(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int v3, MMG5_int ref)
int MMG3D_Set_ridge(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Set_solsAtVerticesSize(MMG5_pMesh mesh, MMG5_pSol *sol, int nsols, MMG5_int nentities, int *typSol)
int MMG3D_Free_names(const int starter,...)
int MMG3D_Set_outputSolName(MMG5_pMesh mesh, MMG5_pSol sol, const char *solout)
int MMG3D_Get_iparameter(MMG5_pMesh mesh, MMG5_int iparam)
int MMG3D_Set_outputMeshName(MMG5_pMesh mesh, const char *meshout)
int MMG3D_Set_parallelTriangle(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Set_prism(MMG5_pMesh mesh, MMG5_int v0, MMG5_int v1, MMG5_int v2, MMG5_int v3, MMG5_int v4, MMG5_int v5, MMG5_int ref, MMG5_int pos)
int MMG3D_Get_ithSols_inSolsAtVertices(MMG5_pSol sol, int i, double *s)
int MMG3D_setMeshSize_initData(MMG5_pMesh mesh, MMG5_int np, MMG5_int ne, MMG5_int nprism, MMG5_int nt, MMG5_int nquad, MMG5_int na)
int MMG3D_Chk_meshData(MMG5_pMesh mesh, MMG5_pSol met)
int MMG3D_Get_scalarSols(MMG5_pSol met, double *s)
MMG5_int MMG3D_Add_vertex(MMG5_pMesh mesh, double c0, double c1, double c2, MMG5_int ref)
int MMG3D_Get_solsAtVerticesSize(MMG5_pMesh mesh, MMG5_pSol *sol, int *nsols, MMG5_int *np, int *typSol)
int MMG3D_Get_triangles(MMG5_pMesh mesh, MMG5_int *tria, MMG5_int *refs, int *areRequired)
int MMG3D_Unset_parallelTriangle(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Set_tensorSol(MMG5_pSol met, double m11, double m12, double m13, double m22, double m23, double m33, MMG5_int pos)
int MMG3D_Get_quadrilateral(MMG5_pMesh mesh, MMG5_int *v0, MMG5_int *v1, MMG5_int *v2, MMG5_int *v3, MMG5_int *ref, int *isRequired)
int MMG3D_Get_tetrahedra(MMG5_pMesh mesh, MMG5_int *tetra, MMG5_int *refs, int *areRequired)
int MMG3D_Set_vertex(MMG5_pMesh mesh, double c0, double c1, double c2, MMG5_int ref, MMG5_int pos)
int MMG3D_Get_scalarSol(MMG5_pSol met, double *s)
int MMG3D_Get_meshSize(MMG5_pMesh mesh, MMG5_int *np, MMG5_int *ne, MMG5_int *nprism, MMG5_int *nt, MMG5_int *nquad, MMG5_int *na)
int MMG3D_Set_prisms(MMG5_pMesh mesh, MMG5_int *prisms, MMG5_int *refs)
void MMG3D_Init_parameters(MMG5_pMesh mesh)
int MMG3D_Free_all(const int starter,...)
int MMG3D_Set_iparameter(MMG5_pMesh mesh, MMG5_pSol sol, int iparam, MMG5_int val)
int MMG3D_Unset_requiredTetrahedron(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Unset_requiredVertex(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Set_normalAtVertex(MMG5_pMesh mesh, MMG5_int k, double n0, double n1, double n2)
int MMG3D_Set_requiredEdge(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Set_meshSize(MMG5_pMesh mesh, MMG5_int np, MMG5_int ne, MMG5_int nprism, MMG5_int nt, MMG5_int nquad, MMG5_int na)
int MMG3D_Unset_requiredTriangle(MMG5_pMesh mesh, MMG5_int k)
int MMG3D_Unset_parallelTriangles(MMG5_pMesh mesh, MMG5_int *parIdx, MMG5_int npar)
int MMG3D_Set_requiredTriangles(MMG5_pMesh mesh, MMG5_int *reqIdx, MMG5_int nreq)
int MMG3D_Set_requiredTetrahedra(MMG5_pMesh mesh, MMG5_int *reqIdx, MMG5_int nreq)
int MMG3D_Set_solSize(MMG5_pMesh mesh, MMG5_pSol sol, int typEntity, MMG5_int np, int typSol)
int MMG3D_Set_tetrahedra(MMG5_pMesh mesh, MMG5_int *tetra, MMG5_int *refs)
static int MMG3D_skipIso(MMG5_pMesh mesh)
int ier
const int starter
MMG5_pMesh MMG5_pSol * sol
if(!ier) exit(EXIT_FAILURE)
va_start(argptr, starter)
MMG5_pMesh char * meshin
MMG5_pMesh * mesh
va_end(argptr)
const int va_list argptr
static double MMG5_caltet_iso(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTetra pt)
static double MMG5_caltet_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTetra pt)
static double MMG3D_caltetLES_iso(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTetra pt)
API headers for the mmg3d library.
@ MMG3D_DPARAM_hmin
Definition: libmmg3d.h:97
@ MMG3D_IPARAM_debug
Definition: libmmg3d.h:72
@ MMG3D_IPARAM_numberOfLocalParam
Definition: libmmg3d.h:87
@ MMG3D_IPARAM_isoref
Definition: libmmg3d.h:95
@ MMG3D_IPARAM_noswap
Definition: libmmg3d.h:82
@ MMG3D_IPARAM_opnbdy
Definition: libmmg3d.h:77
@ MMG3D_DPARAM_angleDetection
Definition: libmmg3d.h:96
@ MMG3D_DPARAM_hsiz
Definition: libmmg3d.h:99
@ MMG3D_IPARAM_isosurf
Definition: libmmg3d.h:75
@ MMG3D_DPARAM_hausd
Definition: libmmg3d.h:100
@ MMG3D_IPARAM_nosurf
Definition: libmmg3d.h:84
@ MMG3D_IPARAM_anisosize
Definition: libmmg3d.h:92
@ MMG3D_IPARAM_nomove
Definition: libmmg3d.h:83
@ MMG3D_IPARAM_renum
Definition: libmmg3d.h:91
@ MMG3D_DPARAM_hgrad
Definition: libmmg3d.h:101
@ MMG3D_IPARAM_nosizreq
Definition: libmmg3d.h:94
@ MMG3D_DPARAM_rmc
Definition: libmmg3d.h:104
@ MMG3D_IPARAM_angle
Definition: libmmg3d.h:73
@ MMG3D_IPARAM_noinsert
Definition: libmmg3d.h:81
@ MMG3D_DPARAM_ls
Definition: libmmg3d.h:103
@ MMG3D_DPARAM_hgradreq
Definition: libmmg3d.h:102
@ MMG3D_IPARAM_xreg
Definition: libmmg3d.h:86
@ MMG3D_DPARAM_hmax
Definition: libmmg3d.h:98
@ MMG3D_IPARAM_numsubdomain
Definition: libmmg3d.h:90
@ MMG3D_IPARAM_lag
Definition: libmmg3d.h:78
@ MMG3D_IPARAM_nreg
Definition: libmmg3d.h:85
@ MMG3D_IPARAM_numberOfMat
Definition: libmmg3d.h:89
@ MMG3D_IPARAM_verbose
Definition: libmmg3d.h:70
@ MMG3D_IPARAM_numberOfLSBaseReferences
Definition: libmmg3d.h:88
@ MMG3D_IPARAM_optimLES
Definition: libmmg3d.h:80
@ MMG3D_IPARAM_optim
Definition: libmmg3d.h:79
@ MMG3D_IPARAM_iso
Definition: libmmg3d.h:74
@ MMG3D_IPARAM_octree
Definition: libmmg3d.h:93
@ MMG3D_IPARAM_nofem
Definition: libmmg3d.h:76
@ MMG3D_IPARAM_mem
Definition: libmmg3d.h:71
MMG5_int MMG3D_newPt(MMG5_pMesh mesh, double c[3], int16_t tag, MMG5_int src)
Definition: zaldy_3d.c:39
#define MMG3D_ALPHAD
MMG5_int MMG3D_newElt(MMG5_pMesh mesh)
Definition: zaldy_3d.c:99
int MMG3D_Free_all_var(va_list argptr)
Definition: variadic_3d.c:261
int MMG3D_Free_structures_var(va_list argptr)
Definition: variadic_3d.c:449
double MMG5_caltet33_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTetra pt)
Definition: quality_3d.c:109
int MMG3D_Free_names_var(va_list argptr)
Definition: variadic_3d.c:547
#define MMG3D_VOLFRAC
int MMG3D_Init_mesh_var(va_list argptr)
Definition: variadic_3d.c:177
#define MMG3D_TETRA_REALLOC(mesh, jel, wantedGap, law)
int MMG3D_memOption(MMG5_pMesh mesh)
Definition: zaldy_3d.c:271
int MMG3D_setMeshSize_alloc(MMG5_pMesh)
Definition: zaldy_3d.c:288
LIBMMG_CORE_EXPORT int MMG5_Set_multiMat(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int ref, int split, MMG5_int rin, MMG5_int rex)
Definition: libtools.c:102
LIBMMG_CORE_EXPORT int MMG5_Set_lsBaseReference(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int br)
Definition: libtools.c:174
@ MMG5_Vector
Definition: libmmgtypes.h:214
@ MMG5_Tensor
Definition: libmmgtypes.h:215
@ MMG5_Scalar
Definition: libmmgtypes.h:213
@ MMG5_Notype
Definition: libmmgtypes.h:212
@ MMG5_Noentity
Definition: libmmgtypes.h:223
@ MMG5_Vertex
Definition: libmmgtypes.h:224
@ MMG5_Tetrahedron
Definition: libmmgtypes.h:227
@ MMG5_Triangle
Definition: libmmgtypes.h:226
#define MG_Tria
#define MG_REQ
#define MG_GEO
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MG_EOK(pt)
#define MG_NUL
#define MMG5_INCREASE_MEM_MESSAGE()
#define MMG5_ON
#define MG_PARBDY
#define MMG5_LAG
#define MMG5_PROCTREE
#define MG_MIN(a, b)
#define MG_MAX(a, b)
#define MMG5_ADD_MEM(mesh, size, message, law)
#define MMG5_TAB_RECALLOC(mesh, ptr, initSize, wantedGap, type, message, law)
#define MG_Tetra
#define MMG5_LS
#define MMG5_OFF
#define MG_CRN
double MMG5_orvol(MMG5_pPoint point, MMG5_int *v)
Definition: tools.c:951
#define MMG5_ANGEDG
#define MMG5_EPSD2
#define MG_REF
#define MMG5_FEM
#define MMG5_DEL_MEM(mesh, ptr)
#define MMG5_SAFE_RECALLOC(ptr, prevSize, newSize, type, message, law)
Structure to store edges of a MMG mesh.
Definition: libmmgtypes.h:305
MMG5_int b
Definition: libmmgtypes.h:306
MMG5_int ref
Definition: libmmgtypes.h:307
int16_t tag
Definition: libmmgtypes.h:310
MMG5_int a
Definition: libmmgtypes.h:306
MMG5_hgeom * geom
Definition: libmmgtypes.h:575
int8_t iso
Definition: libmmgtypes.h:534
int8_t parTyp
Definition: libmmgtypes.h:541
int8_t ddebug
Definition: libmmgtypes.h:532
double hsiz
Definition: libmmgtypes.h:518
int8_t isosurf
Definition: libmmgtypes.h:535
int8_t sethmin
Definition: libmmgtypes.h:544
MMG5_int * br
Definition: libmmgtypes.h:520
uint8_t ani
Definition: libmmgtypes.h:546
uint8_t noswap
Definition: libmmgtypes.h:546
double rmc
Definition: libmmgtypes.h:519
double hmin
Definition: libmmgtypes.h:518
int8_t setfem
Definition: libmmgtypes.h:536
MMG5_pMat mat
Definition: libmmgtypes.h:554
double hgrad
Definition: libmmgtypes.h:518
uint8_t noinsert
Definition: libmmgtypes.h:546
MMG5_int isoref
Definition: libmmgtypes.h:521
uint8_t metRidTyp
Definition: libmmgtypes.h:547
double hmax
Definition: libmmgtypes.h:518
int PROctree
Definition: libmmgtypes.h:527
double ls
Definition: libmmgtypes.h:519
uint8_t nomove
Definition: libmmgtypes.h:546
uint8_t optimLES
Definition: libmmgtypes.h:546
int8_t lag
Definition: libmmgtypes.h:540
MMG5_int nsd
Definition: libmmgtypes.h:522
uint8_t nosurf
Definition: libmmgtypes.h:546
int8_t sethmax
Definition: libmmgtypes.h:545
uint8_t nosizreq
Definition: libmmgtypes.h:546
MMG5_pPar par
Definition: libmmgtypes.h:517
uint8_t optim
Definition: libmmgtypes.h:546
double dhd
Definition: libmmgtypes.h:518
double hgradreq
Definition: libmmgtypes.h:518
double hausd
Definition: libmmgtypes.h:518
int8_t xreg
Definition: libmmgtypes.h:531
int8_t nreg
Definition: libmmgtypes.h:530
To store user-defined references in the mesh (useful in LS mode)
Definition: libmmgtypes.h:495
MMG5_int ref
Definition: libmmgtypes.h:497
MMG mesh structure.
Definition: libmmgtypes.h:605
MMG5_int ntmax
Definition: libmmgtypes.h:612
MMG5_pQuad quadra
Definition: libmmgtypes.h:648
MMG5_int nc1
Definition: libmmgtypes.h:615
MMG5_Info info
Definition: libmmgtypes.h:651
MMG5_int xt
Definition: libmmgtypes.h:620
MMG5_int ne
Definition: libmmgtypes.h:612
MMG5_pPoint point
Definition: libmmgtypes.h:641
MMG5_pPrism prism
Definition: libmmgtypes.h:645
MMG5_int nquad
Definition: libmmgtypes.h:613
MMG5_int nemax
Definition: libmmgtypes.h:612
MMG5_int npmax
Definition: libmmgtypes.h:612
MMG5_pxPoint xpoint
Definition: libmmgtypes.h:642
MMG5_HGeom htab
Definition: libmmgtypes.h:650
MMG5_int xp
Definition: libmmgtypes.h:620
double gap
Definition: libmmgtypes.h:608
MMG5_int namax
Definition: libmmgtypes.h:612
MMG5_int nei
Definition: libmmgtypes.h:612
MMG5_pTetra tetra
Definition: libmmgtypes.h:643
MMG5_int nt
Definition: libmmgtypes.h:612
MMG5_pTria tria
Definition: libmmgtypes.h:647
MMG5_int np
Definition: libmmgtypes.h:612
MMG5_pEdge edge
Definition: libmmgtypes.h:649
MMG5_int nti
Definition: libmmgtypes.h:612
MMG5_int npi
Definition: libmmgtypes.h:612
MMG5_pxTetra xtetra
Definition: libmmgtypes.h:644
MMG5_int nai
Definition: libmmgtypes.h:612
MMG5_int nprism
Definition: libmmgtypes.h:613
MMG5_int na
Definition: libmmgtypes.h:612
MMG5_int npnil
Definition: libmmgtypes.h:621
double hmin
Definition: libmmgtypes.h:258
double hmax
Definition: libmmgtypes.h:259
double hausd
Definition: libmmgtypes.h:260
MMG5_int ref
Definition: libmmgtypes.h:261
int8_t elt
Definition: libmmgtypes.h:262
Structure to store points of a MMG mesh.
Definition: libmmgtypes.h:270
double n[3]
Definition: libmmgtypes.h:272
int16_t tag
Definition: libmmgtypes.h:284
MMG5_int tmp
Definition: libmmgtypes.h:280
double c[3]
Definition: libmmgtypes.h:271
MMG5_int ref
Definition: libmmgtypes.h:278
MMG5_int flag
Definition: libmmgtypes.h:282
MMG5_int v[6]
Definition: libmmgtypes.h:463
int8_t tag
Definition: libmmgtypes.h:469
MMG5_int ref
Definition: libmmgtypes.h:464
MMG5_int ref
Definition: libmmgtypes.h:368
int16_t tag[4]
Definition: libmmgtypes.h:372
MMG5_int v[4]
Definition: libmmgtypes.h:367
MMG5_int npi
Definition: libmmgtypes.h:667
MMG5_int npmax
Definition: libmmgtypes.h:666
double * m
Definition: libmmgtypes.h:671
MMG5_int np
Definition: libmmgtypes.h:665
MMG5_int v[4]
Definition: libmmgtypes.h:403
MMG5_int ref
Definition: libmmgtypes.h:404
int16_t tag
Definition: libmmgtypes.h:410
int16_t tag[3]
Definition: libmmgtypes.h:342
MMG5_int ref
Definition: libmmgtypes.h:335
MMG5_int v[3]
Definition: libmmgtypes.h:334