WaveBEM: Unsteady Nonlinear Potential Flow Solver for Ship-Wave Interaction.
constrained_matrix.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 // $Id: filtered_matrix.h 23248 2011-01-23 06:03:57Z bangerth $
3 // Version: $Name$
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors
6 //
7 // This file is subject to QPL and may not be distributed
8 // without copyright and license information. Please refer
9 // to the file deal.II/doc/license.html for the text and
10 // further information on this license.
11 //
12 //---------------------------------------------------------------------------
13 #ifndef __deal2__constrained_matrix_h
14 #define __deal2__constrained_matrix_h
15 
16 
17 
18 #include <deal.II/base/config.h>
25 #include <vector>
26 #include <algorithm>
27 
28 DEAL_II_NAMESPACE_OPEN
29 
30 template <typename number> class Vector;
31 template <class VECTOR> class ConstrainedMatrixBlock;
32 
33 
44 template<class VEC, class MATRIX>
46 {
47 public:
48  ConstrainedOperator(const MATRIX &m,
49  const ConstraintMatrix &c) :
50  constraints(c),
51  matrix(m)
52  {}
53 
54 
55 
56  void vmult(VEC &dst, const VEC &src) const;
57 
58  void distribute_rhs(VEC &rhs) const;
59 
60 private:
62  const MATRIX &matrix;
63 };
64 
66 /*---------------------- Inline functions -----------------------------------*/
67 
68 
69 //--------------------------------Iterators--------------------------------------//
70 
71 
72 template<class VEC, class MATRIX>
73 void ConstrainedOperator<VEC,MATRIX>::vmult(VEC &dst, const VEC &src) const
74 {
75  matrix.vmult(dst, src);
76  for (unsigned int i=0; i<dst.size(); ++i)
77  if (constraints.is_constrained(i))
78  {
79  dst(i) = src(i);
80  const std::vector< std::pair < unsigned int, double > >
81  *entries = constraints.get_constraint_entries (i);
82  for (unsigned int j=0; j< entries->size(); ++j)
83  dst(i) -= (*entries)[j].second *
84  src((*entries)[j].first);
85  }
86 }
87 
88 template<class VEC, class MATRIX>
90 {
91  for (unsigned int i=0; i<rhs.size(); ++i)
92  if (constraints.is_constrained(i))
93  rhs(i) = constraints.get_inhomogeneity(i);
94 }
95 
96 
97 DEAL_II_NAMESPACE_CLOSE
98 
99 #endif
100 /*---------------------------- filtered_matrix.h ---------------------------*/
void distribute_rhs(VEC &rhs) const
ConstrainedOperator(const MATRIX &m, const ConstraintMatrix &c)
void vmult(VEC &dst, const VEC &src) const
const ConstraintMatrix & constraints