Hello Jean-Paul, It works, thank you very much for you help. Jiaqi
在 2016年7月17日星期日 UTC-4上午6:03:37,Jean-Paul Pelteret写道: > > Dear Jiaqui, > > The issue here is that when you choose a piece-wise constant ansatz you > end up with exactly the same number of DoFs as there are cells. > deal.II usually treats the output of scalar cell data (e.g. if you were to > output the material ID of each cell) in a special way, so you just need to > specify that it should interpret this data vector as DoF data. > To do this, you simply add the data type enumeration > <https://dealii.org/8.4.0/doxygen/deal.II/group__output.html#ga062005bfe37e877e1f44e1c3e8e6cb27> > > as an argument to the add_data_vector function call. > > data_out.add_data_vector > <https://dealii.org/8.4.0/doxygen/deal.II/classDataOut__DoFData.html#ace4b76e565ba0701c4d32c26075ed3b9> > (solution, "u", > DataOut<dim>::type_dof_data > <https://dealii.org/8.4.0/doxygen/deal.II/classDataOut.html>); > > I hope that this solves your problem! > J-P > > On Saturday, July 16, 2016 at 6:04:39 PM UTC+2, Jiaqi Zhang wrote: >> >> Hey all, >> >> I am trying to solve a level set equation with DG. When I use degree=1, >> everything is ok, but when I change it to degree=0, it cannot output the >> results, and says: >> >> An error occurred in line <957> of file >> </home/seven/Documents/dealii-8.4.1/source/numerics/data_out_dof_data.cc> >> in function >> void dealii::DataOut_DoFData<DoFHandlerType, patch_dim, >> patch_space_dim>::add_data_vector(const VectorType&, const >> std::vector<std::basic_string<char> >&, >> dealii::DataOut_DoFData<DoFHandlerType, patch_dim, >> patch_space_dim>::DataVectorType, const >> std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation>&) >> >> [with VectorType = dealii::Vector<double>; DoFHandlerType = >> dealii::DoFHandler<2>; int patch_dim = 2; int patch_space_dim = 2] >> The violated condition was: >> (dofs == 0) || (triangulation->n_active_cells() != dofs->n_dofs()) >> The name and call sequence of the exception was: >> ExcMessage("Unable to determine the type of vector automatically >> because the number of DoFs " "is equal to the number of cells. Please >> specify DataVectorType.") >> Additional Information: >> Unable to determine the type of vector automatically because the number >> of DoFs is equal to the number of cells. Please specify DataVectorType. >> >> And the following is my code: >> DataOut<dim> data_out; >> data_out.attach_dof_handler (dof_handler); >> data_out.add_data_vector (solution, "u"); >> data_out.build_patches (); >> std::ostringstream filename; >> filename << "sol -" << timestep_number<<".vtk"; >> std::ofstream output (filename.str().c_str()); >> data_out.write_vtk (output); >> >> What can I do to solve this problem? >> >> Thanks, >> Jiaqi >> >> >> -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.