https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: b7fdacad4ed259a16f36cf40a936fae52bcf692e authored by Lars Bilke on 01 March 2021, 13:53:47 UTC
Merge branch 'update-conan' into 'master'
Tip revision: b7fdaca
Divergence.h
/**
 * \file
 *
 * \copyright
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 */

#pragma once

namespace ProcessLib
{
namespace Deformation
{
/// Divergence of displacement, the volumetric strain.
template <int DisplacementDim, int NPOINTS, typename DNDX_Type>
double divergence(
    const Eigen::Ref<Eigen::Matrix<double, NPOINTS * DisplacementDim, 1> const>&
        u,
    DNDX_Type const& dNdx)
{
    double divergence = 0;
    for (int i = 0; i < DisplacementDim; ++i)
    {
        divergence += dNdx.template block<1, NPOINTS>(i, 0) *
                      u.template segment<NPOINTS>(i * NPOINTS);
    }
    return divergence;
}
}  // namespace Deformation
}  // namespace ProcessLib
back to top