deal2lkit: A ToolKit library for Deal.II
parsed_mapped_functions.h
Go to the documentation of this file.
1 //-----------------------------------------------------------
2 //
3 // Copyright (C) 2015 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_mapped_function_h
17 #define _d2k_parsed_mapped_function_h
18 
19 #include <deal2lkit/config.h>
25 #include <algorithm>
26 #include <map>
27 #include <deal2lkit/utilities.h>
28 
29 using namespace dealii;
30 
31 
32 D2K_NAMESPACE_OPEN
33 
70 template <int spacedim>
72 {
73 public:
93  ParsedMappedFunctions (const std::string &name = "Mapped Functions",
94  const unsigned int &n_components=1,
95  const std::string &component_names = "",
96  const std::string &default_id_components = "0=ALL",
97  const std::string &default_id_functions = "",
98  const std::string &default_constants = "");
99 
103  shared_ptr<dealii::Functions::ParsedFunction<spacedim> > get_mapped_function (const unsigned int &id) const;
104 
110  shared_ptr<dealii::Functions::ParsedFunction<spacedim> > get_mapped_normal_function (const unsigned int &id,
111  const unsigned int &fcv) const;
112 
116  ComponentMask get_mapped_mask (const unsigned int &id) const;
117 
121  std::vector<unsigned int> get_mapped_ids() const;
122 
126  std::vector<unsigned int> get_mapped_normal_ids() const;
127 
128 
132  virtual void declare_parameters (ParameterHandler &prm);
133 
137  virtual void parse_parameters_call_back ();
138 
142  bool acts_on_id (unsigned int &id) const;
143 
147  void set_time (const double &t);
148 
149 
152  DeclException2(ExcIdsMismatch, unsigned int, unsigned int,
153  << "The number of ids specified in the field "
154  << "'IDs and component masks' (" << arg1 << ") "
155  << "must match the number of ids "
156  << "set in the field 'IDs and expressions' (" << arg2 <<").");
157 
159  DeclException1(ExcIdNotFound, unsigned int,
160  << "No entry with the id " << arg1 << " exists.");
161 
163  DeclException1(ExcIdNotMatch, unsigned int,
164  << "No component mask associated to the id " << arg1 << " are defined.");
165 
167  DeclException3(ExcWrongComponent, unsigned int, unsigned int, unsigned int,
168  << "At id " << arg1
169  << ", wrong component number has been used: "
170  << arg2 << " is not in the range [0, "
171  << arg3 <<").");
173  DeclException3(ExcWrongVariable, unsigned int, std::string, std::vector<std::string>,
174  << "At id " << arg1
175  << ", wrong variabile name has been used: "
176  << arg2 << " does not belong to the knwon variables: "
177  << print(unique(arg3)) <<".");
178 
179 protected:
180 
181  void split_id_components(const std::string &parsed_idcomponents);
182  void split_id_functions(const std::string &parsed_idfunctions,
183  const std::string &constants);
184  void add_normal_components();
185 
186  void set_normal_functions();
187 
188  std::string name;
189  std::string str_id_components;
190  std::string str_id_functions;
191  std::string str_component_names;
192  std::string str_constants;
193  std::vector<std::string> _component_names;
194  std::vector<std::string> _normal_components;
195  std::vector<std::string> _all_components;
196  std::vector<unsigned int> ids;
197  std::vector<unsigned int> normal_ids;
198  std::map<unsigned int, ComponentMask> id_components;
199  std::map<unsigned int, shared_ptr<dealii::Functions::ParsedFunction<spacedim> > > id_functions;
200  std::map<unsigned int, std::pair<ComponentMask, shared_ptr<dealii::Functions::ParsedFunction<spacedim> > > > mapped_functions;
201  std::map<std::string, std::pair<std::vector<unsigned int>, unsigned int > > mapped_normal_components; // name, (std::vector<boundary ids>, first component vector)
202  std::vector<std::pair<unsigned int, std::string> > normal_components; // first component vector, variable_name+"N"
203  std::map<unsigned int, std::string> id_str_functions;
204  std::map<std::pair<unsigned int, unsigned int>, shared_ptr<dealii::Functions::ParsedFunction<spacedim> > > _normal_functions;
205 
206  const unsigned int n_components;
207 };
208 
209 
210 
211 D2K_NAMESPACE_CLOSE
212 
213 #endif
214 
#define DeclException2(Exception2, type1, type2, outsequence)
A parameter acceptor base class.
const unsigned int n_components
std::vector< std::pair< unsigned int, std::string > > normal_components
std::map< unsigned int, std::string > id_str_functions
std::vector< unsigned int > ids
DeclException1(ExcCannottExecuteCommand, std::string,<< "Cannot execute command "<< arg1<< "\Please verify you have "<< "the needed permissions.")
Cannot execute std::system(command)
std::vector< unsigned int > normal_ids
ParsedMappedFunctions object.
std::vector< std::string > _component_names
std::map< unsigned int, shared_ptr< dealii::Functions::ParsedFunction< spacedim > > > id_functions
std::map< std::string, std::pair< std::vector< unsigned int >, unsigned int > > mapped_normal_components
std::map< std::pair< unsigned int, unsigned int >, shared_ptr< dealii::Functions::ParsedFunction< spacedim > > > _normal_functions
std::map< unsigned int, std::pair< ComponentMask, shared_ptr< dealii::Functions::ParsedFunction< spacedim > > > > mapped_functions
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
std::vector< std::string > _normal_components
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
#define DeclException3(Exception3, type1, type2, type3, outsequence)
std::map< unsigned int, ComponentMask > id_components
std::vector< std::string > _all_components