Paras, > In order to write the post-processed stresses contained partially in several > vectors, to a single file, the class DataOutMaterialWise has been derived > from > DataOut. Furthermore, for visualizing the stresses on the deformed contour, > dealii::MappingQEulerian based on the displacement vector is employed. > Referring to the attached MWE and the three material example mesh file, the > code works fine for /fePolyDegree= 1, i.e. /if first order Lagrange finite > elements are used for the primary problem. However, the code throws an error > when the /merge_patches()/ function is called if higher order elements are > employed.
I haven't gotten around to debugging the underlying problem (it looks like a bug in deal.II to me), but I managed to get it down to around 50 lines of code (see attached). I hope to get around to debugging the actual problem in the next few days. (If you look at the minimal example I attach, you'll see that you will really like the DataOut::set_cell_selection() function that was recently introduced. It will make the DataOutMaterialWise class unnecessary.) Best W. -- ------------------------------------------------------------------------ Wolfgang Bangerth email: bange...@colostate.edu www: http://www.math.colostate.edu/~bangerth/ -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/c0962767-d42b-d309-e10d-a82b8a76d190%40colostate.edu.
#include <deal.II/grid/tria.h> #include <deal.II/grid/grid_in.h> #include <deal.II/grid/grid_out.h> #include <deal.II/dofs/dof_handler.h> #include <deal.II/dofs/dof_accessor.h> #include <deal.II/fe/fe_q.h> #include <deal.II/numerics/data_out.h> #include <iostream> #include <fstream> using namespace dealii; int main() { const unsigned int dim = 2; const std::string inputFile = "mesh-RVE-3Mats.inp"; Triangulation<dim> triangulation_(Triangulation<dim>::maximum_smoothing); GridIn<dim> gridIn; gridIn.attach_triangulation(triangulation_); std::ifstream gridInputStream(inputFile); gridIn.read(gridInputStream, GridIn<dim>::abaqus); FE_Q<dim> ppFE_(1); DoFHandler<dim> ppDoFHandler_(triangulation_); ppDoFHandler_.distribute_dofs(ppFE_); Vector<double> materialIDs_(ppDoFHandler_.get_triangulation().n_active_cells()); const std::string fileNameBase = "mwe-stresses"; const DataOutBase::OutputFormat dataOutputFormat = DataOutBase::vtk; MappingQ1<dim> qMapping; DataOut<dim> dataOutPrimary, dataOutSecondary; dataOutPrimary.attach_dof_handler(ppDoFHandler_); dataOutSecondary.attach_dof_handler(ppDoFHandler_); dataOutPrimary.set_cell_selection([](const typename Triangulation<dim>::cell_iterator &cell) { return (cell->is_active() && cell->material_id() == 1); }); dataOutSecondary.set_cell_selection([](const typename Triangulation<dim>::cell_iterator &cell) { return (cell->is_active() && cell->material_id() == 2); }); { // first add the material-ID data dataOutPrimary.add_data_vector(materialIDs_, "abc"); dataOutPrimary.build_patches(qMapping, 2); } { // first add the material-ID data dataOutSecondary.add_data_vector(materialIDs_, "abc"); dataOutSecondary.build_patches(qMapping, 2); } // error here: dataOutPrimary.merge_patches(dataOutSecondary); // now write to file std::ofstream dataOutStream( fileNameBase + DataOutBase::default_suffix(dataOutputFormat)); dataOutPrimary.write(dataOutStream, dataOutputFormat); }