On 05/09/2017 05:59 PM, Weixiong Zheng wrote:
I got bothered a bit about the problem: the existence of some parameters
depends on the other parameters defining the problem. what I am doing now is
that I have two methods called: declare_parameter(prm) and
declare_other_parameter(prm,prm2) and further I do:
void PROBLEM<dim>::declare_other_parameters(prm,prm2)
{
declare corresponding entries in prm2 after reading input parameters in prm;
}
main ()
{
ParameterHandler prm, prm2;
PROBLEM<dimension>::declare_parameter (prm);
prm.read_input (argv[1]);
PROBLEM<dimension>::declare_other_parameter (prm,prm2);
prm2.read_input (argv[2]);
PROBLEM<dimension> prob (prm,prm2);
}
As you see, I actually do declare entries for parameters for problem
definition and read them in the first file. After that I have to declare extra
entries depending on what I have read in the first file and read in another
file.
What I prefer is a way that I can put everything in one file, any idea for
that please?
There isn't an easy one. The problem is that you can't read parameters that
haven't been declared yet. So you can't declare parameters *in response to*
other parameters.
But there are two options:
* You just declare all possible parameters; depending on the values given for
some parameters, you're just going to ignore some of the others.
* You could require the user to write the first set of parameters at the top
of the file, and then use the 'last_line' argument of
ParameterHandler::parse_input() to stop reading at a specific point, see
https://dealii.org/developer/doxygen/deal.II/classParameterHandler.html#a030e84298d59cfea765f43d8600dee48
You would then declare some additional parameters as you do above, and just
re-read the *entire* file a second time (i.e., not specify an 'end_line').
Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email: [email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.