Skip to content

Tidy up the rheology code #450

@timspainNERSC

Description

@timspainNERSC

On first looking at the rheology code, it looks like an horrendous mess.
However, I suggest that by a few simple typedefs, the code can be made to look more like physics and less like C++.

For example, here is some of the core calculation of the function StressUpdateHighOrder() in BBM.hpp:

            const Eigen::Matrix<double, 1, NGP* NGP> powalphaexpC
                = (d_gauss.array() * expC.array()).pow(params.exponent_relaxation_sigma - 1);
            const Eigen::Matrix<double, 1, NGP* NGP> time_viscous
                = params.undamaged_time_relaxation_sigma * powalphaexpC;

            //! BBM  Computing tildeP according to (Eqn. 7b and Eqn. 8)
            // (Eqn. 8)
            const Eigen::Matrix<double, 1, NGP* NGP> Pmax
                = params.P0 * h_gauss.array().pow(params.exponent_compression_factor) * expC.array();

I would argue that adding a typedef Eigen::Matrix<double, 1, NGP * NGP> GaussVar; makes the physical equations that are being evaluated much clearer:

        // Eqn. 25
        const GaussVar powalphaexpC = (d_gauss.array() * expC.array()).pow(
                params.exponent_relaxation_sigma - 1);
        const GaussVar time_viscous = params.undamaged_time_relaxation_sigma * powalphaexpC;

        //! BBM  Computing tildeP according to (Eqn. 7b and Eqn. 8)
        // (Eqn. 8)
        const GaussVar Pmax = params.P0 * h_gauss.array().pow(params.exponent_compression_factor)
                * expC.array();

because the code is no longer dominated by the types and template arguments. To me, even as someone experienced with C++, this is easier to read.

There may be other renamings and rearrangings that are possible to make the code in these functions even clearer.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions