Git reference: Tutorial example 06-bc-newton.
Another common natural boundary condition is the Newton (sometimes called Robin) condition of the form
\dd{u}{n} + c_1 u = c_2, \ \ \ \ c_1 \ne 0.
Analogously to Neumann conditions, also Newton conditions yield surface integrals. However, this time they are both in the bilinear form and in the linear form, The bilinear form is a sum of volume and surface forms that can be added to the weak formulation using the methods add_matrix_form() and add_matrix_form_surf(). The surface bilinear form must have the following prototype:
template<typename Real, typename Scalar>
Scalar bilinear_form_surf(int n, double *wt, Func<Scalar> *u_ext[], Func<Real> *u, Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext);
Inside this function you can use predefined forms such as int_u_v, int_F_u_v (see the file src/integrals/h1.h) or your custom forms.
The following code snippet contains the linear and bilinear forms:
template<typename Real, typename Scalar>
Scalar bilinear_form(int n, double *wt, Func<Scalar> *u_ext[], Func<Real> *u, Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext)
{
return int_grad_u_grad_v<Real, Scalar>(n, wt, u, v);
}
template<typename Real, typename Scalar>
Scalar bilinear_form_surf(int n, double *wt, Func<Scalar> *u_ext[], Func<Real> *u, Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext)
{
return H * int_u_v<Real, Scalar>(n, wt, u, v);
}
template<typename Real, typename Scalar>
Scalar linear_form_surf(int n, double *wt, Func<Scalar> *u_ext[], Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext)
{
return T0 * H * int_v<Real, Scalar>(n, wt, v);
}
Here, T_0 is the exterior temperature, and H is the heat flux. The above forms are registered using:
// Initialize the weak formulation.
WeakForm wf;
wf.add_matrix_form(callback(bilinear_form));
wf.add_matrix_form_surf(callback(bilinear_form_surf), NEWTON_BDY);
wf.add_vector_form_surf(callback(linear_form_surf), NEWTON_BDY);
Here NEWTON_BDY is the boundary marker for the Newton boundary. The following figures show the solution and singularity of gradient at the re-entrant corner: