33 #include "libmesh/numeric_vector.h" 34 #include "libmesh/sparse_matrix.h" 35 #include "libmesh/dof_map.h" 36 #include "libmesh/petsc_nonlinear_solver.h" 37 #include "libmesh/petsc_vector.h" 45 _base_sol_sensitivity (nullptr) {
108 (std::vector<libMesh::NumericVector<Real>*>& basis,
109 std::map<MAST::StructuralQuantityType, RealMatrixX*>& mat_qty_map) {
116 n_basis = (
unsigned int)basis.size();
119 std::map<MAST::StructuralQuantityType, RealMatrixX*>::iterator
120 it = mat_qty_map.begin(),
121 end = mat_qty_map.end();
123 for ( ; it != end; it++)
124 *it->second = RealMatrixX::Zero(n_basis, n_basis);
131 std::vector<libMesh::dof_id_type> dof_indices;
132 const libMesh::DofMap& dof_map = nonlin_sys.get_dof_map();
135 std::unique_ptr<libMesh::NumericVector<Real> > localized_solution;
141 std::vector<libMesh::NumericVector<Real>*> localized_basis(n_basis);
142 for (
unsigned int i=0; i<n_basis; i++)
151 libMesh::MeshBase::const_element_iterator el =
152 nonlin_sys.get_mesh().active_local_elements_begin();
153 const libMesh::MeshBase::const_element_iterator end_el =
154 nonlin_sys.get_mesh().active_local_elements_end();
159 for ( ; el != end_el; ++el) {
161 const libMesh::Elem* elem = *el;
163 dof_map.dof_indices (elem, dof_indices);
166 unsigned int ndofs = (
unsigned int)dof_indices.size();
169 mat.setZero(ndofs, ndofs);
170 basis_mat.setZero(ndofs, n_basis);
172 for (
unsigned int i=0; i<dof_indices.size(); i++) {
175 sol(i) = (*localized_solution)(dof_indices[i]);
178 for (
unsigned int j=0; j<n_basis; j++)
179 basis_mat(i,j) = (*localized_basis[j])(dof_indices[i]);
197 it = mat_qty_map.begin();
198 end = mat_qty_map.end();
200 for ( ; it != end; it++) {
207 dof_map.constrain_element_matrix(m, dof_indices);
211 (*it->second) += basis_mat.transpose() * mat * basis_mat;
226 for (
unsigned int i=0; i<basis.size(); i++)
227 delete localized_basis[i];
230 it = mat_qty_map.begin();
231 end = mat_qty_map.end();
234 for ( ; it != end; it++)
246 std::vector<libMesh::NumericVector<Real>*>& basis,
247 std::map<MAST::StructuralQuantityType, RealMatrixX*>& mat_qty_map) {
253 n_basis = (
unsigned int)basis.size();
257 std::map<MAST::StructuralQuantityType, RealMatrixX*>::iterator
258 it = mat_qty_map.begin(),
259 end = mat_qty_map.end();
261 for ( ; it != end; it++)
262 *it->second = RealMatrixX::Zero(n_basis, n_basis);
269 std::vector<libMesh::dof_id_type> dof_indices;
270 const libMesh::DofMap& dof_map =
_system->
system().get_dof_map();
273 std::unique_ptr<libMesh::NumericVector<Real> >
275 localized_solution_sens;
289 std::vector<libMesh::NumericVector<Real>*> localized_basis(n_basis);
290 for (
unsigned int i=0; i<n_basis; i++)
299 libMesh::MeshBase::const_element_iterator el =
300 nonlin_sys.get_mesh().active_local_elements_begin();
301 const libMesh::MeshBase::const_element_iterator end_el =
302 nonlin_sys.get_mesh().active_local_elements_end();
307 for ( ; el != end_el; ++el) {
309 const libMesh::Elem* elem = *el;
311 dof_map.dof_indices (elem, dof_indices);
315 unsigned int ndofs = (
unsigned int)dof_indices.size();
319 mat.setZero(ndofs, ndofs);
320 basis_mat.setZero(ndofs, n_basis);
327 for (
unsigned int i=0; i<dof_indices.size(); i++) {
332 sol(i) = (*localized_solution)(dof_indices[i]);
333 dsol(i) = (*localized_solution_sens)(dof_indices[i]);
336 for (
unsigned int j=0; j<n_basis; j++)
337 basis_mat(i,j) = (*localized_basis[j])(dof_indices[i]);
349 it = mat_qty_map.begin();
350 end = mat_qty_map.end();
352 for ( ; it != end; it++) {
359 dof_map.constrain_element_matrix(m, dof_indices);
363 (*it->second) += basis_mat.transpose() * mat * basis_mat;
378 for (
unsigned int i=0; i<basis.size(); i++)
379 delete localized_basis[i];
382 it = mat_qty_map.begin();
383 end = mat_qty_map.end();
386 for ( ; it != end; it++)
MAST::AssemblyElemOperations * _elem_ops
provides assembly elem operations for use by this class
MAST::NonlinearSystem & system()
libMesh::DenseMatrix< Real > DenseRealMatrix
void clear_base_solution(bool if_sens=false)
Clears the pointer to base solution.
This class implements a system for solution of nonlinear systems.
void set_qty_to_evaluate(MAST::StructuralQuantityType q)
virtual void set_elem_solution_sensitivity(const RealVectorX &sol)
sets the element solution sensitivity
virtual void assemble_reduced_order_quantity_sensitivity(const MAST::FunctionBase &f, std::vector< libMesh::NumericVector< Real > * > &basis, std::map< MAST::StructuralQuantityType, RealMatrixX * > &mat_qty_map)
calculates the sensitivity of reduced order matrix given the basis provided in basis.
virtual void set_elem_solution(const RealVectorX &sol)
sets the element solution
MAST::SystemInitialization * _system
System for which this assembly is performed.
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...
virtual void clear_discipline_and_system()
clears association with a system to this discipline
StructuralFluidInteractionAssembly()
constructor associates this assembly object with the system
Matrix< Real, Dynamic, Dynamic > RealMatrixX
void parallel_sum(const libMesh::Parallel::Communicator &c, RealMatrixX &mat)
virtual void assemble_reduced_order_quantity(std::vector< libMesh::NumericVector< Real > * > &basis, std::map< MAST::StructuralQuantityType, RealMatrixX * > &mat_qty_map)
calculates the reduced order matrix given the basis provided in basis.
virtual ~StructuralFluidInteractionAssembly()
destructor resets the association of this assembly object with the system
virtual void clear_discipline_and_system()
clears association with a system to this discipline, and vice-a-versa
void copy(DenseRealMatrix &m1, const RealMatrixX &m2)
void clear()
clear the solution
Matrix< Real, Dynamic, 1 > RealVectorX
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 init(const MAST::GeomElem &elem)=0
initializes the object for calculation of element quantities for the specified elem.
virtual void elem_calculations(bool if_jac, RealVectorX &vec, RealMatrixX &mat)
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...
virtual void set_elem_velocity(const RealVectorX &vel)
sets the element velocity
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 if_jac, RealVectorX &vec, RealMatrixX &mat)
void init(const libMesh::NumericVector< Real > &sol, const libMesh::NumericVector< Real > *dsol=nullptr)
initializes the data structures to perform the interpolation function of sol.
const libMesh::NumericVector< Real > * _base_sol
base solution about which this eigenproblem is defined.
virtual void clear_elem()
clears the element initialization
void use_base_sol_for_sensitivity(bool f)
if set to true, the sensitivity calculation will include the sensitivity of base solution.
virtual void init(const libMesh::Elem &elem, const MAST::SystemInitialization &sys_init)
initialize the object for the specified reference elem.
virtual void set_elem_acceleration(const RealVectorX &accel)
sets the element acceleration
MAST::MeshFieldFunction * _sol_function
system solution that will be initialized before each solution