18 #ifndef _FUEL_CELL_APPLICATION_CORE_MESH_LOOP_INFO_OBJECTS_H_
19 #define _FUEL_CELL_APPLICATION_CORE_MESH_LOOP_INFO_OBJECTS_H_
22 #include <deal.II/base/geometry_info.h>
23 #include <deal.II/base/quadrature_lib.h>
24 #include <deal.II/base/vector_slice.h>
25 #include <deal.II/lac/block_indices.h>
26 #include <deal.II/fe/fe.h>
27 #include <deal.II/fe/fe_tools.h>
28 #include <deal.II/fe/fe_values.h>
29 #include <deal.II/dofs/dof_tools.h>
35 #include <boost/shared_ptr.hpp>
43 using namespace dealii;
65 namespace ApplicationCore
93 template<
int dim,
typename TYPE>
98 const std::vector<unsigned int>& local_dof_indices,
99 unsigned int first_index,
100 unsigned int n_indices,
101 std::vector< std::vector<TYPE> >& result)
103 Assert(
false, ExcNotImplemented());
113 const std::vector<unsigned int>& local_dof_indices,
114 unsigned int first_index,
115 unsigned int n_indices,
116 std::vector< std::vector<double> >& result)
119 VectorSlice<std::vector< std::vector<double> > > aux(result);
120 fe_values.get_function_values(fe_vector,
121 make_slice(local_dof_indices, first_index, n_indices),
133 const std::vector<unsigned int>& local_dof_indices,
134 unsigned int first_index,
135 unsigned int n_indices,
136 std::vector< std::vector< Tensor<1,dim> > >& result)
138 VectorSlice< std::vector< std::vector< Tensor<1,dim> > > > aux(result);
139 fe_values.get_function_gradients(fe_vector,
140 make_slice(local_dof_indices, first_index, n_indices),
152 const std::vector<unsigned int>& local_dof_indices,
153 unsigned int first_index,
154 unsigned int n_indices,
155 std::vector< std::vector< Tensor<2,dim> > >& result)
157 fe_values.get_function_hessians(fe_vector,
158 make_slice(local_dof_indices, first_index, n_indices),
211 template<
int dim,
int spacedim>
215 std::vector<unsigned int> sizes(fe.n_blocks());
216 DoFTools::count_dofs_per_block(dof_handler, sizes);
217 global.reinit(sizes);
223 template<
int dim,
int spacedim>
227 std::vector<unsigned int> sizes(fe.n_blocks());
229 base_element.resize(fe.n_blocks());
231 for(
unsigned int i = 0; i < base_element.size(); ++i)
232 base_element[i] = fe.block_to_base_index(i).first;
234 local_renumbering.resize(fe.n_dofs_per_cell());
235 FETools::compute_block_renumbering(fe,
267 template<
int dim,
int spacedim = dim>
296 template<
typename DHCellIterator>
297 void reinit(
const DHCellIterator& c);
303 template<
typename DHCellIterator,
typename DHFaceIterator>
304 void reinit(
const DHCellIterator& c,
305 const DHFaceIterator& f,
306 const unsigned int fn);
312 template<
typename DHCellIterator,
typename DHFaceIterator>
313 void reinit(
const DHCellIterator& c,
314 const DHFaceIterator& f,
315 const unsigned int fn,
316 const unsigned int sn);
404 template<
int dim,
int spacedim>
408 block_info(&block_info,
409 typeid(*this).name())
414 template<
int dim,
int spacedim>
419 block_info(&block_info,
420 typeid(*this).name())
425 template<
int dim,
int spacedim>
426 template<
typename DHCellIterator>
437 face_number =
static_cast<unsigned int>(-1);
438 sub_number =
static_cast<unsigned int>(-1);
443 template<
int dim,
int spacedim>
444 template<
typename DHCellIterator,
typename DHFaceIterator>
448 const DHFaceIterator& f,
449 const unsigned int fn)
464 sub_number =
static_cast<unsigned int>(-1);
469 template<
int dim,
int spacedim>
470 template<
typename DHCellIterator,
typename DHFaceIterator>
474 const DHFaceIterator& f,
475 const unsigned int fn,
476 const unsigned int sn)
496 template<
int dim,
int spacedim>
501 indices.resize(c->get_fe().dofs_per_cell);
503 if(block_info->local_renumbering.size() == 0)
505 c->get_dof_indices(indices);
509 indices_org.resize(c->get_fe().dofs_per_cell);
510 c->get_dof_indices(indices_org);
512 for(
unsigned int i = 0; i < indices.size(); ++i)
513 indices[this->block_info->local_renumbering[i]] = indices_org[i];
543 template<
int dim,
typename FEVALUESBASE>
586 template<
typename FEVALUES>
590 const Quadrature<FEVALUES::integral_dimension>& quadrature,
591 const UpdateFlags flags);
606 template<
typename DHCellIterator>
607 void reinit(
const DHCellIterator& c);
612 template<
typename DHCellIterator,
typename DHFaceIterator>
613 void reinit(
const DHCellIterator& c,
614 const DHFaceIterator& f,
615 const unsigned int fn);
620 template<
typename DHCellIterator,
typename DHFaceIterator>
621 void reinit(
const DHCellIterator& c,
622 const DHFaceIterator& f,
623 const unsigned int fn,
624 const unsigned int sn);
632 template<
typename TYPE>
633 void fill_local_data(std::vector< std::vector< std::vector<TYPE> > >& data,
634 bool split_fevalues)
const;
644 const FEVALUESBASE&
fe()
const;
649 const FEVALUESBASE&
fe(
unsigned int i)
const;
682 std::vector< std::vector< std::vector<double> > >
values;
690 std::vector< std::vector< std::vector< Tensor<1,dim> > > >
gradients;
695 std::vector< std::vector< std::vector< Tensor<1,dim> > > >&
derivatives;
703 std::vector< std::vector< std::vector< Tensor<2,dim> > > >
hessians;
715 std::vector< boost::shared_ptr<FEVALUESBASE> >
fevalv;
730 template<
int dim,
typename FEVALUESBASE>
736 global_data(0, typeid(*this).name()),
737 derivatives(gradients),
743 template<
int dim,
typename FEVALUESBASE>
751 derivatives(gradients),
757 template<
int dim,
typename FEVALUESBASE>
758 template<
typename FEVALUES>
764 const Quadrature<FEVALUES::integral_dimension>& quadrature,
765 const UpdateFlags flags)
767 if( this->block_info->local_renumbering.size() != 0 )
769 fevalv.resize(fe.n_base_elements());
770 for(
unsigned int i = 0; i < fevalv.size(); ++i)
772 fevalv[i] = boost::shared_ptr<FEVALUESBASE>(
new FEVALUES(mapping,
781 fe_val_unsplit = boost::shared_ptr<FEVALUESBASE>(
new FEVALUES(mapping,
790 fevalv[0] = boost::shared_ptr<FEVALUESBASE>(
new FEVALUES(mapping,
797 values.resize(global_data->n_vectors(),
798 std::vector< std::vector<double> >(fe.n_components(),
799 std::vector<double>(quadrature.size())
802 gradients.resize(global_data->n_vectors(),
803 std::vector< std::vector< Tensor<1,dim> > >(fe.n_components(),
804 std::vector< Tensor<1,dim> >(quadrature.size())
807 hessians.resize(global_data->n_vectors(),
808 std::vector< std::vector< Tensor<2,dim> > >(fe.n_components(),
809 std::vector< Tensor<2,dim> >(quadrature.size())
816 template<
int dim,
typename FEVALUESBASE>
826 template<
int dim,
typename FEVALUESBASE>
827 template<
typename DHCellIterator>
834 for(
unsigned int i = 0; i < fevalv.size(); ++i)
836 FEVALUESBASE& fe_values_base = *fevalv[i];
837 FEValues<dim>& fe_values =
dynamic_cast<FEValues<dim>&
>(fe_values_base);
838 fe_values.reinit(this->cell);
841 FEVALUESBASE& fe_values_base_unsplit = *fe_val_unsplit;
842 FEValues<dim>& fe_values_unsplit =
dynamic_cast<FEValues<dim>&
>(fe_values_base_unsplit);
843 fe_values_unsplit.reinit(this->dof_active_cell);
845 const bool split_fevalues = this->block_info->local_renumbering.size() != 0;
846 fill_local_data(values,
848 fill_local_data(gradients,
856 template<
int dim,
typename FEVALUESBASE>
857 template<
typename DHCellIterator,
typename DHFaceIterator>
861 const DHFaceIterator& f,
862 const unsigned int fn)
868 for(
unsigned int i = 0; i < fevalv.size(); ++i)
870 FEVALUESBASE& fe_values_base = *fevalv[i];
871 FEFaceValues<dim>& fe_face_values =
dynamic_cast<FEFaceValues<dim>&
>(fe_values_base);
872 fe_face_values.reinit(this->cell,
876 FEVALUESBASE& fe_values_base_unsplit = *fe_val_unsplit;
877 FEFaceValues<dim>& fe_face_values_unsplit =
dynamic_cast<FEFaceValues<dim>&
>(fe_values_base_unsplit);
878 fe_face_values_unsplit.reinit(this->dof_active_cell,
881 const bool split_fevalues = this->block_info->local_renumbering.size() != 0;
882 fill_local_data(values,
884 fill_local_data(gradients,
892 template<
int dim,
typename FEVALUESBASE>
893 template<
typename DHCellIterator,
typename DHFaceIterator>
897 const DHFaceIterator& f,
898 const unsigned int fn,
899 const unsigned int sn)
903 for(
unsigned int i = 0; i < fevalv.size(); ++i)
905 FEVALUESBASE& fe_values_base = *fevalv[i];
906 FESubfaceValues<dim>& fe_subface_values =
dynamic_cast<FESubfaceValues<dim>&
>(fe_values_base);
907 fe_subface_values.reinit(this->cell,
912 FEVALUESBASE& fe_values_base_unsplit = *fe_val_unsplit;
913 FESubfaceValues<dim>& fe_subface_values_unsplit =
dynamic_cast<FESubfaceValues<dim>&
>(fe_values_base_unsplit);
914 fe_subface_values_unsplit.reinit(this->dof_active_cell,
918 const bool split_fevalues = this->block_info->local_renumbering.size() != 0;
919 fill_local_data(values,
921 fill_local_data(gradients,
929 template<
int dim,
typename FEVALUESBASE>
930 template<
typename TYPE>
934 bool split_fevalues)
const
938 std::vector< std::vector<TYPE> > local_data;
940 unsigned int comp = 0;
941 for(
unsigned int b = 0; b < this->block_info->base_element.size(); ++b)
943 const unsigned int no_fe = this->block_info->base_element[b];
944 const FEValuesBase<dim>& fe_values_base = this->fe(no_fe);
946 const unsigned int n_comp = fe_values_base.get_fe().n_components();
947 local_data.resize(n_comp,
948 std::vector<TYPE>(fe_values_base.n_quadrature_points));
950 for(
unsigned int i = 0; i < this->global_data->n_vectors(); ++i)
952 const FEVector& src = this->global_data->vector(i);
956 this->block_info->local.block_start(b),
957 fe_values_base.dofs_per_cell,
960 for(
unsigned int c = 0; c < local_data.size(); ++c)
961 for(
unsigned int k = 0; k < local_data[c].size(); ++k)
962 data[i][comp+c][k] = local_data[c][k];
970 for(
unsigned int i = 0; i < this->global_data->n_vectors(); ++i)
972 const FEVector& src = this->global_data->vector(i);
973 const FEValuesBase<dim>& fe_values_base = this->fe();
979 fe_values_base.get_fe().dofs_per_cell,
987 template<
int dim,
typename FEVALUESBASE>
992 AssertDimension(fevalv.size(), 1);
998 template<
int dim,
typename FEVALUESBASE>
1003 Assert( i < fevalv.size(), ExcIndexRange(i, 0, fevalv.size()) );
1009 template<
int dim,
typename FEVALUESBASE>
1014 return *fe_val_unsplit;
1019 template<
int dim,
typename FEVALUESBASE>
Definition: dof_application.h:67
void reinit(const DHCellIterator &c)
Set the current cell and fill indices.
Definition: mesh_loop_info_objects.h:429
void initialize(const FEVALUES *FE_VALUES, const FiniteElement< dim > &fe, const Mapping< dim > &mapping, const Quadrature< FEVALUES::integral_dimension > &quadrature, const UpdateFlags flags)
Build internal structures fevalv and allocate memory for values, gradients, hessians.
Definition: mesh_loop_info_objects.h:761
const unsigned int dim
Definition: fcst_constants.h:23
unsigned int sub_number
The number of the current subface on the current face of the current cell.
Definition: mesh_loop_info_objects.h:369
Definition: dof_application.h:68
A small structure collecting the different BlockIndices of FEVector vectors (for instance, solution) involved in the computations.
Definition: mesh_loop_info_objects.h:173
BlockIndices global
The block structure of the global FEVector solution.
Definition: mesh_loop_info_objects.h:178
SmartPointer< const FEVectors > global_data
The smart pointer to the FEVectors object called global_data.
Definition: mesh_loop_info_objects.h:674
void initialize_data(const FEVectors &data)
Initialize global_data.
Definition: mesh_loop_info_objects.h:819
void clear()
Resize fevalv to 0.
Definition: mesh_loop_info_objects.h:1022
void reinit(const DHCellIterator &c)
Reinitialize internal data for use on a cell.
Definition: mesh_loop_info_objects.h:830
unsigned int face_number
The number of the current face on the current cell.
Definition: mesh_loop_info_objects.h:357
Definition: dof_application.h:69
bool multigrid
true if we assemble for multigrid.
Definition: mesh_loop_info_objects.h:669
std::vector< std::vector< std::vector< Tensor< 1, dim > > > > & derivatives
Definition: mesh_loop_info_objects.h:695
Very basic info class only containing information on geometry and degrees of freedom on a mesh entity...
Definition: mesh_loop_info_objects.h:268
SmartPointer< const BlockInfo > block_info
The block structure of the problem at hand.
Definition: mesh_loop_info_objects.h:385
IntegrationInfo(const BlockInfo &block_info)
Constructor.
Definition: mesh_loop_info_objects.h:732
This class is created for the objects handed to the mesh loops.
Definition: mesh_loop_info_objects.h:544
DoFInfo(const BlockInfo &block_info)
Constructor.
Definition: mesh_loop_info_objects.h:406
boost::shared_ptr< FEVALUESBASE > fe_val_unsplit
In the MODE1 (or in the main mode), the class splits an FEVALUESBASE object into several sub-objects ...
Definition: mesh_loop_info_objects.h:723
std::vector< std::vector< std::vector< Tensor< 1, dim > > > > gradients
The vector containing the gradients of finite element functions in the quadrature points...
Definition: mesh_loop_info_objects.h:690
std::vector< BlockIndices > levels
The multilevel block structure of the global FEVector solution.
Definition: mesh_loop_info_objects.h:188
void initialize(const DoFHandler< dim, spacedim > &dof_handler)
Fill the structure globally with values describing the DoFHandler.
Definition: mesh_loop_info_objects.h:212
void fill_data(const FEValuesBase< dim > &fe_values, const FEVector &fe_vector, const std::vector< unsigned int > &local_dof_indices, unsigned int first_index, unsigned int n_indices, std::vector< std::vector< TYPE > > &result)
Helper functions computing the desired data in each quadrature point of a mesh entity by calling FEVa...
Definition: mesh_loop_info_objects.h:96
void initialize_local(const DoFHandler< dim, spacedim > &dof_handler)
Fill the structure locally with values describing the DoFHandler.
Definition: mesh_loop_info_objects.h:224
Triangulation< dim >::face_iterator face
The current Triangulation<dim> face.
Definition: mesh_loop_info_objects.h:346
std::vector< unsigned int > indices
The local dof indices associated with the current cell.
Definition: mesh_loop_info_objects.h:380
BlockIndices local
The block structure of a local FEVector solution.
Definition: mesh_loop_info_objects.h:183
std::vector< std::vector< std::vector< Tensor< 2, dim > > > > hessians
The vector containing the hessians of finite element functions in the quadrature points.
Definition: mesh_loop_info_objects.h:703
void get_indices(const typename DoFHandler< dim, spacedim >::cell_iterator c)
Fill indices.
Definition: mesh_loop_info_objects.h:499
std::vector< std::vector< std::vector< double > > > values
The vector containing the values of finite element functions in the quadrature points.
Definition: mesh_loop_info_objects.h:682
std::vector< unsigned int > local_renumbering
A vector containing the internal renumbering of degrees of freedom from the standard ordering on a ce...
Definition: mesh_loop_info_objects.h:206
Definition: dof_application.h:70
const FEVALUESBASE & get_fe_val_unsplit() const
Access to fe_val_unsplit.
Definition: mesh_loop_info_objects.h:1012
DoFHandler< dim >::active_cell_iterator dof_active_cell
The current DoFHandler<dim> active cell.
Definition: mesh_loop_info_objects.h:331
void fill_local_data(std::vector< std::vector< std::vector< TYPE > > > &data, bool split_fevalues) const
Use the finite element functions in global_data and fill the vectors values, gradients, hessians.
Definition: mesh_loop_info_objects.h:933
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:46
The data type used in function calls of Application.
Definition: fe_vectors.h:59
std::vector< boost::shared_ptr< FEVALUESBASE > > fevalv
The vector of smart pointers to FEVALUESBASE objects.
Definition: mesh_loop_info_objects.h:715
DoFHandler< dim >::face_iterator dof_face
The current DoFHandler<dim> face.
Definition: mesh_loop_info_objects.h:336
DoFHandler< dim >::cell_iterator dof_cell
The current DoFHandler<dim> cell.
Definition: mesh_loop_info_objects.h:326
std::vector< unsigned int > base_element
A vector of base elements.
Definition: mesh_loop_info_objects.h:195
Triangulation< dim >::cell_iterator cell
The current Triangulation<dim> cell.
Definition: mesh_loop_info_objects.h:341
std::vector< unsigned int > indices_org
Auxiliary vector.
Definition: mesh_loop_info_objects.h:399
const FEVALUESBASE & fe() const
Access to a single actual FEVALUES object.
Definition: mesh_loop_info_objects.h:990