32 #include "libmesh/numeric_vector.h" 33 #include "libmesh/sparse_matrix.h" 34 #include "libmesh/dof_map.h" 41 _base_sol_sensitivity (nullptr) {
91 libMesh::SparseMatrix<Real>* B) {
100 libMesh::SparseMatrix<Real>
109 std::unique_ptr<libMesh::NumericVector<Real> >
121 std::vector<libMesh::dof_id_type> dof_indices;
122 const libMesh::DofMap& dof_map = eigen_sys.get_dof_map();
125 libMesh::MeshBase::const_element_iterator el =
126 eigen_sys.get_mesh().active_local_elements_begin();
127 const libMesh::MeshBase::const_element_iterator end_el =
128 eigen_sys.get_mesh().active_local_elements_end();
133 for ( ; el != end_el; ++el) {
135 const libMesh::Elem* elem = *el;
137 dof_map.dof_indices (elem, dof_indices);
146 unsigned int ndofs = (
unsigned int)dof_indices.size();
148 mat_A.setZero(ndofs, ndofs);
149 mat_B.setZero(ndofs, ndofs);
153 for (
unsigned int i=0; i<dof_indices.size(); i++)
154 sol(i) = (*localized_solution)(dof_indices[i]);
167 dof_map.constrain_element_matrix(A, dof_indices);
168 dof_map.constrain_element_matrix(B, dof_indices);
170 matrix_A.add_matrix (A, dof_indices);
171 matrix_B.add_matrix (B, dof_indices);
186 libMesh::SparseMatrix<Real>* sensitivity_A,
187 libMesh::SparseMatrix<Real>* sensitivity_B) {
196 libMesh::SparseMatrix<Real>& matrix_A = *sensitivity_A;
197 libMesh::SparseMatrix<Real>& matrix_B = *sensitivity_B;
203 std::unique_ptr<libMesh::NumericVector<Real> >
205 localized_solution_sens;
223 std::vector<libMesh::dof_id_type> dof_indices;
224 const libMesh::DofMap& dof_map = eigen_sys.get_dof_map();
227 libMesh::MeshBase::const_element_iterator el =
228 eigen_sys.get_mesh().active_local_elements_begin();
229 const libMesh::MeshBase::const_element_iterator end_el =
230 eigen_sys.get_mesh().active_local_elements_end();
235 for ( ; el != end_el; ++el) {
237 const libMesh::Elem* elem = *el;
239 dof_map.dof_indices (elem, dof_indices);
248 unsigned int ndofs = (
unsigned int)dof_indices.size();
250 mat_A.setZero(ndofs, ndofs);
251 mat_B.setZero(ndofs, ndofs);
257 for (
unsigned int i=0; i<dof_indices.size(); i++)
258 sol(i) = (*localized_solution)(dof_indices[i]);
266 for (
unsigned int i=0; i<dof_indices.size(); i++)
267 sol(i) = (*localized_solution_sens)(dof_indices[i]);
283 dof_map.constrain_element_matrix(A, dof_indices);
284 dof_map.constrain_element_matrix(B, dof_indices);
286 matrix_A.add_matrix (A, dof_indices);
287 matrix_B.add_matrix (B, dof_indices);
291 sensitivity_A->close();
292 sensitivity_B->close();
MAST::AssemblyElemOperations * _elem_ops
provides assembly elem operations for use by this class
MAST::NonlinearSystem & system()
virtual void eigenproblem_assemble(libMesh::SparseMatrix< Real > *A, libMesh::SparseMatrix< Real > *B)
assembles the matrices for eigenproblem depending on the analysis type
libMesh::DenseMatrix< Real > DenseRealMatrix
This class implements a system for solution of nonlinear systems.
virtual ~EigenproblemAssembly()
destructor resets the association with the eigen system from this assembly object ...
void set_base_solution(const libMesh::NumericVector< Real > &sol, bool if_sens=false)
if the eigenproblem is defined about a non-zero base solution, then this method provides the object w...
virtual void set_elem_solution_sensitivity(const RealVectorX &sol)
sets the element solution sensitivity
virtual void elem_calculations(RealMatrixX &mat_A, RealMatrixX &mat_B)=0
performs the element calculations over elem, and returns the element matrices for the eigenproblem ...
virtual void set_elem_solution(const RealVectorX &sol)
sets the element solution
MAST::SystemInitialization * _system
System for which this assembly is performed.
MAST::PhysicsDisciplineBase * _discipline
PhysicsDisciplineBase object for which this class is assembling.
virtual void set_elem_data(unsigned int dim, const libMesh::Elem &ref_elem, MAST::GeomElem &elem) const =0
some analyses may want to set additional element data before initialization of the GeomElem...
void clear_base_solution(bool if_sens=false)
Clears the pointer to the solution.
virtual bool eigenproblem_sensitivity_assemble(const MAST::FunctionBase &f, libMesh::SparseMatrix< Real > *sensitivity_A, libMesh::SparseMatrix< Real > *sensitivity_B)
Assembly function.
Matrix< Real, Dynamic, Dynamic > RealMatrixX
const libMesh::NumericVector< Real > * _base_sol
base solution about which this eigenproblem is defined.
void copy(DenseRealMatrix &m1, const RealMatrixX &m2)
Matrix< Real, Dynamic, 1 > RealVectorX
virtual void init(const MAST::GeomElem &elem)=0
initializes the object for calculation of element quantities for the specified elem.
std::unique_ptr< libMesh::NumericVector< Real > > build_localized_vector(const libMesh::System &sys, const libMesh::NumericVector< Real > &global) const
localizes the parallel vector so that the local copy stores all values necessary for calculation of t...
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
const libMesh::NumericVector< Real > * _base_sol_sensitivity
sensitivity of base solution may be needed for sensitivity analysis.
virtual void elem_sensitivity_calculations(const MAST::FunctionBase &f, bool base_sol, RealMatrixX &mat_A, RealMatrixX &mat_B)=0
performs the element sensitivity calculations over elem, and returns the element matrices for the eig...
virtual void clear_elem()
clears the element initialization
virtual void init(const libMesh::Elem &elem, const MAST::SystemInitialization &sys_init)
initialize the object for the specified reference elem.
EigenproblemAssembly()
constructor associates the eigen system with this assembly object