v0.16.3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential Struct Reference

#include "users_modules/eshelbian_plasticity/src/LogarithmicDirectionalDerivatives.hpp"

Collaboration diagram for EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential:
[legend]

Public Member Functions

template<class A >
 SymmetricExponential (const A &a)
 
SymmetricExponential negated () const
 
Symmetric first (const Symmetric &e) const
 
Symmetric second (const Symmetric &e1, const Symmetric &e2) const
 
Symmetric third (const Symmetric &e1, const Symmetric &e2, const Symmetric &e3) const
 
template<int N>
void fill (const Matrix< N > &argument, Matrix< N > &result) const
 

Static Public Member Functions

static Symmetric symmetric (View block)
 

Public Attributes

FTensor::Tensor1< double, 3 > values
 
FTensor::Tensor2< double, 3, 3 > vectors
 
Symmetric value
 

Private Member Functions

Tensor toEigenbasis (const Symmetric &e) const
 
Symmetric fromEigenbasis (const Tensor &t) const
 
Tensor firstInBasis (const Tensor &x) const
 
Tensor secondInBasis (const Tensor &x, const Tensor &y) const
 
Tensor thirdInBasis (const Tensor &x, const Tensor &y, const Tensor &z) const
 
void prepareDifferences ()
 

Static Private Member Functions

static const EigenMatrix::Fun< double > & expFun ()
 

Private Attributes

double second_ [3][3]
 
double third_ [3][3][3]
 
double fourth_ [3][3][3][3]
 

Detailed Description

Exponential of a symmetric matrix with its directional derivatives up to third order from the eigen-decomposition. The value is EigenMatrix::getMat (MatrixFunction.hpp). The derivatives use the divided-difference expansion in the eigenbasis (components X_ab of a direction, exp[...] divided differences of exp at the eigenvalues): (D exp[E])_ab = exp[l_a,l_b] E_ab, (D^2 exp[E,F])_ab = sum_c exp[l_a,l_c,l_b] (E_ac F_cb + F_ac E_cb), (D^3 exp[E,F,G])_ab = sum_{c,d} exp[l_a,l_c,l_d,l_b] sum_{perm (X,Y,Z) of (E,F,G)} X_ac Y_cd Z_db. The divided differences are evaluated as a short series when eigenvalues are close, so coincident and nearly coincident eigenvalues are exact; the confluent formulas of EigenMatrix::getDiffMat and getDiffDiffMat apply only to eigenvalues equal to 1e-14 and lose about eps/gap^2 in between. The decomposition and the difference tables are formed once per base and reused for every direction set.

Definition at line 227 of file LogarithmicDirectionalDerivatives.hpp.

Constructor & Destructor Documentation

◆ SymmetricExponential()

template<class A >
EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::SymmetricExponential ( const A &  a)
inlineexplicit

Definition at line 228 of file LogarithmicDirectionalDerivatives.hpp.

228 {
229 FTENSOR_INDEXES(3, i, j);
230 vectors(i, j) = a(i, j);
232 "Cannot diagonalise symmetric exponential argument");
235 }
#define FTENSOR_INDEXES(DIM,...)
constexpr double a
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
auto getMat(A &&t_val, B &&t_vec, Fun< double > f)
Get the Mat object.
MoFEMErrorCode computeEigenValuesSymmetric(const MatrixDouble &mat, VectorDouble &eig, MatrixDouble &eigen_vec)
compute eigenvalues of a symmetric matrix using lapack dsyev

Member Function Documentation

◆ expFun()

static const EigenMatrix::Fun< double > & EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::expFun ( )
inlinestaticprivate

Definition at line 307 of file LogarithmicDirectionalDerivatives.hpp.

307 {
308 static const EigenMatrix::Fun<double> f = [](double x) {
309 return std::exp(x);
310 };
311 return f;
312 }
boost::function< T(const T)> Fun

◆ fill()

template<int N>
void EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::fill ( const Matrix< N > &  argument,
Matrix< N > &  result 
) const
inline

Fill the jet of exp at this base: block 0 the value, single-bit blocks the first derivatives in the (symmetric) direction blocks of argument, two-bit blocks the second and the three-bit block the third derivative. A zero direction block gives zero derivatives.

Definition at line 277 of file LogarithmicDirectionalDerivatives.hpp.

