[petsc-users] Could DMComposite handle two vectors with different grid sizes.

Barry Smith bsmith at mcs.anl.gov
Tue Jul 27 20:29:31 CDT 2010



   What you are doing below looks ok. This builds the DM and DMMG.  See tutorials/multiphysics/mp1.c for an example that uses SNES to solve a nonlinear equation on the grids.

   Barry



On Jul 27, 2010, at 7:36 PM, (Rebecca) Xuefei YUAN wrote:

> Dear all,
> 
> If I have two different vectors (with different dof, stencil width and grid sizes), could I use DMComposite to handle this?
> 
> The following is the piece of code for assemble this DMComposite in DMMG.
> 
> 	tempparameters.mxfield				= 5;
> 	tempparameters.myfield				= 5;
> 
> 	tempparameters.mxgrid	= tempparameters.mxfield+1;
> 	tempparameters.mygrid	= tempparameters.myfield+1;
> 
> 	ierr	= DMMGCreate(comm, tempparameters.numberOfLevels, &appCtx, &dmmg);CHKERRQ(ierr);
> 
> 	ierr	= DMCompositeCreate(comm,&packer);CHKERRQ(ierr);
> 
> 	ierr	= DACreate2d(comm,DA_NONPERIODIC,DA_STENCIL_BOX, tempparameters.mxfield, tempparameters.myfield, PETSC_DECIDE, PETSC_DECIDE, 4, 3, PETSC_NULL, PETSC_NULL, &da_fff);CHKERRQ(ierr);
> 	ierr	= DASetFieldName(da_fff, 0, "phi");CHKERRQ(ierr);
> 	ierr	= DASetFieldName(da_fff, 1, "vz");CHKERRQ(ierr);
> 	ierr	= DASetFieldName(da_fff, 2, "psi");CHKERRQ(ierr);
> 	ierr	= DASetFieldName(da_fff, 3, "bz");CHKERRQ(ierr);
> 	ierr	= DACreate2d(comm,DA_NONPERIODIC,DA_STENCIL_BOX, tempparameters.mxgrid, tempparameters.mygrid, PETSC_DECIDE, PETSC_DECIDE, 1, tempparameters.gridStencilWidth, PETSC_NULL, PETSC_NULL, &da_ggg);CHKERRQ(ierr);
> 	ierr	= DASetFieldName(da_ggg, 0, "disp");CHKERRQ(ierr);
> 
> 	ierr	= DMCompositeAddDM(packer,(DM)da_fff);CHKERRQ(ierr);
> 	ierr	= DMCompositeAddDM(packer,(DM)da_ggg);CHKERRQ(ierr);
> 	ierr	= DMCompositeAddArray(packer,0,1);CHKERRQ(ierr);
> 
> 	ierr	= DMMGSetDM(dmmg, (DM)packer);CHKERRQ(ierr);
> 
> 	ierr	= DADestroy(da_fff);CHKERRQ(ierr);
> 	ierr	= DADestroy(da_ggg);CHKERRQ(ierr);
> 
> .........................................................
> 
> 	ierr	= DMCompositeDestroy(packer);CHKERRQ(ierr);
> 	ierr	= DMMGDestroy(dmmg);CHKERRQ(ierr);
> 
> 
> I understand that for numberOfLevels(nl)>1, the grid size difference is no longer 1, but 3(nl=2), 5(nl=3), could I use DMComposite to handle such a case successfully?
> 
> I was not able to get examples for such a case, is there any?
> 
> Thanks a lot!
> 
> 
> 
> -- 
> (Rebecca) Xuefei YUAN
> Department of Applied Physics and Applied Mathematics
> Columbia University
> Tel:917-399-8032
> www.columbia.edu/~xy2102
> 



More information about the petsc-users mailing list