I currently have a UnitCubeMesh
and I wish to output the values of my solution Temperature
at the midpoints of each facet on a boundary, rather than on the nodes. Currently I have a method to project Temperature
over my mesh and output the midpoints of the facets on my boundary, but I am unsure how to extend this to include values of Temperature
at the midpoints of these facets:
How can this be done?
from dolfin import *
import numpy as np
mesh = UnitCubeMesh(10,10,10)
class marker(SubDomain):
def inside(self, x, on_boundary):
return near(x[2], 1) and on_boundary
Space = FunctionSpace(mesh,'P', 1)
Temperature = project(Expression("x[0]+0.1*x[1]+ x[2]", degree=2), Space) # Temperature solution across mesh
V = FunctionSpace(mesh,'P', 1)
tdim = mesh.topology().dim()
fdim = tdim - 1
mf = MeshFunction("size_t", mesh, fdim, 0)
value = 1
marker().mark(mf, value)
facet_indices = np.flatnonzero(mf.array() == value)
surface_facets = np.array(list(facets(mesh)))[facet_indices]
mesh.init(fdim, tdim)
f_to_c = mesh.topology()(fdim, tdim)
c_to_f = mesh.topology()(tdim, fdim)
for facet in surface_facets:
midpoint = facet.midpoint().array()