277 {
278 FTENSOR_INDEXES(3, i, j);
279 result.data.fill(0.);
280 result[0](i, j) = value(i, j);
281 std::array<Tensor, N> e;
282 std::array<bool, N> active{};
283 for (int d = 0; d != N; ++d) {
284 const auto block = symmetric(argument[1 << d]);
285 active[d] = block(i, j) * block(i, j) > 0.;
286 if (active[d]) {
287 e[d] = toEigenbasis(block);
288 result[1 << d](i, j) = fromEigenbasis(firstInBasis(e[d]))(i, j);
289 }
290 }
291 for (int d1 = 0; d1 != N; ++d1)
292 for (int d2 = d1 + 1; d2 != N; ++d2)
293 if (active[d1] && active[d2])
294 result[(1 << d1) | (1 << d2)](i, j) =
295 fromEigenbasis(secondInBasis(e[d1], e[d2]))(i, j);
296 if constexpr (N == 3)
297 if (active[0] && active[1] && active[2])
298 result[7](i, j) = fromEigenbasis(thirdInBasis(e[0], e[1], e[2]))(i, j);
299 }
bool active
const int N
Definition speed_test.cpp:3

◆ first()

Symmetric EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::first ( const Symmetric &  e) const
inline

D exp(A)[e]

Definition at line 248 of file LogarithmicDirectionalDerivatives.hpp.

248 {
250 }

◆ firstInBasis()

Tensor EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::firstInBasis ( const Tensor &  x) const
inlineprivate

Definition at line 334 of file LogarithmicDirectionalDerivatives.hpp.

334 {
335 Tensor t;
336 for (int a = 0; a != 3; ++a)
337 for (int b = 0; b != 3; ++b)
338 t(a, b) = second_[a][b] * x(a, b);
339 return t;
340 }
constexpr double t
plate stiffness
Definition plate.cpp:58

◆ fromEigenbasis()

Symmetric EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::fromEigenbasis ( const Tensor &  t) const
inlineprivate

Definition at line 323 of file LogarithmicDirectionalDerivatives.hpp.

323 {
324 FTENSOR_INDEXES(3, i, j);
325 FTensor::Index<'a', 3> a;
326 FTensor::Index<'b', 3> b;
327 Tensor full;
328 full(i, j) = vectors(a, i) * (t(a, b) * vectors(b, j));
329 Symmetric result;
330 result(i, j) = (full(i, j) || full(j, i)) / 2.;
331 return result;
332 }

◆ negated()

SymmetricExponential EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::negated ( ) const
inline

exp(-A) from the same eigenvectors, without a second diagonalisation.

Definition at line 238 of file LogarithmicDirectionalDerivatives.hpp.

238 {
239 SymmetricExponential result(*this);
240 FTENSOR_INDEXES(3, i);
241 result.values(i) = -values(i);
242 result.value = EigenMatrix::getMat(result.values, result.vectors, expFun());
243 result.prepareDifferences();
244 return result;
245 }

◆ prepareDifferences()

void EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::prepareDifferences ( )
inlineprivate

Divided differences of exp at the eigenvalues for every index tuple. The eigenvalues are ascending (LAPACK dsyev), so for a sorted tuple the extreme points are its first and last entry and the recursion exp[p_0..p_k] = (exp[p_1..p_k] - exp[p_0..p_{k-1}]) / (p_k - p_0) divides by the largest spread; tuples with a small spread use the series.

Definition at line 375 of file LogarithmicDirectionalDerivatives.hpp.

375 {
376#ifndef NDEBUG
377 if (values(0) > values(1) || values(1) > values(2))
378 THROW_MESSAGE("Eigenvalues are expected in ascending order");
379#endif
380 const auto l = [&](int a) { return values(a); };
381 const auto close = [](double spread) {
382 return spread <= detail::closeSpread;
383 };
384 const double e[3] = {std::exp(l(0)), std::exp(l(1)), std::exp(l(2))};
385 for (int a = 0; a != 3; ++a)
386 for (int b = a; b != 3; ++b)
387 second_[a][b] = second_[b][a] =
389 std::array<double, 2>{l(a), l(b)})
390 : (e[b] - e[a]) / (l(b) - l(a));
391 for (int a = 0; a != 3; ++a)
392 for (int b = a; b != 3; ++b)
393 for (int c = b; c != 3; ++c)
394 third_[a][b][c] =
395 close(l(c) - l(a))
397 std::array<double, 3>{l(a), l(b), l(c)})
398 : (second_[b][c] - second_[a][b]) / (l(c) - l(a));
399 for (int a = 0; a != 3; ++a)
400 for (int b = 0; b != 3; ++b)
401 for (int c = 0; c != 3; ++c) {
402 std::array<int, 3> s{a, b, c};
403 std::sort(s.begin(), s.end());
404 third_[a][b][c] = third_[s[0]][s[1]][s[2]];
405 }
406 for (int a = 0; a != 3; ++a)
407 for (int b = a; b != 3; ++b)
408 for (int c = b; c != 3; ++c)
409 for (int d = c; d != 3; ++d)
410 fourth_[a][b][c][d] =
411 close(l(d) - l(a))
413 std::array<double, 4>{l(a), l(b), l(c), l(d)})
414 : (third_[b][c][d] - third_[a][b][c]) / (l(d) - l(a));
415 for (int a = 0; a != 3; ++a)
416 for (int b = 0; b != 3; ++b)
417 for (int c = 0; c != 3; ++c)
418 for (int d = 0; d != 3; ++d) {
419 std::array<int, 4> s{a, b, c, d};
420 std::sort(s.begin(), s.end());
421 fourth_[a][b][c][d] = fourth_[s[0]][s[1]][s[2]][s[3]];
422 }
423 }
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
const double c
speed of light (cm/ns)
FTensor::Index< 'l', 3 > l

