Skip to content

Commit 3e4dba2

Browse files
authored
Merge pull request #4130 from lindsayad/print-in-headers
Further migration of print implementations to headers
2 parents 27e3784 + 22850dc commit 3e4dba2

4 files changed

Lines changed: 50 additions & 55 deletions

File tree

include/numerics/dense_vector_base.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
// Local Includes
2525
#include "libmesh/libmesh_common.h"
26+
#include "libmesh/int_range.h"
2627

2728
// C++ includes
2829

@@ -105,6 +106,15 @@ class DenseVectorBase
105106
void print_scientific(std::ostream & os, unsigned precision=8) const;
106107
};
107108

109+
template<typename T>
110+
void DenseVectorBase<T>::print (std::ostream & os) const
111+
{
112+
for (auto i : make_range(this->size()))
113+
os << std::setw(8)
114+
<< this->el(i)
115+
<< std::endl;
116+
}
117+
108118
} // namespace libMesh
109119

110120

include/numerics/type_tensor.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,46 @@ bool TypeTensor<T>::operator == (const TypeTensor<T> & rhs) const
13871387

13881388
}
13891389

1390+
template <typename T>
1391+
void TypeTensor<T>::print(std::ostream & os) const
1392+
{
1393+
#if LIBMESH_DIM == 1
1394+
1395+
os << "x=" << (*this)(0,0) << std::endl;
1396+
1397+
#endif
1398+
#if LIBMESH_DIM == 2
1399+
1400+
os << "(xx,xy)=("
1401+
<< std::setw(8) << (*this)(0,0) << ", "
1402+
<< std::setw(8) << (*this)(0,1) << ")"
1403+
<< std::endl;
1404+
os << "(yx,yy)=("
1405+
<< std::setw(8) << (*this)(1,0) << ", "
1406+
<< std::setw(8) << (*this)(1,1) << ")"
1407+
<< std::endl;
1408+
1409+
#endif
1410+
#if LIBMESH_DIM == 3
1411+
1412+
os << "(xx,xy,xz)=("
1413+
<< std::setw(8) << (*this)(0,0) << ", "
1414+
<< std::setw(8) << (*this)(0,1) << ", "
1415+
<< std::setw(8) << (*this)(0,2) << ")"
1416+
<< std::endl;
1417+
os << "(yx,yy,yz)=("
1418+
<< std::setw(8) << (*this)(1,0) << ", "
1419+
<< std::setw(8) << (*this)(1,1) << ", "
1420+
<< std::setw(8) << (*this)(1,2) << ")"
1421+
<< std::endl;
1422+
os << "(zx,zy,zz)=("
1423+
<< std::setw(8) << (*this)(2,0) << ", "
1424+
<< std::setw(8) << (*this)(2,1) << ", "
1425+
<< std::setw(8) << (*this)(2,2) << ")"
1426+
<< std::endl;
1427+
#endif
1428+
}
1429+
13901430
template <typename T, typename T2>
13911431
inline
13921432
TypeTensor<typename CompareTypes<T, T2>::supertype>

src/numerics/dense_vector_base.C

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,6 @@ void DenseVectorBase<T>::print_scientific (std::ostream & os, unsigned precision
4646
}
4747

4848

49-
50-
template<typename T>
51-
void DenseVectorBase<T>::print (std::ostream & os) const
52-
{
53-
for (auto i : make_range(this->size()))
54-
os << std::setw(8)
55-
<< this->el(i)
56-
<< std::endl;
57-
}
58-
59-
6049
//--------------------------------------------------------------
6150
// Explicit instantiations
6251
template class LIBMESH_EXPORT DenseVectorBase<Real>;

src/numerics/type_tensor.C

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -35,50 +35,6 @@ namespace libMesh
3535
// TypeTensor<T> class member functions
3636

3737

38-
template <typename T>
39-
void TypeTensor<T>::print(std::ostream & os) const
40-
{
41-
#if LIBMESH_DIM == 1
42-
43-
os << "x=" << (*this)(0,0) << std::endl;
44-
45-
#endif
46-
#if LIBMESH_DIM == 2
47-
48-
os << "(xx,xy)=("
49-
<< std::setw(8) << (*this)(0,0) << ", "
50-
<< std::setw(8) << (*this)(0,1) << ")"
51-
<< std::endl;
52-
os << "(yx,yy)=("
53-
<< std::setw(8) << (*this)(1,0) << ", "
54-
<< std::setw(8) << (*this)(1,1) << ")"
55-
<< std::endl;
56-
57-
#endif
58-
#if LIBMESH_DIM == 3
59-
60-
os << "(xx,xy,xz)=("
61-
<< std::setw(8) << (*this)(0,0) << ", "
62-
<< std::setw(8) << (*this)(0,1) << ", "
63-
<< std::setw(8) << (*this)(0,2) << ")"
64-
<< std::endl;
65-
os << "(yx,yy,yz)=("
66-
<< std::setw(8) << (*this)(1,0) << ", "
67-
<< std::setw(8) << (*this)(1,1) << ", "
68-
<< std::setw(8) << (*this)(1,2) << ")"
69-
<< std::endl;
70-
os << "(zx,zy,zz)=("
71-
<< std::setw(8) << (*this)(2,0) << ", "
72-
<< std::setw(8) << (*this)(2,1) << ", "
73-
<< std::setw(8) << (*this)(2,2) << ")"
74-
<< std::endl;
75-
#endif
76-
}
77-
78-
79-
80-
81-
8238
template <typename T>
8339
void TypeTensor<T>::write_unformatted (std::ostream & out_stream,
8440
const bool newline) const

0 commit comments

Comments
 (0)