This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

imposing boundary condition manually in parallel

0 votes

Hi,

I want to impose the boundary condition on a complex system manually and I use the following lines. This code works very well when I use only one processor but when I try to use more than one processor I got some error that the function does not work. Could you please let me know how to implement these lines in parallel?

test=np.array(test, dtype='into')
if manual:
# Modif A: zero bc row & set diagonal to 1
A.ident_local(test)
A.apply('insert')

# Modif b: entry in the bc row is taken from bc_f
bc_values = interpolate(bc_f, V).vector().array()
# print bc_values
b_values = b.array()
b_values[test] = bc_values[test]
#print b_values
b.set_local(b_values)
b.apply('insert')
asked Apr 7, 2016 by Abi FEniCS Novice (270 points)

1 Answer

0 votes

Most likely the array test contains indices exceeding b.local_size(). Your code should work if on each process test is an array of local dof indices owned by that process.

answered Apr 7, 2016 by Magne Nordaas FEniCS Expert (13,820 points)

The array test contains the dofs that I want to impose boundary conditions on them.
Since I am a beginner in using fences, could you please let me know how to do this when I use more than one processor?

It should be noted that I got the following errors:

Primary job terminated normally, but 1 process returned

a non-zero exit code.. Per user-direction, the job has been aborted.


mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

Process name: [[3900,1],4]

Exit code: 1

and also:

Traceback (most recent call last):
File "Thrombus_Stokes.py", line 164, in
Traceback (most recent call last):
File "Thrombus_Stokes.py", line 164, in
Traceback (most recent call last):
A.ident_local(test)
A.ident_local(test)
RuntimeError:

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at


*** fenics@fenicsproject.org


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function 'MatZeroRowsLocal'.
*** Reason: PETSc error code is: 63.
*** Where: This error was encountered inside /opt/programs/FEniCS-1.5/tmp/dolfin-7d7omz3kxfhh/dolfin/la/PETScMatrix.cpp.
*** Process: unknown


*** DOLFIN version: 1.5.0
*** Git changeset:
*** -------------------------------------------------------------------------

The best way to enforce essential boundary conditions is usually to use DirichletBC. Why do you have to use a manual implementation here?

The error you get, PETSc error code 63, comes from calling A.ident_local with an argument that is out of range. It could be that you correctly identify the local dofs, but some of them are not owned by the process. If this is the case you simply need to restrict the dofs array to the owned dofs, e.g.

bc_dofs = ...
bc_dofs = bc_dofs[numpy.where(bc_dofs < b.local_size())]

How do you identify the boundary dofs?

...