Hi Roy, Fantastic! Thank you so much for your help. It works great for us now.
Best, Shawn On Tue, Oct 1, 2019 at 1:41 PM Stogner, Roy H <royst...@ices.utexas.edu> wrote: > > On Mon, 30 Sep 2019, Yuxiang Wang wrote: > > > I am trying to adapt the systems_of_equations_ex7.C to heterogeneous > > Dirichlet BC, and I seem to hit a few challenges. Could you please help > me > > out here? > > > > 1) My first attempt is simply adding the heterogeneous BC like a linear > > problem and used > > `dof_map.heterogenously_constrain_element_matrix_and_vector (Ke, Fe, > > dof_indices)` instead of the `dof_map.constrain_element_matrix_and_vector > > (Ke, Fe, dof_indices)` in the jacobian() function. Note that I did NOT > > have `system.rhs->add_vector (Fe, dof_indices)` in the jacobian() > function. > > The solution seems to be slightly wrong - in the result file, some nodes > > did not have the right prescribed displacements, although their > neighboring > > nodes seemed correct. Then I added the `system.rhs->add_vector (Fe, > > dof_indices)` in the jacobian() function then the results diverged. > > Treating the heterogeneous BC like a linear problem is tricky if you > don't have control over what the solver's doing under the hood. > > What we tend to do now in that case is a cheat: treat the constrained > DoFs as "mutable" in the C++ sense, do enforce_constraints_exactly() > before each residual or Jacobian evaluation, do homogeneous assembly > during the evaluations, then do enforce_constraints_exactly() one > final time after the solver returns. See petsc_diff_solver.C for > example. > > > 2) I noticed that the BCs have to be applied before the es.init(). > > > However, for NonlinearImplicitSystem we may want to divide the > > solution into multiple steps and we'd then need to update the > > heterogeneous BC per step. Would this be possible? > > If you have nonlinear (or time-varying) heterogeneous Dirichlet BCs, > System::reinit_constraints() can be used to recalculate the constraint > equations from them when you need. > --- > Roy > -- Yuxiang "Shawn" Wang, PhD yw...@virginia.edu +1 (434) 284-0836 _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmesh-users