On 02/13/2017 06:15 AM, Franco Milicchio wrote:
Hello,

I know this is a weird question, but is there a way of telling a *Map*
that there is a default value?

For instance I'd like to express something like "*stress:4, power*"
instead of what I have to do right now, such as "*stress:4, power:8*"
(or whatever number).

The following is the code I am using now:

        params->declare_entry("csv", "strain:3, work:1",
dealii::Patterns::Map(dealii::Patterns::Selection("time|displacement|stress|strain|work|power"),
dealii::Patterns::Integer(0), 1), "Dump to CSV file, comma separated
values (time, displacement, stress, strain, work, power)");

Not a weird question. But also not something that's implemented.

I've been thinking for a minute on how to implement this, but the answer is that it's not going to be easy because the patterns are really only used to describe if a particular value for a parameter *satisfies certain requirements*, but the patterns have nothing to do with the code that later on parses and interprets the value.

So one thing you can do is to describe the parameter as
  Patterns::Map(Patterns::Selection("..."), Patterns::Anything(), 1)
which works because Anything also matches the empty string (along with anything else, of course). You would then just have to ensure later on that what is in this spot is either the empty string (which you can interpret as a default value), or indeed a positive integer.

I'm going to note that figuring out that a string is indeed a positive integer (and nothing else) is not trivial.

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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to