From d363104b262ddc641aa4286cc2236f1dd20a6a12 Mon Sep 17 00:00:00 2001 From: kanschat Date: Tue, 19 Oct 2010 20:25:21 +0000 Subject: [PATCH] transfer more operators git-svn-id: https://svn.dealii.org/trunk@22389 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/integrators/differential.h | 192 ++++++++++++++++++ deal.II/deal.II/include/integrators/l2.h | 122 +++++++++++ 2 files changed, 314 insertions(+) create mode 100644 deal.II/deal.II/include/integrators/differential.h create mode 100644 deal.II/deal.II/include/integrators/l2.h diff --git a/deal.II/deal.II/include/integrators/differential.h b/deal.II/deal.II/include/integrators/differential.h new file mode 100644 index 0000000000..5beec751cb --- /dev/null +++ b/deal.II/deal.II/include/integrators/differential.h @@ -0,0 +1,192 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 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. +// +//--------------------------------------------------------------------------- +#ifndef __deal2__integrators_differential_h +#define __deal2__integrators_differential_h + + +#include +#include +#include +#include +#include +#include +#include + +DEAL_II_NAMESPACE_OPEN + +namespace LocalIntegrators +{ +/** + * @brief Local integrators related to first order differential operators and their traces. + * + * @author Guido Kanschat + * @date 2010 + */ + namespace Differential + { +/** + * Cell matrix for divergence. The derivative is on the trial function. + * + * \f[ + * \int_Z v\nabla \cdot u \,dx + * \f] + */ + template + void divergence_matrix ( + FullMatrix& M, + const FEValuesBase& fe, + const FEValuesBase& fetest, + double factor = 1.) + { + unsigned int fecomp = fe.get_fe().n_components(); + const unsigned int n_dofs = fe.dofs_per_cell; + const unsigned int t_dofs = fetest.dofs_per_cell; + AssertDimension(fecomp, dim); + AssertDimension(M.m(), t_dofs); + AssertDimension(M.n(), n_dofs); + + for (unsigned k=0;k + void gradient_matrix( + FullMatrix& M, + const FEValuesBase& fe, + const FEValuesBase& fetest, + double factor = 1.) + { + unsigned int fecomp = fetest.get_fe().n_components(); + const unsigned int t_dofs = fetest.dofs_per_cell; + const unsigned int n_dofs = fe.dofs_per_cell; + + AssertDimension(fecomp, dim); + AssertDimension(fe.get_fe().n_components(), 1); + AssertDimension(M.m(), t_dofs); + AssertDimension(M.n(), n_dofs); + + for (unsigned k=0;k& Du = fe.shape_grad(j,k); + M(i,j) += dx * vv * Du[d]; + } + } + } + } + +/** + * The trace of the divergence + * operator, namely the product + * of the normal component of the + * vector valued trial space and + * the test space. + * @f[ + * \int_F (\mathbf u\cdot \mathbf n) v \,ds + * @f] + */ + template + void + u_dot_n_matrix ( + FullMatrix& M, + const FEValuesBase& fe, + const FEValuesBase& fetest, + double factor = 1.) + { + unsigned int fecomp = fe.get_fe().n_components(); + const unsigned int n_dofs = fe.dofs_per_cell; + const unsigned int t_dofs = fetest.dofs_per_cell; + + AssertDimension(fecomp, dim); + AssertDimension(fetest.get_fe().n_components(), 1); + AssertDimension(M.m(), t_dofs); + AssertDimension(M.n(), n_dofs); + + for (unsigned k=0;k ndx = factor * fe.JxW(k) * fe.normal_vector(k); + for (unsigned i=0;i + void + u_dot_n_residual ( + Vector& result, + const FEValuesBase& fe, + const FEValuesBase& fetest, + const VectorSlice > >& data, + double factor = 1.) + { + unsigned int fecomp = fe.get_fe().n_components(); + const unsigned int t_dofs = fetest.dofs_per_cell; + + AssertDimension(fecomp, dim); + AssertDimension(fetest.get_fe().n_components(), 1); + AssertDimension(result.size(), t_dofs); + AssertVectorVectorDimension (data, dim, fe.n_quadrature_points); + + for (unsigned k=0;k ndx = factor * fe.normal_vector(k) * fe.JxW(k); + + for (unsigned i=0;i +#include +#include +#include +#include +#include +#include + +DEAL_II_NAMESPACE_OPEN + +namespace LocalIntegrators +{ +/** + * @brief Local integrators related to L2-inner products. + * + * @author Guido Kanschat + * @date 2010 + */ + namespace L2 + { +/** + * The mass matrix. + * + * \f[ + * (a u,v) + * \f] + */ + template + void mass_matrix ( + FullMatrix& M, + const FEValuesBase& fe, + const double factor = 1.) + { + const unsigned int n_dofs = fe.dofs_per_cell; + const unsigned int n_components = fe.get_fe().n_components(); + + for (unsigned k=0;kL2-inner product for scalar functions. + * + * \f[ + * (f,v) + * \f] + */ + template + void L2 ( + Vector& result, + const FEValuesBase& fe, + const std::vector& input, + const double factor = 1.) + { + const unsigned int n_dofs = fe.dofs_per_cell; + AssertDimension(result.size(), n_dofs); + AssertDimension(fe.get_fe().n_components(), 1); + AssertDimension(input.size(), fe.n_quadrature_points); + + for (unsigned k=0;kL2-inner product for a slice of a vector valued + * right hand side. + * + * \f[ + * \int_Z f\cdot v\,dx + * \f] + */ + template + void L2 ( + Vector& result, + const FEValuesBase& fe, + const VectorSlice > >& input, + const double factor = 1.) + { + const unsigned int n_dofs = fe.dofs_per_cell; + const unsigned int fe_components = fe.get_fe().n_components(); + const unsigned int n_components = input.size(); + + AssertDimension(result.size(), n_dofs); + AssertDimension(input.size(), fe_components); + + for (unsigned k=0;k