-/* $Id$ */
/* Author: Wolfgang Bangerth, Ralf Hartmann, University of Heidelberg, 2001 */
/* $Id$ */
/* */
-/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2011 by the deal.II authors */
+/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 2001 */
/* $Id$ */
/* */
-/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2009, 2011 by the deal.II authors */
+/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Guido Kanschat, Texas A&M University, 2009 */
/* $Id$ */
/* */
-/* Copyright (C) 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 2001, 2002 */
/* $Id$ */
/* */
-/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2011 by the deal.II authors */
+/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, ETH Zurich, 2002 */
/* $Id$ */
/* */
-/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 2002 */
/* $Id$ */
/* */
-/* Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Guido Kanschat, University of Heidelberg, 2003 */
/* Baerbel Janssen, University of Heidelberg, 2010 */
/* Wolfgang Bangerth, Texas A&M University, 2010 */
/* $Id$ */
/* */
-/* Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Texas at Austin, 2000, 2004 */
/* $Id$ */
/* */
-/* Copyright (C) 2000, 2004, 2005, 2006, 2007, 2008, 2009, 2011 by the deal.II authors */
+/* Copyright (C) 2000, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Texas at Austin, 2000, 2004, 2005 */
/* $Id$ */
/* */
-/* Copyright (C) 2000, 2004, 2005, 2006, 2007, 2008, 2009, 2011 by the deal.II authors */
+/* Copyright (C) 2000, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Luca Heltai, Wolfgang Bangerth, 2005 */
/* $Id$ */
/* */
-/* Copyright (C) 2005, 2006, 2011 by the deal.II authors */
+/* Copyright (C) 2005, 2006, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 1999 */
/* $Id$ */
/* */
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, Texas A&M University, 2005, 2006 */
/* $Id$ */
/* */
-/* Copyright (C) 2005, 2006, 2007, 2008, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Yan Li, Wolfgang Bangerth, Texas A&M University, 2006 */
/* $Id$ */
-/* $Id$ */
/* Author: Wolfgang Bangerth, Texas A&M University, 2008 */
/* $Id$ */
/* */
-/* Copyright (C) 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, Texas A&M University, 2006 */
/* $Id$ */
/* Version: $Name: $ */
/* */
-/* Copyright (C) 2006, 2007, 2008, 2009, 2011 by the deal.II authors */
+/* Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
-/* Version: $Name: $ */
-/* */
-/* Copyright (C) 2006, 2007, 2008, 2009, 2011 by the deal.II authors */
-/* Author: Xing Jin, Wolfgang Bangerth, Texas A&M University, 2006 */
+/* Author: Xing Jin, Wolfgang Bangerth, Texas A&M University, 2006 */
+
+/* $Id$ */
+/* Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
-/* Copyright (C) 2006, 2007, 2008, 2009, 2011 by the deal.II authors */
-/* Author: Ivan Christov, Wolfgang Bangerth, Texas A&M University, 2006 */
+/* Author: Ivan Christov, Wolfgang Bangerth, Texas A&M University, 2006 */
+
+/* $Id$ */
+/* Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 1999 */
/* $Id$ */
/* */
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011 by the deal.II authors */
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, Texas A&M University, 2006, 2007 */
/* $Id$ */
/* */
-/* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
+/* Author: Yaqi Wang, Texas A&M University, 2009, 2010 */
+
/* $Id$ */
-/* Version: $Name: $ */
/* */
-/* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors and Yaqi Wang */
+/* Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Moritz Allmaras, Texas A&M University, 2007 */
-/* */
-/* Copyright (C) 2007, 2008, 2010, 2011 by the deal.II authors and M. Allmaras */
+/* $Id$ */
+/* Copyright (C) 2007, 2008, 2010, 2011, 2012 by the deal.II authors and M. Allmaras */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, 1999, Guido Kanschat, 2011 */
/* $Id$ */
/* */
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Tobias Leicht, 2007 */
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 2007, 2008, 2011 by the deal.II authors */
+/* Copyright (C) 2007, 2008, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Martin Kronbichler, Uppsala University,
Wolfgang Bangerth, Texas A&M University 2007, 2008 */
/* $Id$ */
/* */
-/* Copyright (C) 2007, 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Martin Kronbichler, Uppsala University,
Wolfgang Bangerth, Texas A&M University,
Timo Heister, University of Goettingen, 2008-2011 */
/* */
-/* Copyright (C) 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: David Neckels, Boulder, Colorado, 2007, 2008 */
/* $Id$ */
/* */
-/* Copyright (C) 2007, 2008, 2009, 2010, 2011 by the deal.II authors and David Neckels */
+/* Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors and David Neckels */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-//---------------------------- step-34.cc ---------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2009, 2010, 2011 by the deal.II authors
-//
-// This file is subject to QPL and may not be distributed
-// without copyright and license information. Please refer
-// to the file deal.II/doc/license.html for the text and
-// further information on this license.
-//
-// Authors: Luca Heltai, Cataldo Manigrasso
-//
-//---------------------------- step-34.cc ---------------------------
-
+/* Author: Luca Heltai, Cataldo Manigrasso, 2009 */
+
+/* $Id$ */
+/* */
+/* Copyright (C) 2009, 2010, 2011, 2012 by deal.II authors */
+/* */
+/* This file is subject to QPL and may not be distributed */
+/* without copyright and license information. Please refer */
+/* to the file deal.II/doc/license.html for the text and */
+/* further information on this license. */
// @sect3{Include files}
-/* $Id$ */
-/* Version: $Name: $ */
-/* */
-/* Copyright (C) 2007, 2008, 2009, 2010, 2011 by the deal.II authors */
-/* Author: Abner Salgado, Texas A&M University 2009 */
+/* Author: Abner Salgado, Texas A&M University 2009 */
+
+/* $Id$ */
+/* */
+/* Copyright (C) 2009, 2010, 2011, 2012 by deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Toby D. Young, Polish Academy of Sciences, */
/* Wolfgang Bangerth, Texas A&M University */
/* $Id$*/
/* */
-/* Copyright (C) 2009, 2011 by the deal.II authors */
+/* Copyright (C) 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
-/* Author: Katharina Kormann, Martin Kronbichler, Uppsala University, 2009 */
+/* Authors: Katharina Kormann, Martin Kronbichler, Uppsala University, 2009 */
/* $Id$ */
/* */
-/* Copyright (C) 2009, 2010 by the deal.II authors */
+/* Copyright (C) 2009, 2010, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Authors: Andrea Bonito, Sebastian Pauletti. */
/* $Id$ */
/* */
-/* Copyright (C) 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Guido Kanschat, Texas A&M University, 2009 */
/* $Id$ */
/* */
-/* Copyright (C) 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 1999 */
/* $Id$ */
/* */
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
// respectively. Apart from this,
// everything is as before.
template <int dim>
-class Step4
+class Step4
{
public:
Step4 ();
void run ();
-
+
private:
void make_grid ();
void setup_system();
// constructor which has default
// values for all arguments.
template <int dim>
-class RightHandSide : public Function<dim>
+class RightHandSide : public Function<dim>
{
public:
RightHandSide () : Function<dim>() {}
-
+
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
};
template <int dim>
-class BoundaryValues : public Function<dim>
+class BoundaryValues : public Function<dim>
{
public:
BoundaryValues () : Function<dim>() {}
-
+
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
};
// at zero as usual in C and C++.
template <int dim>
double RightHandSide<dim>::value (const Point<dim> &p,
- const unsigned int /*component*/) const
+ const unsigned int /*component*/) const
{
double return_value = 0;
for (unsigned int i=0; i<dim; ++i)
// what we return:
template <int dim>
double BoundaryValues<dim>::value (const Point<dim> &p,
- const unsigned int /*component*/) const
+ const unsigned int /*component*/) const
{
return p.square();
}
{
GridGenerator::hyper_cube (triangulation, -1, 1);
triangulation.refine_global (4);
-
+
std::cout << " Number of active cells: "
<< triangulation.n_active_cells()
<< std::endl
CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
DoFTools::make_sparsity_pattern (dof_handler, c_sparsity);
sparsity_pattern.copy_from(c_sparsity);
-
+
system_matrix.reinit (sparsity_pattern);
-
+
solution.reinit (dof_handler.n_dofs());
system_rhs.reinit (dof_handler.n_dofs());
}
// way we assemble matrix and right
// hand side vector dimension
// independently: there is simply no
- // difference to the
+ // difference to the
// two-dimensional case. Since the
// important objects used in this
// function (quadrature formula,
// don't have to care about most
// things.
template <int dim>
-void Step4<dim>::assemble_system ()
-{
+void Step4<dim>::assemble_system ()
+{
QGauss<dim> quadrature_formula(2);
// We wanted to have a non-constant right
// us by also giving it the
// #update_quadrature_points
// flag:
- FEValues<dim> fe_values (fe, quadrature_formula,
+ FEValues<dim> fe_values (fe, quadrature_formula,
update_values | update_gradients |
update_quadrature_points | update_JxW_values);
typename DoFHandler<dim>::active_cell_iterator
cell = dof_handler.begin_active(),
endc = dof_handler.end();
-
+
for (; cell!=endc; ++cell)
{
fe_values.reinit (cell);
// making things a lot simpler if one
// wants to write code dimension
// independently.
-
+
// With the local systems assembled,
// the transfer into the global matrix
// and right hand side is done exactly
system_matrix.add (local_dof_indices[i],
local_dof_indices[j],
cell_matrix(i,j));
-
+
system_rhs(local_dof_indices[i]) += cell_rhs(i);
}
}
-
+
// As the final step in this function, we
// wanted to have non-homogeneous boundary
// values in this example, unlike the one
// function is copied verbatim from the
// previous example.
template <int dim>
-void Step4<dim>::solve ()
+void Step4<dim>::solve ()
{
SolverControl solver_control (1000, 1e-12);
SolverCG<> solver (solver_control);
// additional output, it is the same
// as for the previous example.
template <int dim>
-void Step4<dim>::run ()
+void Step4<dim>::run ()
{
std::cout << "Solving problem in " << dim << " space dimensions." << std::endl;
-
+
make_grid();
setup_system ();
assemble_system ();
// written. By changing it you can get more
// information about the innards of the
// library.
-int main ()
+int main ()
{
deallog.depth_console (0);
{
Step4<2> laplace_problem_2d;
laplace_problem_2d.run ();
}
-
+
{
Step4<3> laplace_problem_3d;
laplace_problem_3d.run ();
}
-
+
return 0;
}
-/* $Id$ */
/* Author: Wolfgang Bangerth, Texas A&M University, 2009, 2010 */
/* Timo Heister, University of Goettingen, 2009, 2010 */
/* $Id$ */
/* */
-/* Copyright (C) 2009, 2010, 2011 by Timo Heister and the deal.II authors */
+/* Copyright (C) 2009, 2010, 2011, 2012 by Timo Heister and the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, Texas A&M University, 2008 */
/* $Id$ */
/* */
-/* Copyright (C) 2008, 2009, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Markus Buerg, University of Karlsruhe, 2010 */
/* $Id$ */
/* */
-/* Copyright (C) 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, Texas A&M University, 2011 */
/* $Id$ */
/* */
-/* Copyright (C) 2011 by the deal.II authors */
+/* Copyright (C) 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 */
/* $Id$ */
/* */
-/* Copyright (C) 2011 by the deal.II authors */
+/* Copyright (C) 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 1999 */
/* $Id$ */
/* */
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
DoFTools::make_sparsity_pattern (dof_handler, c_sparsity);
sparsity_pattern.copy_from(c_sparsity);
-
+
system_matrix.reinit (sparsity_pattern);
-
+
solution.reinit (dof_handler.n_dofs());
system_rhs.reinit (dof_handler.n_dofs());
}
// would like to use here.
static const HyperBallBoundary<dim> boundary;
triangulation.set_boundary (0, boundary);
-
+
for (unsigned int cycle=0; cycle<6; ++cycle)
{
std::cout << "Cycle " << cycle << ':' << std::endl;
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 */
/* $Id$ */
/* */
-/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth and Ralf Hartmann, University of Heidelberg, 2000 */
/* $Id$ */
/* */
-/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2011 by the deal.II authors */
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
// place of declaration (i.e. where we
// declare that such a variable exists).
template <int dim>
- class SolutionBase
+ class SolutionBase
{
protected:
- static const unsigned int n_source_centers = 3;
+ static const unsigned int n_source_centers = 3;
static const Point<dim> source_centers[n_source_centers];
static const double width;
};
template <>
const Point<1>
SolutionBase<1>::source_centers[SolutionBase<1>::n_source_centers]
- = { Point<1>(-1.0 / 3.0),
- Point<1>(0.0),
+ = { Point<1>(-1.0 / 3.0),
+ Point<1>(0.0),
Point<1>(+1.0 / 3.0) };
// Likewise, we can provide an explicit
template <>
const Point<2>
SolutionBase<2>::source_centers[SolutionBase<2>::n_source_centers]
- = { Point<2>(-0.5, +0.5),
- Point<2>(-0.5, -0.5),
+ = { Point<2>(-0.5, +0.5),
+ Point<2>(-0.5, -0.5),
Point<2>(+0.5, -0.5) };
// There remains to assign a value to the
{
public:
Solution () : Function<dim>() {}
-
+
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
-
+
virtual Tensor<1,dim> gradient (const Point<dim> &p,
const unsigned int component = 0) const;
};
return_value += std::exp(-x_minus_xi.square() /
(this->width * this->width));
}
-
+
return return_value;
}
for (unsigned int i=0; i<this->n_source_centers; ++i)
{
const Point<dim> x_minus_xi = p - this->source_centers[i];
-
+
// For the gradient, note that
// its direction is along
// (x-x_i), so we add up
(this->width * this->width)) *
x_minus_xi);
}
-
+
return return_value;
}
{
public:
RightHandSide () : Function<dim>() {}
-
+
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
};
for (unsigned int i=0; i<this->n_source_centers; ++i)
{
const Point<dim> x_minus_xi = p - this->source_centers[i];
-
+
// The first contribution is
// the Laplacian:
return_value += ((2*dim - 4*x_minus_xi.square()/
- (this->width * this->width)) /
+ (this->width * this->width)) /
(this->width * this->width) *
std::exp(-x_minus_xi.square() /
(this->width * this->width)));
return_value += std::exp(-x_minus_xi.square() /
(this->width * this->width));
}
-
+
return return_value;
}
// the number of the refinement cycle, and
// consequently gets it as an argument.
template <int dim>
- class HelmholtzProblem
+ class HelmholtzProblem
{
public:
enum RefinementMode {
global_refinement, adaptive_refinement
};
-
+
HelmholtzProblem (const FiniteElement<dim> &fe,
const RefinementMode refinement_mode);
~HelmholtzProblem ();
void run ();
-
+
private:
void setup_system ();
void assemble_system ();
// This is no different than before:
template <int dim>
- HelmholtzProblem<dim>::~HelmholtzProblem ()
+ HelmholtzProblem<dim>::~HelmholtzProblem ()
{
dof_handler.clear ();
}
// library. It requires only a single
// line of code. Some more information
// on this can be found in step-2.
- //
+ //
// Note, however, that when you
// renumber the degrees of freedom,
// you must do so immediately after
// face quadrature formula is then
// straightforward:
template <int dim>
- void HelmholtzProblem<dim>::assemble_system ()
- {
+ void HelmholtzProblem<dim>::assemble_system ()
+ {
QGauss<dim> quadrature_formula(3);
QGauss<dim-1> face_quadrature_formula(3);
Vector<double> cell_rhs (dofs_per_cell);
std::vector<unsigned int> local_dof_indices (dofs_per_cell);
-
+
// Then we need objects which can
// evaluate the values, gradients,
// etc of the shape functions at
// (see below). The class that gives
// us this information is called
// FEFaceValues:
- FEValues<dim> fe_values (*fe, quadrature_formula,
+ FEValues<dim> fe_values (*fe, quadrature_formula,
update_values | update_gradients |
update_quadrature_points | update_JxW_values);
- FEFaceValues<dim> fe_face_values (*fe, face_quadrature_formula,
+ FEFaceValues<dim> fe_face_values (*fe, face_quadrature_formula,
update_values | update_quadrature_points |
update_normal_vectors | update_JxW_values);
// would to go other ways here, of
// course.
const Solution<dim> exact_solution;
-
+
// Now for the main loop over all
// cells. This is mostly unchanged
// from previous examples, so we
right_hand_side.value_list (fe_values.get_quadrature_points(),
rhs_values);
-
+
for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
for (unsigned int i=0; i<dofs_per_cell; ++i)
{
// which is the value that we
// have assigned to that
// portions of the boundary
- // composing Gamma2 in the
+ // composing Gamma2 in the
// <code>run()</code> function further
// below. (The
// default value of boundary
system_matrix.add (local_dof_indices[i],
local_dof_indices[j],
cell_matrix(i,j));
-
+
system_rhs(local_dof_indices[i]) += cell_rhs(i);
}
}
// Solving the system of equations is
// done in the same way as before:
template <int dim>
- void HelmholtzProblem<dim>::solve ()
+ void HelmholtzProblem<dim>::solve ()
{
SolverControl solver_control (1000, 1e-12);
SolverCG<> cg (solver_control);
template <int dim>
void HelmholtzProblem<dim>::refine_grid ()
{
- switch (refinement_mode)
+ switch (refinement_mode)
{
case global_refinement:
{
GridRefinement::refine_and_coarsen_fixed_number (triangulation,
estimated_error_per_cell,
0.3, 0.03);
-
+
triangulation.execute_coarsening_and_refinement ();
break;
// of that value. This is
// equivalent to taking the l2
// (lower case <code>l</code>) norm of the
- // vector of norms on each cell:
+ // vector of norms on each cell:
Vector<float> difference_per_cell (triangulation.n_active_cells());
VectorTools::integrate_difference (dof_handler,
solution,
// first time.
const unsigned int n_active_cells=triangulation.n_active_cells();
const unsigned int n_dofs=dof_handler.n_dofs();
-
- std::cout << "Cycle " << cycle << ':'
+
+ std::cout << "Cycle " << cycle << ':'
<< std::endl
<< " Number of active cells: "
<< n_active_cells
// that we want to have part of the
// boundary marked as Neumann type,
// rather than Dirichlet.
- //
+ //
// For this, we will use the
// following convention: Faces
// belonging to Gamma1 will have the
// refinement step) and refined the
// mesh only after that.
template <int dim>
- void HelmholtzProblem<dim>::run ()
+ void HelmholtzProblem<dim>::run ()
{
for (unsigned int cycle=0; cycle<7; ++cycle)
{
}
else
refine_grid ();
-
+
// The next steps are already
// known from previous
// basic set-up of every finite
// element program:
setup_system ();
-
+
assemble_system ();
solve ();
// number as an argument.
process_solution (cycle);
}
-
+
// @sect5{Output of graphical data}
-
+
// After the last iteration we output the
// solution on the finest grid. This is
// done using the following sequence of
// appropriate for GMV output, open a file,
// and add the solution vector to the
// object that will do the actual output:
- gmv_filename += ".gmv";
+ gmv_filename += ".gmv";
std::ofstream output (gmv_filename.c_str());
DataOut<dim> data_out;
data_out.write_gmv (output);
// @sect5{Output of convergence tables}
-
+
// After graphical output, we would also
// like to generate tables from the error
// computations we have done in
// filled a table object with the number of
// cells for each refinement step as well
// as the errors in different norms.
-
+
// For a nicer textual output of this data,
// one may want to set the precision with
// which the values will be written upon
// above the specific columns.
std::cout << std::endl;
convergence_table.write_text(std::cout);
-
+
// The table can also be written
// into a LaTeX file. The (nicely)
// formatted table can be viewed at
default:
Assert (false, ExcNotImplemented());
}
-
+
error_filename += ".tex";
std::ofstream error_table_file(error_filename.c_str());
-
+
convergence_table.write_tex(error_table_file);
-
+
// @sect5{Further table manipulations}
// In case of global refinement, it
// cells":
convergence_table.add_column_to_supercolumn("cycle", "n cells");
convergence_table.add_column_to_supercolumn("cells", "n cells");
-
+
// Next, it isn't necessary to
// always output all columns,
// or in the order in which
// will then only have to change this
// one instance, rather than all uses
// below:
-int main ()
+int main ()
{
const unsigned int dim = 2;
{
using namespace dealii;
using namespace Step7;
-
+
deallog.depth_console (0);
// Now for the three calls to
std::cout << "Solving with Q1 elements, adaptive refinement" << std::endl
<< "=============================================" << std::endl
<< std::endl;
-
+
FE_Q<dim> fe(1);
HelmholtzProblem<dim>
helmholtz_problem_2d (fe, HelmholtzProblem<dim>::adaptive_refinement);
std::cout << std::endl;
}
-
+
{
std::cout << "Solving with Q1 elements, global refinement" << std::endl
<< "===========================================" << std::endl
<< std::endl;
-
+
FE_Q<dim> fe(1);
HelmholtzProblem<dim>
helmholtz_problem_2d (fe, HelmholtzProblem<dim>::global_refinement);
std::cout << std::endl;
}
-
+
{
std::cout << "Solving with Q2 elements, global refinement" << std::endl
<< "===========================================" << std::endl
<< std::endl;
-
+
FE_Q<dim> fe(2);
HelmholtzProblem<dim>
helmholtz_problem_2d (fe, HelmholtzProblem<dim>::global_refinement);
std::cout << std::endl;
}
-
+
}
catch (std::exception &exc)
{
<< std::endl;
return 1;
}
- catch (...)
+ catch (...)
{
std::cerr << std::endl << std::endl
<< "----------------------------------------------------"
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 */
/* $Id$ */
/* */
-/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
-/* $Id$ */
/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 */
/* $Id$ */
/* */
-/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011 by the deal.II authors */
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */