Uclus,
the usual style is to create the DataOut object every time you are writing
into a file, and then let the variable die at the end of the scope again,
rather than keeping it around for the next time you want to create output. You
might want to take a look at how time dependent programs do this, say step-26.
Of course, in that case you will want to write to a different file in each
iteration. Right now, your code snippet suggests that you don't actually ever
write into the f_output stream.
For your particular error, I don't know whether that is going to solve the
problem. It may be that you have no cells on a particular MPI process and that
that is what the error indicates -- that would be a bug. But I would first try
to address the issue mentioned above.
Best
W.
On 2/16/22 03:07, Uclus Heis wrote:
> *** Caution: EXTERNAL Sender ***
>
> Dear Timo,
>
> Thank you for the comments.
>
> I am doing now one file per iteration. However, when running with mpirun more
> tha 1 MPI ranks I get an error in the writing function.
> My code right now looks :
>
> DataOut<dim> data_out;
> data_out.attach_dof_handler(dof_handler);
> for(int freq_iter=0 ... ) ///solver loop, /
> {
> ... ///computes the solution per frequency/
> string nname = "rb";
> string nit = to_string(freq_iter);
> string fitame =nname+nit;
>
> string f_output("./solution-" + std::to_string(freq_iter) + ".h5");
> data_out.add_data_vector(locally_relevant_solution, fitame);
>
> data_out.build_patches();
> DataOutBase::DataOutFilterFlags flags(true, true);
> DataOutBase::DataOutFilter data_filter(flags);
> data_out.write_filtered_data(data_filter);
> data_out.write_hdf5_parallel(data_filter, "solution.h5", MPI_COMM_WORLD);
> }
>
> The error is the following:
>
> /An error occurred in line <7811> of file
> </zhome/32/9/115503/dealii-candi/tmp/unpack/deal.II-v9.3.1/source/base/data_out_base.cc>
> in function/
>
> /void dealii::DataOutBase::write_hdf5_parallel(const
> std::vector<dealii::DataOutBase::Patch<dim, spacedim> >&, const
> dealii::DataOutBase::DataOutFilter&, bool, const string&, const string&,
> ompi_communicator_t* const&) [with int dim = 2; int spacedim = 2; std::string
> = std::__cxx11::basic_string<char>; MPI_Comm = ompi_communicator_t*]/
>
> /The violated condition was: /
>
> /patches.size() > 0/
>
> /Additional information: /
>
> /You are trying to write graphical data into a file, but no data is available
> in the intermediate format that the DataOutBase functions require. /
>
> /Did you forget to call a function such as DataOut::build_patches()?/
> for(int freq_iter=0 ... ) ///solver loop, /
> {
> ... ///computes the solution per frequency/
> string nname = "rb";
> string nit = to_string(freq_iter);
> string fitame =nname+nit;
> data_out.add_data_vector(locally_relevant_solution, fitame);
> }
> data_out.build_patches();
> DataOutBase::DataOutFilterFlags flags(true, true);
> DataOutBase::DataOutFilter data_filter(flags);
> data_out.write_filtered_data(data_filter);
> data_out.write_hdf5_parallel(data_filter, "solution.h5",
> MPI_COMM_WORLD);
>
>
> Thank you for you time.
>
> --
> The deal.II project is located at
http://www.dealii.org/
> <
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709788029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=41v0VEMkBpUsm2%2F7LxuDHYSMjiAJwPV6lrdV5I004sY%3D&reserved=0>
> <
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709788029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=KaISQ9K%2B52cwOtJweK%2FSYkw7%2FDH2m7IxQFQw%2BM8UX%2FY%3D&reserved=0>
> <
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2F540023f3-2531-4d00-97dc-8d24c3e9219en%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709788029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=foKjVcsp103Vf3JBf%2FxpnAzrrtSg5xa7qy5jQusG%2Bz8%3D&reserved=0>.
> <
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709944242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=r%2F%2FWgc6fxp5tBxb1hy%2BvbcJw4oKVAqTsx3J%2B4iOA5Qg%3D&reserved=0>
> <
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709944242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=OmmdWhqbJmmPzpKaSpOyITjOaJkZxLJ4V0KgGkkEcgU%3D&reserved=0>
> ---
> 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+un...@googlegroups.com.
>
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/dealii/252db675-766c-476d-b7d6-758d2c403f39n%40googlegroups.com
> <
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2F252db675-766c-476d-b7d6-758d2c403f39n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709944242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=xGTClKk%2F%2FiEKqvR6yp6ZXU4eM5kP74yxJXU04x0HZO4%3D&reserved=0>.
> <
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709944242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=r%2F%2FWgc6fxp5tBxb1hy%2BvbcJw4oKVAqTsx3J%2B4iOA5Qg%3D&reserved=0>
> <
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709944242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=OmmdWhqbJmmPzpKaSpOyITjOaJkZxLJ4V0KgGkkEcgU%3D&reserved=0>
> ---
> 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+un...@googlegroups.com
> <mailto:
dealii+un...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/dealii/600b490f-2f1d-4003-8819-ecc302db3d56n%40googlegroups.com
> <
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2F600b490f-2f1d-4003-8819-ecc302db3d56n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca1494995e20447207baf08d9f13435ef%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637806029709944242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=YplACYBIRARQRt17Kj5LypVt315yQpPyjgPiv1Qvxfw%3D&reserved=0>.
--
------------------------------------------------------------------------
Wolfgang Bangerth email:
bang...@colostate.edu
www:
http://www.math.colostate.edu/~bangerth/