From: Wolfgang Bangerth Date: Fri, 15 May 1998 17:10:54 +0000 (+0000) Subject: Add interpolation/projection and the like of functions to vectors. X-Git-Tag: v8.0.0~22963 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b42677f7003c8405441e703d910a7022cbea9e45;p=dealii.git Add interpolation/projection and the like of functions to vectors. git-svn-id: https://svn.dealii.org/trunk@291 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h new file mode 100644 index 0000000000..6039f447ca --- /dev/null +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -0,0 +1,54 @@ +/*---------------------------- vectors.h ---------------------------*/ +/* $Id$ */ +#ifndef __vectors_H +#define __vectors_H +/*---------------------------- vectors.h ---------------------------*/ + + +template class DoFHandler; +template class Function; +template class Quadrature; +template class Boundary; +template class FiniteElement; +class ConstraintMatrix; +class dVector; + + + +/** + * Provide a class which assembles some standard vectors. Among these are + * interpolations and projections of continuous functions to the finite + * element space and other operations. + */ +template +class VectorCreator { + public: + /** + * Compute the interpolation of + * #function# at the ansatz points to + * the finite element space. + */ + static void interpolate (const DoFHandler &dof, + const FiniteElement &fe, + const Function &function, + dVector &vec); + + /** + * Compute the projection of + * #function# to the finite element space. + */ + static void project (const DoFHandler &dof, + const ConstraintMatrix &constraints, + const FiniteElement &fe, + const Quadrature &q, + const Boundary &boundary, + const Function &function, + dVector &vec); +}; + + + +/*---------------------------- vectors.h ---------------------------*/ +/* end of #ifndef __vectors_H */ +#endif +/*---------------------------- vectors.h ---------------------------*/ diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc new file mode 100644 index 0000000000..040410d3c7 --- /dev/null +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -0,0 +1,65 @@ +/* $Id$ */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../../mia/control.h" +#include "../../../mia/vectormemory.h" +#include "../../../mia/cg.h" + + +template +void VectorCreator::interpolate (const DoFHandler &dof, + const FiniteElement &fe, + const Function &function, + dVector &vec) { + ; +}; + + + + +template +void VectorCreator::project (const DoFHandler &dof, + const ConstraintMatrix &constraints, + const FiniteElement &fe, + const Quadrature &q, + const Boundary &boundary, + const Function &function, + dVector &vec) { + vec.reinit (dof.n_dofs()); + + dSMatrixStruct sparsity(dof.n_dofs(), + dof.n_dofs(), + dof.max_couplings_between_dofs()); + dof.make_sparsity_pattern (sparsity); + + dSMatrix mass_matrix (sparsity); + dVector tmp (mass_matrix.n()); + MatrixCreator::create_mass_matrix (dof, fe, q, boundary, + mass_matrix, function, vec); + + int max_iter = 4000; + double tolerance = 1.e-16; + Control control1(max_iter,tolerance); + PrimitiveVectorMemory memory(tmp.size()); + CG cg(control1,memory); + + // solve + cg (mass_matrix, vec, tmp); + // distribute solution + constraints.distribute (vec); +}; + + + + +template VectorCreator<1>; +template VectorCreator<2>;