◆ second()

Symmetric EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::second ( const Symmetric &  e1,
const Symmetric &  e2 
) const
inline

D^2 exp(A)[e1, e2]

Definition at line 253 of file LogarithmicDirectionalDerivatives.hpp.

253 {
255 }

◆ secondInBasis()

Tensor EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::secondInBasis ( const Tensor &  x,
const Tensor &  y 
) const
inlineprivate

Definition at line 342 of file LogarithmicDirectionalDerivatives.hpp.

342 {
343 Tensor t;
344 for (int a = 0; a != 3; ++a)
345 for (int b = 0; b != 3; ++b) {
346 double sum = 0.;
347 for (int c = 0; c != 3; ++c)
348 sum += third_[a][c][b] * (x(a, c) * y(c, b) + y(a, c) * x(c, b));
349 t(a, b) = sum;
350 }
351 return t;
352 }

◆ symmetric()

static Symmetric EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::symmetric ( View  block)
inlinestatic

Symmetric part of a jet block.

Definition at line 265 of file LogarithmicDirectionalDerivatives.hpp.

265 {
266 FTENSOR_INDEXES(3, i, j);
267 Symmetric result;
268 result(i, j) = (block(i, j) || block(j, i)) / 2.;
269 return result;
270 }

◆ third()

Symmetric EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::third ( const Symmetric &  e1,
const Symmetric &  e2,
const Symmetric &  e3 
) const
inline

D^3 exp(A)[e1, e2, e3]

Definition at line 258 of file LogarithmicDirectionalDerivatives.hpp.

259 {
260 return fromEigenbasis(
262 }

◆ thirdInBasis()

Tensor EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::thirdInBasis ( const Tensor &  x,
const Tensor &  y,
const Tensor &  z 
) const
inlineprivate

Definition at line 354 of file LogarithmicDirectionalDerivatives.hpp.

354 {
355 Tensor t;
356 for (int a = 0; a != 3; ++a)
357 for (int b = 0; b != 3; ++b) {
358 double sum = 0.;
359 for (int c = 0; c != 3; ++c)
360 for (int d = 0; d != 3; ++d)
361 sum += fourth_[a][c][d][b] *
362 (x(a, c) * y(c, d) * z(d, b) + x(a, c) * z(c, d) * y(d, b) +
363 y(a, c) * x(c, d) * z(d, b) + y(a, c) * z(c, d) * x(d, b) +
364 z(a, c) * x(c, d) * y(d, b) + z(a, c) * y(c, d) * x(d, b));
365 t(a, b) = sum;
366 }
367 return t;
368 }

◆ toEigenbasis()

Tensor EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::toEigenbasis ( const Symmetric &  e) const
inlineprivate

Definition at line 314 of file LogarithmicDirectionalDerivatives.hpp.

314 {
315 FTENSOR_INDEXES(3, i, j);
316 FTensor::Index<'a', 3> a;
317 FTensor::Index<'b', 3> b;
318 Tensor c;
319 c(a, b) = vectors(a, i) * (e(i, j) * vectors(b, j));
320 return c;
321 }

Member Data Documentation

◆ fourth_

double EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::fourth_[3][3][3][3]
private

Definition at line 428 of file LogarithmicDirectionalDerivatives.hpp.

◆ second_

double EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::second_[3][3]
private

exp[l_a,l_b], exp[l_a,l_b,l_c], exp[l_a,l_b,l_c,l_d].

Definition at line 426 of file LogarithmicDirectionalDerivatives.hpp.

◆ third_

double EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::third_[3][3][3]
private

Definition at line 427 of file LogarithmicDirectionalDerivatives.hpp.

◆ value

Symmetric EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::value

Definition at line 304 of file LogarithmicDirectionalDerivatives.hpp.

◆ values

FTensor::Tensor1<double, 3> EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::values

Definition at line 301 of file LogarithmicDirectionalDerivatives.hpp.

◆ vectors

FTensor::Tensor2<double, 3, 3> EshelbianPlasticity::LogarithmicDirectionalDerivatives::SymmetricExponential::vectors

Eigenvectors in rows (MoFEM convention).

Definition at line 303 of file LogarithmicDirectionalDerivatives.hpp.


The documentation for this struct was generated from the following file: