50 fprintf(stdout,
"\n ELAPSED TIME %s\n",stim);
66 int i,j,ret,npar,nbr,split;
67 MMG5_int ref,rin,rex,br;
68 char *ptr,buf[256],data[256];
82 if ( ptr ) *ptr =
'\0';
85 in = fopen(data,
"rb");
88 sprintf(data,
"%s",
"DEFAULT.mmgs");
89 in = fopen(data,
"rb");
94 fprintf(stderr,
" ** In %s: %s file NOT FOUND. \n",__func__,data);
95 fprintf(stdout,
" ## ERROR: UNABLE TO LOAD PARAMETER FILE.\n");
100 fprintf(stdout,
"\n %%%% %s OPENED\n",data);
105 while ( !feof(in) ) {
107 ret = fscanf(in,
"%255s",data);
108 if ( !ret || feof(in) )
break;
109 for (i=0; (size_t)i<strlen(data); i++) data[i] = tolower(data[i]);
112 if ( !strcmp(data,
"lsreferences") ) {
113 ret = fscanf(in,
"%d",&npar);
115 fprintf(stderr,
" %%%% Wrong format for lsreferences: %d\n",npar);
124 fgetpos(in,&position);
128 if ( strcmp(data,
"nosplit") ) {
129 fsetpos(in,&position);
140 else if ( !strcmp(data,
"parameters") ) {
144 fprintf(stderr,
" %%%% Wrong format for parameters: %d\n",npar);
148 fprintf(stderr,
" %%%% Too many local parameters %d. Abort\n",npar);
158 MMG_FSCANF(in,
"%" MMG5_PRId
" %255s ",&ref,buf);
159 ret = fscanf(in,
"%f %f %f",&fp1,&fp2,&hausd);
162 fprintf(stderr,
" %%%% Wrong format: %s\n",buf);
166 for (j=0; (size_t)j<strlen(buf); j++) buf[j] = tolower(buf[j]);
168 if ( !strcmp(buf,
"triangles") || !strcmp(buf,
"triangle") ) {
174 fprintf(stdout,
" %%%% Wrong format: %s\n",buf);
181 else if ( !strcmp(data,
"lsbasereferences") ) {
194 fprintf(stderr,
" %%%% Wrong format: %s\n",data);
222 if ( ptr ) *ptr =
'\0';
224 strcat(data,
".mmgs");
227 if ( !(out = fopen(data,
"wb")) ) {
228 fprintf(stderr,
"\n ** UNABLE TO OPEN %s.\n",data);
232 fprintf(stdout,
"\n %%%% %s OPENED\n",data);
242 fprintf(out,
"parameters\n %d\n",npar);
250 fprintf(stdout,
" -- WRITING COMPLETED\n");
288 fprintf(stderr,
"\n ## Error: %s: "
289 "unable to save of a local parameter file with"
290 " the default parameters values because local parameters"
291 " are provided.\n",__func__);
296 if (
mesh->
info.
imprim > 0 ) fprintf(stdout,
"\n -- INPUT DATA\n");
300 if ( met && met->
np && (met->
np !=
mesh->
np) ) {
301 fprintf(stderr,
"\n ## WARNING: WRONG SOLUTION NUMBER. IGNORED\n");
307 fprintf(stderr,
"\n ## WARNING: WRONG SOLUTION NUMBER. IGNORED\n");
315 fprintf(stdout,
" -- INPUT DATA COMPLETED. %s\n",stim);
322 fprintf(stdout,
"\n -- DEFAULT PARAMETERS COMPUTATION\n");
349 fprintf(stderr,
"\n ## Error: %s: unable to save the local parameters file.\n"
350 " Exit program.\n",__func__);
358int main(
int argc,
char *argv[]) {
361 int ier,ierSave,fmtin,fmtout;
366 setvbuf(stdout, NULL, _IOLBF, 1024);
367 setvbuf(stderr, NULL, _IOLBF, 1024);
370#ifndef MMG_COMPARABLE_OUTPUT
371 fprintf(stdout,
" -- MMGS, Release %s (%s) \n",MMG_VERSION_RELEASE,MMG_RELEASE_DATE);
372 fprintf(stdout,
" %s\n",MMG_COPYRIGHT);
373 fprintf(stdout,
" %s %s\n",__DATE__,__TIME__);
405 fprintf(stdout,
"\n -- INPUT DATA\n");
440 if (
ier < 1 ) {
break; }
445 fprintf(stderr,
"\n ## ERROR: UNABLE TO LOAD LEVEL-SET.\n");
450 fprintf(stdout,
" ## ERROR: UNABLE TO LOAD METRIC.\n");
457 fprintf(stdout,
" ## ERROR: UNABLE TO GIVE A NAME TO THE METRIC.\n");
463 fprintf(stderr,
"\n ## ERROR: WRONG DATA TYPE OR WRONG SOLUTION NUMBER.\n");
476 fprintf(stderr,
" ** %s NOT FOUND.\n",
mesh->
namein);
477 fprintf(stderr,
" ** UNABLE TO OPEN INPUT FILE.\n");
485 fprintf(stderr,
"\n ## ERROR: NO ISOVALUE DATA.\n");
498 fprintf(stdout,
" -- DATA READING COMPLETED. %s\n",stim);
511 fprintf(stdout,
"\n ## ERROR: IMPOSSIBLE TO PROVIDE BOTH A METRIC"
512 " AND A SOLUTION IN ADAPTATION MODE.\n");
522 fprintf(stdout,
"\n -- WRITING DATA FILE %s\n",
mesh->
nameout);
545 if ( met && met->
np ) {
555 if (
mesh->
info.
imprim > 0 ) fprintf(stdout,
" -- WRITING COMPLETED\n");
int MMG5_Compute_constantSize(MMG5_pMesh mesh, MMG5_pSol met, double *hsiz)
const char * MMG5_Get_formatName(enum MMG5_Format fmt)
int MMG5_Get_format(char *ptr, int fmt)
char * MMG5_Get_filenameExt(char *filename)
int MMGS_Set_iparameter(MMG5_pMesh mesh, MMG5_pSol sol, int iparam, MMG5_int val)
set an integer parameter of the remesher
int MMGS_Set_localParameter(MMG5_pMesh mesh, MMG5_pSol sol, int typ, MMG5_int ref, double hmin, double hmax, double hausd)
set a local parameter
int MMGS_Init_mesh(const int starter,...)
Initialize a mesh structure and optionally the associated solution and metric structures.
int MMGS_Set_inputSolName(MMG5_pMesh mesh, MMG5_pSol sol, const char *solin)
Set the name of the input solution file.
int MMGS_Set_lsBaseReference(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int br)
Set a new level-set base reference.
int MMGS_Set_multiMat(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int ref, int split, MMG5_int rin, MMG5_int rout)
Set the reference mapping for the elements of reference ref in level-set discretization mode.
int MMGS_Free_names(const int starter,...)
Structure deallocations before return.
MMG5_pMesh MMG5_pSol * sol
program main
Example for using mmglib (basic use)
void tminit(mytime *t, int maxtim)
Initialize mytime object.
void printim(double elps, char *stim)
Print real time.
void chrono(int cmode, mytime *ptt)
Function to measure time.
int MMGS_loadSol(MMG5_pMesh mesh, MMG5_pSol met, const char *filename)
Load a metric field (or other solution) in medit's .sol format.
int MMGS_loadMshMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Load a mesh and possibly a solution in .msh format from file.
int MMGS_saveMesh(MMG5_pMesh mesh, const char *filename)
Save a mesh in .mesh or .meshb format.
int MMGS_saveMshMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Write mesh and optionally one data field in MSH file format (.msh extension).
int MMGS_saveSol(MMG5_pMesh mesh, MMG5_pSol met, const char *filename)
Write an isotropic or anisotropic metric in medit file format.
int MMGS_loadMesh(MMG5_pMesh mesh, const char *filename)
Load a mesh (in .mesh/.mesb format) from file.
int MMGS_loadVtuMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol sol, const char *filename)
Load a mesh and possibly data in VTU (VTK) format from file.
int MMGS_saveVtuMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Write mesh and optionally one data field vtu Vtk file format (.vtu extension).
int MMGS_loadVtpMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol sol, const char *filename)
Load a mesh and optionally a solution in VTP (VTK) format from file.
int MMGS_saveVtkMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Write mesh and optionally one data field in Vtk file format (.vtk extension).
int MMGS_loadVtkMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol sol, const char *filename)
Load a mesh and possibly data in VTK format from file.
int MMGS_saveVtpMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Save a mesh and optionally one data field in VTP format.
LIBMMG_CORE_EXPORT int MMG5_unscaleMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol ls)
LIBMMG_CORE_EXPORT int MMG5_scaleMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol ls)
int MMGS_mmgsls(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_pSol umet)
Main "program" for level-set discretization.
int MMGS_mmgslib(MMG5_pMesh mesh, MMG5_pSol met)
Main "program" for mesh adaptation.
void MMGS_Set_commonFunc(void)
Set common function pointers between mmgs and mmg3d to the matching mmgs functions.
API headers and documentation for the mmgs library.
LIBMMGS_EXPORT int MMGS_parsar(int argc, char *argv[], MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol sol)
Store command line arguments.
LIBMMGS_EXPORT int(* MMGS_doSol)(MMG5_pMesh mesh, MMG5_pSol met)
Compute an isotropic size map according to the mean of the length of the edges passing through a vert...
LIBMMGS_EXPORT void MMGS_setfunc(MMG5_pMesh mesh, MMG5_pSol met)
Set function pointers for caltet, lenedg, defsiz and gradsiz.
@ MMGS_IPARAM_numberOfLocalParam
@ MMGS_IPARAM_numberOfLSBaseReferences
@ MMGS_IPARAM_numberOfMat
#define MMGS_RETURN_AND_FREE(mesh, met, ls, val)
#define MMG5_STRONGFAILURE
#define MMG5_MMAT_NoSplit
#define _LIBMMG5_RETURN(mesh, sol, met, val)
static void MMG5_excfun(int sigid)
#define MMG5_FILESTR_LGTH
#define MMG_FSCANF(stream, format,...)
#define MMG5_DEL_MEM(mesh, ptr)
static int MMGS_defaultOption(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol sol)
static int MMGS_parsop(MMG5_pMesh mesh, MMG5_pSol met)
static int MMGS_writeLocalParam(MMG5_pMesh mesh)
mytime MMG5_ctim[TIMEMAX]
static void MMG5_endcod(void)
Cell for linked list of integer value.