On 01/10/2017 08:26 AM, Jean-Paul Pelteret wrote:
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?
|
enumElasticityParameters{LameParameter,PoissonRatio,ShearModulus,YoungsModulus,BulkModulus,...etc};
template<ElasticityParametersP1,ElasticityParametersP2,typenameNumber>
Number
kappa(constNumber &,constNumber &)
{
AssertThrow(false,ExcNotImplemented());
return0.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;
}
|
That still leaves many many functions to implement. Overloading is also
burdensome to program in this case because it creates so many separate
functions (up to 30) for each coefficient you want to compute.
If you want to go this route, why not do
double lambda (const ElasticityParameter coefficient1_kind,
const double coefficient1,
const ElasticityParameter coefficient2_kind,
const double coefficient2);
where the first two ElasticityParameter arguments indicate how the next
argument is to be interpreted?
This way, you only need one function. Internally, it would just have
nested switches.
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.