This example uses the same domain as the previous one, and the same equation
(1)
but the Neumann condition on the “Outer” boundary is replaced with a Newton condition of the form
(2)
where is a heat transfer coefficient and
exterior
temperature. On the boundary parts “Bottom”, “Left” and “Inner” we keep
the nonconstant Dirichlet condition
The weak formulation is
(3)
Using the Newton condition (2), we obtain
(4)
Thus in addition to all types of weak forms from the previous example 05-bc-neumann we now also have a surface matrix form
This integral can be added using the default form DefaultMatrixFormSurf.
The header of the custom form CustomWeakFormPoissonNewton is defined in
definitions.h:
class CustomWeakFormPoissonNewton : public WeakForm<double>
{
public:
CustomWeakFormPoissonNewton(std::string mat_al, Hermes1DFunction<double>* lambda_al,
std::string mat_cu, Hermes1DFunction<double>* lambda_cu,
Hermes2DFunction<double>* vol_src_term, std::string bdy_heat_flux,
double alpha, double t_exterior);
};
and its constructor in definitions.cpp:
CustomWeakFormPoissonNewton::CustomWeakFormPoissonNewton(std::string mat_al, Hermes1DFunction<double>* lambda_al,
std::string mat_cu, Hermes1DFunction<double>* lambda_cu,
Hermes2DFunction<double>* vol_src_term, std::string bdy_heat_flux,
double alpha, double t_exterior) : WeakForm<double>(1)
{
// Jacobian forms - volumetric.
add_matrix_form(new DefaultJacobianDiffusion<double>(0, 0, mat_al, lambda_al));
add_matrix_form(new DefaultJacobianDiffusion<double>(0, 0, mat_cu, lambda_cu));
// Jacobian forms - surface.
add_matrix_form_surf(new DefaultMatrixFormSurf<double>(0, 0, bdy_heat_flux, new Hermes2DFunction<double>(alpha)));
// Residual forms - volumetric.
add_vector_form(new DefaultResidualDiffusion<double>(0, mat_al, lambda_al));
add_vector_form(new DefaultResidualDiffusion<double>(0, mat_cu, lambda_cu));
add_vector_form(new DefaultVectorFormVol<double>(0, HERMES_ANY, vol_src_term));
// Residual forms - surface.
add_vector_form_surf(new DefaultResidualSurf<double>(0, bdy_heat_flux, new Hermes2DFunction<double>(alpha)));
add_vector_form_surf(new DefaultVectorFormSurf<double>(0, bdy_heat_flux, new Hermes2DFunction<double>(-alpha * t_exterior)));
};