DOpE
pointconstraintsmaker.h
Go to the documentation of this file.
1 
24 #ifndef POINTCONSTRAINTSMAKER_H_
25 #define POINTCONSTRAINTSMAKER_H_
26 
28 
29 namespace DOpE
30 {
41  template<template<int, int> class DH, int dopedim, int dealdim = dopedim>
42  class PointConstraints : public UserDefinedDoFConstraints<DH,dopedim,dealdim>
43  {
44  public:
45  PointConstraints(const std::vector<dealii::Point<dealdim> > &c_points,
46  const std::vector<std::vector<bool> > &c_comps)
47  : UserDefinedDoFConstraints<DH,dopedim,dealdim>(), c_points_(c_points), c_comps_(c_comps)
48  {
49  if(c_points_.size() != c_comps_.size())
50  throw DOpEException("Number of Entries not matching!","PointConstraints::PointConstraints");
51  }
52 
53  virtual void MakeStateDoFConstraints(
54  const DOpEWrapper::DoFHandler<dealdim, DH> & dof_handler,
55  dealii::ConstraintMatrix& constraint_matrix) const;
56 
57  virtual void
59  const DOpEWrapper::DoFHandler<dopedim, DH> & /*dof_handler*/,
60  dealii::ConstraintMatrix& /*dof_constraints*/) const {}
61 
62  private:
63 
64  const std::vector<Point<dealdim> > & c_points_;
65  const std::vector<std::vector<bool> > & c_comps_;
66  };
67 
68  template<template<int, int> class DH, int dopedim, int dealdim>
70  const DOpEWrapper::DoFHandler<dealdim, DH > & dof_handler,
71  dealii::ConstraintMatrix& constraint_matrix) const
72  {
73  std::vector<dealii::Point<dealdim> > support_points(dof_handler.n_dofs());
74  STHInternals::MapDoFsToSupportPoints(this->GetMapping(),dof_handler, support_points);
75  for(unsigned int i = 0; i < c_points_.size(); i++)
76  {
77  std::vector<bool> selected_dofs(dof_handler.n_dofs());
78 #if DEAL_II_MAJOR_VERSION >= 8
79  //Newer dealii Versions have changed the interface
80  dealii::ComponentMask components(c_comps_[i]);
81  DoFTools::extract_dofs(dof_handler,components,selected_dofs);
82 #else //Less than 8.0
83 #if DEAL_II_MAJOR_VERSION >= 7
84 #if DEAL_II_MINOR_VERSION >= 3
85  //Newer dealii Versions have changed the interface
86  dealii::ComponentMask components(c_comps_[i]);
87  DoFTools::extract_dofs(dof_handler,components,selected_dofs);
88 #else //Less than 7.3
89  DoFTools::extract_dofs(dof_handler,c_comps_[i],selected_dofs);
90 #endif
91 #else //Less than 7.0
92  DoFTools::extract_dofs(dof_handler,c_comps_[i],selected_dofs);
93 #endif
94 #endif
95 
96  bool found = false;
97  for(unsigned int p = 0; p < support_points.size(); p++)
98  {
99  if(c_points_[i].distance(support_points[p]) < 1.e-12)
100  {
101  found = true;
102  if(selected_dofs[p] == true)
103  {
104  constraint_matrix.add_line(p);
105  }
106  //Note that you cannot stop the loop here, since more than
107  //one dof may be located at a given point!
108  }
109  }
110  if(!found)
111  {
112  throw DOpEException("Points not found!","PointConstraints::MakeStateDoFConstraints");
113  }
114  }
115  }
116 
117 }
118 
119 #endif /* POINTCONSTRAINTSMAKER_H_ */
Definition: pointconstraintsmaker.h:42
Definition: userdefineddofconstraints.h:55
virtual void MakeControlDoFConstraints(const DOpEWrapper::DoFHandler< dopedim, DH > &, dealii::ConstraintMatrix &) const
Definition: pointconstraintsmaker.h:58
void MapDoFsToSupportPoints(const DOpEWrapper::Mapping< dealdim, dealii::DoFHandler > &mapping, const DOpEWrapper::DoFHandler< dealdim, dealii::DoFHandler > &dh, VECTOR &support_points)
Definition: sth_internals.h:47
Definition: dopeexception.h:35
virtual void MakeStateDoFConstraints(const DOpEWrapper::DoFHandler< dealdim, DH > &dof_handler, dealii::ConstraintMatrix &constraint_matrix) const
Definition: pointconstraintsmaker.h:69
PointConstraints(const std::vector< dealii::Point< dealdim > > &c_points, const std::vector< std::vector< bool > > &c_comps)
Definition: pointconstraintsmaker.h:45