From 4b7e77f1a598a150adda6c8a478e964ae9774926 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sun, 11 May 2008 05:32:12 +0000 Subject: [PATCH] A bit further. git-svn-id: https://svn.dealii.org/trunk@16074 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-33/step-33.cc | 48 ++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/deal.II/examples/step-33/step-33.cc b/deal.II/examples/step-33/step-33.cc index 33b1ed1333..d30e11a3e3 100644 --- a/deal.II/examples/step-33/step-33.cc +++ b/deal.II/examples/step-33/step-33.cc @@ -93,7 +93,6 @@ // namespace: using namespace dealii; -#define DIMENSION 2 // @sect3{Flux function definition} @@ -115,10 +114,25 @@ using namespace dealii; // introduce using a template parameter: namespace EulerEquations { - // We define the number of components in - // the system. Euler's has one entry for - // momenta in each spatial direction, plus - // the energy and density components. + // First a few inline functions that + // describe the various components of our + // solution vector in a generic way. This + // includes the number of components in the + // system (Euler's equations have one entry + // for momenta in each spatial direction, + // plus the energy and density components, + // for a total of dim+2 + // components), as well as functions that + // describe the index within the solution + // vector of the first momentum component, + // the density component, and the energy + // density component. Note that all these + // numbers depend on the space dimension; + // defining them in a generic way (rather + // than by implicit convention) makes our + // code more flexible and makes it easier + // to later extend it, for example by + // adding more components to the equations. template inline unsigned int n_components () @@ -126,11 +140,13 @@ namespace EulerEquations return dim + 2; } + template + inline + unsigned int first_momentum_component () + { + return 0; + } - // Define a handle to the density and energy - // indices. We have arrange the momenta to - // be first, then density, and, lastly, - // energy. template inline unsigned int density_component () @@ -138,8 +154,6 @@ namespace EulerEquations return dim; } - - template inline unsigned int energy_component () @@ -148,8 +162,12 @@ namespace EulerEquations } - // The gas constant. This value is - // representative of air. + // Next, we define the gas constant. This + // value is representative of a gas that + // consists of molecules composed of two + // atoms, such as air which consists up to + // small traces almost entirely of $N_2$ + // and $O_2$. const double gas_gamma = 1.4; } @@ -169,7 +187,7 @@ using namespace EulerEquations; // exactly like the Euler equations one is // used to seeing. We evaluate the flux at a // single quadrature point. -template +template void Flux(std::vector > &flux, const Point &/*point*/, const std::vector &W) @@ -2113,7 +2131,7 @@ int main (int argc, char *argv[]) } try { - ConsLaw cons; + ConsLaw<2> cons; cons.declare_parameters(); cons.load_parameters(argv[1]); cons.run (); -- 2.39.5