Hello,
I'm sure there is a simple solution to this question, but after some research and trying I can't figure out on my own how to do this...
As the title says, I want to evaluate the solution u
of a PDE on (different) boundaries of my domain.
I defined something like
class Right(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-13 # tolerance for coordinate comparisons
return on_boundary and abs(x[0] - x0_max) < tol
class Top(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-13 # tolerance for coordinate comparisons
return on_boundary and abs(x[1] - x1_max) < tol
and would now like to evaluate my function (or get the maximum of it) on each of the boundaries, i.e. get the values of my function on the Top SubDomain
and on the Right SubDomain
.
I tried to use a MeshFunction (subdomains = MeshFunction('size_t', mesh, 2))
and mark the corresponding parts of the boundaries and iterate through the cells:
for cell_no in range(len(subdomains.array())):
subdomain_no = subdomains.array()[cell_no]
if (subdomain_no == 2):
print u.vector()[cell_no]
resulting in an error:
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 59.
NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on exactly when Open MPI kills them.
Going through all coordinates of my mesh and test whether they are on the boundary would also be possible, but isn't there are simpler way to do this, using MeshFunction
or FaceFuntion
?