That would work quite nicely but my only concern is that, again, one might end up with many structs along with the many function definitions in order to accommodate all of the potential permutations.
What do you think of this concept as an alternative? enum ElasticityParameters {LameParameter, PoissonRatio, ShearModulus, YoungsModulus, BulkModulus, ...etc}; template<ElasticityParameters P1, ElasticityParameters P2, typename Number> Number kappa (const Number &, const Number &) { AssertThrow(false, ExcNotImplemented()); return 0.0; } template<> Number bulk_modulus < LameParameter, PoissonRatio > (const Number &lambda, const Number &mu) { const double kappa = lambda + 2.0/3.0*mu; AssertThrow(kappa > 0.0, ExcMessage("Non-positive bulk modulus!")); return kappa; } template<> Number bulk_modulus <PoissonRatio, LameParameter> (const Number &mu, const Number &lambda) { return bulk_modulus < LameParameter, PoissonRatio > (lambda, mu); } template<> Number bulk_modulus< ShearModulus, PoissonRatio > (const Number &mu, const Number &nu) { const double kappa = (2.0 * mu * (1.0 + nu)) / (3.0 * (1.0 - 2.0 * nu)); AssertThrow(kappa > 0.0, ExcMessage("Non-positive bulk modulus!")); return kappa; } On Tuesday, January 10, 2017 at 2:45:13 PM UTC+1, Wolfgang Bangerth wrote: > > On 01/10/2017 06:18 AM, Jean-Paul Pelteret wrote: > > Do you have any recommendations on a function hierarchy/naming scheme? > Most > > of these functions will take two numbers and return another one, which > > means that most of them have the same argument list. In my own code I > have > > nested namespaces and functions like double > > Constitutive_Parameters::Bulk_modulus::from_lambda_and_mu(double lambda, > > double mu) This can get untidy quite quickly, but I can’t think of a > much > > better alternative… > > What if you had structures Lambda_Mu, E_nu, ..., and functions of the form > double lambda (const E_nu &e_and_nu) > ? This way, the arguments have proper types that make their meaning > obvious, > and you can overload functions such as lambda() above for different > argument > types. > > 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.