Another idea:
create a struct ElasticProperties that can be constructed using
different functions (maybe with functions like make_from_mu_and_nu())
and that has member functions to compute arbitrary output. Internally
it would convert to one representation during construction.

On Tue, Jan 10, 2017 at 11:13 AM, Wolfgang Bangerth
<bange...@colostate.edu> wrote:
> 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: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.math.colostate.edu_-7Ebangerth_&d=CwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=4k7iKXbjGC8LfYxVJJXiaYVu6FRWmEjX38S7JmlS9Vw&m=KsKpisT2SJKkJfw0UdJ44pzX9KWaIqMyAZIucA9gclI&s=Owply6urjzGRxMYxAgJFs7Bj-U-ou6-PTKKWPOP3p_E&e=
>  
>
> --
> The deal.II project is located at 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.dealii.org_&d=CwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=4k7iKXbjGC8LfYxVJJXiaYVu6FRWmEjX38S7JmlS9Vw&m=KsKpisT2SJKkJfw0UdJ44pzX9KWaIqMyAZIucA9gclI&s=qfEv66s2nvK5QndgYJKZHaVSIhy2dpDAsNXZCwd5nJ0&e=
>  
> For mailing list/forum options, see
> https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_forum_dealii-3Fhl-3Den&d=CwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=4k7iKXbjGC8LfYxVJJXiaYVu6FRWmEjX38S7JmlS9Vw&m=KsKpisT2SJKkJfw0UdJ44pzX9KWaIqMyAZIucA9gclI&s=L3zM-ccG2kAp7MR6RuPNKuHtpsSCI5Zj5-4pR9ersFA&e=
>  
> --- 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://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_optout&d=CwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=4k7iKXbjGC8LfYxVJJXiaYVu6FRWmEjX38S7JmlS9Vw&m=KsKpisT2SJKkJfw0UdJ44pzX9KWaIqMyAZIucA9gclI&s=2CkGJNpmXO40MGnqVAH7OXIVZ61MONUVfS0Qe5p3q40&e=
>  .



-- 
Timo Heister
http://www.math.clemson.edu/~heister/

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

Reply via email to