Dear All,

I am trying to read a list of integers from the parameter file using the 
dealii::Patterns::List class.
However, I get a runtime error which can be reproduced using the attached 
MWE.

I also tried the approach described (for tensor) in 
https://groups.google.com/g/dealii/c/TvtcOnxeVjw/m/9uaSAh-kAwAJ but it 
doesn't seem to work for the current case.

It would be great help if someone could help me understand where I go wrong?

Thanks in advance and best regards,
Paras



-- 
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/a478ba5e-0150-4fb5-8e90-0faf1c86b9fbn%40googlegroups.com.
#include <deal.II/base/patterns.h>
#include <deal.II/base/parameter_handler.h>
#include <string>

using UnsignedIntType = unsigned int;

 void Declare_blockNonlinearSolverParameters(dealii::ParameterHandler &parameterHandler)
{
    parameterHandler.declare_entry(
      "Num Max Newton Iters",
      "10|10",
      dealii::Patterns::List(dealii::Patterns::Integer(1), 2, 8, "|"),
      "Allowed maximum number of newton iterations for inner loops");
}

int main()
{
    // decalre the parameters to be read
    dealii::ParameterHandler paramHandler;
    paramHandler.enter_subsection("Block Nonlinear Solver");
    Declare_blockNonlinearSolverParameters(paramHandler);
    paramHandler.leave_subsection();

    // generate and read the param file
    const std::string paramsBNlSolverTest01 =
  "subsection Block Nonlinear Solver                                       \n"
  "    # Allowed maximum number of newton iterations for inner loops       \n"
  "    set Num Max Newton Iters = 27|30|45                                 \n"
  "end                                                                     \n";
    std::stringstream paramFileString;
    paramFileString << paramsBNlSolverTest01;
    paramHandler.parse_input(paramFileString);

    //extract the read params
    
    paramHandler.enter_subsection("Block Nonlinear Solver");
    const std::string nMaxItersString = paramHandler.get("Num Max Newton Iters");
    std::cout << "nMaxItersString: " << nMaxItersString << std::endl;    
    std::vector<UnsignedIntType> nIters;
    nIters = dealii::Patterns::Tools::Convert<decltype(nIters)>::to_value(nMaxItersString);
    paramHandler.leave_subsection();
}

Reply via email to