On 09/10/2016 03:49 AM, [email protected] wrote:

I have a dimension independent code which can work for 1D, 2D and 3D. The
dimension of the problem is defined in the input file. Is there a way to
declare a constant integer variable (dim) for template?

for 1D
dim = 1;
for 2D
dim = 2;
else
dim = 3;

then,

FEM<dim> solid("parameters.prm");
solid.run();

The problem is that the <dim> template parameter is something the compiler needs to know at compile time, but you want to only determine it at run time. This doesn't easily work.

But you can do this with tricks -- take a look at the main() function of ASPECT, for example:
 https://github.com/geodynamics/aspect/blob/master/source/main.cc
lines 452-490.

Best
 Wolfgang

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

Reply via email to