[petsc-users] DMPlexCreateLocalVec Within a function

Matthew Kury mkury at berkeley.edu
Fri Apr 15 18:23:20 CDT 2016


Hello, 

	I have done some reading and I have not been able to find out what the proper way to create and use vectors within a function.

	If I have a function that passes in dm and V then: 
+++
		DMPlexGetLocalVec(dm, &VLocal) ;
		DMGlobalToLocalBegin(dm,V,INSERT_VALUES,VLocal); 
		DMGlobalToLocalEnd(dm,V,INSERT_VALUES,VLocal) ;

		VecGetArray(VLoc,VLocalArray);

		“Stuff with VLocalArray”

		VecRestoreArray(VLoc,VLocalArray);
		
		DMLocalToGlobalBegin(dm,VLocal,ADD_VALUES,V);
		DMLocalToGlobalEnd(dm,VLocal,ADD_VALUES,V);

		DMRestoreLocalVector(dm,&VLocal);
+++

	The second time I call the function I get errors with the VecGetArray() function.  I would appreciate any advice as to what is going wrong. 

Thank you, 

Matthew



More information about the petsc-users mailing list