Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
mmg3.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
34#include "mmgcommon_private.h"
35
49short MMG5_dikmov ( MMG5_pMesh mesh,MMG5_pSol disp,short *lastt,short shortmax,
50 MMG5_int chkmovmesh(MMG5_pMesh,MMG5_pSol,short,MMG5_int*) ) {
51 int it,maxit;
52 short t,tmin,tmax;
53 int8_t ier;
54
55 maxit = 200;
56 it = 0;
57
58 tmin = 0;
59 tmax = shortmax;
60
61 *lastt = 0;
62
63 /* If full displacement can be achieved */
64 if ( !chkmovmesh(mesh,disp,tmax,NULL) )
65 return tmax;
66
67 /* Else, find the largest displacement by dichotomy */
68 assert ( tmax > tmin && "t will be used uninitialized if we don't enter next loop");
69
70 while( tmin != tmax && it < maxit ) {
71 t = (tmin+tmax)/2;
72
73 /* Case that tmax = tmin +1 : check move with tmax */
74 if ( t == tmin ) {
75 ier = chkmovmesh(mesh,disp,tmax,NULL);
76 if ( !ier ) {
77 return tmax;
78 }
79 else {
80 if ( tmin==0 ) {
81 *lastt = tmax;
82 }
83 return tmin;
84 }
85 }
86
87 /* General case: check move with t */
88 ier = chkmovmesh(mesh,disp,t,NULL);
89 if ( !ier ) {
90 tmin = t;
91 }
92 else
93 tmax = t;
94
95 it++;
96 }
97
98 if ( tmin==0 ) {
99 *lastt=t;
100 }
101
102 return tmin;
103}
104
115 FILE *out;
116 MMG5_int k;
117 char data[256],*ptr;
118
119 strcpy(data,disp->namein);
120 ptr = strstr(data,".sol");
121 *ptr = '\0';
122 strcat(data,".o.disp.sol");
123
124 out = fopen(data,"w");
125
126 fprintf(out,"MeshVersionFormatted 1\n\nDimension\n%d\n\n",disp->dim);
127 fprintf(out,"SolAtVertices\n%"MMG5_PRId"\n 1 2\n",disp->np);
128
129 /* Print solutions */
130 for(k=1; k<= disp->np; k++) {
131 int i;
132 for ( i=0; i<mesh->dim; ++i ) {
133 fprintf(out," %f",disp->m[mesh->dim*k+i]);
134 }
135 fprintf(out,"\n");
136 }
137
138 fprintf(out,"\nEnd");
139 fclose(out);
140
141 return 1;
142}
int ier
MMG5_pMesh * mesh
int MMG5_saveDisp(MMG5_pMesh mesh, MMG5_pSol disp)
Definition: mmg3.c:114
short MMG5_dikmov(MMG5_pMesh mesh, MMG5_pSol disp, short *lastt, short shortmax, MMG5_int chkmovmesh(MMG5_pMesh, MMG5_pSol, short, MMG5_int *))
common functions for lagrangian meshing.
Definition: mmg3.c:49
MMG mesh structure.
Definition: libmmgtypes.h:613
char * namein
Definition: libmmgtypes.h:682
double * m
Definition: libmmgtypes.h:680
MMG5_int np
Definition: libmmgtypes.h:674