indices of boundary dofs #2545
-
Dear developers, I'm dealing with a diffusion-reaction problem in which the diffusion equation is a pde that is solved in a rectangle domain for concentrations. Reaction equations are non-pde and fsolve from scipy.optimize is used to solve the system of algebraic equations. The reactions only occur at the bottom and top boundaries; therefore, I need the indices of boundary dofs to loop only over them but not the whole domain. I tried to use par_loop but could not use the external fsolve.c function in the loopy kernel. Now, I transfer the ufl function to ndarray NumPy and loop over all dofs. It works, but the run time is not efficient; e.g., the CPU run time for the solution of diffusion equation without reaction is about 20 seconds but for the diffusion-reaction is about 9 mins. I thought at least the loop size could be decreased and limited to the boundary dofs instead of looping over the whole dofs. Any other ideas to make the algorithm more efficient would be appreciated. A simple example of the indices of boundary dofs (bottom and top) is as follows. I need a general method to catch these indices.
And an example of a diffusion-reaction code is as follows:
Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can build a |
Beta Was this translation helpful? Give feedback.
You can build a
bc = DirichletBC(V, 0, (mesh, labels, you, want))
and thenbc.nodes
gives you indices into the.data
array that are on the boundary.