40 namespace PointValueHistoryImplementation
59 const unsigned int n_independent_variables)
60 : n_indep(n_independent_variables)
72 std::vector<std::vector<double>>(
n_indep, std::vector<double>(0));
81 const unsigned int n_independent_variables)
82 : dof_handler(&dof_handler)
83 , n_indep(n_independent_variables)
95 std::vector<std::vector<double>>(
n_indep, std::vector<double>(0));
127 if (have_dof_handler)
130 dof_handler->get_triangulation().signals.any_change.connect(
131 [
this]() { this->tria_change_listener(); });
160 if (have_dof_handler)
163 dof_handler->get_triangulation().signals.any_change.connect(
164 [
this]() { this->tria_change_listener(); });
175 if (have_dof_handler)
177 tria_listener.disconnect();
191 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
192 AssertThrow(!triangulation_changed, ExcDoFHandlerChanged());
204 dof_handler->get_fe().get_unit_support_points());
209 dof_handler->get_fe().get_unit_support_points().
size();
210 unsigned int n_components = dof_handler->get_fe(0).n_components();
215 dof_handler->begin_active();
231 unsigned int component =
232 dof_handler->get_fe().system_to_component_index(
support_point).first;
247 for (; cell !=
endc; ++cell)
254 unsigned int component = dof_handler->get_fe()
272 std::vector<types::global_dof_index> local_dof_indices(
273 dof_handler->get_fe().n_dofs_per_cell());
295 for (
unsigned int component = 0;
296 component < dof_handler->get_fe(0).n_components();
331 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
332 AssertThrow(!triangulation_changed, ExcDoFHandlerChanged());
345 dof_handler->get_fe().get_unit_support_points());
350 dof_handler->get_fe().get_unit_support_points().
size();
351 unsigned int n_components = dof_handler->get_fe(0).n_components();
356 dof_handler->begin_active();
366 std::vector<typename DoFHandler<dim>::active_cell_iterator>
current_cell(
367 locations.size(), cell);
376 unsigned int component =
377 dof_handler->get_fe().system_to_component_index(
support_point).first;
395 for (; cell !=
endc; ++cell)
401 unsigned int component = dof_handler->get_fe()
407 for (
unsigned int point = 0; point < locations.size(); ++point)
421 std::vector<types::global_dof_index> local_dof_indices(
422 dof_handler->get_fe().n_dofs_per_cell());
423 for (
unsigned int point = 0; point < locations.size(); ++point)
425 current_cell[point]->get_dof_indices(local_dof_indices);
428 for (
unsigned int component = 0;
429 component < dof_handler->get_fe(0).n_components();
465 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
466 AssertThrow(!triangulation_changed, ExcDoFHandlerChanged());
469 if (mask.represents_the_all_selected_mask() ==
false)
470 component_mask.insert(std::make_pair(
vector_name, mask));
472 component_mask.insert(
475 dof_handler->get_fe(0).n_components(),
true))));
480 std::pair<std::string, std::vector<std::string>>
empty_names(
486 std::pair<std::string, std::vector<std::vector<double>>>
pair_data;
489 (mask.represents_the_all_selected_mask() ==
false ?
490 mask.n_selected_components() :
491 dof_handler->get_fe(0).n_components());
496 std::vector<double>(0));
505 const unsigned int n_components)
507 std::vector<bool>
temp_mask(n_components,
true);
516 const std::vector<std::string> &component_names)
518 typename std::map<std::string, std::vector<std::string>>
::iterator names =
520 Assert(names != component_names_map.end(),
523 typename std::map<std::string, ComponentMask>::iterator mask =
525 Assert(mask != component_mask.end(),
ExcMessage(
"vector_name not in class"));
526 unsigned int n_stored = mask->second.n_selected_components();
531 names->second = component_names;
561 dof_handler =
nullptr;
562 have_dof_handler =
false;
578template <
typename VectorType>
581 const VectorType & solution)
587 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
588 AssertThrow(!triangulation_changed, ExcDoFHandlerChanged());
594 static_cast<int>(independent_values[0].size())) < 2,
602 typename std::map<std::string, std::vector<std::vector<double>>>
::iterator
607 typename std::map<std::string, ComponentMask>::iterator mask =
609 Assert(mask != component_mask.end(),
ExcMessage(
"vector_name not in class"));
612 mask->second.n_selected_components(dof_handler->get_fe(0).n_components());
614 typename std::vector<
616 point = point_geometry_data.begin();
626 comp < dof_handler->get_fe(0).n_components();
629 if (mask->second[
comp])
646template <
typename VectorType>
650 const VectorType & solution,
658 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
663 static_cast<int>(independent_values[0].size())) < 2,
673 "The update of normal vectors may not be requested for evaluation of "
674 "data on cells via DataPostprocessor."));
675 FEValues<dim> fe_values(dof_handler->get_fe(), quadrature, update_flags);
676 unsigned int n_components = dof_handler->get_fe(0).n_components();
677 unsigned int n_quadrature_points = quadrature.
size();
685 n_quadrature_points);
686 std::vector<Tensor<1, dim, typename VectorType::value_type>>
688 std::vector<Tensor<2, dim, typename VectorType::value_type>>
694 std::vector<std::vector<Tensor<1, dim, typename VectorType::value_type>>>
700 std::vector<std::vector<Tensor<2, dim, typename VectorType::value_type>>>
707 typename std::vector<
709 point = point_geometry_data.begin();
710 Assert(!dof_handler->get_triangulation().is_mixed_mesh(),
712 const auto reference_cell =
713 dof_handler->get_triangulation().get_reference_cells()[0];
718 const Point<dim> requested_location = point->requested_location;
732 std::vector<Point<dim>> quadrature_points =
733 fe_values.get_quadrature_points();
734 double distance = cell->diameter();
738 if (requested_location.distance(quadrature_points[
q_point]) <
743 requested_location.distance(quadrature_points[
q_point]);
749 if (n_components == 1)
771 fe_values.get_function_gradients(solution,
774 std::vector<Tensor<1, dim>>(
779 fe_values.get_function_hessians(solution,
782 std::vector<Tensor<2, dim>>(
810 fe_values.get_function_gradients(solution,
820 fe_values.get_function_hessians(solution,
839 typename std::vector<std::string>::const_iterator name =
843 typename std::map<std::string,
849 typename std::map<std::string, ComponentMask>::iterator mask =
850 component_mask.find(*name);
851 Assert(mask != component_mask.end(),
855 mask->second.n_selected_components(n_output_variables);
860 comp < n_output_variables;
863 if (mask->second[
comp])
878template <
typename VectorType>
882 const VectorType & solution,
894template <
typename VectorType>
898 const VectorType & solution)
900 using number =
typename VectorType::value_type;
905 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
911 static_cast<int>(independent_values[0].size())) < 2,
919 typename std::map<std::string, std::vector<std::vector<double>>>
::iterator
924 typename std::map<std::string, ComponentMask>::iterator mask =
926 Assert(mask != component_mask.end(),
ExcMessage(
"vector_name not in class"));
929 mask->second.n_selected_components(dof_handler->get_fe(0).n_components());
931 typename std::vector<
933 point = point_geometry_data.begin();
943 point->requested_location,
951 if (mask->second[
comp])
955 .push_back(value(
comp));
971 Assert(deep_check(
false), ExcDataLostSync());
973 dataset_key.push_back(
key);
989 Assert(n_indep != 0, ExcNoIndependent());
991 static_cast<int>(independent_values[0].size())) < 2,
994 for (
unsigned int component = 0; component < n_indep; ++component)
995 independent_values[component].push_back(
indep_values[component]);
1003 const std::string & base_name,
1013 std::string
filename = base_name +
"_indep.gpl";
1016 to_gnuplot <<
"# Data independent of mesh location\n";
1021 if (indep_names.size() > 0)
1031 for (
unsigned int component = 0; component < n_indep; ++component)
1033 to_gnuplot <<
"<Indep_" << component <<
"> ";
1042 for (
unsigned int component = 0; component < n_indep; ++component)
1055 if (have_dof_handler)
1057 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
1060 point_geometry_data.size(),
1062 point_geometry_data.size()));
1077 typename std::vector<internal::PointValueHistoryImplementation::
1079 point_geometry_data.begin();
1081 point != point_geometry_data.end();
1086 std::string
filename = base_name +
"_" +
1098 to_gnuplot <<
"# Requested location: " << point->requested_location
1100 to_gnuplot <<
"# DoF_index : Support location (for each component)\n";
1101 for (
unsigned int component = 0;
1102 component < dof_handler->get_fe(0).n_components();
1105 to_gnuplot <<
"# " << point->solution_indices[component] <<
" : "
1106 << point->support_point_locations[component] <<
'\n';
1108 if (triangulation_changed)
1110 <<
"# (Original components and locations, may be invalidated by mesh change.)\n";
1116 if (triangulation_changed)
1125 if (indep_names.size() > 0)
1134 for (
unsigned int component = 0; component < n_indep; ++component)
1136 to_gnuplot <<
"<Indep_" << component <<
"> ";
1142 typename std::map<std::string, ComponentMask>::iterator mask =
1144 unsigned int n_stored = mask->second.n_selected_components();
1145 std::vector<std::string> names =
1148 if (names.size() > 0)
1152 for (
const auto &name : names)
1159 for (
unsigned int component = 0; component <
n_stored;
1174 for (
unsigned int component = 0; component < n_indep; ++component)
1181 typename std::map<std::string, ComponentMask>::iterator mask =
1183 unsigned int n_stored = mask->second.n_selected_components();
1185 for (
unsigned int component = 0; component <
n_stored;
1211 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
1212 AssertThrow(!triangulation_changed, ExcDoFHandlerChanged());
1216 typename std::vector<
1218 point = point_geometry_data.begin();
1219 for (; point != point_geometry_data.end(); ++point)
1221 for (
unsigned int component = 0;
1222 component < dof_handler->get_fe(0).n_components();
1225 dof_vector(point->solution_indices[component]) = 1;
1235 std::vector<std::vector<
Point<dim>>> &locations)
1238 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
1239 AssertThrow(!triangulation_changed, ExcDoFHandlerChanged());
1242 typename std::vector<
1244 point = point_geometry_data.begin();
1246 for (; point != point_geometry_data.end(); ++point)
1262 AssertThrow(have_dof_handler, ExcDoFHandlerRequired());
1264 locations = std::vector<Point<dim>>();
1269 unsigned int n_quadrature_points = quadrature.
size();
1270 std::vector<Point<dim>> evaluation_points;
1273 typename std::vector<
1275 point = point_geometry_data.begin();
1276 Assert(!dof_handler->get_triangulation().is_mixed_mesh(),
1278 const auto reference_cell =
1279 dof_handler->get_triangulation().get_reference_cells()[0];
1280 for (
unsigned int data_store_index = 0; point != point_geometry_data.end();
1285 Point<dim> requested_location = point->requested_location;
1292 fe_values.reinit(cell);
1294 evaluation_points = fe_values.get_quadrature_points();
1295 double distance = cell->diameter();
1300 if (requested_location.distance(evaluation_points[
q_point]) <
1305 requested_location.distance(evaluation_points[
q_point]);
1318 out <<
"***PointValueHistory status output***\n\n";
1319 out <<
"Closed: " << closed <<
'\n';
1320 out <<
"Cleared: " << cleared <<
'\n';
1321 out <<
"Triangulation_changed: " << triangulation_changed <<
'\n';
1322 out <<
"Have_dof_handler: " << have_dof_handler <<
'\n';
1323 out <<
"Geometric Data" <<
'\n';
1325 typename std::vector<
1327 point = point_geometry_data.begin();
1328 if (point == point_geometry_data.end())
1330 out <<
"No points stored currently\n";
1336 for (; point != point_geometry_data.end(); ++point)
1338 out <<
"# Requested location: " << point->requested_location
1340 out <<
"# DoF_index : Support location (for each component)\n";
1341 for (
unsigned int component = 0;
1342 component < dof_handler->get_fe(0).n_components();
1345 out << point->solution_indices[component] <<
" : "
1346 << point->support_point_locations[component] <<
'\n';
1353 out <<
"#Cannot access DoF_indices once cleared\n";
1358 if (independent_values.size() != 0)
1360 out <<
"Independent value(s): " << independent_values.size() <<
" : "
1361 << independent_values[0].size() <<
'\n';
1362 if (indep_names.size() > 0)
1374 out <<
"No independent values stored\n";
1377 if (data_store.begin() != data_store.end())
1380 <<
"Mnemonic: data set size (mask size, n true components) : n data sets\n";
1386 typename std::map<std::string, ComponentMask>::iterator mask =
1388 Assert(mask != component_mask.end(),
1390 typename std::map<std::string, std::vector<std::string>>
::iterator
1391 component_names = component_names_map.find(
vector_name);
1392 Assert(component_names != component_names_map.end(),
1398 out << mask->second.size() <<
", "
1399 << mask->second.n_selected_components() <<
") : ";
1405 out << mask->second.size() <<
", "
1406 << mask->second.n_selected_components() <<
") : ";
1407 out <<
"No points added" <<
'\n';
1410 if (component_names->second.size() > 0)
1412 for (
const auto &name : component_names->second)
1414 out <<
"<" << name <<
"> ";
1420 out <<
"***end of status output***\n\n";
1435 if (dataset_key.size() != independent_values[0].size())
1440 if (have_dof_handler)
1445 if ((
data_entry.second)[0].size() != dataset_key.size())
1459 if (
std::abs(
static_cast<int>(dataset_key.size()) -
1460 static_cast<int>(independent_values[0].size())) >= 2)
1466 if (have_dof_handler)
1473 static_cast<int>(dataset_key.size())) >= 2)
1502 triangulation_changed =
true;
1507#include "point_value_history.inst"
void reinit(value_type *starting_element, const std::size_t n_elements)
void add_field_name(const std::string &vector_name, const ComponentMask &component_mask=ComponentMask())
void evaluate_field_at_requested_location(const std::string &name, const VectorType &solution)
boost::signals2::connection tria_listener
void add_point(const Point< dim > &location)
PointValueHistory & operator=(const PointValueHistory &point_value_history)
void evaluate_field(const std::string &name, const VectorType &solution)
SmartPointer< const DoFHandler< dim >, PointValueHistory< dim > > dof_handler
Vector< double > mark_support_locations()
std::vector< std::string > indep_names
bool triangulation_changed
std::vector< double > dataset_key
void write_gnuplot(const std::string &base_name, const std::vector< Point< dim > > &postprocessor_locations=std::vector< Point< dim > >())
void status(std::ostream &out)
void add_independent_names(const std::vector< std::string > &independent_names)
PointValueHistory(const unsigned int n_independent_variables=0)
void get_support_locations(std::vector< std::vector< Point< dim > > > &locations)
void add_component_names(const std::string &vector_name, const std::vector< std::string > &component_names)
void start_new_dataset(const double key)
void add_points(const std::vector< Point< dim > > &locations)
std::vector< std::vector< double > > independent_values
void push_back_independent(const std::vector< double > &independent_values)
void get_postprocessor_locations(const Quadrature< dim > &quadrature, std::vector< Point< dim > > &locations)
void tria_change_listener()
bool deep_check(const bool strict)
PointGeometryData(const Point< dim > &new_requested_location, const std::vector< Point< dim > > &new_locations, const std::vector< types::global_dof_index > &new_sol_indices)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcInvalidState()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
typename ActiveSelector::active_cell_iterator active_cell_iterator
@ update_hessians
Second derivatives of shape functions.
@ update_values
Shape function values.
@ update_normal_vectors
Normal vectors.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)