# DMGlobalToLocalSolve
Solve for the global vector that is mapped to a given local vector by `DMGlobalToLocalBegin()`/`DMGlobalToLocalEnd()` with mode = `INSERT_VALUES`.  It is assumed that the sum of all the local vector sizes is greater than or equal to the global vector size, so the solution is a least-squares solution.  It is also assumed that `DMLocalToGlobalBegin()`/`DMLocalToGlobalEnd()` with mode = `ADD_VALUES` is the adjoint of the global-to-local map, so that the least-squares solution may be found by the normal equations. 
## Synopsis
```
#include "petscdm.h" 
#include "petscdmplex.h" 
#include "petscksp.h" 
PetscErrorCode DMGlobalToLocalSolve(DM dm, Vec x, Vec y)
```
collective


## Input Parameters

- ***dm -*** The `DM` object
- ***x -*** The local vector
- ***y -*** The global vector: the input value of globalVec is used as an initial guess



## Output Parameters

- ***y -*** The least-squares solution





## Note
If the `DM` is of type `DMPLEX`, then y is the solution of L' * D * L * y = L' * D * x, where D is a diagonal mask that is 1 for every point in
the union of the closures of the local cells and 0 otherwise.  This difference is only relevant if there are anchor points that are not in the
closure of any local cell (see `DMPlexGetAnchors()`/`DMPlexSetAnchors()`).


## See Also
 [](chapter_ksp), `DM`, `DMGlobalToLocalBegin()`, `DMGlobalToLocalEnd()`, `DMLocalToGlobalBegin()`, `DMLocalToGlobalEnd()`, `DMPlexGetAnchors()`, `DMPlexSetAnchors()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/utils/dmproject.c.html#DMGlobalToLocalSolve">src/ksp/ksp/utils/dmproject.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/utils/dmproject.c)


[Index of all KSP routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
