deal2lkit: A ToolKit library for Deal.II
parsed_zero_average_constraints.h
Go to the documentation of this file.
1 //-----------------------------------------------------------
2 //
3 // Copyright (C) 2016 by the deal2lkit authors
4 //
5 // This file is part of the deal2lkit library.
6 //
7 // The deal2lkit library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal2lkit distribution.
13 //
14 //-----------------------------------------------------------
15 
16 #ifndef _d2k_parsed_zero_average_constraints_h
17 #define _d2k_parsed_zero_average_constraints_h
18 
19 #include <deal2lkit/config.h>
24 #include <algorithm>
25 #include <map>
26 #include <deal2lkit/utilities.h>
29 
30 
31 using namespace dealii;
32 
33 
34 D2K_NAMESPACE_OPEN
35 
64 template <int dim, int spacedim=dim>
66 {
67 public:
86  ParsedZeroAverageConstraints (const std::string &name,
87  const unsigned int &n_components=1,
88  const std::string &component_names = "",
89  const std::string &default_components = "",
90  const std::string &default_boundary_components ="");
91 
92 
97  void apply_zero_average_constraints(const DoFHandler<dim,spacedim> &dof_handler,
98  ConstraintMatrix &constraints) const;
99 
100 
104  ComponentMask get_boundary_mask () const;
105 
106 
110  ComponentMask get_mask () const;
111 
112 
116  virtual void declare_parameters (ParameterHandler &prm);
117 
121  virtual void parse_parameters_call_back ();
122 
123 
124 
126  DeclException2(ExcWrongComponent, unsigned int, unsigned int,
127  << "Wrong component number has been used: "
128  << arg1 << " is not in the range [0, "
129  << arg2 <<").");
130 
132  DeclException2(ExcWrongVariable, std::string, std::vector<std::string>,
133  << "Wrong variabile name has been used: "
134  << arg1 << " does not belong to the knwon variables: "
135  << print(unique(arg2)) <<".");
136 
137 protected:
138 
139  void internal_zero_average_constraints(const DoFHandler<dim,spacedim> &dof_handler,
140  const ComponentMask mask,
141  const bool at_boundary,
142  ConstraintMatrix &constraints) const;
143 
144  std::string name;
145  std::string str_components;
147  std::string str_component_names;
148  std::vector<std::string> _component_names;
149  std::vector<std::string> boundary_components;
150  std::vector<std::string> components;
151 
152  std::vector<bool> mask;
153  std::vector<bool> boundary_mask;
154 
155  const unsigned int n_components;
156 };
157 
158 
159 
160 D2K_NAMESPACE_CLOSE
161 
162 #endif
163 
#define DeclException2(Exception2, type1, type2, outsequence)
A parameter acceptor base class.
std::vector< std::string > boundary_components
std::string print(const std::vector< Type > &list, const std::string sep=",")
Return a string containing the content of the vector, with elements separated by the @ sep parameter...
Definition: utilities.h:425
ParsedZeroAverageConstraints class.
std::vector< T > unique(const std::vector< T > &myvector)
A simple function that accepts a vector as an input and returns a second vector containing only the u...
Definition: utilities.h:412