Commit a400bfae by Mark Olesen Committed by Andrew Heather

### ENH: add rows/cols setters to Tensor, Tensor2D

`- also support transposed construction when given a set of vectors`
parent 0d71607b
 ... ... @@ -111,15 +111,22 @@ public: //- Construct given SymmTensor inline Tensor(const SymmTensor& st); //- Construct given triad of row vectors inline Tensor(const Vector>& tr); //- Construct given triad of row vectors, //- optionally treated as transposed (ie, column vectors) inline Tensor ( const Vector>& vecs, const bool transposed = false ); //- Construct given the three row vectors //- Construct given the three row vectors, //- optionally treated as transposed (ie, column vectors) inline Tensor ( const Vector& x, const Vector& y, const Vector& z const Vector& z, const bool transposed = false ); //- Construct given the nine components ... ... @@ -200,6 +207,14 @@ public: // Runtime check of column index. inline void col(const direction c, const Vector& v); //- Set column values inline void cols ( const Vector& x, const Vector& y, const Vector& z ); // Row-vector access. ... ... @@ -230,6 +245,14 @@ public: // Runtime check of row index. inline void row(const direction r, const Vector& v); //- Set row values inline void rows ( const Vector& x, const Vector& y, const Vector& z ); // Diagonal access. ... ...
 ... ... @@ -66,10 +66,12 @@ inline Foam::Tensor::Tensor template inline Foam::Tensor::Tensor(const SphericalTensor& st) : Tensor::msType(Zero) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0; this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0; this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii(); this->v_[XX] = st.ii(); this->v_[YY] = st.ii(); this->v_[ZZ] = st.ii(); } ... ... @@ -83,20 +85,14 @@ inline Foam::Tensor::Tensor(const SymmTensor& st) template inline Foam::Tensor::Tensor(const Vector>& tr) { this->v_[XX] = tr.x().x(); this->v_[XY] = tr.x().y(); this->v_[XZ] = tr.x().z(); this->v_[YX] = tr.y().x(); this->v_[YY] = tr.y().y(); this->v_[YZ] = tr.y().z(); this->v_[ZX] = tr.z().x(); this->v_[ZY] = tr.z().y(); this->v_[ZZ] = tr.z().z(); } inline Foam::Tensor::Tensor ( const Vector>& vecs, const bool transposed ) : Tensor(vecs.x(), vecs.y(), vecs.z(), transposed) {} template ... ... @@ -104,12 +100,18 @@ inline Foam::Tensor::Tensor ( const Vector& x, const Vector& y, const Vector& z const Vector& z, const bool transposed ) { this->v_[XX] = x.x(); this->v_[XY] = x.y(); this->v_[XZ] = x.z(); this->v_[YX] = y.x(); this->v_[YY] = y.y(); this->v_[YZ] = y.z(); this->v_[ZX] = z.x(); this->v_[ZY] = z.y(); this->v_[ZZ] = z.z(); if (transposed) { this->cols(x, y, z); } else { this->rows(x, y, z); } } ... ... @@ -428,6 +430,34 @@ inline void Foam::Tensor::row(const Vector& v) } template inline void Foam::Tensor::cols ( const Vector& x, const Vector& y, const Vector& z ) { this->v_[XX] = x.x(); this->v_[XY] = y.x(); this->v_[XZ] = z.x(); this->v_[YX] = x.y(); this->v_[YY] = y.y(); this->v_[YZ] = z.y(); this->v_[ZX] = x.z(); this->v_[ZY] = y.z(); this->v_[ZZ] = z.z(); } template inline void Foam::Tensor::rows ( const Vector& x, const Vector& y, const Vector& z ) { this->v_[XX] = x.x(); this->v_[XY] = x.y(); this->v_[XZ] = x.z(); this->v_[YX] = y.x(); this->v_[YY] = y.y(); this->v_[YZ] = y.z(); this->v_[ZX] = z.x(); this->v_[ZY] = z.y(); this->v_[ZZ] = z.z(); } template inline void Foam::Tensor::col(const direction c, const Vector& v) { ... ...
 ... ... @@ -159,6 +159,9 @@ public: // Runtime check of column index. inline void col(const direction c, const Vector2D& v); //- Set column values inline void cols(const Vector2D& x, const Vector2D& y); // Row-vector access. ... ... @@ -186,6 +189,9 @@ public: // Runtime check of row index. inline void row(const direction r, const Vector2D& v); //- Set row values inline void rows(const Vector2D& x, const Vector2D& y); // Diagonal access. ... ...
 ... ... @@ -60,9 +60,11 @@ inline Foam::Tensor2D::Tensor2D(const SymmTensor2D& st) template inline Foam::Tensor2D::Tensor2D(const SphericalTensor2D& st) : Tensor2D::msType(Zero) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[XX] = st.ii(); this->v_[YY] = st.ii(); } ... ... @@ -267,6 +269,30 @@ inline void Foam::Tensor2D::row(const Vector2D& v) } template inline void Foam::Tensor2D::cols ( const Vector2D& x, const Vector2D& y ) { this->v_[XX] = x.x(); this->v_[XY] = y.x(); this->v_[YX] = x.y(); this->v_[YY] = y.y(); } template inline void Foam::Tensor2D::rows ( const Vector2D& x, const Vector2D& y ) { this->v_[XX] = x.x(); this->v_[XY] = x.y(); this->v_[YX] = y.x(); this->v_[YY] = y.y(); } template inline void Foam::Tensor2D::col ( ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!