///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
/// 
/// =========================================================================
//! @examplefile stokes_dirichlet_dg.icc The Stokes problem with Dirichlet boundary condition by the discontinuous Galerkin method -- solver function
void stokes_dirichlet_dg (const space& Xh, const space& Qh,
  form& a, form& b, form& c, form& mp, field& lh, field& kh,
  integrate_option iopt = integrate_option())
{
  size_t k = Xh.degree();
  size_t d = Xh.get_geo().dimension();
  Float beta = (k+1)*(k+d)/Float(d);
  trial u (Xh), p (Qh);
  test  v (Xh), q (Qh);
  a  = integrate (2*ddot(Dh(u),Dh(v)), iopt)
     + integrate ("sides",    beta*penalty()*dot(jump(u),jump(v))
	 	- 2*dot(jump(u),average(Dh(v)*normal()))
	 	- 2*dot(jump(v),average(Dh(u)*normal())), iopt);
  lh = integrate (dot(f(),v), iopt) 
     + integrate ("boundary", beta*penalty()*dot(g(),v)
                - 2*dot(g(),Dh(v)*normal()), iopt);
  b  = integrate (dot(u,grad_h(q)), iopt)
     + integrate ("internal_sides", - dot(average(u),normal())*jump(q), iopt);
  kh = integrate ("boundary", dot(g(),normal())*q, iopt);
  c  = integrate ("internal_sides", h_local()*jump(p)*jump(q), iopt);
  mp = integrate (p*q, iopt);
}
