17 #ifndef dealii_matrix_free_h 18 #define dealii_matrix_free_h 20 #include <deal.II/base/aligned_vector.h> 21 #include <deal.II/base/exceptions.h> 22 #include <deal.II/base/quadrature.h> 23 #include <deal.II/base/vectorization.h> 24 #include <deal.II/base/thread_local_storage.h> 25 #include <deal.II/base/template_constraints.h> 26 #include <deal.II/fe/fe.h> 27 #include <deal.II/fe/mapping.h> 28 #include <deal.II/fe/mapping_q1.h> 29 #include <deal.II/lac/vector_operation.h> 30 #include <deal.II/lac/la_parallel_vector.h> 31 #include <deal.II/lac/block_vector_base.h> 32 #include <deal.II/lac/constraint_matrix.h> 33 #include <deal.II/dofs/dof_handler.h> 34 #include <deal.II/grid/grid_tools.h> 35 #include <deal.II/hp/dof_handler.h> 36 #include <deal.II/hp/q_collection.h> 37 #include <deal.II/matrix_free/task_info.h> 38 #include <deal.II/matrix_free/shape_info.h> 39 #include <deal.II/matrix_free/dof_info.h> 40 #include <deal.II/matrix_free/mapping_info.h> 48 DEAL_II_NAMESPACE_OPEN
104 template <
int dim,
typename Number=
double>
177 none = internal::MatrixFreeFunctions::TaskInfo::none,
190 color = internal::MatrixFreeFunctions::TaskInfo::color
478 template <
typename DoFHandlerType,
typename QuadratureType>
480 const DoFHandlerType &dof_handler,
482 const QuadratureType &quad,
489 template <
typename DoFHandlerType,
typename QuadratureType>
490 void reinit (
const DoFHandlerType &dof_handler,
492 const QuadratureType &quad,
502 template <
typename DoFHandlerType,
typename QuadratureType>
505 const DoFHandlerType &dof_handler,
508 const QuadratureType &quad,
531 template <
typename DoFHandlerType,
typename QuadratureType>
533 const std::vector<const DoFHandlerType *> &dof_handler,
534 const std::vector<const ConstraintMatrix *> &constraint,
535 const std::vector<QuadratureType> &quad,
542 template <
typename DoFHandlerType,
typename QuadratureType>
543 void reinit (
const std::vector<const DoFHandlerType *> &dof_handler,
544 const std::vector<const ConstraintMatrix *> &constraint,
545 const std::vector<QuadratureType> &quad,
555 template <
typename DoFHandlerType,
typename QuadratureType>
558 const std::vector<const DoFHandlerType *> &dof_handler,
559 const std::vector<const ConstraintMatrix *> &constraint,
560 const std::vector<IndexSet> &locally_owned_set,
561 const std::vector<QuadratureType> &quad,
571 template <
typename DoFHandlerType,
typename QuadratureType>
573 const std::vector<const DoFHandlerType *> &dof_handler,
574 const std::vector<const ConstraintMatrix *> &constraint,
575 const QuadratureType &quad,
582 template <
typename DoFHandlerType,
typename QuadratureType>
583 void reinit (
const std::vector<const DoFHandlerType *> &dof_handler,
584 const std::vector<const ConstraintMatrix *> &constraint,
585 const QuadratureType &quad,
697 template <
typename OutVector,
typename InVector>
701 const std::pair<
unsigned int,
702 unsigned int> &)> &cell_operation,
705 const bool zero_dst_vector =
false)
const;
748 template <
typename CLASS,
typename OutVector,
typename InVector>
752 const std::pair<
unsigned int,
753 unsigned int> &)
const,
754 const CLASS *owning_class,
757 const bool zero_dst_vector =
false)
const;
762 template <
typename CLASS,
typename OutVector,
typename InVector>
766 const std::pair<
unsigned int,
771 const bool zero_dst_vector =
false)
const;
848 template <
typename OutVector,
typename InVector>
852 const std::pair<
unsigned int,
853 unsigned int> &)> &cell_operation,
857 const std::pair<
unsigned int,
858 unsigned int> &)> &face_operation,
862 const std::pair<
unsigned int,
863 unsigned int> &)> &boundary_operation,
866 const bool zero_dst_vector =
false,
954 template <
typename CLASS,
typename OutVector,
typename InVector>
958 const std::pair<
unsigned int,
959 unsigned int> &)
const,
960 void (CLASS::*face_operation)(
const MatrixFree &,
963 const std::pair<
unsigned int,
964 unsigned int> &)
const,
965 void (CLASS::*boundary_operation)(
const MatrixFree &,
968 const std::pair<
unsigned int,
969 unsigned int> &)
const,
970 const CLASS *owning_class,
973 const bool zero_dst_vector =
false,
980 template <
typename CLASS,
typename OutVector,
typename InVector>
984 const std::pair<
unsigned int,
986 void (CLASS::*face_operation)(
const MatrixFree &,
989 const std::pair<
unsigned int,
991 void (CLASS::*boundary_operation)(
const MatrixFree &,
994 const std::pair<
unsigned int,
999 const bool zero_dst_vector =
false,
1010 std::pair<unsigned int,unsigned int>
1012 const unsigned int fe_degree,
1013 const unsigned int dof_handler_index = 0)
const;
1021 std::pair<unsigned int,unsigned int>
1023 const unsigned int fe_index,
1024 const unsigned int dof_handler_index = 0)
const;
1052 template <
typename VectorType>
1054 const unsigned int dof_handler_index=0)
const;
1076 template <
typename Number2>
1078 const unsigned int dof_handler_index=0)
const;
1090 const std::shared_ptr<const Utilities::MPI::Partitioner> &
1103 get_ghost_set (
const unsigned int dof_handler_index=0)
const;
1114 const std::vector<unsigned int> &
1127 void renumber_dofs (std::vector<types::global_dof_index> &renumbering,
1128 const unsigned int dof_handler_index=0);
1139 template <
int spacedim>
1152 unsigned int n_base_elements (
const unsigned int dof_handler_index)
const;
1230 std::array<types::boundary_id, VectorizedArray<Number>::n_array_elements>
1232 const unsigned int face_number)
const;
1253 const unsigned int vector_number,
1254 const unsigned int fe_component = 0)
const;
1269 const unsigned int vector_number,
1270 const unsigned int dof_handler_index = 0)
const;
1325 const unsigned int hp_active_fe_index = 0)
const;
1332 const unsigned int hp_active_fe_index = 0)
const;
1340 const unsigned int hp_active_fe_index = 0)
const;
1348 const unsigned int hp_active_fe_index = 0)
const;
1355 const unsigned int hp_active_fe_index = 0)
const;
1362 const unsigned int hp_active_fe_index = 0)
const;
1376 std::pair<unsigned int,unsigned int>
1401 template <
typename StreamType>
1408 void print (std::ostream &out)
const;
1433 get_mapping_info ()
const;
1439 get_dof_info (
const unsigned int dof_handler_index_component = 0)
const;
1465 get_shape_info (
const unsigned int dof_handler_index_component = 0,
1466 const unsigned int quad_index = 0,
1467 const unsigned int fe_base_element = 0,
1468 const unsigned int hp_active_fe_index = 0,
1469 const unsigned int hp_active_quad_index = 0)
const;
1523 const std::vector<const ConstraintMatrix *> &constraint,
1524 const std::vector<IndexSet> &locally_owned_set,
1526 const AdditionalData &additional_data);
1533 const std::vector<const ConstraintMatrix *> &constraint,
1534 const std::vector<IndexSet> &locally_owned_set,
1536 const AdditionalData &additional_data);
1546 const std::vector<IndexSet> &locally_owned_set,
1547 const AdditionalData &additional_data);
1553 const AdditionalData &additional_data);
1559 const AdditionalData &additional_data);
1576 active_dof_handler(
usual),
1581 std::vector<SmartPointer<const DoFHandler<dim> > > dof_handler;
1582 std::vector<SmartPointer<const hp::DoFHandler<dim> > > hp_dof_handler;
1593 } active_dof_handler;
1594 unsigned int n_dof_handlers;
1607 std::vector<internal::MatrixFreeFunctions::DoFInfo>
dof_info;
1698 template <
int dim,
typename Number>
1699 template <
typename VectorType>
1703 const unsigned int comp)
const 1706 vec.reinit(dof_info[comp].vector_partitioner->size());
1711 template <
int dim,
typename Number>
1712 template <
typename Number2>
1716 const unsigned int comp)
const 1719 vec.
reinit(dof_info[comp].vector_partitioner);
1724 template <
int dim,
typename Number>
1726 const std::shared_ptr<const Utilities::MPI::Partitioner> &
1730 return dof_info[comp].vector_partitioner;
1735 template <
int dim,
typename Number>
1737 const std::vector<unsigned int> &
1741 return dof_info[comp].constrained_dofs;
1746 template <
int dim,
typename Number>
1752 return dof_handlers.n_dof_handlers;
1757 template <
int dim,
typename Number>
1764 return dof_handlers.dof_handler[dof_no]->get_fe().n_base_elements();
1769 template <
int dim,
typename Number>
1779 template <
int dim,
typename Number>
1789 template <
int dim,
typename Number>
1794 return *(task_info.cell_partition_data.end()-2);
1799 template <
int dim,
typename Number>
1804 return task_info.n_active_cells;
1809 template <
int dim,
typename Number>
1814 return *(task_info.cell_partition_data.end()-2);
1819 template <
int dim,
typename Number>
1824 return *(task_info.cell_partition_data.end()-1)-
1825 *(task_info.cell_partition_data.end()-2);
1830 template <
int dim,
typename Number>
1835 if (task_info.face_partition_data.size() == 0)
1837 return task_info.face_partition_data.back();
1842 template <
int dim,
typename Number>
1847 if (task_info.face_partition_data.size() == 0)
1849 return task_info.boundary_partition_data.back()-task_info.face_partition_data.back();
1854 template <
int dim,
typename Number>
1859 if (task_info.face_partition_data.size() == 0)
1861 return face_info.faces.size() - task_info.boundary_partition_data.back();
1866 template <
int dim,
typename Number>
1871 Assert(macro_face >= task_info.boundary_partition_data[0] &&
1872 macro_face < task_info.boundary_partition_data.back(),
1874 task_info.boundary_partition_data[0],
1875 task_info.boundary_partition_data.back()));
1881 template <
int dim,
typename Number>
1883 std::array<types::boundary_id, VectorizedArray<Number>::n_array_elements>
1885 const unsigned int face_number)
const 1889 Assert(face_info.cell_and_face_boundary_id.size(0)>=n_macro_cells(),
1891 std::array<types::boundary_id, VectorizedArray<Number>::n_array_elements> result;
1893 for (
unsigned int v=0; v<n_active_entries_per_cell_batch(macro_cell); ++v)
1894 result[v] = face_info.cell_and_face_boundary_id(macro_cell, face_number, v);
1900 template <
int dim,
typename Number>
1905 return mapping_info;
1910 template <
int dim,
typename Number>
1916 return dof_info[dof_index];
1921 template <
int dim,
typename Number>
1926 return constraint_pool_row_index.size()-1;
1931 template <
int dim,
typename Number>
1937 return constraint_pool_data.empty() ? nullptr :
1938 constraint_pool_data.data() + constraint_pool_row_index[row];
1943 template <
int dim,
typename Number>
1949 return constraint_pool_data.empty() ? nullptr :
1950 constraint_pool_data.data() + constraint_pool_row_index[row+1];
1955 template <
int dim,
typename Number>
1957 std::pair<unsigned int,unsigned int>
1959 (
const std::pair<unsigned int,unsigned int> &range,
1960 const unsigned int degree,
1961 const unsigned int dof_handler_component)
const 1963 if (dof_info[dof_handler_component].cell_active_fe_index.empty())
1965 AssertDimension (dof_info[dof_handler_component].fe_index_conversion.size(),1);
1966 AssertDimension (dof_info[dof_handler_component].fe_index_conversion[0].size(), 1);
1967 if (dof_info[dof_handler_component].fe_index_conversion[0][0] == degree)
1970 return std::pair<unsigned int,unsigned int> (range.second,range.second);
1973 const unsigned int fe_index =
1974 dof_info[dof_handler_component].fe_index_from_degree(0, degree);
1975 if (fe_index >= dof_info[dof_handler_component].max_fe_index)
1976 return std::pair<unsigned int,unsigned int>(range.second, range.second);
1978 return create_cell_subrange_hp_by_index (range, fe_index, dof_handler_component);
1983 template <
int dim,
typename Number>
1996 template <
int dim,
typename Number>
2001 return n_active_entries_per_cell_batch(cell_batch_number);
2006 template <
int dim,
typename Number>
2011 AssertIndexRange (cell_batch_number, task_info.cell_partition_data.back());
2023 template <
int dim,
typename Number>
2031 face_info.faces[face_batch_number].cells_interior[
n_components-1] ==
2040 template <
int dim,
typename Number>
2044 const unsigned int active_fe_index)
const 2046 return dof_info[dof_handler_index].dofs_per_cell[active_fe_index];
2051 template <
int dim,
typename Number>
2055 const unsigned int active_fe_index)
const 2058 return mapping_info.cell_data[quad_index].descriptor[active_fe_index].n_q_points;
2063 template <
int dim,
typename Number>
2067 const unsigned int active_fe_index)
const 2069 return dof_info[dof_handler_index].dofs_per_face[active_fe_index];
2074 template <
int dim,
typename Number>
2078 const unsigned int active_fe_index)
const 2081 return mapping_info.face_data[quad_index].descriptor[active_fe_index].n_q_points;
2086 template <
int dim,
typename Number>
2091 return dof_info[dof_handler_index].vector_partitioner->locally_owned_range();
2096 template <
int dim,
typename Number>
2101 return dof_info[dof_handler_index].vector_partitioner->ghost_indices();
2106 template <
int dim,
typename Number>
2110 const unsigned int index_quad,
2111 const unsigned int index_fe,
2112 const unsigned int active_fe_index,
2113 const unsigned int active_quad_index)
const 2116 const unsigned int ind = dof_info[dof_handler_index].global_base_element_offset+index_fe;
2121 return shape_info(ind, index_quad,
2122 active_fe_index, active_quad_index);
2127 template <
int dim,
typename Number>
2133 return face_info.faces[macro_face];
2138 template <
int dim,
typename Number>
2142 const unsigned int active_fe_index)
const 2145 return mapping_info.cell_data[quad_index].descriptor[active_fe_index].quadrature;
2150 template <
int dim,
typename Number>
2154 const unsigned int active_fe_index)
const 2157 return mapping_info.face_data[quad_index].descriptor[active_fe_index].quadrature;
2162 template <
int dim,
typename Number>
2169 if (dof_info[0].cell_active_fe_index.empty())
2172 return dof_info[0].cell_active_fe_index[macro_cell];
2177 template <
int dim,
typename Number>
2179 std::pair<unsigned int,unsigned int>
2183 if (dof_info[0].cell_active_fe_index.empty())
2184 return std::make_pair(0U, 0U);
2186 std::pair<unsigned int,unsigned int> result;
2187 for (
unsigned int v=0; v<VectorizedArray<Number>::n_array_elements &&
2189 result.first = std::max(result.first,
2190 dof_info[0].cell_active_fe_index[face_info.faces[macro_face].cells_interior[v]]);
2192 for (
unsigned int v=0; v<VectorizedArray<Number>::n_array_elements &&
2194 result.second = std::max(result.first,
2195 dof_info[0].cell_active_fe_index[face_info.faces[macro_face].cells_exterior[v]]);
2203 template <
int dim,
typename Number>
2208 return indices_are_initialized;
2213 template <
int dim,
typename Number>
2218 return mapping_is_initialized;
2223 template <
int dim,
typename Number>
2227 typedef std::list<std::pair<bool, AlignedVector<VectorizedArray<Number> > > > list_type;
2228 list_type &data = scratch_pad.get();
2229 for (
typename list_type::iterator it=data.begin(); it!=data.end(); ++it)
2230 if (it->first ==
false)
2236 return &data.front().second;
2241 template <
int dim,
typename Number>
2245 typedef std::list<std::pair<bool, AlignedVector<VectorizedArray<Number> > > > list_type;
2246 list_type &data = scratch_pad.get();
2247 for (
typename list_type::iterator it=data.begin(); it!=data.end(); ++it)
2248 if (&it->second == scratch)
2259 template <
int dim,
typename Number>
2264 it=scratch_pad_non_threadsafe.
begin(); it!=scratch_pad_non_threadsafe.end(); ++it)
2265 if (it->first ==
false)
2271 return &scratch_pad_non_threadsafe.front().second;
2276 template <
int dim,
typename Number>
2281 it=scratch_pad_non_threadsafe.
begin(); it!=scratch_pad_non_threadsafe.end(); ++it)
2282 if (&it->second == scratch)
2297 namespace MatrixFreeImplementation
2299 template <
typename DoFHandlerType>
2301 std::vector<IndexSet>
2302 extract_locally_owned_index_sets (
const std::vector<const DoFHandlerType *> &dofh,
2303 const unsigned int level)
2305 std::vector<IndexSet> locally_owned_set;
2306 locally_owned_set.reserve (dofh.size());
2307 for (
unsigned int j=0; j<dofh.size(); j++)
2309 locally_owned_set.push_back(dofh[j]->locally_owned_dofs());
2312 return locally_owned_set;
2315 template <
int dim,
int spacedim>
2317 std::vector<IndexSet>
2318 extract_locally_owned_index_sets (
const std::vector<const ::DoFHandler<dim,spacedim> *> &dofh,
2319 const unsigned int level)
2321 std::vector<IndexSet> locally_owned_set;
2322 locally_owned_set.reserve (dofh.size());
2323 for (
unsigned int j=0; j<dofh.size(); j++)
2325 locally_owned_set.push_back(dofh[j]->locally_owned_dofs());
2327 locally_owned_set.push_back(dofh[j]->locally_owned_mg_dofs(level));
2328 return locally_owned_set;
2335 template <
int dim,
typename Number>
2336 template <
typename DoFHandlerType,
typename QuadratureType>
2338 reinit(
const DoFHandlerType &dof_handler,
2340 const QuadratureType &quad,
2343 std::vector<const DoFHandlerType *> dof_handlers;
2344 std::vector<const ConstraintMatrix *> constraints;
2345 std::vector<QuadratureType> quads;
2347 dof_handlers.push_back(&dof_handler);
2348 constraints.push_back (&constraints_in);
2349 quads.push_back (quad);
2351 std::vector<IndexSet> locally_owned_sets =
2352 internal::MatrixFreeImplementation::extract_locally_owned_index_sets
2355 std::vector<hp::QCollection<1> > quad_hp;
2356 quad_hp.emplace_back (quad);
2359 locally_owned_sets, quad_hp, additional_data);
2364 template <
int dim,
typename Number>
2365 template <
typename DoFHandlerType,
typename QuadratureType>
2368 const DoFHandlerType &dof_handler,
2370 const QuadratureType &quad,
2373 std::vector<const DoFHandlerType *> dof_handlers;
2374 std::vector<const ConstraintMatrix *> constraints;
2376 dof_handlers.push_back(&dof_handler);
2377 constraints.push_back (&constraints_in);
2379 std::vector<IndexSet> locally_owned_sets =
2380 internal::MatrixFreeImplementation::extract_locally_owned_index_sets
2383 std::vector<hp::QCollection<1> > quad_hp;
2384 quad_hp.emplace_back (quad);
2386 internal_reinit(mapping, dof_handlers,constraints,locally_owned_sets,
2387 quad_hp, additional_data);
2392 template <
int dim,
typename Number>
2393 template <
typename DoFHandlerType,
typename QuadratureType>
2395 reinit(
const std::vector<const DoFHandlerType *> &dof_handler,
2396 const std::vector<const ConstraintMatrix *> &constraint,
2397 const std::vector<QuadratureType> &quad,
2400 std::vector<IndexSet> locally_owned_set =
2401 internal::MatrixFreeImplementation::extract_locally_owned_index_sets
2403 std::vector<hp::QCollection<1> > quad_hp;
2404 for (
unsigned int q=0; q<quad.size(); ++q)
2405 quad_hp.emplace_back (quad[q]);
2407 locally_owned_set, quad_hp, additional_data);
2412 template <
int dim,
typename Number>
2413 template <
typename DoFHandlerType,
typename QuadratureType>
2415 reinit(
const std::vector<const DoFHandlerType *> &dof_handler,
2416 const std::vector<const ConstraintMatrix *> &constraint,
2417 const QuadratureType &quad,
2420 std::vector<IndexSet> locally_owned_set =
2421 internal::MatrixFreeImplementation::extract_locally_owned_index_sets
2423 std::vector<hp::QCollection<1> > quad_hp;
2424 quad_hp.emplace_back (quad);
2426 locally_owned_set, quad_hp, additional_data);
2431 template <
int dim,
typename Number>
2432 template <
typename DoFHandlerType,
typename QuadratureType>
2435 const std::vector<const DoFHandlerType *> &dof_handler,
2436 const std::vector<const ConstraintMatrix *> &constraint,
2437 const QuadratureType &quad,
2440 std::vector<IndexSet> locally_owned_set =
2441 internal::MatrixFreeImplementation::extract_locally_owned_index_sets
2443 std::vector<hp::QCollection<1> > quad_hp;
2444 quad_hp.emplace_back (quad);
2445 internal_reinit(mapping, dof_handler,constraint,
2446 locally_owned_set, quad_hp, additional_data);
2451 template <
int dim,
typename Number>
2452 template <
typename DoFHandlerType,
typename QuadratureType>
2455 const std::vector<const DoFHandlerType *> &dof_handler,
2456 const std::vector<const ConstraintMatrix *> &constraint,
2457 const std::vector<QuadratureType> &quad,
2460 std::vector<IndexSet> locally_owned_set =
2461 internal::MatrixFreeImplementation::extract_locally_owned_index_sets
2463 std::vector<hp::QCollection<1> > quad_hp;
2464 for (
unsigned int q=0; q<quad.size(); ++q)
2465 quad_hp.emplace_back (quad[q]);
2466 internal_reinit(mapping, dof_handler,constraint,locally_owned_set,
2467 quad_hp, additional_data);
2472 template <
int dim,
typename Number>
2473 template <
typename DoFHandlerType,
typename QuadratureType>
2476 const std::vector<const DoFHandlerType *> &dof_handler,
2477 const std::vector<const ConstraintMatrix *> &constraint,
2478 const std::vector<IndexSet> &locally_owned_set,
2479 const std::vector<QuadratureType> &quad,
2483 std::vector<hp::QCollection<1> > quad_hp;
2484 for (
unsigned int q=0; q<quad.size(); ++q)
2485 quad_hp.emplace_back (quad[q]);
2486 internal_reinit (mapping,
2488 constraint, locally_owned_set, quad_hp, additional_data);
2505 template <
int dim,
typename Number>
2506 struct VectorDataExchange
2511 static constexpr
unsigned int channel_shift = 103;
2513 VectorDataExchange (const ::MatrixFree<dim,Number> &matrix_free,
2514 const typename ::MatrixFree<dim,Number>::DataAccessOnFaces vector_face_access,
2515 const unsigned int n_components)
2517 matrix_free (matrix_free),
2518 vector_face_access (matrix_free.get_task_info().face_partition_data.empty() ?
2519 ::
MatrixFree<dim,Number>::DataAccessOnFaces::unspecified :
2520 vector_face_access),
2521 ghosts_were_set (false)
2522 #ifdef DEAL_II_WITH_MPI
2529 for (
unsigned int c=0; c<matrix_free.n_components(); ++c)
2530 AssertDimension(matrix_free.get_dof_info(c).vector_partitioner_face_variants.size(), 3);
2533 ~VectorDataExchange ()
2535 #ifdef DEAL_II_WITH_MPI 2536 for (
unsigned int i=0; i<tmp_data.size(); ++i)
2537 if (tmp_data[i] !=
nullptr)
2538 matrix_free.release_scratch_data_non_threadsafe(tmp_data[i]);
2543 const bool check_global_compatibility =
true)
const 2546 (void)check_global_compatibility;
2547 for (
unsigned int c=0; c<matrix_free.n_components(); ++c)
2550 check_global_compatibility
2552 vec.
get_partitioner()->is_globally_compatible(*matrix_free.get_dof_info(c).vector_partitioner)
2555 vec.
get_partitioner()->is_compatible(*matrix_free.get_dof_info(c).vector_partitioner))
2560 return mf_component;
2564 get_partitioner(
const unsigned int mf_component)
const 2566 AssertDimension(matrix_free.get_dof_info(mf_component).vector_partitioner_face_variants.size(),3);
2568 return *matrix_free.get_dof_info(mf_component).vector_partitioner_face_variants[0];
2570 return *matrix_free.get_dof_info(mf_component).vector_partitioner_face_variants[1];
2572 return *matrix_free.get_dof_info(mf_component).vector_partitioner_face_variants[2];
2575 void update_ghost_values_start(
const unsigned int component_in_block_vector,
2578 (void)component_in_block_vector;
2581 ghosts_were_set =
true;
2587 #ifdef DEAL_II_WITH_MPI 2588 const unsigned int mf_component = find_vector_in_mf(vec);
2589 if (&get_partitioner(mf_component) == matrix_free.get_dof_info(mf_component)
2590 .vector_partitioner.get())
2600 tmp_data[component_in_block_vector] = matrix_free.acquire_scratch_data_non_threadsafe();
2605 (component_in_block_vector+channel_shift,
2612 this->requests[component_in_block_vector]);
2617 void update_ghost_values_finish (
const unsigned int component_in_block_vector,
2620 (void)component_in_block_vector;
2626 #ifdef DEAL_II_WITH_MPI 2631 const unsigned int mf_component = find_vector_in_mf(vec);
2633 if (&part == matrix_free.get_dof_info(mf_component).vector_partitioner.get())
2646 this->requests[component_in_block_vector]);
2648 matrix_free.release_scratch_data_non_threadsafe(tmp_data[component_in_block_vector]);
2649 tmp_data[component_in_block_vector] =
nullptr;
2654 void compress_start(
const unsigned int component_in_block_vector,
2657 (void)component_in_block_vector;
2664 #ifdef DEAL_II_WITH_MPI 2666 const unsigned int mf_component = find_vector_in_mf(vec);
2668 if (&part == matrix_free.get_dof_info(mf_component).vector_partitioner.get())
2677 tmp_data[component_in_block_vector] = matrix_free.acquire_scratch_data_non_threadsafe();
2683 component_in_block_vector+channel_shift,
2688 this->requests[component_in_block_vector]);
2693 void compress_finish (
const unsigned int component_in_block_vector,
2696 (void)component_in_block_vector;
2702 #ifdef DEAL_II_WITH_MPI 2706 const unsigned int mf_component = find_vector_in_mf(vec);
2709 if (&part == matrix_free.get_dof_info(mf_component).vector_partitioner.get())
2725 this->requests[component_in_block_vector]);
2727 matrix_free.release_scratch_data_non_threadsafe(tmp_data[component_in_block_vector]);
2728 tmp_data[component_in_block_vector] =
nullptr;
2735 if (ghosts_were_set ==
true)
2743 #ifdef DEAL_II_WITH_MPI 2746 const unsigned int mf_component = find_vector_in_mf(vec);
2748 if (&part == matrix_free.get_dof_info(mf_component).vector_partitioner.get())
2752 for (std::vector<std::pair<unsigned int, unsigned int> >::const_iterator
2756 for (
unsigned int j=my_ghosts->first; j<my_ghosts->second; j++)
2766 void zero_vector_region(
const unsigned int range_index,
2773 const unsigned int mf_component = find_vector_in_mf(vec,
false);
2775 matrix_free.get_dof_info(mf_component);
2791 std::memset(vec.
begin()+start_pos, 0, (end_pos-start_pos)*
sizeof(Number));
2796 const ::MatrixFree<dim,Number> &matrix_free;
2797 const typename ::MatrixFree<dim,Number>::DataAccessOnFaces vector_face_access;
2798 bool ghosts_were_set;
2799 #ifdef DEAL_II_WITH_MPI 2800 std::vector<AlignedVector<Number> *> tmp_data;
2801 std::vector<std::vector<MPI_Request> > requests;
2805 template <
typename VectorStruct>
2808 template <
typename VectorStruct>
2809 unsigned int n_components_block (
const VectorStruct &vec,
2810 std::integral_constant<bool,true>)
2812 unsigned int components = 0;
2813 for (
unsigned int bl=0; bl<vec.n_blocks(); ++bl)
2818 template <
typename VectorStruct>
2819 unsigned int n_components_block (
const VectorStruct &,
2820 std::integral_constant<bool,false>)
2825 template <
typename VectorStruct>
2831 template <
typename VectorStruct>
2833 unsigned int n_components (
const std::vector<VectorStruct> &vec)
2835 unsigned int components = 0;
2836 for (
unsigned int comp=0; comp<vec.size(); comp++)
2841 template <
typename VectorStruct>
2843 unsigned int n_components (
const std::vector<VectorStruct *> &vec)
2845 unsigned int components = 0;
2846 for (
unsigned int comp=0; comp<vec.size(); comp++)
2851 template <
int dim,
typename VectorStruct,
typename Number>
2852 void update_ghost_values_start_block (
const VectorStruct &vec,
2853 const unsigned int channel,
2854 std::integral_constant<bool,true>,
2855 VectorDataExchange<dim,Number> &exchanger);
2856 template <
int dim,
typename VectorStruct,
typename Number>
2857 void reset_ghost_values_block (
const VectorStruct &vec,
2858 std::integral_constant<bool,true>,
2859 VectorDataExchange<dim,Number> &exchanger);
2860 template <
int dim,
typename VectorStruct,
typename Number>
2861 void update_ghost_values_finish_block (
const VectorStruct &vec,
2862 const unsigned int channel,
2863 std::integral_constant<bool,true>,
2864 VectorDataExchange<dim,Number> &exchanger);
2865 template <
int dim,
typename VectorStruct,
typename Number>
2866 void compress_start_block (
const VectorStruct &vec,
2867 const unsigned int channel,
2868 std::integral_constant<bool,true>,
2869 VectorDataExchange<dim,Number> &exchanger);
2870 template <
int dim,
typename VectorStruct,
typename Number>
2871 void compress_finish_block (
const VectorStruct &vec,
2872 const unsigned int channel,
2873 std::integral_constant<bool,true>,
2874 VectorDataExchange<dim,Number> &exchanger);
2875 template <
int dim,
typename VectorStruct,
typename Number>
2876 void zero_vector_region_block (
const unsigned int range_index,
2878 std::integral_constant<bool,true>,
2879 VectorDataExchange<dim,Number> &);
2881 template <
int dim,
typename VectorStruct,
typename Number>
2882 void update_ghost_values_start_block (
const VectorStruct &,
2883 const unsigned int ,
2884 std::integral_constant<bool,false>,
2885 VectorDataExchange<dim,Number> &)
2887 template <
int dim,
typename VectorStruct,
typename Number>
2888 void reset_ghost_values_block (
const VectorStruct &,
2889 std::integral_constant<bool,false>,
2890 VectorDataExchange<dim,Number> &)
2892 template <
int dim,
typename VectorStruct,
typename Number>
2893 void update_ghost_values_finish_block (
const VectorStruct &,
2894 const unsigned int ,
2895 std::integral_constant<bool,false>,
2896 VectorDataExchange<dim,Number> &)
2898 template <
int dim,
typename VectorStruct,
typename Number>
2899 void compress_start_block (
const VectorStruct &,
2900 const unsigned int ,
2901 std::integral_constant<bool,false>,
2902 VectorDataExchange<dim,Number> &)
2904 template <
int dim,
typename VectorStruct,
typename Number>
2905 void compress_finish_block (
const VectorStruct &,
2906 const unsigned int ,
2907 std::integral_constant<bool,false>,
2908 VectorDataExchange<dim,Number> &)
2910 template <
int dim,
typename VectorStruct,
typename Number>
2911 void zero_vector_region_block (
const unsigned int range_index,
2913 std::integral_constant<bool,false>,
2914 VectorDataExchange<dim,Number> &)
2922 template <
int dim,
typename VectorStruct,
typename Number>
2924 void update_ghost_values_start (
const VectorStruct &vec,
2925 VectorDataExchange<dim,Number> &exchanger,
2926 const unsigned int channel = 0)
2928 update_ghost_values_start_block(vec, channel,
2929 std::integral_constant<
bool,
2936 template <
int dim,
typename Number,
typename Number2>
2939 VectorDataExchange<dim,Number2> &exchanger,
2940 const unsigned int channel = 0)
2942 exchanger.update_ghost_values_start(channel, vec);
2947 template <
int dim,
typename VectorStruct,
typename Number>
2949 void update_ghost_values_start (
const std::vector<VectorStruct> &vec,
2950 VectorDataExchange<dim,Number> &exchanger)
2952 unsigned int component_index = 0;
2953 for (
unsigned int comp=0; comp<vec.size(); comp++)
2955 update_ghost_values_start(vec[comp], exchanger, component_index);
2962 template <
int dim,
typename VectorStruct,
typename Number>
2964 void update_ghost_values_start (
const std::vector<VectorStruct *> &vec,
2965 VectorDataExchange<dim,Number> &exchanger)
2967 unsigned int component_index = 0;
2968 for (
unsigned int comp=0; comp<vec.size(); comp++)
2970 update_ghost_values_start(*vec[comp], exchanger, component_index);
2977 template <
int dim,
typename VectorStruct,
typename Number>
2979 void update_ghost_values_start_block (
const VectorStruct &vec,
2980 const unsigned int channel,
2981 std::integral_constant<bool,true>,
2982 VectorDataExchange<dim,Number> &exchanger)
2984 for (
unsigned int i=0; i<vec.n_blocks(); ++i)
2985 update_ghost_values_start(vec.block(i), exchanger, channel+i);
2993 template <
int dim,
typename VectorStruct,
typename Number>
2995 void reset_ghost_values (
const VectorStruct &vec,
2996 VectorDataExchange<dim,Number> &exchanger)
2998 reset_ghost_values_block(vec,
2999 std::integral_constant<
bool,
3006 template <
int dim,
typename Number,
typename Number2>
3009 VectorDataExchange<dim,Number2> &exchanger)
3011 exchanger.reset_ghost_values(vec);
3016 template <
int dim,
typename VectorStruct,
typename Number>
3018 void reset_ghost_values (
const std::vector<VectorStruct> &vec,
3019 VectorDataExchange<dim,Number> &exchanger)
3021 for (
unsigned int comp=0; comp<vec.size(); comp++)
3022 reset_ghost_values(vec[comp], exchanger);
3027 template <
int dim,
typename VectorStruct,
typename Number>
3029 void reset_ghost_values (
const std::vector<VectorStruct *> &vec,
3030 VectorDataExchange<dim,Number> &exchanger)
3032 for (
unsigned int comp=0; comp<vec.size(); comp++)
3033 reset_ghost_values(*vec[comp], exchanger);
3038 template <
int dim,
typename VectorStruct,
typename Number>
3040 void reset_ghost_values_block (
const VectorStruct &vec,
3041 std::integral_constant<bool,true>,
3042 VectorDataExchange<dim,Number> &exchanger)
3044 for (
unsigned int i=0; i<vec.n_blocks(); ++i)
3045 reset_ghost_values(vec.block(i), exchanger);
3050 template <
int dim,
typename VectorStruct,
typename Number>
3052 void update_ghost_values_finish (
const VectorStruct &vec,
3053 VectorDataExchange<dim,Number> &exchanger,
3054 const unsigned int channel = 0)
3056 update_ghost_values_finish_block(vec, channel,
3057 std::integral_constant<
bool,
3064 template <
int dim,
typename Number,
typename Number2>
3067 VectorDataExchange<dim,Number2> &exchanger,
3068 const unsigned int channel = 0)
3070 exchanger.update_ghost_values_finish(channel, vec);
3075 template <
int dim,
typename VectorStruct,
typename Number>
3077 void update_ghost_values_finish (
const std::vector<VectorStruct> &vec,
3078 VectorDataExchange<dim,Number> &exchanger)
3080 unsigned int component_index = 0;
3081 for (
unsigned int comp=0; comp<vec.size(); comp++)
3083 update_ghost_values_finish(vec[comp], exchanger, component_index);
3090 template <
int dim,
typename VectorStruct,
typename Number>
3092 void update_ghost_values_finish (
const std::vector<VectorStruct *> &vec,
3093 VectorDataExchange<dim,Number> &exchanger)
3095 unsigned int component_index = 0;
3096 for (
unsigned int comp=0; comp<vec.size(); comp++)
3098 update_ghost_values_finish(*vec[comp], exchanger, component_index);
3105 template <
int dim,
typename VectorStruct,
typename Number>
3107 void update_ghost_values_finish_block (
const VectorStruct &vec,
3108 const unsigned int channel,
3109 std::integral_constant<bool,true>,
3110 VectorDataExchange<dim,Number> &exchanger)
3112 for (
unsigned int i=0; i<vec.n_blocks(); ++i)
3113 update_ghost_values_finish(vec.block(i), exchanger, channel+i);
3118 template <
int dim,
typename VectorStruct,
typename Number>
3120 void compress_start (VectorStruct &vec,
3121 VectorDataExchange<dim, Number> &exchanger,
3122 const unsigned int channel = 0)
3124 compress_start_block (vec, channel,
3125 std::integral_constant<
bool,
3132 template <
int dim,
typename Number,
typename Number2>
3135 VectorDataExchange<dim,Number2> &exchanger,
3136 const unsigned int channel = 0)
3138 exchanger.compress_start(channel, vec);
3143 template <
int dim,
typename VectorStruct,
typename Number>
3145 void compress_start (std::vector<VectorStruct> &vec,
3146 VectorDataExchange<dim, Number> &exchanger)
3148 unsigned int component_index = 0;
3149 for (
unsigned int comp=0; comp<vec.size(); comp++)
3151 compress_start(vec[comp], exchanger, component_index);
3158 template <
int dim,
typename VectorStruct,
typename Number>
3160 void compress_start (std::vector<VectorStruct *> &vec,
3161 VectorDataExchange<dim, Number> &exchanger)
3163 unsigned int component_index = 0;
3164 for (
unsigned int comp=0; comp<vec.size(); comp++)
3166 compress_start(*vec[comp], exchanger, component_index);
3173 template <
int dim,
typename VectorStruct,
typename Number>
3175 void compress_start_block (VectorStruct &vec,
3176 const unsigned int channel,
3177 std::integral_constant<bool,true>,
3178 VectorDataExchange<dim, Number> &exchanger)
3180 for (
unsigned int i=0; i<vec.n_blocks(); ++i)
3181 compress_start(vec.block(i), exchanger, channel+i);
3186 template <
int dim,
typename VectorStruct,
typename Number>
3188 void compress_finish (VectorStruct &vec,
3189 VectorDataExchange<dim, Number> &exchanger,
3190 const unsigned int channel = 0)
3192 compress_finish_block(vec, channel,
3193 std::integral_constant<
bool,
3200 template <
int dim,
typename Number,
typename Number2>
3203 VectorDataExchange<dim, Number2> &exchanger,
3204 const unsigned int channel = 0)
3206 exchanger.compress_finish(channel, vec);
3211 template <
int dim,
typename VectorStruct,
typename Number>
3213 void compress_finish (std::vector<VectorStruct> &vec,
3214 VectorDataExchange<dim, Number> &exchanger)
3216 unsigned int component_index = 0;
3217 for (
unsigned int comp=0; comp<vec.size(); comp++)
3219 compress_finish(vec[comp], exchanger, component_index);
3226 template <
int dim,
typename VectorStruct,
typename Number>
3228 void compress_finish (std::vector<VectorStruct *> &vec,
3229 VectorDataExchange<dim, Number> &exchanger)
3231 unsigned int component_index = 0;
3232 for (
unsigned int comp=0; comp<vec.size(); comp++)
3234 compress_finish(*vec[comp], exchanger, component_index);
3241 template <
int dim,
typename VectorStruct,
typename Number>
3243 void compress_finish_block (VectorStruct &vec,
3244 const unsigned int channel,
3245 std::integral_constant<bool,true>,
3246 VectorDataExchange<dim, Number> &exchanger)
3248 for (
unsigned int i=0; i<vec.n_blocks(); ++i)
3249 compress_finish(vec.block(i), exchanger, channel+i);
3254 template <
int dim,
typename VectorStruct,
typename Number>
3256 void zero_vector_region (
const unsigned int range_index,
3258 VectorDataExchange<dim, Number> &exchanger)
3260 zero_vector_region_block(range_index, vec,
3261 std::integral_constant<
bool,
3268 template <
int dim,
typename Number,
typename Number2>
3270 void zero_vector_region (
const unsigned int range_index,
3272 VectorDataExchange<dim, Number2> &exchanger)
3274 exchanger.zero_vector_region(range_index, vec);
3279 template <
int dim,
typename VectorStruct,
typename Number>
3281 void zero_vector_region (
const unsigned int range_index,
3282 std::vector<VectorStruct> &vec,
3283 VectorDataExchange<dim, Number> &exchanger)
3285 for (
unsigned int comp=0; comp<vec.size(); comp++)
3286 zero_vector_region(range_index, vec[comp], exchanger);
3291 template <
int dim,
typename VectorStruct,
typename Number>
3293 void zero_vector_region (
const unsigned int range_index,
3294 std::vector<VectorStruct *> &vec,
3295 VectorDataExchange<dim, Number> &exchanger)
3297 for (
unsigned int comp=0; comp<vec.size(); comp++)
3298 zero_vector_region(range_index, *vec[comp], exchanger);
3303 template <
int dim,
typename VectorStruct,
typename Number>
3305 void zero_vector_region_block (
const unsigned int range_index,
3307 std::integral_constant<bool,true>,
3308 VectorDataExchange<dim, Number> &exchanger)
3310 for (
unsigned int i=0; i<vec.n_blocks(); ++i)
3311 zero_vector_region(range_index, vec.block(i), exchanger);
3316 namespace MatrixFreeFunctions
3320 template <
typename,
typename,
typename,
typename,
bool>
3321 struct InterfaceSelector
3325 template <
typename MF,
typename InVector,
typename OutVector,
typename Container>
3326 struct InterfaceSelector<MF, InVector, OutVector, Container, true>
3328 typedef void (Container::*function_type)
3329 (
const MF &, OutVector &,
const InVector &,
3330 const std::pair<unsigned int, unsigned int> &)
const;
3334 template <
typename MF,
typename InVector,
typename OutVector,
typename Container>
3335 struct InterfaceSelector<MF, InVector, OutVector, Container, false>
3337 typedef void (Container::*function_type)
3338 (
const MF &, OutVector &,
const InVector &,
3339 const std::pair<unsigned int, unsigned int> &);
3347 template <
typename MF,
typename InVector,
typename OutVector,
3348 typename Container,
bool is_constant>
3349 class MFWorker :
public MFWorkerInterface
3353 typedef typename MatrixFreeFunctions::InterfaceSelector
3354 <MF,InVector,OutVector,Container,is_constant>::function_type function_type;
3357 MFWorker (
const MF &matrix_free,
3358 const InVector &src,
3360 const bool zero_dst_vector_setting,
3361 const Container &container,
3362 function_type cell_function,
3363 function_type face_function,
3364 function_type boundary_function,
3365 const typename MF::DataAccessOnFaces src_vector_face_access =
3366 MF::DataAccessOnFaces::none,
3367 const typename MF::DataAccessOnFaces dst_vector_face_access =
3368 MF::DataAccessOnFaces::none)
3370 matrix_free (matrix_free),
3371 container (const_cast<Container &>(container)),
3372 cell_function (cell_function),
3373 face_function (face_function),
3374 boundary_function (boundary_function),
3377 src_data_exchanger (matrix_free, src_vector_face_access,
3379 dst_data_exchanger (matrix_free, dst_vector_face_access,
3382 zero_dst_vector_setting(zero_dst_vector_setting && !src_and_dst_are_same)
3386 virtual void cell(
const std::pair<unsigned int,unsigned int> &cell_range)
override 3388 if (cell_function !=
nullptr && cell_range.second > cell_range.first)
3389 (container.*cell_function)(matrix_free, this->dst, this->src, cell_range);
3394 virtual void face(
const std::pair<unsigned int,unsigned int> &face_range)
override 3396 if (face_function !=
nullptr && face_range.second > face_range.first)
3397 (container.*face_function)(matrix_free, this->dst, this->src, face_range);
3402 virtual void boundary(
const std::pair<unsigned int,unsigned int> &face_range)
override 3404 if (boundary_function !=
nullptr && face_range.second > face_range.first)
3405 (container.*boundary_function)(matrix_free, this->dst, this->src, face_range);
3414 virtual void vector_update_ghosts_start()
override 3416 if (!src_and_dst_are_same)
3417 internal::update_ghost_values_start(src, src_data_exchanger);
3421 virtual void vector_update_ghosts_finish()
override 3423 if (!src_and_dst_are_same)
3424 internal::update_ghost_values_finish(src, src_data_exchanger);
3428 virtual void vector_compress_start()
override 3430 internal::compress_start(dst, dst_data_exchanger);
3434 virtual void vector_compress_finish()
override 3436 internal::compress_finish(dst, dst_data_exchanger);
3437 if (!src_and_dst_are_same)
3438 internal::reset_ghost_values(src, src_data_exchanger);
3442 virtual void zero_dst_vector_range(
const unsigned int range_index)
override 3444 if (zero_dst_vector_setting)
3445 internal::zero_vector_region(range_index, dst, dst_data_exchanger);
3449 const MF &matrix_free;
3450 Container &container;
3451 function_type cell_function;
3452 function_type face_function;
3453 function_type boundary_function;
3455 const InVector &src;
3457 VectorDataExchange<MF::dimension,typename MF::value_type> src_data_exchanger;
3458 VectorDataExchange<MF::dimension,typename MF::value_type> dst_data_exchanger;
3459 const bool src_and_dst_are_same;
3460 const bool zero_dst_vector_setting;
3469 template <
class MF,
typename InVector,
typename OutVector>
3470 struct MFClassWrapper
3472 typedef std::function<void (
const MF &, OutVector &,
const InVector &,
3473 const std::pair<unsigned int, unsigned int> &)> function_type;
3475 MFClassWrapper (
const function_type cell,
3476 const function_type face,
3477 const function_type boundary)
3484 void cell_integrator (
const MF &mf, OutVector &dst,
const InVector &src,
3485 const std::pair<unsigned int, unsigned int> &range)
const 3488 cell(mf, dst, src, range);
3491 void face_integrator (
const MF &mf, OutVector &dst,
const InVector &src,
3492 const std::pair<unsigned int, unsigned int> &range)
const 3495 face(mf, dst, src, range);
3498 void boundary_integrator (
const MF &mf, OutVector &dst,
const InVector &src,
3499 const std::pair<unsigned int, unsigned int> &range)
const 3502 boundary(mf, dst, src, range);
3505 const function_type cell;
3506 const function_type face;
3507 const function_type boundary;
3514 template <
int dim,
typename Number>
3515 template <
typename OutVector,
typename InVector>
3522 const std::pair<
unsigned int,
3523 unsigned int> &)> &cell_operation,
3525 const InVector &src,
3526 const bool zero_dst_vector)
const 3528 typedef internal::MFClassWrapper<MatrixFree<dim, Number>, InVector, OutVector> Wrapper;
3529 Wrapper wrap (cell_operation,
nullptr,
nullptr);
3530 internal::MFWorker<MatrixFree<dim, Number>, InVector, OutVector, Wrapper,
true>
3531 worker(*
this, src, dst, zero_dst_vector, wrap, &Wrapper::cell_integrator,
3532 &Wrapper::face_integrator, &Wrapper::boundary_integrator);
3534 task_info.loop (worker);
3539 template <
int dim,
typename Number>
3540 template <
typename OutVector,
typename InVector>
3547 const std::pair<
unsigned int,
3548 unsigned int> &)> &cell_operation,
3552 const std::pair<
unsigned int,
3553 unsigned int> &)> &face_operation,
3557 const std::pair<
unsigned int,
3558 unsigned int> &)> &boundary_operation,
3560 const InVector &src,
3561 const bool zero_dst_vector,
3562 const DataAccessOnFaces dst_vector_face_access,
3563 const DataAccessOnFaces src_vector_face_access)
const 3565 typedef internal::MFClassWrapper<MatrixFree<dim, Number>, InVector, OutVector> Wrapper;
3566 Wrapper wrap (cell_operation, face_operation, boundary_operation);
3567 internal::MFWorker<MatrixFree<dim, Number>, InVector, OutVector, Wrapper,
true>
3568 worker(*
this, src, dst, zero_dst_vector, wrap, &Wrapper::cell_integrator,
3569 &Wrapper::face_integrator, &Wrapper::boundary_integrator,
3570 src_vector_face_access, dst_vector_face_access);
3572 task_info.loop(worker);
3577 template <
int dim,
typename Number>
3578 template <
typename CLASS,
typename OutVector,
typename InVector>
3585 const std::pair<unsigned int, unsigned int> &)
const,
3586 const CLASS *owning_class,
3588 const InVector &src,
3589 const bool zero_dst_vector)
const 3591 internal::MFWorker<MatrixFree<dim, Number>, InVector, OutVector, CLASS,
true>
3592 worker(*
this, src, dst, zero_dst_vector, *owning_class, function_pointer,
nullptr,
nullptr);
3593 task_info.loop(worker);
3598 template <
int dim,
typename Number>
3599 template <
typename CLASS,
typename OutVector,
typename InVector>
3606 const std::pair<unsigned int, unsigned int> &)
const,
3610 const std::pair<unsigned int, unsigned int> &)
const,
3614 const std::pair<unsigned int, unsigned int> &)
const,
3615 const CLASS *owning_class,
3617 const InVector &src,
3618 const bool zero_dst_vector,
3619 const DataAccessOnFaces dst_vector_face_access,
3620 const DataAccessOnFaces src_vector_face_access)
const 3622 internal::MFWorker<MatrixFree<dim, Number>, InVector, OutVector, CLASS,
true>
3623 worker(*
this, src, dst, zero_dst_vector, *owning_class, cell_operation, face_operation,
3624 boundary_operation, src_vector_face_access, dst_vector_face_access);
3625 task_info.loop(worker);
3630 template <
int dim,
typename Number>
3631 template <
typename CLASS,
typename OutVector,
typename InVector>
3638 const std::pair<unsigned int, unsigned int> &),
3639 CLASS *owning_class,
3641 const InVector &src,
3642 const bool zero_dst_vector)
const 3644 internal::MFWorker<MatrixFree<dim, Number>, InVector, OutVector, CLASS,
false>
3645 worker(*
this, src, dst, zero_dst_vector, *owning_class, function_pointer,
nullptr,
nullptr);
3646 task_info.loop(worker);
3651 template <
int dim,
typename Number>
3652 template <
typename CLASS,
typename OutVector,
typename InVector>
3659 const std::pair<unsigned int, unsigned int> &),
3663 const std::pair<unsigned int, unsigned int> &),
3667 const std::pair<unsigned int, unsigned int> &),
3668 CLASS *owning_class,
3670 const InVector &src,
3671 const bool zero_dst_vector,
3672 const DataAccessOnFaces dst_vector_face_access,
3673 const DataAccessOnFaces src_vector_face_access)
const 3675 internal::MFWorker<MatrixFree<dim, Number>, InVector, OutVector, CLASS,
false>
3676 worker(*
this, src, dst, zero_dst_vector, *owning_class, cell_operation,
3677 face_operation, boundary_operation,
3678 src_vector_face_access, dst_vector_face_access);
3679 task_info.loop(worker);
3683 #endif // ifndef DOXYGEN 3687 DEAL_II_NAMESPACE_CLOSE
const IndexSet & get_ghost_set(const unsigned int dof_handler_index=0) const
Transformed quadrature weights.
const Quadrature< dim-1 > & get_face_quadrature(const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
UpdateFlags mapping_update_flags_inner_faces
unsigned int n_physical_cells() const
DoFHandler< dim >::cell_iterator get_cell_iterator(const unsigned int macro_cell_number, const unsigned int vector_number, const unsigned int fe_component=0) const
void reinit(const size_type size, const bool omit_zeroing_entries=false)
void loop(const std::function< void(const MatrixFree< dim, Number > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, const std::function< void(const MatrixFree< dim, Number > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &face_operation, const std::function< void(const MatrixFree< dim, Number > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &boundary_operation, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
internal::MatrixFreeFunctions::TaskInfo task_info
bool indices_are_initialized
static const unsigned int invalid_unsigned_int
unsigned int get_dofs_per_face(const unsigned int fe_component=0, const unsigned int hp_active_fe_index=0) const
UpdateFlags mapping_update_flags_boundary_faces
const Number * constraint_pool_begin(const unsigned int pool_index) const
std::vector< unsigned int > constraint_pool_row_index
unsigned int get_n_q_points_face(const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
#define AssertDimension(dim1, dim2)
internal::MatrixFreeFunctions::MappingInfo< dim, Number > mapping_info
A class that provides a separate storage location on each thread that accesses the object...
unsigned int n_ghost_cell_batches() const
static const unsigned int dimension
std::list< std::pair< bool, AlignedVector< Number > > > scratch_pad_non_threadsafe
const internal::MatrixFreeFunctions::FaceToCellTopology< VectorizedArray< Number >::n_array_elements > & get_face_info(const unsigned int face_batch_number) const
unsigned int local_size() const
std::pair< unsigned int, unsigned int > create_cell_subrange_hp(const std::pair< unsigned int, unsigned int > &range, const unsigned int fe_degree, const unsigned int dof_handler_index=0) const
void initialize_dof_handlers(const std::vector< const DoFHandler< dim > *> &dof_handlers, const AdditionalData &additional_data)
const internal::MatrixFreeFunctions::TaskInfo & get_size_info() const
unsigned int n_components() const
Threads::ThreadLocalStorage< std::list< std::pair< bool, AlignedVector< VectorizedArray< Number > > > > > scratch_pad
std::pair< unsigned int, unsigned int > get_face_category(const unsigned int macro_face) const
const IndexSet & get_locally_owned_set(const unsigned int dof_handler_index=0) const
unsigned int n_active_entries_per_face_batch(const unsigned int face_batch_number) const
std::vector< Number > constraint_pool_data
#define AssertIndexRange(index, range)
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
std::vector< unsigned int > vector_zero_range_list_index
void reinit(const Mapping< dim > &mapping, const DoFHandlerType &dof_handler, const ConstraintMatrix &constraint, const QuadratureType &quad, const AdditionalData additional_data=AdditionalData())
void copy_from(const MatrixFree< dim, Number > &matrix_free_base)
std::array< types::boundary_id, VectorizedArray< Number >::n_array_elements > get_faces_by_cells_boundary_id(const unsigned int macro_cell, const unsigned int face_number) const
std::vector< std::pair< unsigned int, unsigned int > > cell_level_index
const std::vector< std::pair< unsigned int, unsigned int > > & ghost_indices_within_larger_ghost_set() const
void make_connectivity_graph_faces(DynamicSparsityPattern &connectivity)
static ::ExceptionBase & ExcNotInitialized()
#define AssertThrow(cond, exc)
hp::DoFHandler< dim >::active_cell_iterator get_hp_cell_iterator(const unsigned int macro_cell_number, const unsigned int vector_number, const unsigned int dof_handler_index=0) const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< Number > &ghost_array, const ArrayView< Number > &temporary_storage, std::vector< MPI_Request > &requests) const
unsigned int get_dofs_per_cell(const unsigned int dof_handler_index=0, const unsigned int hp_active_fe_index=0) const
unsigned int n_boundary_face_batches() const
unsigned int n_inner_face_batches() const
ActiveSelector::active_cell_iterator active_cell_iterator
bool mapping_is_initialized
AlignedVector< VectorizedArray< Number > > * acquire_scratch_data() const
void export_to_ghosted_array_finish(const ArrayView< Number > &ghost_array, std::vector< MPI_Request > &requests) const
void internal_reinit(const Mapping< dim > &mapping, const std::vector< const DoFHandler< dim > *> &dof_handler, const std::vector< const ConstraintMatrix *> &constraint, const std::vector< IndexSet > &locally_owned_set, const std::vector< hp::QCollection< 1 > > &quad, const AdditionalData &additional_data)
void initialize_dof_vector(VectorType &vec, const unsigned int dof_handler_index=0) const
unsigned int n_components_filled(const unsigned int cell_batch_number) const
static ::ExceptionBase & ExcMessage(std::string arg1)
bool has_ghost_elements() const
void renumber_dofs(std::vector< types::global_dof_index > &renumbering, const unsigned int dof_handler_index=0)
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_vector_partitioner(const unsigned int dof_handler_index=0) const
unsigned int n_ghost_indices() const
virtual size_type size() const override
void zero_out_ghosts() const
bool at_irregular_cell(const unsigned int macro_cell_number) const
Table< 4, internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray< Number > > > shape_info
#define Assert(cond, exc)
static bool is_supported(const FiniteElement< dim, spacedim > &fe)
void print_memory_consumption(StreamType &out) const
const types::boundary_id invalid_boundary_id
bool cell_vectorization_categories_strict
const Number * constraint_pool_end(const unsigned int pool_index) const
const internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray< Number > > & get_shape_info(const unsigned int dof_handler_index_component=0, const unsigned int quad_index=0, const unsigned int fe_base_element=0, const unsigned int hp_active_fe_index=0, const unsigned int hp_active_quad_index=0) const
void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const Number > &locally_owned_array, const ArrayView< Number > &temporary_storage, const ArrayView< Number > &ghost_array, std::vector< MPI_Request > &requests) const
unsigned int n_constraint_pool_entries() const
AdditionalData(const TasksParallelScheme tasks_parallel_scheme=partition_partition, const unsigned int tasks_block_size=0, const UpdateFlags mapping_update_flags=update_gradients|update_JxW_values, const UpdateFlags mapping_update_flags_boundary_faces=update_default, const UpdateFlags mapping_update_flags_inner_faces=update_default, const UpdateFlags mapping_update_flags_faces_by_cells=update_default, const unsigned int level_mg_handler=numbers::invalid_unsigned_int, const bool store_plain_indices=true, const bool initialize_indices=true, const bool initialize_mapping=true, const bool overlap_communication_computation=true, const bool hold_all_faces_to_owned_cells=false, const bool cell_vectorization_categories_strict=false)
void release_scratch_data_non_threadsafe(const AlignedVector< Number > *memory) const
unsigned int n_macro_cells() const
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
TasksParallelScheme tasks_parallel_scheme
AlignedVector< Number > * acquire_scratch_data_non_threadsafe() const
types::boundary_id get_boundary_id(const unsigned int macro_face) const
bool hold_all_faces_to_owned_cells
bool mapping_initialized() const
unsigned int n_ghost_inner_face_batches() const
void compress_start(const unsigned int communication_channel=0, ::VectorOperation::values operation=VectorOperation::add)
unsigned int tasks_block_size
void release_scratch_data(const AlignedVector< VectorizedArray< Number > > *memory) const
void compress_finish(::VectorOperation::values operation)
unsigned int cell_level_index_end_local
internal::MatrixFreeFunctions::FaceInfo< VectorizedArray< Number >::n_array_elements > face_info
unsigned int level_mg_handler
const DoFHandler< dim > & get_dof_handler(const unsigned int dof_handler_index=0) const
Shape function gradients.
void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< const Number > &temporary_storage, const ArrayView< Number > &locally_owned_storage, const ArrayView< Number > &ghost_array, std::vector< MPI_Request > &requests) const
unsigned int get_n_q_points(const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
unsigned int n_active_entries_per_cell_batch(const unsigned int cell_batch_number) const
bool partitioners_are_compatible(const Utilities::MPI::Partitioner &part) const
unsigned int n_base_elements(const unsigned int dof_handler_index) const
UpdateFlags mapping_update_flags
static ::ExceptionBase & ExcNotImplemented()
std::size_t memory_consumption() const
std::vector< unsigned int > vector_zero_range_list
void initialize_indices(const std::vector< const ConstraintMatrix *> &constraint, const std::vector< IndexSet > &locally_owned_set, const AdditionalData &additional_data)
bool indices_initialized() const
unsigned int get_cell_category(const unsigned int macro_cell) const
const internal::MatrixFreeFunctions::DoFInfo & get_dof_info(const unsigned int dof_handler_index_component=0) const
const Quadrature< dim > & get_quadrature(const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
std::vector< internal::MatrixFreeFunctions::DoFInfo > dof_info
static const unsigned int chunk_size_zero_vector
unsigned int n_import_indices() const
unsigned int n_cell_batches() const
bool overlap_communication_computation
UpdateFlags mapping_update_flags_faces_by_cells
std::pair< unsigned int, unsigned int > create_cell_subrange_hp_by_index(const std::pair< unsigned int, unsigned int > &range, const unsigned int fe_index, const unsigned int dof_handler_index=0) const
const internal::MatrixFreeFunctions::TaskInfo & get_task_info() const
std::vector< unsigned int > cell_vectorization_category
static ::ExceptionBase & ExcInternalError()
void cell_loop(const std::function< void(const MatrixFree< dim, Number > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, OutVector &dst, const InVector &src, const bool zero_dst_vector=false) const
void print(std::ostream &out) const
void update_ghost_values_start(const unsigned int communication_channel=0) const
const std::vector< unsigned int > & get_constrained_dofs(const unsigned int dof_handler_index=0) const
void update_ghost_values_finish() const