https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SymmetricRankTwoTensorImplementation.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
12template <>
13void
14SymmetricRankTwoTensor::syev(const char * calculation_type,
15 std::vector<Real> & eigvals,
16 std::vector<Real> & a) const
17{
18 eigvals.resize(Ndim);
19 a.resize(Ndim * Ndim);
20
21 // prepare data for the LAPACKsyev_ routine (which comes from petscblaslapack.h)
22 PetscBLASInt nd = Ndim;
23 PetscBLASInt lwork = 66 * nd;
24 PetscBLASInt info;
25 std::vector<PetscScalar> work(lwork);
26
27 auto A = RankTwoTensor(*this);
28 for (auto i : make_range(Ndim))
29 for (auto j : make_range(Ndim))
30 // a is destroyed by dsyev, and if calculation_type == "V" then eigenvectors are placed
31 // there
32 a[i * Ndim + j] = A(i, j);
33
34 // compute the eigenvalues only (if calculation_type == "N"),
35 // or both the eigenvalues and eigenvectors (if calculation_type == "V")
36 // assume upper triangle of a is stored (second "U")
37 LAPACKsyev_(calculation_type, "U", &nd, &a[0], &nd, &eigvals[0], &work[0], &lwork, &info);
38
39 if (info != 0)
40 mooseError("In computing the eigenvalues and eigenvectors for the symmetric rank-2 tensor (",
42 "), the PETSC LAPACK syev routine returned error code ",
43 info);
44}
45
46template <>
47void
48SymmetricRankTwoTensor::symmetricEigenvalues(std::vector<Real> & eigvals) const
49{
50 std::vector<Real> a;
51 syev("N", eigvals, a);
52}
53
54template <>
55void
57 RankTwoTensor & eigvecs) const
58{
59 std::vector<Real> a;
60 syev("V", eigvals, a);
61
62 for (auto i : make_range(Ndim))
63 for (auto j : make_range(Ndim))
64 eigvecs(j, i) = a[i * Ndim + j];
65}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
for(PetscInt i=0;i< nvars;++i)
RankTwoTensorTempl< Real > RankTwoTensor
void syev(const char *calculation_type, std::vector< Real > &eigvals, std::vector< Real > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if ...
void symmetricEigenvaluesEigenvectors(std::vector< Real > &eigvals, RankTwoTensorTempl< Real > &eigvecs) const
computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order...
static constexpr unsigned int Ndim
tensor dimension and Mandel vector length
void symmetricEigenvalues(std::vector< Real > &eigvals) const
computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:64
MPI_Info info
IntRange< T > make_range(T beg, T end)