Usually the ConditionalOStream-variable is initialized in the constructor 
of the object, as for example in
template <int dim>
MinimalSurfaceProblem<dim>::MinimalSurfaceProblem (const char *file_name)
    :
      mpi_communicator(MPI_COMM_WORLD),
      triangulation(mpi_communicator,
                    typename Triangulation<dim>::MeshSmoothing(Triangulation
<dim>::smoothing_on_refinement | Triangulation<dim>::smoothing_on_coarsening
)),
      n_components(1),
      dof_handler (triangulation),
      fe (FE_Q<dim>(2), n_components * dim),
      pcout(std::cout, (Utilities::MPI::this_mpi_process(mpi_communicator) 
== 0)),

{
}

Now I would like to do that in a function of the class, instead of the 
constructor, so that I am able to write into a log file instead of using 
std::cout. I tried the following methods:
pcout = ConditionalOStream(std::cout, (Utilities::MPI::this_mpi_process(
mpi_communicator) == 0));
resulting in
error: use of deleted function ‘dealii::ConditionalOStream& dealii::
ConditionalOStream::operator=(dealii::ConditionalOStream&&)’
or
pcout = ConditionalOStream pcout_local(std::cout, (Utilities::MPI::
this_mpi_process(mpi_communicator) == 0));
resulting in
error: expected primary-expression before ‘pcout_local’
             pcout = ConditionalOStream pcout_local(std::cout, (Utilities::
MPI::this_mpi_process(mpi_communicator) == 0));
or
pcout = ConditionalOStream::ConditionalOStream(std::cout, (Utilities::MPI::
this_mpi_process(mpi_communicator) == 0));
resulting in 
error: cannot call constructor ‘dealii::ConditionalOStream::
ConditionalOStream’ directly [-fpermissive]
             pcout = ConditionalOStream::ConditionalOStream(std::cout, (
Utilities::MPI::this_mpi_process(mpi_communicator) == 0));

Is there another way I can use in order to replace std::cout with a custom 
stream (such as
std::ofstream file_out_stream;
file_out_stream.open(log_file_name, std::ios::out | std::ios::app);
pcout = ConditionalOStream::ConditionalOStream(file_out_stream, (Utilities::
MPI::this_mpi_process(mpi_communicator) == 0));
)?
Thank you!







-- 
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.

Reply via email to