<div dir="ltr"><div>Hi, Mathew, <br></div><div>It seems for version 3.21.1 and 3.21.5, there is not ex27 for sne/tutorial/.</div><div>Then I cloned the petsc from gitlab. ex27 was found there. For this version, ex12 could be run without the aformentioned error.</div><div>mpirun -n 8<br></div><div>./ex12 -run_type full -dm_plex_dim 3 -dm_distribute -dm_plex_box_faces 10,10,10 -bc_type dirichlet -p<br>etscspace_degree 1 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -ksp_type cg -pc_type sor -snes_adapt_sequence 3 -adaptor_target_num 1000 -dm_plex_metric_h_max 0.5 -dm_ad<br>aptor parmmg -dm_plex_metric_target_complexity 3200</div><div><br></div><div>But the refinement (top one) still can be improved, right?<br></div><div><br></div><div>Thanks,</div><div><br></div><div>Xiaodong <br></div><div><img src="cid:ii_m15512300" alt="test.png" width="578" height="267"><br><img src="cid:ii_m1555s7a1" alt="image.png" width="578" height="575"><br><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Sep 15, 2024 at 9:33 AM Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Sun, Sep 15, 2024 at 7:25 AM neil liu <<a href="mailto:liufield@gmail.com" target="_blank">liufield@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thanks a lot, Jed. <br></div><div>I traced the code and found the following issues, </div><div>1) in <b>PetscErrorCode DMPlexMetricNormalize(DM dm, Vec metricIn, PetscBool restrictSizes, PetscBool restrictAnisotropy, Vec metricOut, Vec determinant),</b></div><div>the metricIn is zero<b>. And this seems not reasonable. <br></b></div><div><b>Go back to,</b></div><div>2) DMAdaptorAdapt_Sequence_Private(DMAdaptor adaptor, Vec inx, PetscBool doSolve, DM *adm, Vec *ax)</div><div>with -sol_adapt_loc_pre_view, -adapt_gradient_view and -adapt_hessian_view, all these three vectors are zero.</div><div>This is not reasonable.</div><div><b>Go back to, <br></b></div><div><b>3) </b>PetscErrorCode DMAdaptorAdapt(DMAdaptor adaptor, Vec x, DMAdaptationStrategy strategy, DM *adm, Vec *ax) <br></div><div> x is zero here. <br></div><div>Go back to, <br></div><div><b>4) </b>PetscCall(SNESSolve(snes, NULL, u)); <br></div><div>The initial guess u is zero. It seems this is the reason. A little weird. An intiial guess with zero should be resonable. <br></div><div><br></div><div>It seems maybe something is not reasonable for the logic in <b>DMPlexMetricNormalize.</b></div></div></blockquote><div><br></div><div>Is the solve not doing anything? We need at least one solution in order to adapt. Did you look at SNES ex27? I adaptively refine that one.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><b>Thanks,</b></div><div><b><br></b></div><div><b>Xiaodong <br></b></div><div><br></div><div><br></div><div><br></div><div><br></div><div><b><br></b></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 13, 2024 at 2:22 PM Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This error message is coming from the following:<br>
<br>
$ rg -B4 'Global metric normalization factor must be in'<br>
src/dm/impls/plex/plexmetric.c<br>
1308- PetscCall(PetscDSSetObjective(ds, 0, detMFunc));<br>
1309- PetscCall(DMPlexComputeIntegralFEM(dmDet, determinant, &integral, NULL));<br>
1310- }<br>
1311- realIntegral = PetscRealPart(integral);<br>
1312: PetscCheck(realIntegral > 1.0e-30, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Global metric normalization factor must be in (0, inf). Is the input metric positive-definite?");<br>
<br>
Perhaps you can independently check what integrand is being provided. It's probably zero or negative. You could apply this patch so the error message will report a value.<br>
<br>
<br>
diff --git i/src/dm/impls/plex/plexmetric.c w/src/dm/impls/plex/plexmetric.c<br>
index 61caeed28de..906cb394027 100644<br>
--- i/src/dm/impls/plex/plexmetric.c<br>
+++ w/src/dm/impls/plex/plexmetric.c<br>
@@ -1309,7 +1309,7 @@ PetscErrorCode DMPlexMetricNormalize(DM dm, Vec metricIn, PetscBool restrictSize<br>
PetscCall(DMPlexComputeIntegralFEM(dmDet, determinant, &integral, NULL));<br>
}<br>
realIntegral = PetscRealPart(integral);<br>
- PetscCheck(realIntegral > 1.0e-30, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Global metric normalization factor must be in (0, inf). Is the input metric positive-definite?");<br>
+ PetscCheck(realIntegral > 1.0e-30, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Global metric normalization factor %g must be in (0, inf). Is the input metric positive-definite?", (double)realIntegral);<br>
factGlob = PetscPowReal(target / realIntegral, 2.0 / dim);<br>
<br>
/* Apply local scaling */<br>
<br>
<br>
neil liu <<a href="mailto:liufield@gmail.com" target="_blank">liufield@gmail.com</a>> writes:<br>
<br>
> Dear Petsc developers and users,<br>
><br>
> I am trying to explore adaptive mesh refinement (tetradedra) with Petsc.<br>
> It seems case 12 ($PETSC DIR/src/snes/tutorials/ex12.c, from paper,<br>
> <a href="https://urldefense.us/v3/__https://arxiv.org/pdf/2201.02806__;!!G_uCfscf7eWS!ZEwaHkvYc_IrjycFr8LiNi-nZcFqu0ZpsydAAomxptQ6C0xkBs3qhn5ba31Z4vipKf4mTrqDm8A5S65DDD_xFg$" rel="noreferrer" target="_blank">https://urldefense.us/v3/__https://arxiv.org/pdf/2201.02806__;!!G_uCfscf7eWS!ZEwaHkvYc_IrjycFr8LiNi-nZcFqu0ZpsydAAomxptQ6C0xkBs3qhn5ba31Z4vipKf4mTrqDm8A5S65DDD_xFg$</a> ) is a good example.<br>
> However when I tried,<br>
> ./ex12 -run_type full -dm_plex_dim 3 -dm_distribute -dm_plex_box_faces<br>
> 10,10,10 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient ball<br>
> -snes_converged<br>
> _reason ::ascii_info_detail -ksp_type cg -pc_type sor -snes_adapt_sequence<br>
> 3 -adaptor_target_num 1000 -dm_plex_metric_h_max 0.5 -dm_adaptor mmg<br>
> L_2 Error: 1.55486<br>
> Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 2<br>
><br>
> it shows the following error,<br>
> [0]PETSC ERROR: --------------------- Error Message<br>
> --------------------------------------------------------------<br>
> [0]PETSC ERROR: Argument out of range<br>
> [0]PETSC ERROR: Global metric normalization factor must be in (0, inf). Is<br>
> the input metric positive-definite?<br>
><br>
> Do you have any suggestions here?<br>
><br>
> Thanks,<br>
><br>
> Xiaodong<br>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!dmsOhOb8Z6LziJbOMbGSNL4APyr2KlT905erGKhckRCcL5hAeaopEC78FlFcKjqla_qzqTAyiHK9lZkXLAStDg$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>