Skip to content

Commit

Permalink
Add unroll and constructor for SymmetricTensor
Browse files Browse the repository at this point in the history
  • Loading branch information
gassmoeller committed May 23, 2024
1 parent 60d92af commit fea380f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions include/aspect/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,36 @@ namespace aspect
*/
namespace Tensors
{
/**
* Convert a vector of doubles to a SymmetricTensor of the same size.
*/
template <int dim>
inline
SymmetricTensor<2,dim>
to_symmetric_tensor(const ArrayView<double> &values)
{
// Assemble stress tensor if elastic behavior is enabled
SymmetricTensor<2,dim> output;
for (unsigned int i=0; i < SymmetricTensor<2,dim>::n_independent_components; ++i)
output[SymmetricTensor<2,dim>::unrolled_to_component_indices(i)] = values[i];

return output;
};



/**
* Convert a vector of doubles to a SymmetricTensor of the same size.
*/
template <int dim>
inline
void
unroll(const SymmetricTensor<2,dim> &tensor,
const ArrayView<double> &values)
{
for (unsigned int i=0; i < SymmetricTensor<2,dim>::n_independent_components; ++i)
values[i] = tensor[SymmetricTensor<2,dim>::unrolled_to_component_indices(i)];
};

/**
* Rotate a 3D 4th order tensor representing the full stiffnexx matrix using a 3D 2nd order rotation tensor
Expand Down

0 comments on commit fea380f

Please sign in to comment.