# Solution transfer from one submesh to other

**URL:** <https://fenicsproject.discourse.group/t/solution-transfer-from-one-submesh-to-other/5151>\
**Category:** mesh\
**Created:** [February 24, 2021, 4:53pm UTC](https://fenicsproject.discourse.group/t/solution-transfer-from-one-submesh-to-other/5151 "2021-02-24T16:53:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![hernan](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/hernan/32/67_2.png) [@hernan](https://fenicsproject.discourse.group/u/hernan)\
**Post date:** [February 25, 2021, 2:25am UTC](https://fenicsproject.discourse.group/t/solution-transfer-from-one-submesh-to-other/5151/2 "2021-02-25T02:25:35Z")

</div>

Hi,

If you use the `MeshView` function (see [here](https://fenicsproject.discourse.group/t/when-will-meshview-become-available/2694) to see how to get the MeshView function [it seems that is also available in the master branch of dolfin]) you can do what you want.

Consider the following modified version of your code snippet:

```auto
import numpy as np
from dolfin import *

class HalfDomain(SubDomain):
    def inside(self, x, on_boundary):
        return between(x[0], (0, 0.5))
class QuarterDomain(SubDomain):
    def inside(self, x, on_boundary):
        return between(x[0], (0, 0.75))

mesh_Complete = UnitCubeMesh(8,8,8);
mark_sub_domain = MeshFunction("size_t", mesh_Complete, mesh_Complete.topology().dim(), 0)

mark_sub_domain.set_all(0)
mark_domain = HalfDomain()
mark_domain.mark(mark_sub_domain, 1)
half_cube_mesh = MeshView.create(mark_sub_domain, 1)

mark_sub_domain.set_all(0)
mark_domain = QuarterDomain()
mark_domain.mark(mark_sub_domain, 1)
quarter_cube_mesh = MeshView.create(mark_sub_domain, 1)

V_half_cube = VectorFunctionSpace(half_cube_mesh, "Lagrange", 2)
u_half_cube = Function(V_half_cube, name="u_half")

##############################################################################
# here solver performs the solution on the half cube and returns the solution vector u_half_cube #
##############################################################################

V_quarter_cube = VectorFunctionSpace(quarter_cube_mesh, "Lagrange", 2)
u_quarter_cube = Function(V_quarter_cube, name="u_quarter")

# Builds cells mapping between parent meshes
half = half_cube_mesh.topology().mapping()[mesh_Complete.id()].cell_map()
quarter = quarter_cube_mesh.topology().mapping()[mesh_Complete.id()].cell_map()

# Builds cells mapping betwen childs
map = [j for i, c in enumerate(half) for j, d in enumerate(quarter) if c==d]

# Get cell dofmaps
half_dofmap = V_half_cube.dofmap()
quarter_dofmap = V_quarter_cube.dofmap()

# Assign values to functions for testint
u_half_cube.vector()[:] = np.random.rand(u_half_cube.vector()[:].size, )

# Assing dofs to quarter
for c in cells(half_cube_mesh):
  u_quarter_cube.vector()[quarter_dofmap.cell_dofs(map[c.index()])] = u_half_cube.vector()[half_dofmap.cell_dofs(c.index())]

File('u_half.pvd') << u_half_cube
File('u_quarter.pvd') << u_quarter_cube

########################################################
# now the u_half_cube has to be transferred to the u_quarter_cube #
# before starting the solver for quarter_cube_mesh #
#########################################################

```

which results in

 ![dsa](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/c/c590118f9cd6266f2b0bf3795d4d9bd29a0fc833.png)

---

_[View the full topic](https://fenicsproject.discourse.group/t/solution-transfer-from-one-submesh-to-other/5151)._
