[petsc-users] DMPLEX Field name changes after getting a Vec
    Matthew Knepley 
    knepley at gmail.com
       
    Wed Apr  1 06:15:50 CDT 2020
    
    
  
On Wed, Apr 1, 2020 at 5:34 AM Pierre Seize <pierre.seize at onera.fr> wrote:
> Hello everyone.
>
> I noticed a strange feature, and I don't know if it is a small bug or if
> it is expected behaviour.
>
> I have a DMPLEX read from a file, and I add a PetscFV field to it. For
> debugging purposes I want to name this PetscFV with PetscObjectSetName. But
> when later I create a global vector, the name of the field gets erased. Is
> it to be expected ?
>
> You are right. It is a bug. I have made a merge request for this fix here:
  https://gitlab.com/petsc/petsc/-/merge_requests/2670
and it seems to work on your example:
master *:~/Downloads/tmp/Pierre$ ./names
DM Object: Mesh 1 MPI processes
  type: plex
Mesh in 0 dimensions:
Labels:
  celltype: 0 strata with value/size ()
Field FV Model:
  adjacency FVM
DM Object: Mesh 1 MPI processes
  type: plex
Mesh in 0 dimensions:
Labels:
  celltype: 0 strata with value/size ()
Field FV Model:
  adjacency FVM
The reason for this behavior was that originally, FEM people named the
fields individually, but
FV people tended to have one field with the physical fields being
components so that they could
have a single Riemann solve for all fields. Now you can name field
components, so this does not
matter anymore.
Thanks,
   Matt
> Here is a minimal working example:
>
> #include <petscdmplex.h>
> int main(int argc, char **argv){
>   PetscErrorCode    ierr;
>
>   DM      dm;
>   PetscFV fvm;
>   Vec     x;
>
>   ierr = PetscInitialize(&argc, &argv, NULL, NULL); if (ierr) return ierr;
>   ierr = DMCreate(PETSC_COMM_WORLD, &dm);                   CHKERRQ(ierr);
>   ierr = DMSetType(dm, DMPLEX);                             CHKERRQ(ierr);
>   ierr = PetscFVCreate(PETSC_COMM_WORLD, &fvm);             CHKERRQ(ierr);
>   ierr = DMAddField(dm, NULL, (PetscObject) fvm);           CHKERRQ(ierr);
>   ierr = PetscObjectSetName((PetscObject) fvm, "FV Model"); CHKERRQ(ierr);
>   ierr = DMView(dm, PETSC_VIEWER_STDOUT_WORLD);             CHKERRQ(ierr);
> <- Here the field is named "FV Model"
>   ierr = DMCreateGlobalVector(dm, &x);                      CHKERRQ(ierr);
>   ierr = DMView(dm, PETSC_VIEWER_STDOUT_WORLD);             CHKERRQ(ierr);
> <- Here the field is named "Field_0"
>
>
>   ierr = VecDestroy(&x);       CHKERRQ(ierr);
>   ierr = PetscFVDestroy(&fvm); CHKERRQ(ierr);
>   ierr = DMDestroy(&dm);       CHKERRQ(ierr);
>   ierr = PetscFinalize();
>   return ierr;
> }
>
-- 
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/20200401/c601fbc0/attachment.html>
    
    
More information about the petsc-users
mailing list