libMesh / libmesh

libMesh github repository
http://libmesh.github.io
GNU Lesser General Public License v2.1
658 stars 286 forks source link

DirichletBoundary lead 0 solution values on boundaries #2909

Open bylore opened 3 years ago

bylore commented 3 years ago

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

vikramvgarg commented 3 years ago

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

bylore commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

Issue #2452 may share some relations with mine

roystgnr commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

bylore commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.

vikramvgarg commented 3 years ago

@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.

bylore commented 3 years ago

@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

roystgnr commented 3 years ago

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.