[petsc-users] Is the results of `DMAdaptLabel` as expected in `src/dm/impls/plex/tests/ex20.c`

Matthew Knepley knepley at gmail.com
Wed Oct 5 03:38:14 CDT 2022


On Wed, Oct 5, 2022 at 7:40 AM Zongze Yang <yangzongze at gmail.com> wrote:

> Matthew Knepley <knepley at gmail.com> 于2022年10月5日周三 00:33写道:
>
>> On Tue, Oct 4, 2022 at 3:19 PM Zongze Yang <yangzongze at gmail.com> wrote:
>>
>>> Hi everyone,
>>>
>>> I am learning how to use the `DMAdaptLabel` for `DMPlex`, and found the
>>> example `src/dm/impls/plex/tests/ex20.c` which label one cell to refine.
>>>
>>> 1. This example is just a uniform refinement when using the following
>>> command. (see attached pdfs for the results).
>>> ```
>>> [real-int32-gcc] z2yang at ws5:~/opt/firedrake/real-int32-gcc/petsc/src/dm/impls/plex/tests$
>>> ./ex20 -dm_plex_box_faces 3,3 -dm_coord_space 0 -pre_adapt_dm_view
>>> ascii::ascii_info -post_adapt_dm_view draw:tikz:figure2.tex
>>> ```
>>>  Is this expected for this example?
>>>
>>
>> Hi Zongze,
>>
>> Yes, I agree this is not easy to see. If you give
>> -dm_plex_transform_view, you can see the kind of transform being used
>>
>> knepley/pylith $:/PETSc3/petsc/petsc-pylith$ PETSC_ARCH=arch-pylith-opt
>> make -j8 -f ./gmakefile test search="dm_impls_plex_tests-ex20_
>> 2d" TIMEOUT=5000 EXTRA_OPTIONS="-dm_plex_transform_view"
>> Using MAKEFLAGS: --jobserver-fds=3,4 -j --
>> EXTRA_OPTIONS=-dm_plex_transform_view TIMEOUT=5000
>> search=dm_impls_plex_tests-ex20_2d
>>         TEST
>> arch-pylith-opt/tests/counts/dm_impls_plex_tests-ex20_2d.counts
>>  ok dm_impls_plex_tests-ex20_2d
>> not ok diff-dm_impls_plex_tests-ex20_2d # Error code: 1
>> #       11a12,14
>> #       > DMPlexTransform Object: 1 MPI process
>> #       >   type: refine_regular
>> #       > Regular refinement DMPlexTransform_0x84000000_1
>>
>> You can see that it is regular refinement, so it ignores the input and
>> refines everything. If you change it, you can get adaptive refinement,
>>
>> knepley/pylith $:/PETSc3/petsc/petsc-pylith$ PETSC_ARCH=arch-pylith-opt
>> make -j8 -f ./gmakefile test search="dm_impls_plex_tests-ex20_
>> 2d" TIMEOUT=5000 EXTRA_OPTIONS="-pre_adapt_dm_view draw
>> -post_adapt_dm_view draw -draw_pause -1 -dm_plex_transform_type refine_sbr"
>>
>> I attached the plot.
>>
>>
>
> Hi  Matt,
>
> Thanks for your clear explanation. Now, I see that by setting different
> transform types I can refine the mesh by different algorithms. But why the
> refinement algorithms are classified as transform?
>

They used to be separately implemented as mesh refinements. However, last
year, I figured out how to compute many kinds of regular refinement,
some adaptive refinement, extrusion, filtering, and change of cell type
using a common algorithm. This is the purpose of DMPlexTransform. I think
I will be able to encompass even more soon. For example, I am almost
finished with refined meshes that respond to all queries, but are never
actually
stored.

  Thanks,

      Matt


