ResInsight/Fwk/AppFwk/cafTensor/cafTensor3.h

75 lines
2.1 KiB
C
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
2020-06-19 00:53:59 -05:00
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2020-06-19 00:53:59 -05:00
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
2020-06-19 00:53:59 -05:00
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfVector3.h"
namespace caf
{
2020-06-19 00:53:59 -05:00
template <typename S>
class Tensor3
{
S m_tensor[6]; // SXX, SYY, SZZ, SXY, SYZ, SZX
public:
Tensor3();
2020-06-19 00:53:59 -05:00
Tensor3( S sxx, S syy, S szz, S sxy, S syz, S szx );
Tensor3( const Tensor3& other );
template <typename T>
explicit Tensor3( const Tensor3<T>& other );
2020-06-19 00:53:59 -05:00
static Tensor3 invalid();
2020-06-19 00:53:59 -05:00
inline Tensor3& operator=( const Tensor3& rhs );
inline Tensor3 operator+( const Tensor3& rhs ) const;
inline Tensor3 operator*( S scale ) const;
2020-06-19 00:53:59 -05:00
bool equals( const Tensor3& mat ) const;
bool operator==( const Tensor3& rhs ) const;
bool operator!=( const Tensor3& rhs ) const;
2020-06-19 00:53:59 -05:00
enum TensorComponentEnum
{
SXX,
SYY,
SZZ,
SXY,
SYZ,
SZX
};
inline S& operator[]( TensorComponentEnum comp );
inline S operator[]( TensorComponentEnum comp ) const;
2020-06-19 00:53:59 -05:00
void setFromInternalLayout( S* tensorData );
void setFromAbaqusLayout( S* tensorData );
2020-06-19 00:53:59 -05:00
cvf::Vec3f calculatePrincipals( cvf::Vec3f principalDirections[3] ) const;
float calculateVonMises() const;
2020-06-19 00:53:59 -05:00
Tensor3 rotated( const cvf::Matrix3<S>& rotMx ) const;
};
2020-06-19 00:53:59 -05:00
typedef Tensor3<float> Ten3f;
typedef Tensor3<double> Ten3d;
2020-06-19 00:53:59 -05:00
} // namespace caf
#include "cafTensor3.inl"