Skip to content

Commit

Permalink
[PL] Use Kelvin vector conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
endJunction committed Jan 30, 2018
1 parent 7a6637a commit 9f8f6bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 48 deletions.
22 changes: 6 additions & 16 deletions MaterialLib/SolidModels/Ehlers-impl.h
Expand Up @@ -34,6 +34,8 @@

#include <boost/math/special_functions/pow.hpp>

#include "MathLib/LinAlg/Eigen/EigenMapTools.h"

namespace MaterialLib
{
namespace Solids
Expand Down Expand Up @@ -673,24 +675,12 @@ SolidEhlers<DisplacementDim>::getInternalVariables() const
&state) != nullptr);
auto const& ehlers_state =
static_cast<StateVariables<DisplacementDim> const&>(state);
auto const& D = ehlers_state.eps_p.D;

cache.resize(KelvinVector::RowsAtCompileTime);

// TODO make a general implementation for converting KelvinVectors
// back to symmetric rank-2 tensors.
for (typename KelvinVector::Index component = 0;
component < KelvinVector::RowsAtCompileTime && component < 3;
++component)
{ // xx, yy, zz components
cache[component] = D[component];
}
for (typename KelvinVector::Index component = 3;
component < KelvinVector::RowsAtCompileTime;
++component)
{ // mixed xy, yz, xz components
cache[component] = D[component] / std::sqrt(2);
}
MathLib::toVector<KelvinVector>(cache,
KelvinVector::RowsAtCompileTime) =
MathLib::KelvinVector::kelvinVectorToSymmetricTensor(
ehlers_state.eps_p.D);

return cache;
}},
Expand Down
36 changes: 4 additions & 32 deletions ProcessLib/SmallDeformation/SmallDeformationFEM.h
Expand Up @@ -320,7 +320,6 @@ class SmallDeformationLocalAssembler
NumLib::LocalToGlobalIndexMap const& /*dof_table*/,
std::vector<double>& cache) const override
{
using KelvinVectorType = typename BMatricesType::KelvinVectorType;
static const int kelvin_vector_size =
MathLib::KelvinVector::KelvinVectorDimensions<
DisplacementDim>::value;
Expand All @@ -331,24 +330,11 @@ class SmallDeformationLocalAssembler
double, kelvin_vector_size, Eigen::Dynamic, Eigen::RowMajor>>(
cache, kelvin_vector_size, num_intpts);

// TODO make a general implementation for converting KelvinVectors
// back to symmetric rank-2 tensors.
for (unsigned ip = 0; ip < num_intpts; ++ip)
{
auto const& sigma = _ip_data[ip].sigma;

for (typename KelvinVectorType::Index component = 0;
component < kelvin_vector_size && component < 3;
++component)
{ // xx, yy, zz components
cache_mat(component, ip) = sigma[component];
}
for (typename KelvinVectorType::Index component = 3;
component < kelvin_vector_size;
++component)
{ // mixed xy, yz, xz components
cache_mat(component, ip) = sigma[component] / std::sqrt(2);
}
cache_mat.col(ip) =
MathLib::KelvinVector::kelvinVectorToSymmetricTensor(sigma);
}

return cache;
Expand All @@ -360,7 +346,6 @@ class SmallDeformationLocalAssembler
NumLib::LocalToGlobalIndexMap const& /*dof_table*/,
std::vector<double>& cache) const override
{
using KelvinVectorType = typename BMatricesType::KelvinVectorType;
auto const kelvin_vector_size =
MathLib::KelvinVector::KelvinVectorDimensions<
DisplacementDim>::value;
Expand All @@ -371,24 +356,11 @@ class SmallDeformationLocalAssembler
double, kelvin_vector_size, Eigen::Dynamic, Eigen::RowMajor>>(
cache, kelvin_vector_size, num_intpts);

// TODO make a general implementation for converting KelvinVectors
// back to symmetric rank-2 tensors.
for (unsigned ip = 0; ip < num_intpts; ++ip)
{
auto const& eps = _ip_data[ip].eps;

for (typename KelvinVectorType::Index component = 0;
component < kelvin_vector_size && component < 3;
++component)
{ // xx, yy, zz components
cache_mat(component, ip) = eps[component];
}
for (typename KelvinVectorType::Index component = 3;
component < kelvin_vector_size;
++component)
{ // mixed xy, yz, xz components
cache_mat(component, ip) = eps[component] / std::sqrt(2);
}
cache_mat.col(ip) =
MathLib::KelvinVector::kelvinVectorToSymmetricTensor(eps);
}

return cache;
Expand Down

0 comments on commit 9f8f6bd

Please sign in to comment.