libMesh
type_tensor.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 
21 // C++ includes
22 #include <iostream>
23 #include <iomanip> // for std::setw, std::setiosflags
24 
25 // Local includes
26 #include "libmesh/type_tensor.h"
27 
28 namespace libMesh
29 {
30 
31 
32 
33 
34 // ------------------------------------------------------------
35 // TypeTensor<T> class member functions
36 
37 
38 template <typename T>
39 void TypeTensor<T>::write_unformatted (std::ostream & out_stream,
40  const bool newline) const
41 {
42  libmesh_assert (out_stream);
43 
44  out_stream << std::setiosflags(std::ios::showpoint)
45  << (*this)(0,0) << " "
46  << (*this)(0,1) << " "
47  << (*this)(0,2) << " ";
48  if (newline)
49  out_stream << '\n';
50 
51  out_stream << std::setiosflags(std::ios::showpoint)
52  << (*this)(1,0) << " "
53  << (*this)(1,1) << " "
54  << (*this)(1,2) << " ";
55  if (newline)
56  out_stream << '\n';
57 
58  out_stream << std::setiosflags(std::ios::showpoint)
59  << (*this)(2,0) << " "
60  << (*this)(2,1) << " "
61  << (*this)(2,2) << " ";
62  if (newline)
63  out_stream << '\n';
64 }
65 
66 
67 
68 template <>
70 {
71  for (unsigned int i=0; i<LIBMESH_DIM; i++)
72  for (unsigned int j=0; j<LIBMESH_DIM; j++)
73  {
74  if ((*this)(i,j) < rhs(i,j))
75  return true;
76  if ((*this)(i,j) > rhs(i,j))
77  return false;
78  }
79  return false;
80 }
81 
82 
83 
84 template <>
86 {
87  for (unsigned int i=0; i<LIBMESH_DIM; i++)
88  for (unsigned int j=0; j<LIBMESH_DIM; j++)
89  {
90  if ((*this)(i,j) > rhs(i,j))
91  return true;
92  if ((*this)(i,j) < rhs(i,j))
93  return false;
94  }
95  return false;
96 }
97 
98 
99 
100 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
101 template <>
103 {
104  for (unsigned int i=0; i<LIBMESH_DIM; i++)
105  for (unsigned int j=0; j<LIBMESH_DIM; j++)
106  {
107  if ((*this)(i,j).real() < rhs(i,j).real())
108  return true;
109  if ((*this)(i,j).real() > rhs(i,j).real())
110  return false;
111  if ((*this)(i,j).imag() < rhs(i,j).imag())
112  return true;
113  if ((*this)(i,j).imag() > rhs(i,j).imag())
114  return false;
115  }
116  return false;
117 }
118 
119 
120 
121 template <>
123 {
124  for (unsigned int i=0; i<LIBMESH_DIM; i++)
125  for (unsigned int j=0; j<LIBMESH_DIM; j++)
126  {
127  if ((*this)(i,j).real() > rhs(i,j).real())
128  return true;
129  if ((*this)(i,j).real() < rhs(i,j).real())
130  return false;
131  if ((*this)(i,j).imag() > rhs(i,j).imag())
132  return true;
133  if ((*this)(i,j).imag() < rhs(i,j).imag())
134  return false;
135  }
136  return false;
137 }
138 
139 
140 
141 #endif
142 
143 
144 
145 // ------------------------------------------------------------
146 // Explicit instantiations
147 template class LIBMESH_EXPORT TypeTensor<Real>;
148 
149 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
150 template class LIBMESH_EXPORT TypeTensor<Complex>;
151 #endif
152 
153 } // namespace libMesh
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
bool operator<(const TypeTensor< T > &rhs) const
The libMesh namespace provides an interface to certain functionality in the library.
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
Definition: tensor_tools.h:36
libmesh_assert(ctx)
void write_unformatted(std::ostream &out_stream, const bool newline=true) const
Unformatted print to the stream out.
Definition: type_tensor.C:39
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
bool operator>(const TypeTensor< T > &rhs) const