Skip to content

Commit 8fe1cc6

Browse files
committed
add symmetric_independent_component_matrix function to utilities.
1 parent da26e02 commit 8fe1cc6

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

include/aspect/utilities.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,13 @@ namespace aspect
10601060
* entry in the list must match one of the allowed operations.
10611061
*/
10621062
std::vector<Operator> create_model_operator_list(const std::vector<std::string> &operator_names);
1063+
1064+
/**
1065+
* Create matrix with unit at independent indices
1066+
*/
1067+
template <int dim>
1068+
SymmetricTensor<2,dim> symmetric_independent_component_matrix (const unsigned int k);
1069+
10631070
}
10641071
}
10651072

source/utilities.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,21 @@ namespace aspect
25322532
}
25332533

25342534

2535+
template <int dim>
2536+
SymmetricTensor<2,dim>
2537+
symmetric_independent_component_matrix (const unsigned int k)
2538+
{
2539+
// somehow I need this, because otherwise it complains that I am passing 3 arguments and it only takes 2...
2540+
const bool boolian = k < SymmetricTensor<2,dim>::n_independent_components;
2541+
Assert(boolian, ExcMessage("The component is larger then the amount of independent components in the matrix.") );
2542+
2543+
const TableIndices<2> indices_ij = SymmetricTensor<2,dim>::unrolled_to_component_indices (k);
2544+
2545+
Tensor<2,dim> result;
2546+
result[indices_ij] = 1;
2547+
2548+
return symmetrize(result);
2549+
}
25352550

25362551

25372552
// Explicit instantiations
@@ -2618,5 +2633,8 @@ namespace aspect
26182633
template std_cxx11::array<double,2> convert_point_to_array<2>(const Point<2> &point);
26192634
template std_cxx11::array<double,3> convert_point_to_array<3>(const Point<3> &point);
26202635

2636+
template SymmetricTensor<2,2> symmetric_independent_component_matrix (const unsigned int k);
2637+
template SymmetricTensor<2,3> symmetric_independent_component_matrix (const unsigned int k);
2638+
26212639
}
26222640
}

0 commit comments

Comments
 (0)