@@ -55,7 +55,7 @@ extern int (*PMMG_interp2bar)(MMG5_pMesh mesh,MMG5_pSol met,MMG5_pSol oldMet,MMG
5555int PMMG_check_inputData (PMMG_pParMesh parmesh )
5656{
5757 MMG5_pMesh mesh ;
58- MMG5_pSol met ;
58+ MMG5_pSol met , ls ;
5959 int k ;
6060
6161 if ( parmesh -> info .imprim > PMMG_VERB_VERSION )
@@ -71,14 +71,14 @@ int PMMG_check_inputData(PMMG_pParMesh parmesh)
7171 " ## Error: lagrangian mode unavailable (MMG3D_IPARAM_lag):\n" );
7272 return 0 ;
7373 } else if ( mesh -> info .iso ) {
74- fprintf (stderr ," ## Error: level-set discretisation unavailable"
75- " (MMG3D_IPARAM_iso):\n" );
76- return 0 ;
74+ fprintf (stderr ,"\n\n ## WARNING: level-set discretisation under construction. \n\n" );
75+ // return 0;
7776 } else if ( mesh -> info .optimLES && met -> size == 6 ) {
7877 fprintf (stdout ," ## Error: strong mesh optimization for LES methods"
7978 " unavailable (MMG3D_IPARAM_optimLES) with an anisotropic metric.\n" );
8079 return 0 ;
8180 }
81+
8282 /* specific meshing */
8383 if ( met -> np ) {
8484 if ( mesh -> info .optim ) {
@@ -128,18 +128,23 @@ int PMMG_check_inputData(PMMG_pParMesh parmesh)
128128int PMMG_preprocessMesh ( PMMG_pParMesh parmesh )
129129{
130130 MMG5_pMesh mesh ;
131- MMG5_pSol met ;
131+ MMG5_pSol met ,ls ;
132+ int8_t tim ;
133+ char stim [32 ];
134+ mytime ctim [TIMEMAX ];
135+
132136
133137 mesh = parmesh -> listgrp [0 ].mesh ;
134138 met = parmesh -> listgrp [0 ].met ;
139+ ls = parmesh -> listgrp [0 ].ls ;
135140
136141 assert ( ( mesh != NULL ) && ( met != NULL ) && "Preprocessing empty args" );
137142
138143 /** Function setters (must be assigned before quality computation) */
139144 MMG3D_Set_commonFunc ();
140145
141146 /** Mesh scaling and quality histogram */
142- if ( !MMG5_scaleMesh (mesh ,met ,NULL ) ) {
147+ if ( !MMG5_scaleMesh (mesh ,met ,ls ) ) {
143148 return PMMG_LOWFAILURE ;
144149 }
145150
@@ -177,17 +182,45 @@ int PMMG_preprocessMesh( PMMG_pParMesh parmesh )
177182 return PMMG_STRONGFAILURE ;
178183 }
179184
185+ /* Discretization of the isovalue */
186+ if (mesh -> info .iso ) {
187+ tim = 1 ;
188+ chrono (ON ,& (ctim [tim ]));
189+ if ( parmesh -> info .imprim > PMMG_VERB_VERSION ) {
190+ fprintf (stdout ,"\n -- PHASE 1a: ISOVALUE DISCRETIZATION \n" );
191+ }
192+ if ( !MMG3D_mmg3d2 (mesh ,ls ,met ) ) {
193+ return PMMG_STRONGFAILURE ;
194+ }
195+ chrono (OFF ,& (ctim [tim ]));
196+ printim (ctim [tim ].gdif ,stim );
197+ if ( parmesh -> info .imprim > PMMG_VERB_VERSION ) {
198+ fprintf (stdout ," -- PHASE 1a COMPLETED %s\n" ,stim );
199+ }
200+ }
201+
180202 /** Mesh analysis */
181203 if ( !MMG3D_analys (mesh ) ) {
182204 return PMMG_STRONGFAILURE ;
183205 }
184206
207+ /* Check if the LS has led to a non-manifold topology */
208+ if ( mesh -> info .iso && !MMG3D_chkmani (mesh ) ) {
209+ fprintf (stderr ,"\n ## LS discretization: non-manifold initial topology. Exit program.\n" );
210+ return PMMG_STRONGFAILURE ;
211+ }
212+ else {
213+ if ( parmesh -> info .imprim > PMMG_VERB_VERSION ) {
214+ fprintf (stdout ," LS discretization OK: no non-manifold topology.\n" );
215+ }
216+ }
217+
185218 if ( parmesh -> info .imprim0 > PMMG_VERB_ITWAVES && (!mesh -> info .iso ) && met -> m ) {
186219 PMMG_prilen (parmesh ,0 ,1 );
187220 }
188221
189222 /** Mesh unscaling */
190- if ( !MMG5_unscaleMesh (mesh ,met ,NULL ) ) {
223+ if ( !MMG5_unscaleMesh (mesh ,met ,ls ) ) {
191224 return PMMG_STRONGFAILURE ;
192225 }
193226
@@ -337,7 +370,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh )
337370
338371int PMMG_distributeMesh_centralized_timers ( PMMG_pParMesh parmesh ,mytime * ctim ) {
339372 MMG5_pMesh mesh ;
340- MMG5_pSol met ;
373+ MMG5_pSol met , ls ;
341374 int ier ,iresult ;
342375 int8_t tim ;
343376 char stim [32 ];
@@ -378,7 +411,8 @@ int PMMG_distributeMesh_centralized_timers( PMMG_pParMesh parmesh,mytime *ctim )
378411
379412 mesh = parmesh -> listgrp [0 ].mesh ;
380413 met = parmesh -> listgrp [0 ].met ;
381- if ( (ier == PMMG_STRONGFAILURE ) && MMG5_unscaleMesh ( mesh , met , NULL ) ) {
414+ ls = parmesh -> listgrp [0 ].ls ;
415+ if ( (ier == PMMG_STRONGFAILURE ) && MMG5_unscaleMesh ( mesh , met , ls ) ) {
382416 ier = PMMG_LOWFAILURE ;
383417 }
384418
@@ -1580,9 +1614,17 @@ int PMMG_parmmglib_post(PMMG_pParMesh parmesh) {
15801614}
15811615
15821616int PMMG_parmmglib_centralized (PMMG_pParMesh parmesh ) {
1617+ return PMMG_parmmg_centralized (parmesh );
1618+ }
1619+
1620+ int PMMG_parmmgls_centralized (PMMG_pParMesh parmesh ) {
1621+ return PMMG_parmmg_centralized (parmesh );
1622+ }
1623+
1624+ int PMMG_parmmg_centralized (PMMG_pParMesh parmesh ) {
15831625 PMMG_pGrp grp ;
15841626 MMG5_pMesh mesh ;
1585- MMG5_pSol met ;
1627+ MMG5_pSol met , ls ;
15861628 int ier ;
15871629 int ierlib ;
15881630 mytime ctim [TIMEMAX ];
@@ -1619,6 +1661,7 @@ int PMMG_parmmglib_centralized(PMMG_pParMesh parmesh) {
16191661 grp = & parmesh -> listgrp [0 ];
16201662 mesh = grp -> mesh ;
16211663 met = grp -> met ;
1664+ ls = grp -> ls ;
16221665
16231666 /** Remeshing */
16241667 tim = 3 ;
0 commit comments