19 #ifndef _FCST_FUELCELL_INITIAL_AND_BOUNDARY_DATA_H_
20 #define _FCST_FUELCELL_INITIAL_AND_BOUNDARY_DATA_H_
22 #define _IS_NOT_CONSTANT_ 1.e300
24 #include <boost/lexical_cast.hpp>
26 #include <base/point.h>
27 #include <base/function.h>
29 #include <lac/vector.h>
30 #include <lac/block_vector.h>
31 #include <lac/block_sparse_matrix.h>
33 #include <dofs/function_map.h>
35 #include <fe/mapping_q1.h>
36 #include <fe/mapping_q.h>
38 #include <numerics/vector_tools.h>
39 #include <numerics/matrix_tools.h>
44 using namespace dealii;
45 using namespace AppFrame;
79 namespace InitialAndBoundaryData
87 template<
typename COMPONENT_xxxID_VALUE_MAP>
89 std::vector< COMPONENT_xxxID_VALUE_MAP >& maps)
96 const std::type_info& info =
typeid(COMPONENT_xxxID_VALUE_MAP);
102 if( maps.size() == 0 )
104 std::cerr <<
"The argument is empty" << std::endl;
110 for(
unsigned int i = 0; i < maps.size(); ++i)
111 if( maps[i].empty() )
113 std::cerr <<
"Outer map/maps of the argument is/are empty" << std::endl;
119 for(
unsigned int i = 0; i < maps.size(); ++i)
120 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
121 iter != maps[i].end();
123 if( iter->second.empty() )
125 std::cerr <<
"Inner map/maps of the argument is/are empty" << std::endl;
131 if( info == material )
132 for(
unsigned int i = 0; i < maps.size(); ++i)
133 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
134 iter != maps[i].end();
136 if( iter->second.find(numbers::invalid_material_id) != iter->second.end() )
138 std::cerr <<
"Invalid material id/ids of the argument" << std::endl;
142 if( info == boundary )
143 for(
unsigned int i = 0; i < maps.size(); ++i)
144 for(
typename COMPONENT_xxxID_VALUE_MAP::const_iterator iter = maps[i].begin();
145 iter != maps[i].end();
147 if( iter->second.find(numbers::invalid_boundary_id) != iter->second.end() )
149 std::cerr <<
"Invalid boundary id/ids of the argument" << std::endl;
160 template<
typename VECTOR,
typename DH>
165 const std::vector< component_materialID_value_map >& maps)
169 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_materialID_value_map >(maps),
170 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::make_piece_wise_constant_initial_data function "
171 "is wrong : check the previous message") );
176 AssertThrow( n_components == dof.get_fe().n_components(),
177 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
179 for(
unsigned int i = 0; i < maps.size(); ++i)
180 for(component_materialID_value_map::const_iterator iter = maps[i].begin();
181 iter != maps[i].end();
184 std::map<types::material_id, double> tmp = iter->second;
186 for(std::map<types::material_id, double>::const_iterator iter2 = tmp.begin();
192 typename FunctionMap<DH::space_dimension>::type2 function_map;
194 const ConstantFunction<DH::space_dimension> constant_function(iter2->second, n_components);
195 function_map[boost::lexical_cast<
unsigned int>(iter2->first)] = &constant_function;
197 std::vector<bool> component_mask(n_components,
false);
200 VectorTools::interpolate( dst,
214 template<
typename VECTOR,
typename DH>
219 const std::vector< component_boundaryID_value_map >& maps)
223 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_boundaryID_value_map >(maps),
224 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::apply_piece_wise_constant_DirichletBCs function "
225 "is wrong : check the previous message") );
230 AssertThrow( n_components == dof.get_fe().n_components(),
231 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
233 for(
unsigned int i = 0; i < maps.size(); ++i)
234 for(component_boundaryID_value_map::const_iterator iter = maps[i].begin();
235 iter != maps[i].end();
238 std::map<types::boundary_id, double> tmp = iter->second;
240 for(std::map<types::boundary_id, double>::const_iterator iter2 = tmp.begin();
246 typename FunctionMap<DH::space_dimension>::type function_map;
248 const ConstantFunction<DH::space_dimension> constant_function(iter2->second, n_components);
249 function_map[boost::lexical_cast<
unsigned int>(iter2->first)] = &constant_function;
251 std::vector<bool> component_mask(n_components,
false);
254 std::map<unsigned int, double> boundary_values;
256 VectorTools::interpolate_boundary_values( mapping,
262 for(std::map<unsigned int, double>::const_iterator iter3 = boundary_values.begin();
263 iter3 != boundary_values.end();
266 dst(iter3->first) = iter3->second;
277 template<
typename DH>
282 const std::vector< component_boundaryID_value_map >& maps)
286 AssertThrow( FuelCell::InitialAndBoundaryData::check< component_boundaryID_value_map >(maps),
287 ExcMessage(
"The last argument in the FuelCell::InitialAndBoundaryData::make_zero_boundary_values function "
288 "is wrong : check the previous message") );
293 AssertThrow( n_components == dof.get_fe().n_components(),
294 ExcDimensionMismatch( n_components , dof.get_fe().n_components() ) );
296 for(
unsigned int i = 0; i < maps.size(); ++i)
297 for(component_boundaryID_value_map::const_iterator iter = maps[i].begin();
298 iter != maps[i].end();
301 std::map<types::boundary_id, double> tmp = iter->second;
303 for(std::map<types::boundary_id, double>::const_iterator iter2 = tmp.begin();
307 typename FunctionMap<DH::space_dimension>::type function_map;
309 const ZeroFunction<DH::space_dimension> zero_function(n_components);
310 function_map[boost::lexical_cast<
unsigned int>(iter2->first)] = &zero_function;
312 std::vector<bool> component_mask(n_components,
false);
315 VectorTools::interpolate_boundary_values( mapping,
329 template<
typename MATRIX,
typename VECTOR,
typename DH>
336 const std::vector< component_boundaryID_value_map >& maps,
337 const bool& repair_diagonal =
false)
339 if( repair_diagonal )
347 std::map<unsigned int, double> boundary_values;
348 FuelCell::InitialAndBoundaryData::make_zero_boundary_values<DH>( boundary_values,
353 MatrixTools::apply_boundary_values( boundary_values,
381 virtual double value(
const Point<dim>& point,
382 const unsigned int no_component = 0)
const;
416 virtual double math_expression(
const Point<dim>& point,
417 const unsigned int no_component = 0)
const;
430 void print_caller_name(
const std::string& caller_name)
const;