> 2. I found there is a function named `DMAdaptLabel_Plex`, and
>>> `DMAdaptLabel` did not call that function when the type of the dm is
>>> `DMPlex`. Is the function `DMAdaptLabel_Plex` still in use?
>>>
>>
>> No. I rewrote all the transformations last year. I think the new form is
>> much smaller, cleaner, and more performant. I should delete this function,
>> but I am finishing
>> up the review of all adaptive refinement with Joe Wallwork at Imperial.
>>
>>
>>> 3. `DMAdaptLabel` seems to lack some useful information when I use the
>>> wrong adaptor. For example, if I set `-dm_adaptor mmg`, then the process
>>> will give a segment fault because the `metric` passed to
>>> `DMAdaptMetric_Mmg_Plex` is NULL, see the output below:
>>> ```
>>> [real-int32-gcc] z2yang at ws5:~/opt/firedrake/real-int32-gcc/petsc/src/dm/impls/plex/tests$
>>> ./ex20 -dm_plex_box_faces 3,3 -dm_coord_space 0 -pre_adapt_dm_view
>>> draw:tikz:figure1.tex -post_adapt_dm_view draw:tikz:figure2.tex -dm_adaptor
>>> mmg
>>> [0]PETSC ERROR:
>>> ------------------------------------------------------------------------
>>> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation,
>>> probably memory access out of range
>>> [0]PETSC ERROR: Try option -start_in_debugger or
>>> -on_error_attach_debugger
>>> [0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and
>>> https://petsc.org/release/faq/
>>> [0]PETSC ERROR: configure using --with-debugging=yes, recompile, link,
>>> and run
>>> [0]PETSC ERROR: to get more information on the crash.
>>> [0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is
>>> causing the crash.
>>> Abort(59) on node 0 (rank 0 in comm 0): application called
>>> MPI_Abort(MPI_COMM_WORLD, 59) - process 0
>>> ```
>>>
>>
>> Hmm, I at least get an error message:
>>
>> #       [0]PETSC ERROR: --------------------- Error Message
>> --------------------------------------------------------------
>> #       [0]PETSC ERROR: Null argument, when expecting valid pointer
>> #       [0]PETSC ERROR: Null Pointer: Parameter # 1
>> #       [0]PETSC ERROR: WARNING! There are option(s) set that were not
>> used! Could be the program crashed before they were used or a spelling
>> mistake, etc!
>> #       [0]PETSC ERROR: Option left: name:-post_adapt_dm_view value:
>> ascii::ascii_info
>> #       [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble
>> shooting.
>> #       [0]PETSC ERROR: Petsc Development GIT revision:
>> v3.17.4-1472-ga50e2f9f007  GIT Date: 2022-09-23 13:01:31 +0000
>> #       [0]PETSC ERROR: ../ex20 on a arch-master-debug named
>> MacBook-Pro.local by knepley Tue Oct  4 17:29:20 2022
>> #       [0]PETSC ERROR: Configure options --PETSC_ARCH=arch-master-debug
>> --download-bamg --download-bison --download-chaco --download-ctetgen
>> --download-egads --download-eigen --download-exodusii --download-fftw
>> --download-hpddm --download-ks --download-libceed --download-libpng
>> --download-metis --download-ml --download-mmg --download-mumps
>> --download-netcdf --download-opencascade --download-p4est
>> --download-parmetis --download-parmmg --download-pnetcdf
>> --download-pragmatic --download-ptscotch --download-scalapack
>> --download-slepc --download-suitesparse --download-superlu_dist
>> --download-tetgen --download-triangle
>> --with-cmake-exec=/PETSc3/petsc/apple/bin/cmake
>> --with-ctest-exec=/PETSc3/petsc/apple/bin/ctest
>> --with-hdf5-dir=/PETSc3/petsc/apple --with-mpi-dir=/PETSc3/petsc/apple
>> --with-petsc4py=1 --with-shared-libraries --with-slepc --with-zlib
>> --download-muparser
>> #       [0]PETSC ERROR: #1 VecViewFromOptions() at
>> /PETSc3/petsc/petsc-dev/src/vec/vec/interface/vector.c:627
>> #       [0]PETSC ERROR: #2 DMAdaptMetric_Mmg_Plex() at
>> /PETSc3/petsc/petsc-dev/src/dm/impls/plex/adaptors/mmg/mmgadapt.c:130
>> #       [0]PETSC ERROR: #3 DMAdaptLabel() at
>> /PETSc3/petsc/petsc-dev/src/dm/interface/dmgenerate.c:179
>> #       [0]PETSC ERROR: #4 main() at
>> /PETSc3/petsc/petsc-dev/src/dm/impls/plex/tests/ex20.c:24
>> #       [0]PETSC ERROR: PETSc Option Table entries:
>> #       [0]PETSC ERROR: -dm_adaptor mmg
>> #       [0]PETSC ERROR: -dm_coord_space 0
>> #       [0]PETSC ERROR: -dm_plex_box_faces 3,3
>> #       [0]PETSC ERROR: -post_adapt_dm_view ascii::ascii_info
>> #       [0]PETSC ERROR: -pre_adapt_dm_view ascii::ascii_info
>> #       [0]PETSC ERROR: ----------------End of Error Message -------send
>> entire error message to petsc-maint at mcs.anl.gov----------
>> #       application called MPI_Abort(MPI_COMM_SELF, 85) - process 0
>>  ok dm_impls_plex_tests-ex20_2d # SKIP Command failed so no diff
>>
>
> I should use  `--with-debugging=yes` when configuring petsc for more
> information.
>
>
>> I agree that it would be nice to segregate the adaptors into those that
>> work with labels and those that work with metrics, but I thought we could
>> have an automated system to convert between metrics and labels. However,
>> I have not implemented it yet, since I am still trying to figure out exactly
>> how everything should work.
>>
> That would be really nice!
>
> Thanks,
> Zongze
>
>   Thanks,
>>
>>      Matt
>>
>>
>>> Thanks,
>>> Zongze Yang
>>>
>>
>>
>> --
>> 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://www.cse.buffalo.edu/~knepley/
>> <http://www.cse.buffalo.edu/~knepley/>
>>
>

-- 
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://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221005/c1321ba8/attachment-0001.html>


More information about the petsc-users mailing list