20 #ifndef _FCST_FUELCELL_INITIAL_AND_BOUNDARY_DATA_H_
21 #define _FCST_FUELCELL_INITIAL_AND_BOUNDARY_DATA_H_
23 #define _IS_NOT_CONSTANT_ 1.e300
25 #include <deal.II/base/point.h>
26 #include <deal.II/base/function.h>
27 #include <deal.II/lac/vector.h>
28 #include <deal.II/dofs/function_map.h>
29 #include <deal.II/fe/mapping_q1.h>
30 #include <deal.II/fe/mapping_q.h>
31 #include <deal.II/numerics/vector_tools.h>
32 #include <deal.II/numerics/matrix_tools.h>
39 using namespace dealii;
40 using namespace FuelCell::ApplicationCore;
97 namespace InitialAndBoundaryData
104 template<
typename COMPONENT_xxxID_VALUE_MAP>
105 const bool check(
const std::vector< COMPONENT_xxxID_VALUE_MAP >& maps)
112 const std::type_info& info =
typeid(COMPONENT_xxxID_VALUE_MAP);
118 if( maps.size() == 0 )
126 for(
unsigned int i = 0; i < maps.size(); ++i)
127 if( maps[i].empty() )
135 for(
unsigned int i = 0; i < maps.size(); ++i)
136 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
137 iter != maps[i].end();
139 if( iter->second.empty() )
147 if( info == material )
148 for(
unsigned int i = 0; i < maps.size(); ++i)
149 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
150 iter != maps[i].end();
152 if( iter->second.find(numbers::invalid_material_id) != iter->second.end() )
158 if( info == boundary )
159 for(
unsigned int i = 0; i < maps.size(); ++i)
160 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
161 iter != maps[i].end();
163 if( iter->second.find(numbers::invalid_boundary_id) != iter->second.end() )
189 template<
typename VECTOR,
typename DH>
194 const std::vector< component_materialID_value_map >& maps)
198 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_materialID_value_map >(maps),
199 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::make_piece_wise_constant_initial_data function "
200 "is wrong : check the previous message") );
205 AssertThrow( n_components == dof.get_fe().n_components(),
206 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
208 for(
unsigned int i = 0; i < maps.size(); ++i)
209 for(component_materialID_value_map::const_iterator iter = maps[i].begin(); iter != maps[i].end(); ++iter)
211 std::map<types::material_id, double> tmp = iter->second;
213 for(std::map<types::material_id, double>::const_iterator iter2 = tmp.begin(); iter2 != tmp.end(); ++iter2)
217 std::map< types::material_id, const Function<DH::space_dimension>* > function_map;
219 const ConstantFunction<DH::space_dimension> constant_function(iter2->second, n_components);
220 function_map[iter2->first] = &constant_function;
222 std::vector<bool> component_mask(n_components,
false);
225 VectorTools::interpolate_based_on_material_id( mapping,
246 template<
typename DH>
251 const std::vector< component_boundaryID_value_map >& maps)
255 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_boundaryID_value_map >(maps),
256 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::make_constant_DirichletBC_values function "
257 "is wrong : check the previous message") );
262 AssertThrow( n_components == dof.get_fe().n_components(),
263 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
265 for(
unsigned int i = 0; i < maps.size(); ++i)
266 for(component_boundaryID_value_map::const_iterator iter = maps[i].begin(); iter != maps[i].end(); ++iter)
268 std::map<types::boundary_id, double> tmp = iter->second;
270 for(std::map<types::boundary_id, double>::const_iterator iter2 = tmp.begin(); iter2 != tmp.end(); ++iter2)
272 typename FunctionMap<DH::space_dimension>::type function_map;
274 const ConstantFunction<DH::space_dimension> constant_function(iter2->second, n_components);
275 function_map[iter2->first] = &constant_function;
278 std::vector<bool> component_mask(n_components,
false);
281 VectorTools::interpolate_boundary_values( mapping,
307 template<
typename VECTOR,
typename DH>
312 const std::vector< component_boundaryID_value_map >& maps)
323 AssertThrow( n_components == dof.get_fe().n_components(),
324 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
326 for(
unsigned int i = 0; i < maps.size(); ++i)
327 for(component_boundaryID_value_map::const_iterator iter = maps[i].begin(); iter != maps[i].end(); ++iter)
329 std::map<types::boundary_id, double> tmp = iter->second;
331 for(std::map<types::boundary_id, double>::const_iterator iter2 = tmp.begin(); iter2 != tmp.end(); ++iter2)
335 typename FunctionMap<DH::space_dimension>::type function_map;
337 const ConstantFunction<DH::space_dimension> constant_function(iter2->second, n_components);
338 function_map[iter2->first] = &constant_function;
340 std::vector<bool> component_mask(n_components,
false);
343 std::map<unsigned int, double> boundary_values;
345 VectorTools::interpolate_boundary_values( mapping,
351 for(std::map<unsigned int, double>::const_iterator iter3 = boundary_values.begin();
352 iter3 != boundary_values.end(); ++iter3)
354 dst(iter3->first) = iter3->second;
364 template<
typename DH>
369 const std::vector< component_boundaryID_value_map >& maps)
380 AssertThrow( n_components == dof.get_fe().n_components(),
381 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
383 for(
unsigned int i = 0; i < maps.size(); ++i)
384 for(component_boundaryID_value_map::const_iterator iter = maps[i].begin(); iter != maps[i].end(); ++iter)
386 std::map<types::boundary_id, double> tmp = iter->second;
388 for(std::map<types::boundary_id, double>::const_iterator iter2 = tmp.begin(); iter2 != tmp.end(); ++iter2)
390 typename FunctionMap<DH::space_dimension>::type function_map;
392 const ZeroFunction<DH::space_dimension> zero_function(n_components);
393 function_map[iter2->first] = &zero_function;
395 std::vector<bool> component_mask(n_components,
false);
398 VectorTools::interpolate_boundary_values( mapping,
416 template<
typename MATRIX,
typename VECTOR,
typename DH>
423 const std::vector< component_boundaryID_value_map >& maps,
433 std::map<unsigned int, double> boundary_values;
434 FuelCell::InitialAndBoundaryData::make_zero_boundary_values<DH>( boundary_values,
439 MatrixTools::apply_boundary_values( boundary_values,
465 virtual double value(
const Point<dim>& point,
466 const unsigned int no_component = 0)
const;
483 const unsigned int n_components = 1);
500 virtual double math_expression(
const Point<dim>& point,
501 const unsigned int no_component = 0)
const;
512 void print_caller_name(
const std::string& caller_name)
const;
528 boost::shared_ptr<ApplicationData>
data;
Definition: dof_application.h:68
const bool check(const std::vector< COMPONENT_xxxID_VALUE_MAP > &maps)
This function does some checkings on its argument maps.
Definition: initial_and_boundary_data.h:105
boost::shared_ptr< ApplicationData > data
Data of the application serves to exchange the information between YourApplication<dim> and children ...
Definition: initial_and_boundary_data.h:528
void make_constant_DirichletBC_values(std::map< unsigned int, double > &dst, const Mapping< DH::dimension, DH::space_dimension > &mapping, const DH &dof, const FuelCell::SystemManagement &system_management, const std::vector< component_boundaryID_value_map > &maps)
Definition: initial_and_boundary_data.h:247
std::map< std::string, std::map< types::material_id, double > > component_materialID_value_map
The typedef for the std::map that reflects the following structure:
Definition: initial_and_boundary_data.h:74
std::map< std::string, std::map< types::boundary_id, double > > component_boundaryID_value_map
The typedef for the std::map that reflects the following structure:
Definition: initial_and_boundary_data.h:85
#define _IS_NOT_CONSTANT_
Definition: initial_and_boundary_data.h:23
void apply_piece_wise_constant_DirichletBCs(VECTOR &dst, const Mapping< DH::dimension, DH::space_dimension > &mapping, const DH &dof, const FuelCell::SystemManagement &system_management, const std::vector< component_boundaryID_value_map > &maps)
This function applies piece wise constant Dirichlet BCs.
Definition: initial_and_boundary_data.h:308
void make_zero_boundary_values(std::map< unsigned int, double > &dst, const Mapping< DH::dimension, DH::space_dimension > &mapping, const DH &dof, const FuelCell::SystemManagement &system_management, const std::vector< component_boundaryID_value_map > &maps)
This function makes zero boundary values.
Definition: initial_and_boundary_data.h:365
This class is a means to make variable initial or boundary data.
Definition: initial_and_boundary_data.h:453
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
const unsigned int solution_name_to_index(const std::string &name) const
This function returns the index of a user defined solution variable with name name stored in solution...
const unsigned int & get_number_of_solution_names() const
This function returns n_solution_names.
Definition: system_management.h:506
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:300
void make_piece_wise_constant_initial_data(VECTOR &dst, const Mapping< DH::dimension, DH::space_dimension > &mapping, const DH &dof, const FuelCell::SystemManagement &system_management, const std::vector< component_materialID_value_map > &maps)
This function makes piece wise constant initial data.
Definition: initial_and_boundary_data.h:190
void repair_diagonal(BlockSparseMatrix< double > &A)
This member function is used to make sure that the BlockSpareMatrix has no zeros in the diagonal...
void apply_zero_boundary_values_to_linear_system(MATRIX &matrix, VECTOR &solution, VECTOR &rhs, const Mapping< DH::dimension, DH::space_dimension > &mapping, const DH &dof, const FuelCell::SystemManagement &system_management, const std::vector< component_boundaryID_value_map > &maps, const bool &repair_diagonal=false)
This function applies zero boundary values to the linear system of equations.
Definition: initial_and_boundary_data.h:417