libmesh icon indicating copy to clipboard operation
libmesh copied to clipboard

DirichletBoundary lead 0 solution values on boundaries

Open bylore opened this issue 4 years ago • 13 comments

I use DirichletBoundary to impose constant boundary values to some boundaries,but the values of the imposed boundary dofs are all zero in the output results(test for both exodus and vtk output format). As can be seen in the figure below, left and right boundary value are all zero, but they should be 0.1 and -0.1 respectively according to the imposed dirichlet boundary conditions. The solution except for these two boundaries seem to be correct. Could you please give me some clues about this issue? image

bylore avatar Apr 25 '21 16:04 bylore

Are you calling equation_systems.init() after adding the bc object to the dof map ?

vikramvgarg avatar Apr 25 '21 20:04 vikramvgarg

Are you calling equation_systems.init() after adding the bc object to the dof map ?

Yes,equation_systems.init() is called after adding the bc object to the dof map.

bylore avatar Apr 26 '21 01:04 bylore

Are you calling equation_systems.init() after adding the bc object to the dof map ?

It seems that the solutions on the constrained boundaries are not saved.

bylore avatar Apr 26 '21 01:04 bylore

Are you calling equation_systems.init() after adding the bc object to the dof map ?

Issue #2452 may share some relations with mine

bylore avatar Apr 26 '21 02:04 bylore

Are you solving a linear system that you build with constrain_element_matrix_and_vector (or one of the other homogeneous-only APIs) rather than heterogeneously_constrain_element_matrix_and_vector?

roystgnr avatar Apr 26 '21 15:04 roystgnr

Except that would leave you without the BC contribution to the problem at all ... I assume that interior solution isn't purely coming from a convective term plus forcing function...

roystgnr avatar Apr 26 '21 15:04 roystgnr

Is enforce_constraints_exactly being called somewhere with the homogeneous parameter set to true?

roystgnr avatar Apr 26 '21 15:04 roystgnr

Are you solving a linear system that you build with constrain_element_matrix_and_vector (or one of the other homogeneous-only APIs) rather than heterogeneously_constrain_element_matrix_and_vector?

I solved a linear system,but using nonlinearimplicitsystem with both constrain_element_vector() and constrain_element_matrix() in the residual and jacobian respectively. enfore_constraints_exactly() is not called. The BC does contributed to the system, but BC values is not saved and output to be zero always.

bylore avatar Apr 27 '21 01:04 bylore

Are you solving a linear system that you build with constrain_element_matrix_and_vector (or one of the other homogeneous-only APIs) rather than heterogeneously_constrain_element_matrix_and_vector?

Examples supplied by libmesh, such as /systems_of_equations/ex5 ex6 ex7, ZeroFunction() is supplied to the BC, it works fine because the BC values are zero. I tried change ZeroFunction() to be some ConstFunction() with a non-zero value and I got the same issue. For example, /systems_of_equations/ex7, I change only one sentence ZeroFunction<Number> zero; to be ConstFunction<Number> zero(0.); and ConstFunction<Number> zero(-1.); and ConstFunction<Number> zero(1.); And the corresponding results of "w" are shown below. 0: image -1: image 1: image

bylore avatar Apr 27 '21 02:04 bylore

Except that would leave you without the BC contribution to the problem at all ... I assume that interior solution isn't purely coming from a convective term plus forcing function...

As shown above, non-zero BC values contributed to the soultion of the system (seems in a correct manner), but node values on BC are output as 0.

bylore avatar Apr 27 '21 02:04 bylore

@bylore, can you try running adjoints/ex3 ? In that example, we apply a zero, const(1) as well as user defined parabolic Dirichlet boundary condition. See line 147 onwards here.

You can choose the output format in the general.in file. I think you will want to set output_exodus = true.

vikramvgarg avatar Apr 27 '21 02:04 vikramvgarg

@bylore, can you try running adjoints/ex3 ? In that example, we apply a zero, const(1) as well as user defined parabolic Dirichlet boundary condition. See line 147 onwards here.

You can choose the output format in the general.in file. I think you will want to set output_exodus = true.

adjoint/ex3 has been run, and it works. The left boundary value of "C" is output to be 1 just as expected.

image

bylore avatar Apr 27 '21 05:04 bylore

For example, /systems_of_equations/ex7

This would seem to be an example of what I was talking about:

~/l/g/normal (master)> grep constrain ../examples/systems*/*ex7/*.C
        dof_map.constrain_element_matrix (Ke, dof_indices);
        dof_map.constrain_element_vector (Re, dof_indices);
~/l/g/normal (master)> grep heterogenous ../examples/systems*/*ex7/*.C
~/l/g/normal (master) [1]>

Those two constraint calls in use in ex7 are intended for homogeneous constraints, as you would want for hanging nodes, for updates to an already-constrained vector, or for homogeneous Dirichlet conditions. (although I'm not sure they're applied consistently after your changes; the solver may be trying to handle heterogeneous constraints and conflicting in strange ways with the residual+jacobian definitions)

grep heterogenous ../examples/*/*/*.C shows several other examples that apply heterogeneous constraints.

roystgnr avatar Apr 27 '21 16:04 roystgnr