Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
src
common
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
49
short
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
while
( tmin != tmax && it < maxit ) {
69
t = (tmin+tmax)/2;
70
71
/* Case that tmax = tmin +1 : check move with tmax */
72
if
( t == tmin ) {
73
ier
= chkmovmesh(
mesh
,disp,tmax,NULL);
74
if
( !
ier
) {
75
return
tmax;
76
}
77
else
{
78
if
( tmin==0 ) {
79
*lastt = tmax;
80
}
81
return
tmin;
82
}
83
}
84
85
/* General case: check move with t */
86
ier
= chkmovmesh(
mesh
,disp,t,NULL);
87
if
( !
ier
) {
88
tmin = t;
89
}
90
else
91
tmax = t;
92
93
it++;
94
}
95
96
if
( tmin==0 ) {
97
*lastt=t;
98
}
99
100
return
tmin;
101
}
102
112
int
MMG5_saveDisp
(
MMG5_pMesh
mesh
,
MMG5_pSol
disp) {
113
FILE *out;
114
MMG5_int k;
115
char
data[256],*ptr;
116
117
strcpy(data,disp->
namein
);
118
ptr = strstr(data,
".sol"
);
119
*ptr =
'\0'
;
120
strcat(data,
".o.disp.sol"
);
121
122
out = fopen(data,
"w"
);
123
124
fprintf(out,
"MeshVersionFormatted 1\n\nDimension\n%d\n\n"
,disp->
dim
);
125
fprintf(out,
"SolAtVertices\n%"
MMG5_PRId
"\n 1 2\n"
,disp->
np
);
126
127
/* Print solutions */
128
for
(k=1; k<= disp->
np
; k++) {
129
int
i;
130
for
( i=0; i<
mesh
->
dim
; ++i ) {
131
fprintf(out,
" %f"
,disp->
m
[
mesh
->
dim
*k+i]);
132
}
133
fprintf(out,
"\n"
);
134
}
135
136
fprintf(out,
"\nEnd"
);
137
fclose(out);
138
139
return
1;
140
}
ier
int ier
Definition:
API_functionsf_2d.c:743
mesh
MMG5_pMesh * mesh
Definition:
API_functionsf_2d.c:66
MMG5_saveDisp
int MMG5_saveDisp(MMG5_pMesh mesh, MMG5_pSol disp)
Definition:
mmg3.c:112
MMG5_dikmov
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
mmgcommon_private.h
MMG5_Mesh
MMG mesh structure.
Definition:
libmmgtypes.h:605
MMG5_Mesh::dim
int dim
Definition:
libmmgtypes.h:610
MMG5_Sol
Definition:
libmmgtypes.h:662
MMG5_Sol::namein
char * namein
Definition:
libmmgtypes.h:673
MMG5_Sol::m
double * m
Definition:
libmmgtypes.h:671
MMG5_Sol::dim
int dim
Definition:
libmmgtypes.h:664
MMG5_Sol::np
MMG5_int np
Definition:
libmmgtypes.h:665
Generated on Tue Dec 13 2022 00:19:50 for Mmg by
1.9.5