[petsc-users] DMPLEX Field name changes after getting a Vec

Pierre Seize pierre.seize at onera.fr
Wed Apr 1 04:34:19 CDT 2020


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 ? 

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;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200401/0897b3c1/attachment-0001.html>


More information about the petsc-users mailing list