39 namespace PointValueHistoryImplementation
46 const std::vector<types::global_dof_index> &new_sol_indices)
48 requested_location = new_requested_location;
49 support_point_locations = new_locations;
50 solution_indices = new_sol_indices;
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));
206 support_point_quadrature,
208 unsigned int n_support_points =
223 std::vector<unsigned int> current_fe_index(n_components,
225 fe_values.reinit(cell);
226 std::vector<Point<dim>> current_points(n_components,
Point<dim>());
227 for (
unsigned int support_point = 0; support_point < n_support_points;
232 unsigned int component =
234 current_points[component] = fe_values.quadrature_point(support_point);
235 current_fe_index[component] = support_point;
248 for (; cell != endc; cell++)
250 fe_values.reinit(cell);
252 for (
unsigned int support_point = 0; support_point < n_support_points;
258 Point<dim> test_point = fe_values.quadrature_point(support_point);
261 location.
distance(current_points[component]))
264 current_points[component] = test_point;
266 current_fe_index[component] = support_point;
272 std::vector<types::global_dof_index> local_dof_indices(
274 std::vector<types::global_dof_index> new_solution_indices;
275 current_cell->get_dof_indices(local_dof_indices);
295 for (
unsigned int component = 0;
299 new_solution_indices.push_back(
300 local_dof_indices[current_fe_index[component]]);
304 new_point_geometry_data(location, current_points, new_solution_indices);
313 data_entry.second.resize(data_entry.second.size() + n_stored);
347 support_point_quadrature,
349 unsigned int n_support_points =
366 std::vector<typename DoFHandler<dim>::active_cell_iterator> current_cell(
367 locations.size(), cell);
369 fe_values.reinit(cell);
370 std::vector<Point<dim>> temp_points(n_components,
Point<dim>());
371 std::vector<unsigned int> temp_fe_index(n_components, 0);
372 for (
unsigned int support_point = 0; support_point < n_support_points;
377 unsigned int component =
379 temp_points[component] = fe_values.quadrature_point(support_point);
380 temp_fe_index[component] = support_point;
382 std::vector<std::vector<Point<dim>>> current_points(
383 locations.size(), temp_points);
384 std::vector<std::vector<unsigned int>> current_fe_index(locations.size(),
396 for (; cell != endc; cell++)
398 fe_values.reinit(cell);
399 for (
unsigned int support_point = 0; support_point < n_support_points;
405 Point<dim> test_point = fe_values.quadrature_point(support_point);
409 if (locations[
point].distance(test_point) <
410 locations[
point].distance(current_points[
point][component]))
413 current_points[
point][component] = test_point;
414 current_cell[
point] = cell;
415 current_fe_index[
point][component] = support_point;
421 std::vector<types::global_dof_index> local_dof_indices(
425 current_cell[
point]->get_dof_indices(local_dof_indices);
426 std::vector<types::global_dof_index> new_solution_indices;
428 for (
unsigned int component = 0;
432 new_solution_indices.push_back(
433 local_dof_indices[current_fe_index[
point][component]]);
437 new_point_geometry_data(locations[
point],
438 current_points[point],
439 new_solution_indices);
449 data_entry.second.resize(data_entry.second.size() + n_stored);
473 std::make_pair(vector_name,
480 std::pair<std::string, std::vector<std::string>> empty_names(
481 vector_name, std::vector<std::string>());
486 std::pair<std::string, std::vector<std::vector<double>>> pair_data;
487 pair_data.first = vector_name;
488 const unsigned int n_stored =
495 std::vector<std::vector<double>> vector_size(n_datastreams,
496 std::vector<double>(0));
497 pair_data.second = vector_size;
507 std::vector<bool> temp_mask(n_components,
true);
515 const std::string & vector_name,
516 const std::vector<std::string> &component_names)
518 typename std::map<std::string, std::vector<std::string>>::iterator names =
523 typename std::map<std::string, ComponentMask>::iterator mask =
526 unsigned int n_stored = mask->second.n_selected_components();
528 Assert(component_names.size() == n_stored,
531 names->second = component_names;
538 const std::vector<std::string> &independent_names)
578 template <
typename VectorType>
602 typename std::map<std::string, std::vector<std::vector<double>>>::iterator
603 data_store_field =
data_store.find(vector_name);
607 typename std::map<std::string, ComponentMask>::iterator mask =
611 unsigned int n_stored =
614 typename std::vector<
618 ++
point, ++data_store_index)
625 for (
unsigned int store_index = 0, comp = 0;
629 if (mask->second[comp])
631 unsigned int solution_index = point->solution_indices[comp];
633 ->second[data_store_index * n_stored + store_index]
646 template <
typename VectorType>
649 const std::vector<std::string> &vector_names,
673 "The update of normal vectors may not be requested for evaluation of " 674 "data on cells via DataPostprocessor."));
677 unsigned int n_quadrature_points = quadrature.
size();
679 unsigned int n_output_variables = data_postprocessor.
get_names().size();
684 std::vector<typename VectorType::value_type> scalar_solution_values(
685 n_quadrature_points);
686 std::vector<Tensor<1, dim, typename VectorType::value_type>>
687 scalar_solution_gradients(n_quadrature_points);
688 std::vector<Tensor<2, dim, typename VectorType::value_type>>
689 scalar_solution_hessians(n_quadrature_points);
691 std::vector<Vector<typename VectorType::value_type>> vector_solution_values(
694 std::vector<std::vector<Tensor<1, dim, typename VectorType::value_type>>>
695 vector_solution_gradients(
700 std::vector<std::vector<Tensor<2, dim, typename VectorType::value_type>>>
701 vector_solution_hessians(
707 typename std::vector<
711 ++
point, ++data_store_index)
714 const Point<dim> requested_location = point->requested_location;
722 fe_values.reinit(cell);
723 std::vector<Vector<double>> computed_quantities(
728 fe_values.get_quadrature_points();
729 double distance = cell->diameter();
730 unsigned int selected_point = 0;
731 for (
unsigned int q_point = 0; q_point < n_quadrature_points; q_point++)
733 if (requested_location.
distance(quadrature_points[q_point]) <
736 selected_point = q_point;
738 requested_location.
distance(quadrature_points[q_point]);
744 if (n_components == 1)
760 fe_values.get_function_values(solution, scalar_solution_values);
762 std::vector<double>(1, scalar_solution_values[selected_point]);
766 fe_values.get_function_gradients(solution,
767 scalar_solution_gradients);
769 std::vector<Tensor<1, dim>>(
770 1, scalar_solution_gradients[selected_point]);
774 fe_values.get_function_hessians(solution,
775 scalar_solution_hessians);
777 std::vector<Tensor<2, dim>>(
778 1, scalar_solution_hessians[selected_point]);
783 std::vector<Point<dim>>(1, quadrature_points[selected_point]);
787 computed_quantities);
796 fe_values.get_function_values(solution, vector_solution_values);
800 vector_solution_values[selected_point].
end(),
805 fe_values.get_function_gradients(solution,
806 vector_solution_gradients);
810 vector_solution_gradients[selected_point].
end(),
815 fe_values.get_function_hessians(solution,
816 vector_solution_hessians);
820 vector_solution_hessians[selected_point].
end(),
825 std::vector<Point<dim>>(1, quadrature_points[selected_point]);
828 computed_quantities);
834 typename std::vector<std::string>::const_iterator name =
835 vector_names.begin();
836 for (; name != vector_names.end(); ++name)
838 typename std::map<std::string,
839 std::vector<std::vector<double>>>::iterator
844 typename std::map<std::string, ComponentMask>::iterator mask =
849 unsigned int n_stored =
850 mask->second.n_selected_components(n_output_variables);
854 for (
unsigned int store_index = 0, comp = 0;
855 comp < n_output_variables;
858 if (mask->second[comp])
861 ->second[data_store_index * n_stored + store_index]
862 .push_back(computed_quantities[0](comp));
873 template <
typename VectorType>
876 const std::string & vector_name,
881 std::vector<std::string> vector_names;
882 vector_names.push_back(vector_name);
883 evaluate_field(vector_names, solution, data_postprocessor, quadrature);
889 template <
typename VectorType>
892 const std::string &vector_name,
895 using number =
typename VectorType::value_type;
914 typename std::map<std::string, std::vector<std::vector<double>>>::iterator
915 data_store_field =
data_store.find(vector_name);
919 typename std::map<std::string, ComponentMask>::iterator mask =
923 unsigned int n_stored =
926 typename std::vector<
931 ++
point, ++data_store_index)
938 point->requested_location,
943 for (
unsigned int store_index = 0, comp = 0; comp < mask->second.size();
946 if (mask->second[comp])
949 ->second[data_store_index * n_stored + store_index]
950 .push_back(
value(comp));
976 const std::vector<double> &indep_values)
989 for (
unsigned int component = 0; component <
n_indep; component++)
998 const std::string & base_name,
999 const std::vector<
Point<dim>> &postprocessor_locations)
1008 std::string filename = base_name +
"_indep.gpl";
1009 std::ofstream to_gnuplot(filename.c_str());
1011 to_gnuplot <<
"# Data independent of mesh location\n";
1014 to_gnuplot <<
"# <Key> ";
1020 to_gnuplot <<
"<" << indep_name <<
"> ";
1026 for (
unsigned int component = 0; component <
n_indep; component++)
1028 to_gnuplot <<
"<Indep_" << component <<
"> ";
1033 for (
unsigned int key = 0; key <
dataset_key.size(); key++)
1037 for (
unsigned int component = 0; component <
n_indep; component++)
1053 AssertThrow(postprocessor_locations.size() == 0 ||
1054 postprocessor_locations.size() ==
1072 typename std::vector<internal::PointValueHistoryImplementation::
1073 PointGeometryData<dim>>::iterator
point =
1075 for (
unsigned int data_store_index = 0;
1077 ++
point, ++data_store_index)
1081 std::string filename = base_name +
"_" +
1088 std::ofstream to_gnuplot(filename.c_str());
1093 to_gnuplot <<
"# Requested location: " << point->requested_location
1095 to_gnuplot <<
"# DoF_index : Support location (for each component)\n";
1096 for (
unsigned int component = 0;
1100 to_gnuplot <<
"# " << point->solution_indices[component] <<
" : " 1101 << point->support_point_locations[component] <<
"\n";
1105 <<
"# (Original components and locations, may be invalidated by mesh change.)\n";
1107 if (postprocessor_locations.size() != 0)
1109 to_gnuplot <<
"# Postprocessor location: " 1110 << postprocessor_locations[data_store_index];
1112 to_gnuplot <<
" (may be approximate)\n";
1114 to_gnuplot <<
"#\n";
1118 to_gnuplot <<
"# <Key> ";
1124 to_gnuplot <<
"<" << indep_name <<
"> ";
1129 for (
unsigned int component = 0; component <
n_indep; component++)
1131 to_gnuplot <<
"<Indep_" << component <<
"> ";
1137 typename std::map<std::string, ComponentMask>::iterator mask =
1139 unsigned int n_stored = mask->second.n_selected_components();
1140 std::vector<std::string> names =
1143 if (names.size() > 0)
1147 for (
const auto &name : names)
1149 to_gnuplot <<
"<" << name <<
"> ";
1154 for (
unsigned int component = 0; component < n_stored;
1157 to_gnuplot <<
"<" << data_entry.first <<
"_" << component
1165 for (
unsigned int key = 0; key <
dataset_key.size(); key++)
1169 for (
unsigned int component = 0; component <
n_indep; component++)
1174 for (
const auto &data_entry : data_store)
1176 typename std::map<std::string, ComponentMask>::iterator mask =
1178 unsigned int n_stored = mask->second.n_selected_components();
1180 for (
unsigned int component = 0; component < n_stored;
1185 << (data_entry.second)[data_store_index * n_stored +
1211 typename std::vector<
1216 for (
unsigned int component = 0;
1220 dof_vector(point->solution_indices[component]) = 1;
1230 std::vector<std::vector<
Point<dim>>> &locations)
1236 std::vector<std::vector<Point<dim>>> actual_points;
1237 typename std::vector<
1243 actual_points.push_back(point->support_point_locations);
1245 locations = actual_points;
1252 std::vector<std::vector<
Point<dim>>> &locations)
1267 locations = std::vector<Point<dim>>();
1272 unsigned int n_quadrature_points = quadrature.
size();
1273 std::vector<Point<dim>> evaluation_points;
1276 typename std::vector<
1280 ++
point, ++data_store_index)
1284 Point<dim> requested_location = point->requested_location;
1290 fe_values.reinit(cell);
1292 evaluation_points = fe_values.get_quadrature_points();
1293 double distance = cell->diameter();
1294 unsigned int selected_point = 0;
1296 for (
unsigned int q_point = 0; q_point < n_quadrature_points; q_point++)
1298 if (requested_location.
distance(evaluation_points[q_point]) <
1301 selected_point = q_point;
1303 requested_location.
distance(evaluation_points[q_point]);
1307 locations.push_back(evaluation_points[selected_point]);
1316 out <<
"***PointValueHistory status output***\n\n";
1317 out <<
"Closed: " <<
closed <<
"\n";
1318 out <<
"Cleared: " <<
cleared <<
"\n";
1321 out <<
"Geometric Data" 1324 typename std::vector<
1329 out <<
"No points stored currently\n";
1337 out <<
"# Requested location: " << point->requested_location
1339 out <<
"# DoF_index : Support location (for each component)\n";
1340 for (
unsigned int component = 0;
1344 out << point->solution_indices[component] <<
" : " 1345 << point->support_point_locations[component] <<
"\n";
1352 out <<
"#Cannot access DoF_indices once cleared\n";
1366 out <<
"<" << indep_name <<
"> ";
1373 out <<
"No independent values stored\n";
1379 <<
"Mnemonic: data set size (mask size, n true components) : n data sets\n";
1384 std::string vector_name = data_entry.first;
1385 typename std::map<std::string, ComponentMask>::iterator mask =
1389 typename std::map<std::string, std::vector<std::string>>::iterator
1394 if (data_entry.second.size() != 0)
1396 out << data_entry.first <<
": " << data_entry.second.size() <<
" (";
1397 out << mask->second.size() <<
", " 1398 << mask->second.n_selected_components() <<
") : ";
1399 out << (data_entry.second)[0].size() <<
"\n";
1403 out << data_entry.first <<
": " << data_entry.second.size() <<
" (";
1404 out << mask->second.size() <<
", " 1405 << mask->second.n_selected_components() <<
") : ";
1406 out <<
"No points added" 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";
1445 if ((data_entry.second)[0].size() !=
dataset_key.size())
1459 if (std::abs(static_cast<int>(
dataset_key.size()) -
1472 if (std::abs(static_cast<int>((data_entry.second)[0].size()) -
1507 #include "point_value_history.inst"
std::vector< std::vector< double > > independent_values
const Triangulation< dim, spacedim > & get_triangulation() const
static ::ExceptionBase & ExcDataLostSync()
PointValueHistory(const unsigned int n_independent_variables=0)
std::vector< std::vector< Tensor< 2, spacedim > > > solution_hessians
std::vector< internal::PointValueHistoryImplementation::PointGeometryData< dim > > point_geometry_data
std::vector< double > solution_values
void get_support_locations(std::vector< std::vector< Point< dim >>> &locations)
cell_iterator end() const
void quadrature_points(const Triangulation< dim, spacedim > &triangulation, const Quadrature< dim > &quadrature, const std::vector< std::vector< BoundingBox< spacedim >>> &global_bounding_boxes, ParticleHandler< dim, spacedim > &particle_handler, const Mapping< dim, spacedim > &mapping=StaticMappingQ1< dim, spacedim >::mapping)
static ::ExceptionBase & ExcDoFHandlerChanged()
std::vector< double > dataset_key
bool represents_the_all_selected_mask() const
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
Transformed quadrature points.
#define AssertThrow(cond, exc)
std::vector< std::string > indep_names
SmartPointer< const DoFHandler< dim >, PointValueHistory< dim > > dof_handler
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
bool has_support_points() const
active_cell_iterator begin_active(const unsigned int level=0) const
static ::ExceptionBase & ExcNoIndependent()
void add_component_names(const std::string &vector_name, const std::vector< std::string > &component_names)
void add_field_name(const std::string &vector_name, const ComponentMask &component_mask=ComponentMask())
boost::signals2::connection tria_listener
static ::ExceptionBase & ExcInvalidState()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
std::vector< std::vector< Tensor< 1, spacedim > > > solution_gradients
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void evaluate_field_at_requested_location(const std::string &name, const VectorType &solution)
PointGeometryData(const Point< dim > &new_requested_location, const std::vector< Point< dim >> &new_locations, const std::vector< types::global_dof_index > &new_sol_indices)
Only a constructor needed for this class (a struct really)
void get_postprocessor_locations(const Quadrature< dim > &quadrature, std::vector< Point< dim >> &locations)
#define DEAL_II_NAMESPACE_CLOSE
std::map< std::string, std::vector< std::vector< double > > > data_store
void evaluate_field(const std::string &name, const VectorType &solution)
types::global_dof_index n_dofs() const
VectorType::value_type * end(VectorType &V)
void start_new_dataset(const double key)
PointValueHistory & operator=(const PointValueHistory &point_value_history)
std::vector< Tensor< 2, spacedim > > solution_hessians
Second derivatives of shape functions.
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
unsigned int size() const
const unsigned int dofs_per_cell
std::vector< Tensor< 1, spacedim > > solution_gradients
const std::vector< Point< dim > > & get_unit_support_points() const
void add_independent_names(const std::vector< std::string > &independent_names)
void tria_change_listener()
Vector< double > mark_support_locations()
bool deep_check(const bool strict)
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) const
std::vector< Point< spacedim > > evaluation_points
unsigned int n_components() const
bool triangulation_changed
#define DEAL_II_NAMESPACE_OPEN
VectorType::value_type * begin(VectorType &V)
std::map< std::string, ComponentMask > component_mask
Shape function gradients.
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
void write_gnuplot(const std::string &base_name, const std::vector< Point< dim >> &postprocessor_locations=std::vector< Point< dim >>())
void get_points(std::vector< std::vector< Point< dim >>> &locations)
unsigned int n_selected_components(const unsigned int overall_number_of_components=numbers::invalid_unsigned_int) const
void status(std::ostream &out)
static ::ExceptionBase & ExcNotImplemented()
void add_point(const Point< dim > &location)
std::map< std::string, std::vector< std::string > > component_names_map
void add_points(const std::vector< Point< dim >> &locations)
void copy(const T *begin, const T *end, U *dest)
virtual std::vector< std::string > get_names() const =0
static ::ExceptionBase & ExcDoFHandlerRequired()
std::vector<::Vector< double > > solution_values
static ::ExceptionBase & ExcInternalError()
virtual UpdateFlags get_needed_update_flags() const =0
void push_back_independent(const std::vector< double > &independent_values)