35 #include "libmesh/numeric_vector.h"    36 #include "libmesh/dof_map.h"    42 _discipline       (nullptr),
    44 _sol_function     (nullptr),
    45 _solver_monitor   (nullptr),
    46 _param_dependence (nullptr) {
    65                        "Error: Discipline not yet attached to Assembly.");
    75                        "Error: Discipline not yet attached to Assembly.");
    86                        "Error: System not yet attached to Assembly.");
    95                        "Error: System not yet attached to Assembly.");
   104                        "Error: Not yet initialized.");
   113                        "Error: System not yet attached to Assembly.");
   166                        "Error: Assembly should be cleared before attaching System.");
   190                        "Error: Assembly should be cleared before attaching Elem.");
   209 std::unique_ptr<libMesh::NumericVector<Real> >
   212                        const libMesh::NumericVector<Real>& global)
 const {
   214     libMesh::NumericVector<Real>* local =
   215     libMesh::NumericVector<Real>::build(sys.comm()).release();
   217     const std::vector<libMesh::dof_id_type>& send_list =
   218     sys.get_dof_map().get_send_list();
   220     local->init(sys.n_dofs(),
   225     global.localize(*local, send_list);
   227     return std::unique_ptr<libMesh::NumericVector<Real> >(local);
   255                                      bool if_localize_sol,
   270     std::vector<libMesh::dof_id_type> dof_indices;
   271     const libMesh::DofMap& dof_map = 
_system->
system().get_dof_map();
   273     const libMesh::NumericVector<Real>*
   276     std::unique_ptr<libMesh::NumericVector<Real> > localized_solution;
   277     if (if_localize_sol) {
   279         sol_vec = localized_solution.get();
   289     libMesh::MeshBase::const_element_iterator       el     =
   290     nonlin_sys.get_mesh().active_local_elements_begin();
   291     const libMesh::MeshBase::const_element_iterator end_el =
   292     nonlin_sys.get_mesh().active_local_elements_end();
   295     for ( ; el != end_el; ++el) {
   297         const libMesh::Elem* elem = *el;
   311         dof_map.dof_indices (elem, dof_indices);
   314         unsigned int ndofs = (
unsigned int)dof_indices.size();
   317         for (
unsigned int i=0; i<dof_indices.size(); i++)
   318             sol(i) = (*sol_vec)(dof_indices[i]);
   320         output.
init(geom_elem);
   341                             bool if_localize_sol,
   343                             libMesh::NumericVector<Real>& dq_dX) {
   359     std::vector<libMesh::dof_id_type> dof_indices;
   360     const libMesh::DofMap& dof_map = 
_system->
system().get_dof_map();
   362     const libMesh::NumericVector<Real>*
   365     std::unique_ptr<libMesh::NumericVector<Real> > localized_solution;
   367     if (if_localize_sol) {
   369         sol_vec = localized_solution.get();
   379     libMesh::MeshBase::const_element_iterator       el     =
   380     nonlin_sys.get_mesh().active_local_elements_begin();
   381     const libMesh::MeshBase::const_element_iterator end_el =
   382     nonlin_sys.get_mesh().active_local_elements_end();
   385     for ( ; el != end_el; ++el) {
   387         const libMesh::Elem* elem = *el;
   398         dof_map.dof_indices (elem, dof_indices);
   401         unsigned int ndofs = (
unsigned int)dof_indices.size();
   405         for (
unsigned int i=0; i<dof_indices.size(); i++)
   406             sol(i) = (*sol_vec)(dof_indices[i]);
   411         output.
init(geom_elem);
   418         dof_map.constrain_element_vector(v, dof_indices);
   419         dq_dX.add_vector(v, dof_indices);
   437                                     bool if_localize_sol,
   438                                     const libMesh::NumericVector<Real>* dXdp,
   439                                     bool if_localize_sol_sens,
   457     std::vector<libMesh::dof_id_type> dof_indices;
   458     const libMesh::DofMap& dof_map = 
_system->
system().get_dof_map();
   460     const libMesh::NumericVector<Real>
   464     std::unique_ptr<libMesh::NumericVector<Real> >
   466     localized_solution_sens;
   468     if (if_localize_sol) {
   470         sol_vec = localized_solution.get();
   476         if (if_localize_sol_sens) {
   478             dsol_vec = localized_solution_sens.get();
   490     libMesh::MeshBase::const_element_iterator       el     =
   491     nonlin_sys.get_mesh().active_local_elements_begin();
   492     const libMesh::MeshBase::const_element_iterator end_el =
   493     nonlin_sys.get_mesh().active_local_elements_end();
   496     for ( ; el != end_el; ++el) {
   498         const libMesh::Elem* elem = *el;
   519         dof_map.dof_indices (elem, dof_indices);
   522         unsigned int ndofs = (
unsigned int)dof_indices.size();
   526         for (
unsigned int i=0; i<dof_indices.size(); i++) {
   527             sol(i)  = (*sol_vec)(dof_indices[i]);
   529                 dsol(i) = (*dsol_vec)(dof_indices[i]);
   536         output.
init(geom_elem);
   558                                      bool if_localize_sol,
   559                                      const libMesh::NumericVector<Real>& adj_sol,
   563                                      const bool include_partial_sens) {
   570     libMesh::NumericVector<Real>
   571     &dres_dp = nonlin_sys.add_sensitivity_rhs();
   578     dq_dp = adj_sol.dot(dres_dp);
   580     if (include_partial_sens) {
   596 (
const libMesh::NumericVector<Real>&           X,
   597  bool                                          if_localize_sol,
   598  const libMesh::NumericVector<Real>&           adj_sol,
   599  const std::vector<const MAST::FunctionBase*>& p_vec,
   602  std::vector<Real>&                            sens) {
   606     libmesh_assert_equal_to(sens.size(), p_vec.size());
   611     std::fill(sens.begin(), sens.end(), 0.);
   614     for (
unsigned int i=0; i<p_vec.size(); i++) nonlin_sys.add_sensitivity_rhs(i);
   618     for (
unsigned int i=0; i<p_vec.size(); i++) {
   622         libMesh::NumericVector<Real>
   623         &dres_dp = nonlin_sys.get_sensitivity_rhs(i);
   630     for (
unsigned int i=0; i<p_vec.size(); i++) {
   634         libMesh::NumericVector<Real>
   635         &dres_dp = nonlin_sys.add_sensitivity_rhs(i);
   637         sens[i] = adj_sol.dot(dres_dp);
 
MAST::AssemblyElemOperations * _elem_ops
provides assembly elem operations for use by this class 
const MAST::NonlinearSystem & system() const
MAST::NonlinearSystem & system()
void init(const libMesh::NumericVector< Real > &sol, bool reuse_vector)
initializes the data structures to perform the interpolation function of sol. 
virtual bool if_elem_depends_on_parameter(const libMesh::Elem &e, const MAST::FunctionBase &p) const =0
AssemblyBase()
constructor takes a reference to the discipline that provides the boundary conditions, volume loads, properties, etc. 
void clear_solver_monitor()
clears the monitor object 
This class implements a system for solution of nonlinear systems. 
virtual bool if_evaluate_for_element(const MAST::GeomElem &elem) const
checks to see if the object has been told about the subset of elements and if the specified element i...
virtual void calculate_output_derivative(const libMesh::NumericVector< Real > &X, bool if_localize_sol, MAST::OutputAssemblyElemOperations &output, libMesh::NumericVector< Real > &dq_dX)
calculates  
bool override_flag
if true, assume zero solution sensitivity when elem does not dependent on parameter. 
virtual Real calculate_output_adjoint_sensitivity(const libMesh::NumericVector< Real > &X, bool if_localize_sol, const libMesh::NumericVector< Real > &adj_sol, const MAST::FunctionBase &p, MAST::AssemblyElemOperations &elem_ops, MAST::OutputAssemblyElemOperations &output, const bool include_partial_sens=true)
Evaluates the total sensitivity of output wrt p using the adjoint solution provided in adj_sol for a ...
virtual void clear_elem_operation_object()
clears the association of this object with the assembly element operation object. ...
This provides a wrapper FieldFunction compatible class that interpolates the solution using libMesh's...
void attach_solution_function(MAST::MeshFieldFunction &f)
tells the assembly object that this function is will need to be initialized before each residual eval...
void attach_elem_parameter_dependence_object(MAST::AssemblyBase::ElemParameterDependence &dep)
This object, if provided by user, will be used to reduce unnecessary computations in sensitivity anal...
virtual void set_elem_solution_sensitivity(const RealVectorX &sol)
sets the element solution sensitivity 
void set_solver_monitor(MAST::AssemblyBase::SolverMonitor &monitor)
attaches the solver monitor, which is a user provided routine that is called each time ...
virtual void set_assembly(MAST::AssemblyBase &assembly)
sets the assembly object 
This provides the base class for definitin of element level contribution of output quantity in an ana...
virtual void zero_for_sensitivity()=0
zeroes the output quantity values stored inside this object so that assembly process can begin...
bool close_matrix
flag to control the closing fo the Jacobian after assembly 
virtual void set_elem_operation_object(MAST::AssemblyElemOperations &elem_ops)
attaches a element operation to this object, and associated this with the element operation object...
virtual void set_elem_solution(const RealVectorX &sol)
sets the element solution 
virtual void evaluate()=0
this is the abstract interface to be implemented by derived classes. 
std::set< unsigned int > diagonal_elem_subdomain_id
subdomain ids for which residuakl and Jacobian contributions will not be computed. 
MAST::SystemInitialization * _system
System for which this assembly is performed. 
virtual void calculate_output(const libMesh::NumericVector< Real > &X, bool if_localize_sol, MAST::OutputAssemblyElemOperations &output)
calculates the value of quantity . 
void detach_solution_function()
removes the attachment of the solution function 
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...
virtual void clear_discipline_and_system()
clears association with a system to this discipline 
libMesh::DenseVector< Real > DenseRealVector
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...
virtual void clear_assembly()
clears the assembly object 
void copy(DenseRealMatrix &m1, const RealMatrixX &m2)
void clear()
clear the solution 
Matrix< Real, Dynamic, 1 > RealVectorX
virtual Real output_sensitivity_total(const MAST::FunctionBase &p)=0
virtual void init(const MAST::GeomElem &elem)=0
initializes the object for calculation of element quantities for the specified elem. 
virtual void output_derivative_for_elem(RealVectorX &dq_dX)=0
returns the output quantity derivative with respect to state vector in dq_dX. 
virtual void calculate_output_direct_sensitivity(const libMesh::NumericVector< Real > &X, bool if_localize_sol, const libMesh::NumericVector< Real > *dXdp, bool if_localize_sol_sens, const MAST::FunctionBase &p, MAST::OutputAssemblyElemOperations &output)
evaluates the sensitivity of the outputs in the attached discipline with respect to the parametrs in ...
void clear_elem_parameter_dependence_object()
MAST::AssemblyBase::SolverMonitor * get_solver_monitor()
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
Inherited objects from this class can be provided by the user provide assessment of whether or not an...
virtual void calculate_output_adjoint_sensitivity_multiple_parameters_no_direct(const libMesh::NumericVector< Real > &X, bool if_localize_sol, const libMesh::NumericVector< Real > &adj_sol, const std::vector< const MAST::FunctionBase *> &p_vec, MAST::AssemblyElemOperations &elem_ops, MAST::OutputAssemblyElemOperations &output, std::vector< Real > &sens)
Evaluates the dot product between adj_sol and sensitivity of residual about X for multiple parameter_...
MAST::SystemInitialization & system_init()
virtual void zero_for_analysis()=0
zeroes the output quantity values stored inside this object so that assembly process can begin...
MAST::AssemblyBase::ElemParameterDependence * _param_dependence
If provided by user, this object is used by sensitiivty analysis to check for whether or the current ...
virtual void set_discipline_and_system(MAST::PhysicsDisciplineBase &discipline, MAST::SystemInitialization &system)
attaches a system to this discipline 
virtual void clear_elem()
clears the element initialization 
const MAST::PhysicsDisciplineBase & discipline() const
virtual ~AssemblyBase()
virtual destructor 
MAST::AssemblyElemOperations & get_elem_ops()
virtual void init(const libMesh::Elem &elem, const MAST::SystemInitialization &sys_init)
initialize the object for the specified reference elem. 
MAST::AssemblyBase::SolverMonitor * _solver_monitor
User provided solver monitor is attached to the linear nonlinear solvers, if provided. 
virtual void evaluate_sensitivity(const MAST::FunctionBase &f)=0
this evaluates all relevant sensitivity components on the element. 
MAST::MeshFieldFunction * _sol_function
system solution that will be initialized before each solution 
virtual bool sensitivity_assemble(const libMesh::NumericVector< Real > &X, bool if_localize_sol, const MAST::FunctionBase &f, libMesh::NumericVector< Real > &sensitivity_rhs, bool close_vector=true)
Assembly function.