Simpatico
v1.10
|
#include <Tensor.h>
Public Member Functions | |
Constructors | |
Tensor () | |
Default constructor. More... | |
Tensor (const Tensor &t) | |
Copy constructor. More... | |
Tensor (double scalar) | |
Constructor, initialize all elements to a scalar value. More... | |
Tensor (const double a[][Dimension]) | |
Construct Tensor from double [][Dimension] 2D C array. More... | |
Assignment | |
Tensor & | operator= (const Tensor &t) |
Copy assignment. More... | |
Tensor & | operator= (const double a[][Dimension]) |
Assignment from C double [Dimension][Dimension] 2D array. More... | |
Arithmetic Assignment | |
void | operator+= (const Tensor &dt) |
Add tensor dt to this tensor. More... | |
void | operator-= (const Tensor &dt) |
Subtract tensor dt from this tensor. More... | |
void | operator*= (double s) |
Multiply this tensor by scalar s. More... | |
void | operator/= (double s) |
Divide this tensor by scalar s. More... | |
Array Subscript | |
const double & | operator() (int i, int j) const |
Return one element by value. More... | |
double & | operator() (int i, int j) |
Return one element by non-const reference. More... | |
Tensor valued functions (result assigned to invoking object) | |
Tensor & | zero () |
Set all elements of this tensor to zero. More... | |
Tensor & | identity () |
Set this to the identity (unity) tensor. More... | |
Tensor & | setRow (int i, const Vector &r) |
Set row i of this Tensor to elements of Vector r. More... | |
Tensor & | setColumn (int i, const Vector &r) |
Set column i of this Tensor to elements of Vector r. More... | |
Tensor & | add (const Tensor &t1, const Tensor &t2) |
Add tensors t1 and t2. More... | |
Tensor & | subtract (const Tensor &t1, const Tensor &t2) |
Subtract tensor t2 from t1. More... | |
Tensor & | multiply (const Tensor &t, double s) |
Multiply a tensor t by a scalar s. More... | |
Tensor & | divide (const Tensor &t, double s) |
Divide a Tensor t by a scalar s. More... | |
Tensor & | transpose (const Tensor &t) |
Compute transpose of a tensor. More... | |
Tensor & | transpose () |
Transpose this tensor. More... | |
Tensor & | symmetrize (const Tensor &t) |
Compute symmetric part of a tensor t. More... | |
Tensor & | symmetrize () |
Symmetrize this tensor. More... | |
Tensor & | dyad (const Vector &v1, const Vector &v2) |
Create dyad of two vectors. More... | |
Miscellaneous | |
double | trace () const |
Return the trace of this tensor. More... | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize this to/from an archive. More... | |
Friends | |
bool | operator== (const Tensor &t1, const Tensor &t2) |
Equality for Tensors. More... | |
bool | operator== (const Tensor &t1, const double t2[][Dimension]) |
Equality of Tensor and 2D C array. More... | |
std::istream & | operator>> (std::istream &in, Tensor &tensor) |
istream extractor for a Tensor. More... | |
std::ostream & | operator<< (std::ostream &out, const Tensor &tensor) |
ostream inserter for a Tensor. More... | |
Static Members | |
static const Tensor | Zero = Tensor(0.0) |
Constant Tensor with all zero elements. More... | |
static const Tensor | Identity = Tensor().identity() |
Constant idenity Tensor (diagonal diagonal elements all 1). More... | |
static void | initStatic () |
Call to guarantee initialization of Zero and Identity tensors. More... | |
static void | commitMpiType () |
Commit MPI datatype MpiTraits<Tensor>::type. More... | |
|
inline |
|
inlineexplicit |
Constructor, initialize all elements to a scalar value.
scalar | initial value for all elements. |
Definition at line 417 of file Tensor.h.
References Util::DimensionSq.
|
inlineexplicit |
Construct Tensor from double [][Dimension] 2D C array.
a | 2D array a[Dimension][Dimension] |
Definition at line 428 of file Tensor.h.
References Util::Dimension.
Copy assignment.
t | Tensor to assign. |
Definition at line 468 of file Tensor.h.
References Util::DimensionSq.
|
inline |
Assignment from C double [Dimension][Dimension] 2D array.
a | 2D array a[Dimension][Dimension] |
Definition at line 480 of file Tensor.h.
References Util::Dimension.
|
inline |
Add tensor dt to this tensor.
Upon return, *this = *this + dt.
dt | tensor increment (input) |
Definition at line 495 of file Tensor.h.
References Util::DimensionSq.
|
inline |
Subtract tensor dt from this tensor.
Upon return, *this = *this - dt.
dt | tensor increment (input) |
Definition at line 506 of file Tensor.h.
References Util::DimensionSq.
|
inline |
Multiply this tensor by scalar s.
Upon return, *this = (*this)*s.
s | scalar multiplier |
Definition at line 517 of file Tensor.h.
References Util::DimensionSq.
|
inline |
Divide this tensor by scalar s.
Upon return, *this = (*this)/s.
s | scalar divisor (input) |
Definition at line 528 of file Tensor.h.
References Util::DimensionSq.
|
inline |
Return one element by value.
i | row element index |
j | column element index |
Definition at line 539 of file Tensor.h.
References Util::Dimension.
|
inline |
Return one element by non-const reference.
i | row element index |
j | column element index |
Definition at line 552 of file Tensor.h.
References Util::Dimension.
|
inline |
Set all elements of this tensor to zero.
Definition at line 441 of file Tensor.h.
References Util::DimensionSq.
Referenced by DdMd::BondTensorAutoCorr::computeData(), DdMd::BondPotentialImpl< Interaction >::computeForcesAndStress(), DdMd::PairPotentialImpl< Interaction >::computeForcesAndStress(), DdMd::Simulation::computeKineticStress(), McMd::MdEwaldPotential::computeStress(), McMd::MdSpmePotential::computeStress(), McMd::MdEwaldPairPotentialImpl< Interaction >::computeStress(), DdMd::AnglePotentialImpl< Interaction >::computeStress(), DdMd::BondPotentialImpl< Interaction >::computeStress(), DdMd::DihedralPotentialImpl< Interaction >::computeStress(), DdMd::PairPotentialImpl< Interaction >::computeStress(), McMd::Cluster::momentTensor(), DdMd::Potential::reduceStress(), Util::setToZero(), and DdMd::Simulation::virialStress().
|
inline |
Set this to the identity (unity) tensor.
Definition at line 453 of file Tensor.h.
References Util::Dimension, and Util::DimensionSq.
Set row i of this Tensor to elements of Vector r.
Definition at line 737 of file Tensor.h.
References Util::Dimension.
Set column i of this Tensor to elements of Vector r.
Definition at line 749 of file Tensor.h.
References Util::Dimension.
Add tensors t1 and t2.
Upon return, *this = t1 + t2.
t1 | tensor |
t2 | tensor |
Definition at line 567 of file Tensor.h.
References Util::DimensionSq.
Referenced by McMd::MdStressAutoCorr::computeStress(), McMd::MdSpmePotential::computeStress(), McMd::MdEwaldPotential::computeStress(), DdMd::StressAutoCorrelation::data(), DdMd::VirialStressTensor::sample(), DdMd::VirialStressTensorAverage::sample(), DdMd::OutputStressTensor::sample(), DdMd::StressAutoCorr::sample(), McMd::StressAutoCorr< SystemType >::sample(), and McMd::StressTensorAverage< SystemType >::sample().
Subtract tensor t2 from t1.
Upon return, *this == t1 - t2.
t1 | tensor (input) |
t2 | tensor (input) |
Definition at line 581 of file Tensor.h.
References Util::DimensionSq.
Multiply a tensor t by a scalar s.
Upon return, *this == v*s.
t | tensor factor |
s | scalar factor |
Definition at line 595 of file Tensor.h.
References Util::DimensionSq.
Divide a Tensor t by a scalar s.
Upon return, *this = v/s;
t | tensor input |
s | scalar denominator |
Definition at line 609 of file Tensor.h.
References Util::DimensionSq.
Compute transpose of a tensor.
Upon return, *this is the transpose of t
t | input tensor |
Definition at line 636 of file Tensor.h.
References Util::Dimension.
|
inline |
Transpose this tensor.
Upon return, *this is transposed.
Definition at line 657 of file Tensor.h.
References Util::Dimension.
Compute symmetric part of a tensor t.
Upon return, *this = [t + t.transpose()]/2
t | tensor input |
Definition at line 678 of file Tensor.h.
References Util::Dimension.
|
inline |
Symmetrize this tensor.
Upon return, this is symmetrized, equal to half the sum of the original tensor and its transpose.
Definition at line 701 of file Tensor.h.
References Util::Dimension.
Create dyad of two vectors.
Upon return, *this equals the dyad v1 ^ v2. Equivalently: (*this)(i , j) == v1[i]*v2[j]
v1 | vector input |
v2 | vector input |
Definition at line 763 of file Tensor.h.
References Util::Dimension.
Referenced by McMd::MdEwaldPotential::computeStress(), McMd::MdSpmePotential::computeStress(), McMd::Cluster::momentTensor(), and McMd::IntraBondTensorAutoCorr< SystemType >::sample().
|
inline |
Return the trace of this tensor.
Definition at line 621 of file Tensor.h.
References Util::Dimension.
Referenced by DdMd::NphIntegrator::integrateStep1(), DdMd::NptIntegrator::integrateStep1(), DdMd::NphIntegrator::integrateStep2(), and DdMd::NptIntegrator::integrateStep2().
|
inline |
Serialize this to/from an archive.
ar | archive |
version | archive version id |
Definition at line 720 of file Tensor.h.
References Util::DimensionSq.
|
static |
Call to guarantee initialization of Zero and Identity tensors.
Call this function once to guarantee that this file is linked.
Definition at line 27 of file Tensor.cpp.
References UTIL_THROW.
Referenced by Util::initStatic().
|
static |
Commit MPI datatype MpiTraits<Tensor>::type.
Definition at line 125 of file Tensor.cpp.
References Util::MpiStructBuilder::addMember(), Util::MpiStructBuilder::commit(), Util::Dimension, and Util::MpiStructBuilder::setBase().
Equality for Tensors.
Definition at line 43 of file Tensor.cpp.
|
friend |
Equality of Tensor and 2D C array.
Definition at line 56 of file Tensor.cpp.
|
friend |
istream extractor for a Tensor.
Input elements of a tensor from stream, without line breaks.
in | input stream |
tensor | Tensor to be read from stream |
Definition at line 93 of file Tensor.cpp.
|
friend |
ostream inserter for a Tensor.
Output elements of a tensor to stream, without line breaks.
out | output stream |
tensor | Tensor to be written to stream |
Definition at line 104 of file Tensor.cpp.
Constant idenity Tensor (diagonal diagonal elements all 1).
Definition at line 302 of file Tensor.h.
Referenced by McMd::MdEwaldPotential::computeStress(), and McMd::MdSpmePotential::computeStress().