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 <base/point.h>
26 #include <base/function.h>
28 #include <lac/vector.h>
29 #include <lac/block_vector.h>
30 #include <lac/block_sparse_matrix.h>
32 #include <dofs/function_map.h>
34 #include <fe/mapping_q1.h>
35 #include <fe/mapping_q.h>
37 #include <numerics/vector_tools.h>
38 #include <numerics/matrix_tools.h>
44 using namespace dealii;
45 using namespace FuelCell::ApplicationCore;
102 namespace InitialAndBoundaryData
109 template<
typename COMPONENT_xxxID_VALUE_MAP>
110 const bool check(
const std::vector< COMPONENT_xxxID_VALUE_MAP >& maps)
117 const std::type_info& info =
typeid(COMPONENT_xxxID_VALUE_MAP);
123 if( maps.size() == 0 )
131 for(
unsigned int i = 0; i < maps.size(); ++i)
132 if( maps[i].empty() )
140 for(
unsigned int i = 0; i < maps.size(); ++i)
141 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
142 iter != maps[i].end();
144 if( iter->second.empty() )
152 if( info == material )
153 for(
unsigned int i = 0; i < maps.size(); ++i)
154 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
155 iter != maps[i].end();
157 if( iter->second.find(numbers::invalid_material_id) != iter->second.end() )
163 if( info == boundary )
164 for(
unsigned int i = 0; i < maps.size(); ++i)
165 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
166 iter != maps[i].end();
168 if( iter->second.find(numbers::invalid_boundary_id) != iter->second.end() )
194 template<
typename VECTOR,
typename DH>
199 const std::vector< component_materialID_value_map >& maps)
203 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_materialID_value_map >(maps),
204 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::make_piece_wise_constant_initial_data function "
205 "is wrong : check the previous message") );
210 AssertThrow( n_components == dof.get_fe().n_components(),
211 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
213 for(
unsigned int i = 0; i < maps.size(); ++i)
214 for(component_materialID_value_map::const_iterator iter = maps[i].begin(); iter != maps[i].end(); ++iter)
216 std::map<types::material_id, double> tmp = iter->second;
218 for(std::map<types::material_id, double>::const_iterator iter2 = tmp.begin(); iter2 != tmp.end(); ++iter2)
222 std::map< types::material_id, const Function<DH::space_dimension>* > function_map;
224 const ConstantFunction<DH::space_dimension> constant_function(iter2->second, n_components);
225 function_map[iter2->first] = &constant_function;
227 std::vector<bool> component_mask(n_components,
false);
230 VectorTools::interpolate_based_on_material_id( mapping,
251 template<
typename DH>
256 const std::vector< component_boundaryID_value_map >& maps)
260 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_boundaryID_value_map >(maps),
261 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::make_constant_DirichletBC_values function "
262 "is wrong : check the previous message") );
267 AssertThrow( n_components == dof.get_fe().n_components(),
268 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
270 for(
unsigned int i = 0; i < maps.size(); ++i)
271 for(component_boundaryID_value_map::const_iterator iter = maps[i].begin(); iter != maps[i].end(); ++iter)
273 std::map<types::boundary_id, double> tmp = iter->second;
275 for(std::map<types::boundary_id, double>::const_iterator iter2 = tmp.begin(); iter2 != tmp.end(); ++iter2)
277 typename FunctionMap<DH::space_dimension>::type function_map;
279 const ConstantFunction<DH::space_dimension> constant_function(iter2->second, n_components);
280 function_map[iter2->first] = &constant_function;
283 std::vector<bool> component_mask(n_components,
false);
286 VectorTools::interpolate_boundary_values( mapping,
312 template<
typename VECTOR,
typename DH>
317 const std::vector< component_boundaryID_value_map >& maps)
321 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_boundaryID_value_map >(maps),
322 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::apply_piece_wise_constant_DirichletBCs function "
323 "is wrong : check the previous message") );
328 AssertThrow( n_components == dof.get_fe().n_components(),
329 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
331 for(
unsigned int i = 0; i < maps.size(); ++i)
332 for(component_boundaryID_value_map::const_iterator iter = maps[i].begin(); iter != maps[i].end(); ++iter)
334 std::map<types::boundary_id, double> tmp = iter->second;
336 for(std::map<types::boundary_id, double>::const_iterator iter2 = tmp.begin(); iter2 != tmp.end(); ++iter2)
340 typename FunctionMap<DH::space_dimension>::type function_map;
342 const ConstantFunction<DH::space_dimension> constant_function(iter2->second, n_components);
343 function_map[iter2->first] = &constant_function;
345 std::vector<bool> component_mask(n_components,
false);
348 std::map<unsigned int, double> boundary_values;
350 VectorTools::interpolate_boundary_values( mapping,
356 for(std::map<unsigned int, double>::const_iterator iter3 = boundary_values.begin();
357 iter3 != boundary_values.end(); ++iter3)
359 dst(iter3->first) = iter3->second;
369 template<
typename DH>
374 const std::vector< component_boundaryID_value_map >& maps)
378 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_boundaryID_value_map >(maps),
379 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::make_zero_boundary_values function "
380 "is wrong : check the previous message") );
385 AssertThrow( n_components == dof.get_fe().n_components(),
386 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
388 for(
unsigned int i = 0; i < maps.size(); ++i)
389 for(component_boundaryID_value_map::const_iterator iter = maps[i].begin(); iter != maps[i].end(); ++iter)
391 std::map<types::boundary_id, double> tmp = iter->second;
393 for(std::map<types::boundary_id, double>::const_iterator iter2 = tmp.begin(); iter2 != tmp.end(); ++iter2)
395 typename FunctionMap<DH::space_dimension>::type function_map;
397 const ZeroFunction<DH::space_dimension> zero_function(n_components);
398 function_map[iter2->first] = &zero_function;
400 std::vector<bool> component_mask(n_components,
false);
403 VectorTools::interpolate_boundary_values( mapping,
421 template<
typename MATRIX,
typename VECTOR,
typename DH>
428 const std::vector< component_boundaryID_value_map >& maps,
438 std::map<unsigned int, double> boundary_values;
439 FuelCell::InitialAndBoundaryData::make_zero_boundary_values<DH>( boundary_values,
444 MatrixTools::apply_boundary_values( boundary_values,
470 virtual double value(
const Point<dim>& point,
471 const unsigned int no_component = 0)
const;
488 const unsigned int n_components = 1);
505 virtual double math_expression(
const Point<dim>& point,
506 const unsigned int no_component = 0)
const;
517 void print_caller_name(
const std::string& caller_name)
const;
533 boost::shared_ptr<ApplicationData>
data;
Definition: dof_application.h:83
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:110
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:533
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:252
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:79
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:90
#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:313
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:370
This class is a means to make variable initial or boundary data.
Definition: initial_and_boundary_data.h:458
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:464
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:271
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:195
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:422