16 #include <deal.II/base/memory_consumption.h> 17 #include <deal.II/base/quadrature_lib.h> 19 #include <deal.II/dofs/dof_accessor.h> 20 #include <deal.II/dofs/dof_handler.h> 22 #include <deal.II/fe/fe.h> 23 #include <deal.II/fe/fe_values.h> 24 #include <deal.II/fe/mapping_q1.h> 26 #include <deal.II/grid/tria_iterator.h> 28 #include <deal.II/hp/fe_values.h> 30 #include <deal.II/lac/block_vector.h> 31 #include <deal.II/lac/vector.h> 33 #include <deal.II/numerics/data_out_stack.h> 37 DEAL_II_NAMESPACE_OPEN
40 template <
int dim,
int spacedim,
typename DoFHandlerType>
51 template <
int dim,
int spacedim,
typename DoFHandlerType>
64 for (
typename std::vector<DataVector>::const_iterator i =
dof_data.begin();
68 for (
typename std::vector<DataVector>::const_iterator i =
cell_data.begin();
75 template <
int dim,
int spacedim,
typename DoFHandlerType>
78 const DoFHandlerType &dof)
82 Assert(dim == DoFHandlerType::dimension,
89 template <
int dim,
int spacedim,
typename DoFHandlerType>
92 const std::string &name,
95 std::vector<std::string> names;
96 names.push_back(name);
101 template <
int dim,
int spacedim,
typename DoFHandlerType>
104 const std::vector<std::string> &names,
116 for (
const auto &name : names)
118 for (
const auto &data_set :
dof_data)
119 for (
const auto &data_set_name : data_set.names)
123 for (
const auto &data_set_name : data_set.names)
143 template <
int dim,
int spacedim,
typename DoFHandlerType>
144 template <
typename number>
148 const std::string & name)
150 const unsigned int n_components =
dof_handler->get_fe(0).n_components();
152 std::vector<std::string> names;
156 if ((n_components == 1) ||
159 names.resize(1, name);
165 names.resize(n_components);
166 for (
unsigned int i = 0; i < n_components; ++i)
168 std::ostringstream namebuf;
170 names[i] = name + namebuf.str();
178 template <
int dim,
int spacedim,
typename DoFHandlerType>
179 template <
typename number>
183 const std::vector<std::string> &names)
190 (names.size() == 1)) ||
192 (names.size() ==
dof_handler->get_fe(0).n_components())),
194 names.size(),
dof_handler->get_fe(0).n_components()));
195 for (
const auto &name : names)
198 Assert(name.find_first_not_of(
"abcdefghijklmnopqrstuvwxyz" 199 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 200 "0123456789_<>()") == std::string::npos,
203 name.find_first_not_of(
"abcdefghijklmnopqrstuvwxyz" 204 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 205 "0123456789_<>()")));
210 typename std::vector<DataVector>::iterator data_vector =
dof_data.begin();
211 for (; data_vector !=
dof_data.end(); ++data_vector)
212 if (data_vector->names == names)
214 data_vector->data.reinit(vec.
size());
215 std::copy(vec.
begin(), vec.
end(), data_vector->data.begin());
232 dof_handler->get_triangulation().n_active_cells()))
234 typename std::vector<DataVector>::iterator data_vector =
236 for (; data_vector !=
cell_data.end(); ++data_vector)
237 if (data_vector->names == names)
239 data_vector->data.reinit(vec.
size());
240 std::copy(vec.
begin(), vec.
end(), data_vector->data.begin());
253 template <
int dim,
int spacedim,
typename DoFHandlerType>
256 const unsigned int nnnn_subdivisions)
260 unsigned int n_subdivisions =
263 Assert(n_subdivisions >= 1,
271 const unsigned int n_components =
dof_handler->get_fe(0).n_components();
272 const unsigned int n_datasets =
278 unsigned int n_patches = 0;
279 for (
typename DoFHandlerType::active_cell_iterator cell =
309 const unsigned int n_q_points = patch_points.
size();
310 std::vector<double> patch_values(n_q_points);
311 std::vector<Vector<double>> patch_values_system(n_q_points,
321 default_patch.
data.
reinit(n_datasets, n_q_points * (n_subdivisions + 1));
326 typename std::vector<::DataOutBase::Patch<dim + 1, dim + 1>>::iterator
328 unsigned int cell_number = 0;
329 for (
typename DoFHandlerType::active_cell_iterator cell =
332 ++cell, ++patch, ++cell_number)
394 x_fe_patch_values.
reinit(cell);
396 x_fe_patch_values.get_present_fe_values();
399 for (
unsigned int dataset = 0; dataset <
dof_data.size(); ++dataset)
401 if (n_components == 1)
405 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
406 for (
unsigned int q = 0; q < n_q_points; ++q)
407 patch->data(dataset, q + n_q_points * i) =
414 patch_values_system);
415 for (
unsigned int component = 0; component < n_components;
417 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
418 for (
unsigned int q = 0; q < n_q_points; ++q)
419 patch->data(dataset * n_components + component,
420 q + n_q_points * i) =
421 patch_values_system[q](component);
426 for (
unsigned int dataset = 0; dataset <
cell_data.size(); ++dataset)
428 const double value =
cell_data[dataset].data(cell_number);
429 for (
unsigned int q = 0; q < n_q_points; ++q)
430 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
431 patch->data(dataset +
dof_data.size() * n_components,
432 q * (n_subdivisions + 1) + i) = value;
439 template <
int dim,
int spacedim,
typename DoFHandlerType>
445 for (
typename std::vector<DataVector>::iterator i =
dof_data.begin();
450 for (
typename std::vector<DataVector>::iterator i =
cell_data.begin();
458 template <
int dim,
int spacedim,
typename DoFHandlerType>
473 template <
int dim,
int spacedim,
typename DoFHandlerType>
474 const std::vector<::DataOutBase::Patch<dim + 1, dim + 1>> &
482 template <
int dim,
int spacedim,
typename DoFHandlerType>
483 std::vector<std::string>
486 std::vector<std::string> names;
487 for (
typename std::vector<DataVector>::const_iterator dataset =
491 names.insert(names.end(), dataset->names.begin(), dataset->names.end());
492 for (
typename std::vector<DataVector>::const_iterator dataset =
496 names.insert(names.end(), dataset->names.begin(), dataset->names.end());
504 #include "data_out_stack.inst" 507 DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNameAlreadyUsed(std::string arg1)
std::size_t memory_consumption() const
std::vector< DataVector > cell_data
static ::ExceptionBase & ExcDataAlreadyAdded()
void attach_dof_handler(const DoFHandlerType &dof_handler)
void get_function_values(const InputVector &fe_function, std::vector< typename InputVector::value_type > &values) const
std::vector< DataVector > dof_data
unsigned int default_subdivisions
static ::ExceptionBase & ExcInvalidNumberOfSubdivisions(int arg1)
virtual std::vector< std::string > get_dataset_names() const override
static ::ExceptionBase & ExcDataNotCleared()
SmartPointer< const DoFHandlerType, DataOutStack< dim, spacedim, DoFHandlerType > > dof_handler
std::size_t memory_consumption() const
std::vector< std::string > names
static ::ExceptionBase & ExcNoDoFHandlerSelected()
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
void declare_data_vector(const std::string &name, const VectorType vector_type)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcInvalidNumberOfNames(int arg1, int arg2)
virtual const std::vector<::DataOutBase::Patch< dim+1, dim+1 > > & get_patches() const override
static ::ExceptionBase & ExcInvalidCharacter(std::string arg1, size_t arg2)
unsigned int n_subdivisions
void reinit(const TriaIterator< DoFCellAccessor< DoFHandlerType, lda >> cell, const unsigned int q_index=numbers::invalid_unsigned_int, const unsigned int mapping_index=numbers::invalid_unsigned_int, const unsigned int fe_index=numbers::invalid_unsigned_int)
static ::ExceptionBase & ExcVectorNotDeclared(std::string arg1)
unsigned int size() const
void build_patches(const unsigned int n_subdivisions=0)
std::vector<::DataOutBase::Patch< dim+1, dim+1 > > patches
void validate_dataset_names() const
static ::ExceptionBase & ExcNotImplemented()
void finish_parameter_value()
void new_parameter_value(const double parameter_value, const double parameter_step)
void add_data_vector(const Vector< number > &vec, const std::string &name)
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static ::ExceptionBase & ExcInternalError()