Public Member Functions | |
PerThreadData (const unsigned int n_solution_vectors, const unsigned int n_components, const unsigned int max_n_q_points, const unsigned int subdomain_id, const unsigned int material_id) | |
void | resize (const unsigned int n_components, const unsigned int max_n_q_points) |
Public Attributes | |
std::vector< std::vector < std::vector< double > > > | phi |
std::vector< std::vector < std::vector< Tensor< 1, dim > > > > | psi |
std::vector< std::vector < std::vector< Tensor< 1, dim > > > > | neighbor_psi |
std::vector< Point< dim > > | normal_vectors |
std::vector< double > | coefficient_values1 |
std::vector< Vector< double > > | coefficient_values |
std::vector< double > | JxW_values |
const unsigned int | subdomain_id |
const unsigned int | material_id |
All small temporary data objects that are needed once per thread by the several functions of the error estimator are gathered in this struct. The reason for this structure is mainly that we have a number of functions that operate on cells or faces and need a number of small temporary data objects. Since these functions may run in parallel, we cannot make these objects member variables of the enclosing class. On the other hand, declaring them locally in each of these functions would require their reallocating every time we visit the next cell or face, which we found can take a significant amount of time if it happens often even in the single threaded case (10-20 per cent in our measurements); however, most importantly, memory allocation requires synchronisation in multithreaded mode. While that is done by the C++ library and has not to be handcoded, it nevertheless seriously damages the ability to efficiently run the functions of this class in parallel, since they are quite often blocked by these synchronisation points, slowing everything down by a factor of two or three.
Thus, every thread gets an instance of this class to work with and needs not allocate memory itself, or synchronise with other threads.
The sizes of the arrays are initialized with the maximal number of entries necessary for the hp case. Within the loop over individual cells, we then resize the arrays as necessary. Since for std::vector resizing to a smaller size doesn't imply memory allocation, this is fast.
KellyErrorEstimator< dim, spacedim >::PerThreadData::PerThreadData | ( | const unsigned int | n_solution_vectors, | |
const unsigned int | n_components, | |||
const unsigned int | max_n_q_points, | |||
const unsigned int | subdomain_id, | |||
const unsigned int | material_id | |||
) |
Constructor.
void KellyErrorEstimator< dim, spacedim >::PerThreadData::resize | ( | const unsigned int | n_components, | |
const unsigned int | max_n_q_points | |||
) |
Constructor.
std::vector<std::vector<std::vector<double> > > KellyErrorEstimator< dim, spacedim >::PerThreadData::phi |
A vector to store the jump of the normal vectors in the quadrature points for each of the solution vectors (i.e. a temporary value). This vector is not allocated inside the functions that use it, but rather globally, since memory allocation is slow, in particular in presence of multiple threads where synchronisation makes things even slower.
std::vector<std::vector<std::vector<Tensor<1,dim> > > > KellyErrorEstimator< dim, spacedim >::PerThreadData::psi |
A vector for the gradients of the finite element function on one cell
Let psi be a short name for a grad u_h
, where the third index be the component of the finite element, and the second index the number of the quadrature point. The first index denotes the index of the solution vector.
std::vector<std::vector<std::vector<Tensor<1,dim> > > > KellyErrorEstimator< dim, spacedim >::PerThreadData::neighbor_psi |
The same vector for a neighbor cell
std::vector<Point<dim> > KellyErrorEstimator< dim, spacedim >::PerThreadData::normal_vectors |
The normal vectors of the finite element function on one face
std::vector<double> KellyErrorEstimator< dim, spacedim >::PerThreadData::coefficient_values1 |
Two arrays needed for the values of coefficients in the jumps, if they are given.
std::vector<Vector<double> > KellyErrorEstimator< dim, spacedim >::PerThreadData::coefficient_values |
std::vector<double> KellyErrorEstimator< dim, spacedim >::PerThreadData::JxW_values |
Array for the products of Jacobian determinants and weights of quadraturs points.
const unsigned int KellyErrorEstimator< dim, spacedim >::PerThreadData::subdomain_id |
The subdomain id we are to care for.
const unsigned int KellyErrorEstimator< dim, spacedim >::PerThreadData::material_id |
The material id we are to care for.