20 #ifndef __mast_utility__ 21 #define __mast_utility__ 28 #include "libmesh/parallel.h" 33 template <
typename ValType>
42 const unsigned int n = v.size();
43 libmesh_assert_equal_to(v_real.size(), n);
52 const unsigned int n = v.size();
53 libmesh_assert_equal_to(v_real.size(), 2*n);
55 for (
unsigned int i=0; i<n; i++)
56 v(i) =
Complex(v_real(i), v_real(i+n));
61 template <
typename ValType>
70 const unsigned int mm = m.m(), nn = m.n();
71 libmesh_assert_equal_to(m_real.m(), mm);
72 libmesh_assert_equal_to(m_real.n(), nn);
81 const unsigned int mm = m.m(), nn = m.n();
82 libmesh_assert_equal_to(m_real.m(), 2*mm);
83 libmesh_assert_equal_to(m_real.n(), 2*nn);
85 for (
unsigned int i=0; i<mm; i++)
86 for (
unsigned int j=0; j<nn; j++)
87 m(i,j) =
Complex(m_real(i,j), -m_real(i,j+nn));
97 template <
typename ValType>
99 const ValType& elem_vec);
108 template <
typename ValType>
110 const ValType& elem_mat);
117 assembled_mat += elem_mat;
125 assembled_vec += elem_vec;
136 m = (
unsigned int)elem_mat.rows(),
137 n = (
unsigned int)elem_mat.cols();
138 libmesh_assert_equal_to(assembled_mat.rows(), m*2);
139 libmesh_assert_equal_to(assembled_mat.cols(), n*2);
140 for (
unsigned int i=0; i<m; i++)
141 for (
unsigned int j=0; j<n; j++) {
142 assembled_mat(i,j) += std::real(elem_mat(i,j));
143 assembled_mat(i+m,j+n) += std::real(elem_mat(i,j));
144 assembled_mat(i,j+n) += -std::imag(elem_mat(i,j));
145 assembled_mat(i+m,j) += std::imag(elem_mat(i,j));
155 const unsigned int n = (
unsigned int)elem_vec.size();
156 libmesh_assert_equal_to(assembled_vec.size(), n*2);
158 for (
unsigned int i=0; i<n; i++) {
159 assembled_vec(i) += std::real(elem_vec(i));
160 assembled_vec(i+n) += std::imag(elem_vec(i));
169 const unsigned int m=(
unsigned int)m2.rows(), n=(
unsigned int)m2.cols();
171 for (
unsigned int i=0; i<m; i++)
172 for (
unsigned int j=0; j<n; j++)
181 const unsigned int m=(
unsigned int)m1.m(), n=(
unsigned int)m1.n();
183 for (
unsigned int i=0; i<m; i++)
184 for (
unsigned int j=0; j<n; j++)
193 const unsigned int m=(
unsigned int)v2.rows();
195 for (
unsigned int i=0; i<m; i++)
203 const unsigned int m=(
unsigned int)v2.size();
205 v1 = RealVectorX::Zero(m);
207 for (
unsigned int i=0; i<m; i++)
218 m = (
unsigned int)mat.rows(),
219 n = (
unsigned int)mat.cols();
221 std::vector<Real> vals(m*n);
222 for (
unsigned int i=0; i<m; i++)
223 for (
unsigned int j=0; j<n; j++)
224 vals[m*j+i] = mat(i,j);
228 for (
unsigned int i=0; i<m; i++)
229 for (
unsigned int j=0; j<n; j++)
230 mat(i,j) = vals[m*j+i];
240 m = (
unsigned int)mat.rows(),
241 n = (
unsigned int)mat.cols();
243 std::vector<Complex> vals(m*n);
244 for (
unsigned int i=0; i<m; i++)
245 for (
unsigned int j=0; j<n; j++)
246 vals[m*j+i] = mat(i,j);
250 for (
unsigned int i=0; i<m; i++)
251 for (
unsigned int j=0; j<n; j++)
252 mat(i,j) = vals[m*j+i];
260 #endif // __mast_utility__ libMesh::DenseMatrix< Real > DenseRealMatrix
void add_to_assembled_matrix(RealMatrixX &assembled_mat, const ValType &elem_mat)
All calculations in MAST are done using Real numbers.
void transform_to_elem_vector(libMesh::DenseVector< ValType > &v, const DenseRealVector &v_real)
Matrix< Complex, Dynamic, 1 > ComplexVectorX
libMesh::DenseVector< Real > DenseRealVector
void transform_to_elem_matrix(libMesh::DenseMatrix< ValType > &m, const DenseRealMatrix &m_real)
Matrix< Real, Dynamic, Dynamic > RealMatrixX
void parallel_sum(const libMesh::Parallel::Communicator &c, RealMatrixX &mat)
Matrix< Complex, Dynamic, Dynamic > ComplexMatrixX
void copy(DenseRealMatrix &m1, const RealMatrixX &m2)
libMesh::DenseMatrix< Complex > DenseComplexMatrix
Matrix< Real, Dynamic, 1 > RealVectorX
libMesh::DenseVector< Complex > DenseComplexVector
void add_to_assembled_vector(RealVectorX &assembled_vec, const ValType &elem_vec)
All calculations in MAST are done using Real numbers.