15 #ifndef _DEALII_APPFRAME_MESH_WORKER_INFO_H_
16 #define _DEALII_APPFRAME_MESH_WORKER_INFO_H_
18 #include <base/geometry_info.h>
19 #include <base/quadrature_lib.h>
20 #include <base/mg_level_object.h>
22 #include <lac/block_indices.h>
25 #include <fe/fe_tools.h>
27 #include <multigrid/mg_tools.h>
31 #include <boost/shared_ptr.hpp>
39 using namespace dealii;
40 using namespace AppFrame;
123 template<
int dim,
int spacedim>
127 std::vector<unsigned int> sizes(fe.n_blocks());
128 DoFTools::count_dofs_per_block(dof_handler, sizes);
129 global.reinit(sizes);
135 template<
int dim,
int spacedim>
139 std::vector<unsigned int> sizes(fe.n_blocks());
141 base_element.resize(fe.n_blocks());
143 for(
unsigned int i = 0; i < base_element.size(); ++i)
144 base_element[i] = fe.block_to_base_index(i).first;
146 local_renumbering.resize(fe.n_dofs_per_cell());
147 FETools::compute_block_renumbering(fe,
157 template<
int dim,
int spacedim>
162 std::vector< std::vector<unsigned int> > sizes(mg_dof_handler.get_tria().n_levels(),
163 std::vector<unsigned int>(mg_dof_handler.get_fe().n_blocks())
166 MGTools::count_dofs_per_block(mg_dof_handler, sizes);
168 levels.resize(sizes.size());
169 for(
unsigned int i = 0; i < sizes.size(); ++i)
170 levels[i].reinit(sizes[i]);
209 void add_vector(
const std::string& name,
211 bool gradients =
false,
212 bool hessians =
false);
229 return (selection.size() == 0);
235 bool has_values()
const
237 return selected_values;
243 bool has_gradients()
const
245 return selected_gradients;
251 bool has_hessians()
const
253 return selected_hessians;
259 unsigned int n_values()
const
261 return cache_values.size();
267 unsigned int n_gradients()
const
269 return cache_gradients.size();
275 unsigned int n_hessians()
const
277 return cache_hessians.size();
283 unsigned int value_index(
unsigned int i)
const
285 AssertIndexRange(i, cache_values.size());
286 return cache_values[i];
292 unsigned int gradient_index(
unsigned int i)
const
294 AssertIndexRange(i, cache_gradients.size());
295 return cache_gradients[i];
301 unsigned int hessian_index(
unsigned int i)
const
303 AssertIndexRange(i, cache_hessians.size());
304 return cache_hessians[i];
312 template<
typename STREAM>
313 void print(STREAM& s,
384 selection(other.selection),
385 selected_values(other.selected_values),
386 selected_gradients(other.selected_gradients),
387 selected_hessians(other.selected_hessians)
418 for(std::vector<ListEntry>::const_iterator iter =
selection.begin();
422 const unsigned int k = src.
find_vector(iter->name);
424 Assert( k != deal_II_numbers::invalid_unsigned_int,
425 ApplicationData::ExcNotFound(
"vector", iter->name) );
433 template<
typename STREAM>
442 s << std::endl <<
"gradients: ";
445 s << std::endl <<
"hessians: ";
467 const std::vector<double>&)
494 const std::vector<double>&)
519 namespace InfoObjects
553 template<
int dim,
typename TYPE>
558 const std::vector<unsigned int>& local_dof_indices,
559 unsigned int first_index,
560 unsigned int n_indices,
561 std::vector< std::vector<TYPE> >& result)
563 Assert(
false, ExcNotImplemented());
571 const std::vector<unsigned int>& local_dof_indices,
572 unsigned int first_index,
573 unsigned int n_indices,
574 std::vector< std::vector<double> >& result)
576 fe_values.get_function_values(fe_vector,
577 make_slice(local_dof_indices, first_index, n_indices),
587 const std::vector<unsigned int>& local_dof_indices,
588 unsigned int first_index,
589 unsigned int n_indices,
592 fe_values.get_function_grads(fe_vector,
593 make_slice(local_dof_indices, first_index, n_indices),
603 const std::vector<unsigned int>& local_dof_indices,
604 unsigned int first_index,
605 unsigned int n_indices,
608 fe_values.get_function_hessians(fe_vector,
609 make_slice(local_dof_indices, first_index, n_indices),
640 template<
int dim,
int spacedim = dim>
660 template<
typename DHCellIterator>
669 face_number = deal_II_numbers::invalid_unsigned_int;
670 sub_number = deal_II_numbers::invalid_unsigned_int;
678 template<
typename DHCellIterator,
typename DHFaceIterator>
680 const DHFaceIterator& f,
681 const unsigned int n)
696 sub_number = deal_II_numbers::invalid_unsigned_int;
704 template<
typename DHCellIterator,
typename DHFaceIterator>
706 const DHFaceIterator& f,
707 const unsigned int n,
708 const unsigned int s)
801 template<
int dim,
int spacedim>
805 block_info(&block_info,
806 typeid(*this).name())
809 template<
int dim,
int spacedim>
814 block_info(&block_info,
815 typeid(*this).name())
818 template<
int dim,
int spacedim>
823 indices.resize(c->get_fe().dofs_per_cell);
825 if(block_info->local_renumbering.size() == 0)
827 c->get_dof_indices(indices);
831 indices_org.resize(c->get_fe().dofs_per_cell);
832 c->get_dof_indices(indices_org);
834 for(
unsigned int i = 0; i < indices.size(); ++i)
835 indices[this->block_info->local_renumbering[i]] = indices_org[i];
839 template<
int dim,
int spacedim>
844 indices.resize(c->get_fe().dofs_per_cell);
846 if(block_info->local_renumbering.size() == 0)
848 c->get_mg_dof_indices(indices);
852 indices_org.resize(c->get_fe().dofs_per_cell);
853 c->get_mg_dof_indices(indices_org);
855 for(
unsigned int i = 0; i < indices.size(); ++i)
856 indices[this->block_info->local_renumbering[i]] = indices_org[i];
906 template<
int dim,
typename FEVALUESBASE>
964 template<
typename FEVALUES>
968 const Quadrature<FEVALUES::integral_dimension>& quadrature,
969 const UpdateFlags flags);
1007 const FEVALUESBASE&
fe()
const
1009 AssertDimension(
fevalv.size(), 1);
1014 const FEVALUESBASE&
fe(
unsigned int i)
const
1016 Assert( i <
fevalv.size(), ExcIndexRange(i, 0,
fevalv.size()) );
1030 template<
typename DHCellIterator>
1031 void reinit(
const DHCellIterator& c);
1037 template<
typename DHCellIterator,
typename DHFaceIterator>
1038 void reinit(
const DHCellIterator& c,
1039 const DHFaceIterator& f,
1040 const unsigned int fn);
1046 template<
typename DHCellIterator,
typename DHFaceIterator>
1047 void reinit(
const DHCellIterator& c,
1048 const DHFaceIterator& f,
1049 const unsigned int fn,
1050 const unsigned int sn);
1064 template<
typename TYPE>
1065 void fill_local_data(std::vector< std::vector< std::vector<TYPE> > >& data,
1066 bool split_fevalues)
const;
1100 std::vector< std::vector< std::vector<double> > >
values;
1110 std::vector< std::vector< std::vector< Tensor<1,dim> > > >
gradients;
1113 std::vector< std::vector< std::vector< Tensor<1,dim> > > >&
derivatives;
1123 std::vector< std::vector< std::vector< Tensor<2,dim> > > >
hessians;
1135 template<
typename TYPE>
1136 void fill_local_data(std::vector< std::vector< std::vector<TYPE> > >& data,
1138 bool split_fevalues)
const;
1141 std::vector< boost::shared_ptr<FEVALUESBASE> >
fevalv;
1154 template<
int dim,
typename FEVALUESBASE>
1160 global_data(0, typeid(*this).name()),
1161 derivatives(gradients),
1165 template<
int dim,
typename FEVALUESBASE>
1173 derivatives(gradients),
1177 template<
int dim,
typename FEVALUESBASE>
1178 template<
typename FEVALUES>
1184 const Quadrature<FEVALUES::integral_dimension>& quadrature,
1185 const UpdateFlags flags)
1187 if( this->block_info->local_renumbering.size() != 0 )
1189 fevalv.resize(fe.n_base_elements());
1190 for(
unsigned int i = 0; i < fevalv.size(); ++i)
1192 fevalv[i] = boost::shared_ptr<FEVALUESBASE>(
new FEVALUES(mapping,
1201 fe_val_unsplit = boost::shared_ptr<FEVALUESBASE>(
new FEVALUES(mapping,
1210 fevalv[0] = boost::shared_ptr<FEVALUESBASE>(
new FEVALUES(mapping,
1217 values.resize(global_data->n_vectors(),
1218 std::vector< std::vector<double> >(fe.n_components(),
1219 std::vector<double>(quadrature.size())
1222 gradients.resize(global_data->n_vectors(),
1223 std::vector< std::vector< Tensor<1,dim> > >(fe.n_components(),
1224 std::vector< Tensor<1,dim> >(quadrature.size())
1227 hessians.resize(global_data->n_vectors(),
1228 std::vector< std::vector< Tensor<2,dim> > >(fe.n_components(),
1229 std::vector< Tensor<2,dim> >(quadrature.size())
1234 template<
int dim,
typename FEVALUESBASE>
1235 template<
typename DHCellIterator>
1242 for(
unsigned int i = 0; i < fevalv.size(); ++i)
1244 FEVALUESBASE& fe_values_base = *fevalv[i];
1245 FEValues<dim>& fe_values =
dynamic_cast<FEValues<dim>&
>(fe_values_base);
1246 fe_values.reinit(this->cell);
1251 FEVALUESBASE& fe_values_base_unsplit = *fe_val_unsplit;
1252 FEValues<dim>& fe_values_unsplit =
dynamic_cast<FEValues<dim>&
>(fe_values_base_unsplit);
1253 fe_values_unsplit.reinit(this->dof_active_cell);
1257 const bool split_fevalues = this->block_info->local_renumbering.size() != 0;
1258 fill_local_data(values,
1261 fill_local_data(gradients,
1264 fill_local_data(hessians,
1269 template<
int dim,
typename FEVALUESBASE>
1270 template<
typename DHCellIterator,
typename DHFaceIterator>
1274 const DHFaceIterator& f,
1275 const unsigned int fn)
1281 for(
unsigned int i = 0; i < fevalv.size(); ++i)
1283 FEVALUESBASE& fe_values_base = *fevalv[i];
1284 FEFaceValues<dim>& fe_face_values =
dynamic_cast<FEFaceValues<dim>&
>(fe_values_base);
1285 fe_face_values.reinit(this->cell,
1291 FEVALUESBASE& fe_values_base_unsplit = *fe_val_unsplit;
1292 FEFaceValues<dim>& fe_face_values_unsplit =
dynamic_cast<FEFaceValues<dim>&
>(fe_values_base_unsplit);
1293 fe_face_values_unsplit.reinit(this->dof_active_cell,
1298 const bool split_fevalues = this->block_info->local_renumbering.size() != 0;
1299 fill_local_data(values,
1302 fill_local_data(gradients,
1305 fill_local_data(hessians,
1310 template<
int dim,
typename FEVALUESBASE>
1311 template<
typename DHCellIterator,
typename DHFaceIterator>
1315 const DHFaceIterator& f,
1316 const unsigned int fn,
1317 const unsigned int sn)
1324 for(
unsigned int i = 0; i < fevalv.size(); ++i)
1326 FEVALUESBASE& fe_values_base = *fevalv[i];
1327 FESubfaceValues<dim>& fe_subface_values =
dynamic_cast<FESubfaceValues<dim>&
>(fe_values_base);
1328 fe_subface_values.reinit(this->cell,
1335 FEVALUESBASE& fe_values_base_unsplit = *fe_val_unsplit;
1336 FESubfaceValues<dim>& fe_subface_values_unsplit =
dynamic_cast<FESubfaceValues<dim>&
>(fe_values_base_unsplit);
1337 fe_subface_values_unsplit.reinit(this->dof_active_cell,
1343 const bool split_fevalues = this->block_info->local_renumbering.size() != 0;
1344 fill_local_data(values,
1347 fill_local_data(gradients,
1350 fill_local_data(hessians,
1355 template<
int dim,
typename FEVALUESBASE>
1356 template<
typename TYPE>
1360 bool split_fevalues)
const
1364 std::vector< std::vector<TYPE> > local_data;
1366 unsigned int comp = 0;
1367 for(
unsigned int b = 0; b < this->block_info->base_element.size(); ++b)
1369 const unsigned int no_fe = this->block_info->base_element[b];
1370 const FEValuesBase<dim>& fe_values_base = this->fe(no_fe);
1372 const unsigned int n_comp = fe_values_base.get_fe().n_components();
1373 local_data.resize(n_comp,
1374 std::vector<TYPE>(fe_values_base.n_quadrature_points));
1376 for(
unsigned int i = 0; i < this->global_data->n_vectors(); ++i)
1378 const FEVector& src = this->global_data->vector(i);
1382 this->block_info->local.block_start(b),
1383 fe_values_base.dofs_per_cell,
1386 for(
unsigned int c = 0; c < local_data.size(); ++c)
1387 for(
unsigned int k = 0; k < local_data[c].size(); ++k)
1388 data[i][comp+c][k] = local_data[c][k];
1396 for(
unsigned int i = 0; i < this->global_data->n_vectors(); ++i)
1398 const FEVector& src = this->global_data->vector(i);
1399 const FEValuesBase<dim>& fe_values_base = this->fe();
1405 fe_values_base.get_fe().dofs_per_cell,
1411 template<
int dim,
typename FEVALUESBASE>
1412 template<
typename TYPE>
1417 bool split_fevalues)
const
1421 std::vector< std::vector<TYPE> > local_data;
1423 unsigned int comp = 0;
1424 for(
unsigned int b = 0; b < this->block_info->base_element.size(); ++b)
1426 const unsigned int no_fe = this->block_info->base_element[b];
1427 const FEValuesBase<dim>& fe_values_base = this->fe(no_fe);
1429 const unsigned int n_comp = fe_values_base.get_fe().n_components();
1430 local_data.resize(n_comp,
1431 std::vector<TYPE>(fe_values_base.n_quadrature_points));
1436 for(
unsigned int i = 0; i < n; ++i)
1442 this->block_info->local.block_start(b),
1443 fe_values_base.dofs_per_cell,
1446 for(
unsigned int c = 0; c < local_data.size(); ++c)
1447 for(
unsigned int k = 0; k < local_data[c].size(); ++k)
1448 data[i][comp+c][k] = local_data[c][k];
1456 for(
unsigned int i = 0; i < this->global_data->n_vectors(); ++i)
1458 const FEVector& src = this->global_data->vector(i);
1459 const FEValuesBase<dim>& fe_values_base = this->fe();
1465 fe_values_base.get_fe().dofs_per_cell,
1493 template<
typename WORKER>
1516 cell_info(block_info),
1517 bdry_info(block_info),
1518 face_info(block_info),
1519 subface_info(block_info),
1520 neighbor_info(block_info)
1524 template<
typename WORKER>
1532 FEValues<dim>* fe_values = 0;
1533 FEFaceValues<dim>* fe_face_values = 0;
1534 FESubfaceValues<dim>* fe_subface_values = 0;
1536 cell_info.initialize_selector(integrator.cell_selector);
1537 bdry_info.initialize_selector(integrator.bdry_selector);
1538 face_info.initialize_selector(integrator.face_selector);
1539 subface_info.initialize_selector(integrator.face_selector);
1540 neighbor_info.initialize_selector(integrator.face_selector);
1542 cell_info.initialize_data(global_data);
1543 bdry_info.initialize_data(global_data);
1544 face_info.initialize_data(global_data);
1545 subface_info.initialize_data(global_data);
1546 neighbor_info.initialize_data(global_data);
1548 cell_info.initialize(fe_values,
1551 integrator.cell_quadrature,
1552 integrator.cell_flags);
1554 bdry_info.initialize(fe_face_values,
1557 integrator.bdry_quadrature,
1558 integrator.face_flags);
1560 face_info.initialize(fe_face_values,
1563 integrator.face_quadrature,
1564 integrator.face_flags);
1566 subface_info.initialize(fe_subface_values,
1569 integrator.face_quadrature,
1570 integrator.face_flags);
1572 neighbor_info.initialize(fe_face_values,
1575 integrator.face_quadrature,
1576 integrator.ngbr_flags);