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,
115 for (std::vector<std::string>::const_iterator name = names.begin();
119 for (
typename std::vector<DataVector>::const_iterator data_set =
123 for (
unsigned int i = 0; i < data_set->names.size(); ++i)
126 for (
typename std::vector<DataVector>::const_iterator data_set =
130 for (
unsigned int i = 0; i < data_set->names.size(); ++i)
149 template <
int dim,
int spacedim,
typename DoFHandlerType>
150 template <
typename number>
154 const std::string & name)
156 const unsigned int n_components =
dof_handler->get_fe(0).n_components();
158 std::vector<std::string>
names;
162 if ((n_components == 1) ||
165 names.resize(1, name);
171 names.resize(n_components);
172 for (
unsigned int i = 0; i < n_components; ++i)
174 std::ostringstream namebuf;
176 names[i] = name + namebuf.str();
184 template <
int dim,
int spacedim,
typename DoFHandlerType>
185 template <
typename number>
189 const std::vector<std::string> &
names)
196 (names.size() == 1)) ||
198 (names.size() ==
dof_handler->get_fe(0).n_components())),
200 names.size(),
dof_handler->get_fe(0).n_components()));
201 for (
unsigned int i = 0; i < names.size(); ++i)
202 Assert(names[i].find_first_not_of(
"abcdefghijklmnopqrstuvwxyz" 203 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 204 "0123456789_<>()") == std::string::npos,
207 names[i].find_first_not_of(
"abcdefghijklmnopqrstuvwxyz" 208 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 209 "0123456789_<>()")));
213 typename std::vector<DataVector>::iterator data_vector =
dof_data.begin();
214 for (; data_vector !=
dof_data.end(); ++data_vector)
215 if (data_vector->names == names)
217 data_vector->data.reinit(vec.
size());
218 std::copy(vec.
begin(), vec.
end(), data_vector->data.begin());
235 dof_handler->get_triangulation().n_active_cells()))
237 typename std::vector<DataVector>::iterator data_vector =
239 for (; data_vector !=
cell_data.end(); ++data_vector)
240 if (data_vector->names == names)
242 data_vector->data.reinit(vec.
size());
243 std::copy(vec.
begin(), vec.
end(), data_vector->data.begin());
256 template <
int dim,
int spacedim,
typename DoFHandlerType>
259 const unsigned int nnnn_subdivisions)
263 unsigned int n_subdivisions =
266 Assert(n_subdivisions >= 1,
274 const unsigned int n_components =
dof_handler->get_fe(0).n_components();
275 const unsigned int n_datasets =
281 unsigned int n_patches = 0;
282 for (
typename DoFHandlerType::active_cell_iterator cell =
312 const unsigned int n_q_points = patch_points.
size();
313 std::vector<double> patch_values(n_q_points);
314 std::vector<Vector<double>> patch_values_system(n_q_points,
324 default_patch.
data.
reinit(n_datasets, n_q_points * (n_subdivisions + 1));
329 typename std::vector<::DataOutBase::Patch<dim + 1, dim + 1>>::iterator
331 unsigned int cell_number = 0;
332 for (
typename DoFHandlerType::active_cell_iterator cell =
335 ++cell, ++patch, ++cell_number)
397 x_fe_patch_values.
reinit(cell);
402 for (
unsigned int dataset = 0; dataset <
dof_data.size(); ++dataset)
404 if (n_components == 1)
408 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
409 for (
unsigned int q = 0; q < n_q_points; ++q)
410 patch->data(dataset, q + n_q_points * i) =
417 patch_values_system);
418 for (
unsigned int component = 0; component < n_components;
420 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
421 for (
unsigned int q = 0; q < n_q_points; ++q)
422 patch->data(dataset * n_components + component,
423 q + n_q_points * i) =
424 patch_values_system[q](component);
429 for (
unsigned int dataset = 0; dataset <
cell_data.size(); ++dataset)
431 const double value =
cell_data[dataset].data(cell_number);
432 for (
unsigned int q = 0; q < n_q_points; ++q)
433 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
434 patch->data(dataset +
dof_data.size() * n_components,
435 q * (n_subdivisions + 1) + i) = value;
442 template <
int dim,
int spacedim,
typename DoFHandlerType>
448 for (
typename std::vector<DataVector>::iterator i =
dof_data.begin();
453 for (
typename std::vector<DataVector>::iterator i =
cell_data.begin();
461 template <
int dim,
int spacedim,
typename DoFHandlerType>
476 template <
int dim,
int spacedim,
typename DoFHandlerType>
477 const std::vector<::DataOutBase::Patch<dim + 1, dim + 1>> &
485 template <
int dim,
int spacedim,
typename DoFHandlerType>
486 std::vector<std::string>
489 std::vector<std::string>
names;
490 for (
typename std::vector<DataVector>::const_iterator dataset =
494 names.insert(names.end(), dataset->names.begin(), dataset->names.end());
495 for (
typename std::vector<DataVector>::const_iterator dataset =
499 names.insert(names.end(), dataset->names.begin(), dataset->names.end());
507 #include "data_out_stack.inst" 510 DEAL_II_NAMESPACE_CLOSE
static::ExceptionBase & ExcNameAlreadyUsed(std::string arg1)
void get_function_values(const InputVector &fe_function, std::vector< typename InputVector::value_type > &values) const
std::vector< DataVector > cell_data
static::ExceptionBase & ExcDataAlreadyAdded()
void attach_dof_handler(const DoFHandlerType &dof_handler)
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::vector< std::string > names
unsigned int size() const
std::size_t memory_consumption() const
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)
void build_patches(const unsigned int n_subdivisions=0)
std::vector<::DataOutBase::Patch< dim+1, dim+1 > > patches
static::ExceptionBase & ExcNotImplemented()
const ::FEValues< dim, spacedim > & get_present_fe_values() const
void finish_parameter_value()
void validate_dataset_names() const
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()
std::size_t memory_consumption() const