Re: [deal.II] No printing of TimerOutput after catch of exception in MPI based code

2022-05-09 Thread Daniel Arndt
Maurice,

You could try to wrap the calls that might throw in a try-catch block to
deal with the exception yourself (including ignoring it).

Best,
Daniel

On Mon, May 9, 2022 at 11:14 AM 'maurice rohracker' via deal.II User Group <
dealii@googlegroups.com> wrote:

> Dear all,
>
> In the attached mwe we are facing the issue, that the TimerOutput object
> does not print the resulting table to the screen when an exception is
> thrown and caught within in a MPI based code.
>
> We are aware that some collective routine might be needed.
>
> However, is there a way which can handle this easily, such that
> TimerOutput object prints the resulting table to the screen even if an
> exception is thrown or are we missing something?
>
> We were already able to do so in the serial case.
>
> Thanks in advance.
>
> Best regards,
> Maurice
>
> --
> 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/c68d2663-d1a7-4670-a632-9a51abae3d6fn%40googlegroups.com
> 
> .
>

-- 
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/CAOYDWbLFN1GpwKoBuiVVDL6s6YbEmC92wTXLpiwvWeKLFAPLyw%40mail.gmail.com.


[deal.II] No printing of TimerOutput after catch of exception in MPI based code

2022-05-09 Thread 'maurice rohracker' via deal.II User Group
Dear all,

In the attached mwe we are facing the issue, that the TimerOutput object 
does not print the resulting table to the screen when an exception is 
thrown and caught within in a MPI based code.

We are aware that some collective routine might be needed.

However, is there a way which can handle this easily, such that TimerOutput 
object prints the resulting table to the screen even if an exception is 
thrown or are we missing something?

We were already able to do so in the serial case.

Thanks in advance.

Best regards,
Maurice

-- 
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/c68d2663-d1a7-4670-a632-9a51abae3d6fn%40googlegroups.com.
#include 
#include 
#include 
#include 
#include 

using UnsignedIntType = unsigned int;


class MyException : public dealii::ExceptionBase
{
public:
		MyException(const std::string &failureLocation)
		: failureLoc_(failureLocation)
		{
		if ((failureLoc_ != "pf") && (failureLoc_ != "disp") &&
		  (failureLoc_ != "outer"))
		Assert(false, dealii::ExcMessage("Invalid failure location string!"));
		}

		virtual ~MyException() noexcept = default;

		virtual void
		print_info(std::ostream &outStream) const
		{
			if (failureLoc_ == "pf")
			outStream << "Non convergence in the pf loop" << std::endl;
			else if (failureLoc_ == "disp")
			outStream << "Non convergence in the disp loop" << std::endl;
			else if (failureLoc_ == "outer")
			outStream << "Non convergence in the outer loop" << std::endl;
		}

std::string failureLoc_;
};

void Solve_timeStep(dealii::ConditionalOStream &outStream)
{
	static UnsignedIntType timeStepCtr = 0;
	
// do some nonlinear Newton iteration
	outStream << "local time-step counter: " << timeStepCtr << std::endl;

// the procedure fails for 4-th time-step
	if(timeStepCtr ==  4)
	{
		++timeStepCtr;
		AssertThrow(false, MyException("pf")); 
	}

	//if(timeStepCtr == 6)
	//	Assert(false, MyException("disp"));

	++timeStepCtr;
}

void Simulate(dealii::ConditionalOStream &outStream)
{
	const UnsignedIntType nTimeSteps = 10;
	for(UnsignedIntType timeStepCtr=0; timeStepCtrSET(TARGET "mwe-timerOutput-mpi")
SET(TARGET_SRC ${TARGET}.cc)

cmake_minimum_required(VERSION 3.16)

FIND_PACKAGE(deal.II 9.0.0 QUIET HINTS ${deal.II_DIR} ${DEAL_II_DIR} 
$ENV{DEAL_II_DIR})

DEAL_II_INITIALIZE_CACHED_VARIABLES()

PROJECT(${TARGET})
DEAL_II_INVOKE_AUTOPILOT()