16 #include <deal.II/numerics/data_out_stack.h> 17 #include <deal.II/base/quadrature_lib.h> 18 #include <deal.II/base/memory_consumption.h> 19 #include <deal.II/lac/vector.h> 20 #include <deal.II/lac/block_vector.h> 21 #include <deal.II/dofs/dof_handler.h> 22 #include <deal.II/dofs/dof_accessor.h> 23 #include <deal.II/grid/tria_iterator.h> 24 #include <deal.II/fe/fe.h> 25 #include <deal.II/fe/fe_values.h> 26 #include <deal.II/hp/fe_values.h> 27 #include <deal.II/fe/mapping_q1.h> 31 DEAL_II_NAMESPACE_OPEN
34 template <
int dim,
int spacedim,
typename DoFHandlerType>
44 template <
int dim,
int spacedim,
typename DoFHandlerType>
49 template <
int dim,
int spacedim,
typename DoFHandlerType>
60 for (
typename std::vector<DataVector>::const_iterator i=
dof_data.begin();
62 Assert (i->data.size() == 0,
63 ExcDataNotCleared ());
64 for (
typename std::vector<DataVector>::const_iterator i=
cell_data.begin();
66 Assert (i->data.size() == 0,
67 ExcDataNotCleared ());
72 template <
int dim,
int spacedim,
typename DoFHandlerType>
77 Assert (dim==DoFHandlerType::dimension, ExcDimensionMismatch(dim, DoFHandlerType::dimension));
83 template <
int dim,
int spacedim,
typename DoFHandlerType>
87 std::vector<std::string>
names;
88 names.push_back (name);
93 template <
int dim,
int spacedim,
typename DoFHandlerType>
105 for (std::vector<std::string>::const_iterator name=names.begin(); name!=names.end(); ++name)
107 for (
typename std::vector<DataVector>::const_iterator data_set=
dof_data.begin();
108 data_set!=
dof_data.end(); ++data_set)
109 for (
unsigned int i=0; i<data_set->names.size(); ++i)
110 Assert (*name != data_set->names[i], ExcNameAlreadyUsed(*name));
112 for (
typename std::vector<DataVector>::const_iterator data_set=
cell_data.begin();
114 for (
unsigned int i=0; i<data_set->names.size(); ++i)
115 Assert (*name != data_set->names[i], ExcNameAlreadyUsed(*name));
133 template <
int dim,
int spacedim,
typename DoFHandlerType>
134 template <
typename number>
136 const std::string &name)
138 const unsigned int n_components =
dof_handler->get_fe().n_components ();
140 std::vector<std::string>
names;
144 if ((n_components == 1) ||
147 names.resize (1, name);
153 names.resize (n_components);
154 for (
unsigned int i=0; i<n_components; ++i)
156 std::ostringstream namebuf;
158 names[i] = name + namebuf.str();
166 template <
int dim,
int spacedim,
typename DoFHandlerType>
167 template <
typename number>
169 const std::vector<std::string> &
names)
172 Exceptions::DataOut::ExcNoDoFHandlerSelected ());
179 (names.size() ==
dof_handler->get_fe().n_components())),
180 Exceptions::DataOut::ExcInvalidNumberOfNames (names.size(),
182 for (
unsigned int i=0; i<names.size(); ++i)
183 Assert (names[i].find_first_not_of(
"abcdefghijklmnopqrstuvwxyz" 184 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 185 "0123456789_<>()") == std::string::npos,
186 Exceptions::DataOut::ExcInvalidCharacter (names[i],
187 names[i].find_first_not_of(
"abcdefghijklmnopqrstuvwxyz" 188 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 189 "0123456789_<>()")));
193 typename std::vector<DataVector>::iterator data_vector=
dof_data.begin();
194 for (; data_vector!=
dof_data.end(); ++data_vector)
195 if (data_vector->names == names)
197 data_vector->data.reinit (vec.
size());
199 data_vector->data.begin());
209 Assert (
false, ExcVectorNotDeclared (names[0]));
216 typename std::vector<DataVector>::iterator data_vector=
cell_data.begin();
217 for (; data_vector!=
cell_data.end(); ++data_vector)
218 if (data_vector->names == names)
220 data_vector->data.reinit (vec.
size());
222 data_vector->data.begin());
225 Assert (
false, ExcVectorNotDeclared (names[0]));
231 Assert (
false, ExcInternalError());
235 template <
int dim,
int spacedim,
typename DoFHandlerType>
240 unsigned int n_subdivisions = (nnnn_subdivisions != 0)
244 Assert (n_subdivisions >= 1,
245 Exceptions::DataOut::ExcInvalidNumberOfSubdivisions(n_subdivisions));
247 Exceptions::DataOut::ExcNoDoFHandlerSelected());
249 const unsigned int n_components =
dof_handler->get_fe().n_components();
250 const unsigned int n_datasets =
dof_data.size() * n_components +
256 unsigned int n_patches = 0;
257 for (
typename DoFHandlerType::active_cell_iterator
285 const unsigned int n_q_points = patch_points.
size();
286 std::vector<double> patch_values (n_q_points);
287 std::vector<Vector<double> > patch_values_system (n_q_points,
297 default_patch.
data.
reinit (n_datasets, n_q_points*(n_subdivisions+1));
302 typename std::vector< ::DataOutBase::Patch<dim+1,dim+1> >::iterator
304 unsigned int cell_number = 0;
305 for (
typename DoFHandlerType::active_cell_iterator cell=
dof_handler->begin_active();
306 cell !=
dof_handler->end(); ++cell, ++patch, ++cell_number)
308 Assert (cell->is_locally_owned(),
309 ExcNotImplemented());
363 Assert (
false, ExcNotImplemented());
375 x_fe_patch_values.reinit (cell);
377 = x_fe_patch_values.get_present_fe_values ();
380 for (
unsigned int dataset=0; dataset<
dof_data.size(); ++dataset)
382 if (n_components == 1)
386 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
387 for (
unsigned int q=0; q<n_q_points; ++q)
388 patch->data(dataset,q+n_q_points*i) = patch_values[q];
394 patch_values_system);
395 for (
unsigned int component=0; component<n_components; ++component)
396 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
397 for (
unsigned int q=0; q<n_q_points; ++q)
398 patch->data(dataset*n_components+component,
400 = patch_values_system[q](component);
405 for (
unsigned int dataset=0; dataset<
cell_data.size(); ++dataset)
407 const double value =
cell_data[dataset].data(cell_number);
408 for (
unsigned int q=0; q<n_q_points; ++q)
409 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
410 patch->data(dataset+
dof_data.size()*n_components,
411 q*(n_subdivisions+1)+i) = value;
418 template <
int dim,
int spacedim,
typename DoFHandlerType>
423 for (
typename std::vector<DataVector>::iterator i=
dof_data.begin();
427 for (
typename std::vector<DataVector>::iterator i=
cell_data.begin();
434 template <
int dim,
int spacedim,
typename DoFHandlerType>
449 template <
int dim,
int spacedim,
typename DoFHandlerType>
450 const std::vector< ::DataOutBase::Patch<dim+1,dim+1> > &
458 template <
int dim,
int spacedim,
typename DoFHandlerType>
461 std::vector<std::string>
names;
462 for (
typename std::vector<DataVector>::const_iterator dataset=
dof_data.begin();
464 names.insert (names.end(), dataset->names.begin(), dataset->names.end());
465 for (
typename std::vector<DataVector>::const_iterator dataset=
cell_data.begin();
467 names.insert (names.end(), dataset->names.begin(), dataset->names.end());
475 #include "data_out_stack.inst" 478 DEAL_II_NAMESPACE_CLOSE
std::vector< ::DataOutBase::Patch< dim+1, dim+1 > > patches
std::size_t memory_consumption() const
SmartPointer< const DoFHandlerType, DataOutStack< dim, spacedim, DoFHandlerType > > dof_handler
std::vector< DataVector > cell_data
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
std::size_t memory_consumption() const
std::vector< std::string > names
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)
unsigned int n_subdivisions
unsigned int size() const
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
virtual std::vector< std::string > get_dataset_names() const
void build_patches(const unsigned int n_subdivisions=0)
virtual const std::vector< ::DataOutBase::Patch< dim+1, dim+1 > > & get_patches() const
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)