PetscNonlinearSolver enforces a constraint in each residual it hands PETSc.
With nonzero DirichletBoundary values on both ends, the exact solution of -u'' = 0 is the line between them, which a converged solve has to reproduce
105 {
106 LOG_UNIT_TEST;
107
110
114
115
117 const Real left_value = 2, right_value = 5;
118 sys.get_dof_map().add_dirichlet_boundary(
120 sys.get_dof_map().add_dirichlet_boundary(
122
123 LaplaceResidualAndJacobian assembly;
124 sys.nonlinear_solver->residual_and_jacobian_object = &assembly;
125
126 es.init();
127
128
129
130 sys.solution->zero();
131 sys.solution->close();
132 sys.update();
133
134 sys.solve();
135
136 CPPUNIT_ASSERT(sys.nonlinear_solver->converged);
137
138 for (
const Node * node :
mesh.local_node_ptr_range())
139 {
140 const Real x = (*node)(0);
141 const Number exact = left_value + (right_value - left_value) * x;
142 LIBMESH_ASSERT_NUMBERS_EQUAL(
144 }
145 }
Function that returns a single value that never changes.
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
This is the EquationSystems class.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
A Node is like a Point, but with more information.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
static const boundary_id_type left_id
static const boundary_id_type right_id
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real