[petsc-users] Inquiry about metric-based adaptation using MMG in petsc

neil liu liufield at gmail.com
Mon Sep 16 10:10:34 CDT 2024


Hi, Mathew,
It seems for version 3.21.1 and 3.21.5, there is not ex27 for sne/tutorial/.
Then I cloned the petsc from gitlab. ex27 was found there. For this
version, ex12 could be run without the aformentioned error.
mpirun -n 8
./ex12 -run_type full -dm_plex_dim 3 -dm_distribute -dm_plex_box_faces
10,10,10 -bc_type dirichlet -p
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
aptor parmmg -dm_plex_metric_target_complexity 3200

But the refinement (top one) still can be improved, right?

Thanks,

Xiaodong
[image: test.png]
[image: image.png]



On Sun, Sep 15, 2024 at 9:33 AM Matthew Knepley <knepley at gmail.com> wrote:

> On Sun, Sep 15, 2024 at 7:25 AM neil liu <liufield at gmail.com> wrote:
>
>> Thanks a lot, Jed.
>> I traced  the code and found the following issues,
>> 1) in *PetscErrorCode DMPlexMetricNormalize(DM dm, Vec metricIn,
>> PetscBool restrictSizes, PetscBool restrictAnisotropy, Vec metricOut, Vec
>> determinant),*
>> the metricIn is zero
>> *. And this seems not reasonable. *
>> *Go back to,*
>> 2) DMAdaptorAdapt_Sequence_Private(DMAdaptor adaptor, Vec inx, PetscBool
>> doSolve, DM *adm, Vec *ax)
>> with -sol_adapt_loc_pre_view, -adapt_gradient_view and
>> -adapt_hessian_view, all these three vectors are zero.
>> This is not reasonable.
>>
>> *Go back to, *
>> *3) *PetscErrorCode DMAdaptorAdapt(DMAdaptor adaptor, Vec x,
>> DMAdaptationStrategy strategy, DM *adm, Vec *ax)
>>     x is zero here.
>> Go back to,
>> *4)  *PetscCall(SNESSolve(snes, NULL, u));
>> The initial guess u is zero. It seems this is the reason. A little weird.
>> An intiial guess with zero should be resonable.
>>
>> It seems maybe something is not reasonable for the logic in
>> *DMPlexMetricNormalize.*
>>
>
> 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.
>
>   Thanks,
>
>    Matt
>
>
>> *Thanks,*
>>
>>
>> *Xiaodong *
>>
>>
>>
>>
>>
>>
>>
>> On Fri, Sep 13, 2024 at 2:22 PM Jed Brown <jed at jedbrown.org> wrote:
>>
>>> This error message is coming from the following:
>>>
>>> $ rg -B4 'Global metric normalization factor must be in'
>>> src/dm/impls/plex/plexmetric.c
>>> 1308-    PetscCall(PetscDSSetObjective(ds, 0, detMFunc));
>>> 1309-    PetscCall(DMPlexComputeIntegralFEM(dmDet, determinant,
>>> &integral, NULL));
>>> 1310-  }
>>> 1311-  realIntegral = PetscRealPart(integral);
>>> 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?");
>>>
>>> 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.
>>>
>>>
>>> diff --git i/src/dm/impls/plex/plexmetric.c
>>> w/src/dm/impls/plex/plexmetric.c
>>> index 61caeed28de..906cb394027 100644
>>> --- i/src/dm/impls/plex/plexmetric.c
>>> +++ w/src/dm/impls/plex/plexmetric.c
>>> @@ -1309,7 +1309,7 @@ PetscErrorCode DMPlexMetricNormalize(DM dm, Vec
>>> metricIn, PetscBool restrictSize
>>>      PetscCall(DMPlexComputeIntegralFEM(dmDet, determinant, &integral,
>>> NULL));
>>>    }
>>>    realIntegral = PetscRealPart(integral);
>>> -  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?");
>>> +  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);
>>>    factGlob = PetscPowReal(target / realIntegral, 2.0 / dim);
>>>
>>>    /* Apply local scaling */
>>>
>>>
>>> neil liu <liufield at gmail.com> writes:
>>>
>>> > Dear Petsc developers and users,
>>> >
>>> > I am  trying to explore adaptive mesh refinement (tetradedra) with
>>> Petsc.
>>> > It seems case 12 ($PETSC DIR/src/snes/tutorials/ex12.c, from paper,
>>> >
>>> https://urldefense.us/v3/__https://arxiv.org/pdf/2201.02806__;!!G_uCfscf7eWS!ZEwaHkvYc_IrjycFr8LiNi-nZcFqu0ZpsydAAomxptQ6C0xkBs3qhn5ba31Z4vipKf4mTrqDm8A5S65DDD_xFg$
>>> ) is a good example.
>>> > However when I tried,
>>> > ./ex12 -run_type full -dm_plex_dim 3 -dm_distribute -dm_plex_box_faces
>>> > 10,10,10 -bc_type dirichlet -petscspace_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_adaptor mmg
>>> >       L_2 Error: 1.55486
>>> >       Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE
>>> iterations 2
>>> >
>>> > it shows the following error,
>>> > [0]PETSC ERROR: --------------------- Error Message
>>> > --------------------------------------------------------------
>>> > [0]PETSC ERROR: Argument out of range
>>> > [0]PETSC ERROR: Global metric normalization factor must be in (0,
>>> inf). Is
>>> > the input metric positive-definite?
>>> >
>>> > Do  you have any suggestions here?
>>> >
>>> > Thanks,
>>> >
>>> > Xiaodong
>>>
>>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!dmsOhOb8Z6LziJbOMbGSNL4APyr2KlT905erGKhckRCcL5hAeaopEC78FlFcKjqla_qzqTAyiHK9lZki1ilMFA$ 
> <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!dmsOhOb8Z6LziJbOMbGSNL4APyr2KlT905erGKhckRCcL5hAeaopEC78FlFcKjqla_qzqTAyiHK9lZkXLAStDg$ >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240916/237fd2b0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 485255 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240916/237fd2b0/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 1689600 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240916/237fd2b0/attachment-0003.png>


More information about the petsc-users mailing list