MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
nonlinear_implicit_assembly.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 // MAST includes
25 #include "base/nonlinear_system.h"
28 #include "numerics/utility.h"
29 #include "mesh/geom_elem.h"
30 
31 // libMesh includes
32 #include "libmesh/nonlinear_solver.h"
33 #include "libmesh/numeric_vector.h"
34 #include "libmesh/sparse_matrix.h"
35 #include "libmesh/dof_map.h"
36 
37 
38 
41 _post_assembly (nullptr),
42 _res_l2_norm (0.),
43 _first_iter_res_l2_norm (-1.) {
44 
45 }
46 
47 
48 
50 
51 }
52 
53 
54 
55 void
58 
59  _post_assembly = &post;
60 }
61 
62 
63 
64 void
66 residual_and_jacobian (const libMesh::NumericVector<Real>& X,
67  libMesh::NumericVector<Real>* R,
68  libMesh::SparseMatrix<Real>* J,
69  libMesh::NonlinearImplicitSystem& S) {
70 
71  libmesh_assert(_system);
72  libmesh_assert(_discipline);
73  libmesh_assert(_elem_ops);
74 
75  MAST::NonlinearSystem& nonlin_sys = _system->system();
76 
77  // make sure that the system for which this object was created,
78  // and the system passed through the function call are the same
79  libmesh_assert_equal_to(&S, &(nonlin_sys));
80 
81  if (R) R->zero();
82  if (J) J->zero();
83 
84  // iterate over each element, initialize it and get the relevant
85  // analysis quantities
86  RealVectorX vec, sol;
87  RealMatrixX mat;
88 
89  std::vector<libMesh::dof_id_type> dof_indices;
90  const libMesh::DofMap& dof_map = _system->system().get_dof_map();
91 
92 
93  std::unique_ptr<libMesh::NumericVector<Real> > localized_solution;
94  localized_solution.reset(build_localized_vector(nonlin_sys,
95  X).release());
96 
97 
98  // if a solution function is attached, initialize it
99  if (_sol_function)
100  _sol_function->init( X, false);
101 
102 
103  libMesh::MeshBase::const_element_iterator el =
104  nonlin_sys.get_mesh().active_local_elements_begin();
105  const libMesh::MeshBase::const_element_iterator end_el =
106  nonlin_sys.get_mesh().active_local_elements_end();
107 
109  ops = dynamic_cast<MAST::NonlinearImplicitAssemblyElemOperations&>(*_elem_ops);
110 
111  for ( ; el != end_el; ++el) {
112 
113  const libMesh::Elem* elem = *el;
114 
115  dof_map.dof_indices (elem, dof_indices);
116 
117  if (diagonal_elem_subdomain_id.count(elem->subdomain_id())) {
118 
119  if (J) {
120 
121  unsigned int ndofs = (unsigned int)dof_indices.size();
122  mat.setIdentity(ndofs, ndofs);
123  mat *= 1.e-24;
124  DenseRealMatrix m;
125  MAST::copy(m, mat);
126  dof_map.constrain_element_matrix(m, dof_indices);
127  J->add_matrix(m, dof_indices);
128  dof_indices.clear();
129  }
130  }
131  else {
132 
133  MAST::GeomElem geom_elem;
134  ops.set_elem_data(elem->dim(), *elem, geom_elem);
135  geom_elem.init(*elem, *_system);
136 
137  ops.init(geom_elem);
138 
139  // get the solution
140  unsigned int ndofs = (unsigned int)dof_indices.size();
141  sol.setZero(ndofs);
142  vec.setZero(ndofs);
143  mat.setZero(ndofs, ndofs);
144 
145  for (unsigned int i=0; i<dof_indices.size(); i++)
146  sol(i) = (*localized_solution)(dof_indices[i]);
147 
148  ops.set_elem_solution(sol);
149 
150 
151  // if (_sol_function)
152  // physics_elem->attach_active_solution_function(*_sol_function);
153 
154  //_check_element_numerical_jacobian(*physics_elem, sol);
155 
156  // perform the element level calculations
157  ops.elem_calculations(J!=nullptr?true:false,
158  vec, mat);
159 
160  // physics_elem->detach_active_solution_function();
161 
162  ops.clear_elem();
163 
164  // copy to the libMesh matrix for further processing
165  DenseRealVector v;
166  DenseRealMatrix m;
167  if (R)
168  MAST::copy(v, vec);
169  if (J)
170  MAST::copy(m, mat);
171 
172  // constrain the quantities to account for hanging dofs,
173  // Dirichlet constraints, etc.
174  if (R && J)
175  dof_map.constrain_element_matrix_and_vector(m, v, dof_indices);
176  else if (R)
177  dof_map.constrain_element_vector(v, dof_indices);
178  else
179  dof_map.constrain_element_matrix(m, dof_indices);
180 
181  // add to the global matrices
182  if (R) R->add_vector(v, dof_indices);
183  if (J) J->add_matrix(m, dof_indices);
184  dof_indices.clear();
185  }
186  }
187 
188 
189  // add the point loads if any in the discipline
190  if (R && _discipline->point_loads().size()) {
191 
193  loads = _discipline->point_loads();
194 
195  vec = RealVectorX::Zero(_system->n_vars());
196 
197  MAST::PointLoadSetType::const_iterator
198  it = loads.begin(),
199  end = loads.end();
200 
201  const libMesh::dof_id_type
202  first_dof = dof_map.first_dof(nonlin_sys.comm().rank()),
203  end_dof = dof_map.end_dof(nonlin_sys.comm().rank());
204 
205  for ( ; it != end; it++) {
206 
207  // get the point load function
209  &func = (*it)->get<MAST::FieldFunction<RealVectorX>>("load");
210 
211  // get the nodes on which this object defines the load
212  const std::set<const libMesh::Node*>
213  nodes = (*it)->get_nodes();
214 
215  std::set<const libMesh::Node*>::const_iterator
216  n_it = nodes.begin(),
217  n_end = nodes.end();
218 
219  for (; n_it != n_end; n_it++) {
220 
221  // load at the node
222  vec.setZero();
223  func(**n_it, nonlin_sys.time, vec);
224  // multiply with -1 to be consistent with res(X) = 0, which
225  // requires taking the force vector on RHS to the LHS
226  vec *= -1.;
227 
228  dof_map.dof_indices(*n_it, dof_indices);
229 
230  libmesh_assert_equal_to(dof_indices.size(), vec.rows());
231 
232  // zero the components of the vector if they do not
233  // belong to this processor
234  for (unsigned int i=0; i<dof_indices.size(); i++)
235  if (dof_indices[i] < first_dof ||
236  dof_indices[i] >= end_dof)
237  vec(i) = 0.;
238 
239  DenseRealVector v;
240  MAST::copy(v, vec);
241 
242  dof_map.constrain_element_vector(v, dof_indices);
243  R->add_vector(v, dof_indices);
244  dof_indices.clear();
245  }
246  }
247  }
248 
249  // call the post assembly object, if provided by user
250  if (_post_assembly)
251  _post_assembly->post_assembly(X, R, J, S);
252 
253 
254  // if a solution function is attached, clear it
255  if (_sol_function)
256  _sol_function->clear();
257 
258  if (R) {
259 
260  R->close();
261  _res_l2_norm = R->l2_norm();
262  if (_first_iter_res_l2_norm < 0.)
264  }
265  if (J && close_matrix) J->close();
266 }
267 
268 
269 
270 
271 void
273 linearized_jacobian_solution_product (const libMesh::NumericVector<Real>& X,
274  const libMesh::NumericVector<Real>& dX,
275  libMesh::NumericVector<Real>& JdX,
276  libMesh::NonlinearImplicitSystem& S) {
277 
278  libmesh_assert(_system);
279  libmesh_assert(_discipline);
280  libmesh_assert(_elem_ops);
281 
282  // zero the solution vector
283  JdX.zero();
284 
285  MAST::NonlinearSystem& nonlin_sys = _system->system();
286 
287  // make sure that the system for which this object was created,
288  // and the system passed through the function call are the same
289  libmesh_assert_equal_to(&S, &(nonlin_sys));
290 
291  // iterate over each element, initialize it and get the relevant
292  // analysis quantities
293  RealVectorX vec, sol, dsol;
294  RealMatrixX mat;
295 
296  std::vector<libMesh::dof_id_type> dof_indices;
297  const libMesh::DofMap& dof_map = _system->system().get_dof_map();
298 
299 
300  std::unique_ptr<libMesh::NumericVector<Real> >
301  localized_solution,
302  localized_perturbed_solution;
303 
304  localized_solution.reset(build_localized_vector(nonlin_sys,
305  X).release());
306  localized_perturbed_solution.reset(build_localized_vector(nonlin_sys,
307  dX).release());
308 
309 
310  // if a solution function is attached, initialize it
311  if (_sol_function)
312  _sol_function->init( X, false);
313 
314 
315  libMesh::MeshBase::const_element_iterator el =
316  nonlin_sys.get_mesh().active_local_elements_begin();
317  const libMesh::MeshBase::const_element_iterator end_el =
318  nonlin_sys.get_mesh().active_local_elements_end();
319 
321  ops = dynamic_cast<MAST::NonlinearImplicitAssemblyElemOperations&>(*_elem_ops);
322 
323  for ( ; el != end_el; ++el) {
324 
325  const libMesh::Elem* elem = *el;
326 
327  if (diagonal_elem_subdomain_id.count(elem->subdomain_id()))
328  continue;
329 
330  dof_map.dof_indices (elem, dof_indices);
331 
332  MAST::GeomElem geom_elem;
333  ops.set_elem_data(elem->dim(), *elem, geom_elem);
334  geom_elem.init(*elem, *_system);
335 
336  ops.init(geom_elem);
337 
338  // get the solution
339  unsigned int ndofs = (unsigned int)dof_indices.size();
340  sol.setZero(ndofs);
341  dsol.setZero(ndofs);
342  vec.setZero(ndofs);
343  mat.setZero(ndofs, ndofs);
344 
345  for (unsigned int i=0; i<dof_indices.size(); i++) {
346  sol (i) = (*localized_solution) (dof_indices[i]);
347  dsol(i) = (*localized_perturbed_solution)(dof_indices[i]);
348  }
349 
350  ops.set_elem_solution(sol);
351  ops.set_elem_perturbed_solution(dsol);
352 
353 // if (_sol_function)
354 // physics_elem->attach_active_solution_function(*_sol_function);
355 
356  //_check_element_numerical_jacobian(*physics_elem, sol);
357 
358  // perform the element level calculations
360 
361  //physics_elem->detach_active_solution_function();
362  ops.clear_elem();
363 
364  // copy to the libMesh matrix for further processing
365  DenseRealVector v;
366  MAST::copy(v, vec);
367 
368  // constrain the quantities to account for hanging dofs,
369  // Dirichlet constraints, etc.
370  dof_map.constrain_element_vector(v, dof_indices);
371 
372  // add to the global matrices
373  JdX.add_vector(v, dof_indices);
374  dof_indices.clear();
375  }
376 
377 
378  // if a solution function is attached, clear it
379  if (_sol_function)
380  _sol_function->clear();
381 
382  JdX.close();
383 }
384 
385 
386 
387 void
389 second_derivative_dot_solution_assembly (const libMesh::NumericVector<Real>& X,
390  bool if_localize_sol,
391  const libMesh::NumericVector<Real>& dX,
392  bool if_localize_sol_sens,
393  libMesh::SparseMatrix<Real>& d_JdX_dX,
394  libMesh::NonlinearImplicitSystem& S) {
395 
396  libmesh_assert(_system);
397  libmesh_assert(_discipline);
398  libmesh_assert(_elem_ops);
399 
400  // zero the matrix
401  d_JdX_dX.zero();
402 
403  MAST::NonlinearSystem& nonlin_sys = _system->system();
404 
405  // make sure that the system for which this object was created,
406  // and the system passed through the function call are the same
407  libmesh_assert_equal_to(&S, &(nonlin_sys));
408 
409  // iterate over each element, initialize it and get the relevant
410  // analysis quantities
411  RealVectorX sol, dsol;
412  RealMatrixX mat;
413 
414  std::vector<libMesh::dof_id_type> dof_indices;
415  const libMesh::DofMap& dof_map = _system->system().get_dof_map();
416 
417  const libMesh::NumericVector<Real>
418  *sol_vec = nullptr,
419  *dsol_vec = nullptr;
420 
421  std::unique_ptr<libMesh::NumericVector<Real> >
422  localized_solution,
423  localized_perturbed_solution;
424 
425  if (if_localize_sol) {
426  localized_solution.reset(build_localized_vector(nonlin_sys, X).release());
427  sol_vec = localized_solution.get();
428  }
429  else
430  sol_vec = &X;
431 
432  if (if_localize_sol_sens) {
433  localized_perturbed_solution.reset(build_localized_vector(nonlin_sys, dX).release());
434  dsol_vec = localized_perturbed_solution.get();
435  }
436  else
437  dsol_vec = &dX;
438 
439 
440  // if a solution function is attached, initialize it
441  if (_sol_function)
442  _sol_function->init( X, false);
443 
444 
445  libMesh::MeshBase::const_element_iterator el =
446  nonlin_sys.get_mesh().active_local_elements_begin();
447  const libMesh::MeshBase::const_element_iterator end_el =
448  nonlin_sys.get_mesh().active_local_elements_end();
449 
451  ops = dynamic_cast<MAST::NonlinearImplicitAssemblyElemOperations&>(*_elem_ops);
452 
453  for ( ; el != end_el; ++el) {
454 
455  const libMesh::Elem* elem = *el;
456 
457  if (diagonal_elem_subdomain_id.count(elem->subdomain_id()))
458  continue;
459 
460  dof_map.dof_indices (elem, dof_indices);
461 
462  MAST::GeomElem geom_elem;
463  ops.set_elem_data(elem->dim(), *elem, geom_elem);
464  geom_elem.init(*elem, *_system);
465 
466  ops.init(geom_elem);
467 
468  // get the solution
469  unsigned int ndofs = (unsigned int)dof_indices.size();
470  sol.setZero(ndofs);
471  dsol.setZero(ndofs);
472  mat.setZero(ndofs, ndofs);
473 
474  for (unsigned int i=0; i<dof_indices.size(); i++) {
475  sol (i) = (*sol_vec) (dof_indices[i]);
476  dsol(i) = (*dsol_vec)(dof_indices[i]);
477  }
478 
479  ops.set_elem_solution(sol);
481 
482 // if (_sol_function)
483 // physics_elem->attach_active_solution_function(*_sol_function);
484 
485  // perform the element level calculations
487 
488 // physics_elem->detach_active_solution_function();
489  ops.clear_elem();
490 
491  // copy to the libMesh matrix for further processing
492  DenseRealMatrix m;
493  MAST::copy(m, mat);
494 
495  // constrain the quantities to account for hanging dofs,
496  // Dirichlet constraints, etc.
497  dof_map.constrain_element_matrix(m, dof_indices);
498 
499  // add to the global matrices
500  d_JdX_dX.add_matrix(m, dof_indices);
501  }
502 
503 
504  // if a solution function is attached, clear it
505  if (_sol_function)
506  _sol_function->clear();
507 
508  d_JdX_dX.close();
509 }
510 
511 
512 
513 
514 
515 bool
517 sensitivity_assemble (const libMesh::NumericVector<Real>& X,
518  bool if_localize_sol,
519  const MAST::FunctionBase& f,
520  libMesh::NumericVector<Real>& sensitivity_rhs,
521  bool close_vector) {
522 
523  libmesh_assert(_system);
524  libmesh_assert(_discipline);
525  libmesh_assert(_elem_ops);
526 
527  MAST::NonlinearSystem& nonlin_sys = _system->system();
528 
529  sensitivity_rhs.zero();
530 
531  // iterate over each element, initialize it and get the relevant
532  // analysis quantities
533  RealVectorX vec, vec1, sol;
534 
535  std::vector<libMesh::dof_id_type> dof_indices;
536  const libMesh::DofMap& dof_map = nonlin_sys.get_dof_map();
537 
538  const libMesh::NumericVector<Real>
539  *sol_vec = nullptr;
540 
541  std::unique_ptr<libMesh::NumericVector<Real> > localized_solution;
542 
543  if (if_localize_sol) {
544  localized_solution.reset(build_localized_vector(nonlin_sys, X).release());
545  sol_vec = localized_solution.get();
546  }
547  else
548  sol_vec = &X;
549 
550  // if a solution function is attached, initialize it
551  if (_sol_function)
552  _sol_function->init( *nonlin_sys.solution, false);
553 
554  libMesh::MeshBase::const_element_iterator el =
555  nonlin_sys.get_mesh().active_local_elements_begin();
556  const libMesh::MeshBase::const_element_iterator end_el =
557  nonlin_sys.get_mesh().active_local_elements_end();
558 
560  ops = dynamic_cast<MAST::NonlinearImplicitAssemblyElemOperations&>(*_elem_ops);
561 
562  for ( ; el != end_el; ++el) {
563 
564  const libMesh::Elem* elem = *el;
565 
566  if (diagonal_elem_subdomain_id.count(elem->subdomain_id()))
567  continue;
568 
569  // no sensitivity computation assembly is neeed in these cases
570  if (_param_dependence &&
571  // if object is specified and elem does not depend on it
573  continue;
574 
575  dof_map.dof_indices (elem, dof_indices);
576 
577  MAST::GeomElem geom_elem;
578  ops.set_elem_data(elem->dim(), *elem, geom_elem);
579  geom_elem.init(*elem, *_system);
580 
581  ops.init(geom_elem);
582 
583  // get the solution
584  unsigned int ndofs = (unsigned int)dof_indices.size();
585  sol.setZero(ndofs);
586  vec.setZero(ndofs);
587  vec1.setZero(ndofs);
588 
589  for (unsigned int i=0; i<dof_indices.size(); i++)
590  sol(i) = (*sol_vec)(dof_indices[i]);
591 
592  ops.set_elem_solution(sol);
593 
594 // if (_sol_function)
595 // physics_elem->attach_active_solution_function(*_sol_function);
596 
597  ops.elem_sensitivity_calculations(f, vec);
598  if (f.is_topology_parameter()) {
600  vec += vec1;
601  }
602 
603 
604 // physics_elem->detach_active_solution_function();
605  ops.clear_elem();
606 
607  // copy to the libMesh matrix for further processing
608  DenseRealVector v;
609  MAST::copy(v, vec);
610 
611  // constrain the quantities to account for hanging dofs,
612  // Dirichlet constraints, etc.
613  dof_map.constrain_element_vector(v, dof_indices);
614 
615  // add to the global matrices
616  sensitivity_rhs.add_vector(v, dof_indices);
617  dof_indices.clear();
618  }
619 
620  // add the point loads if any in the discipline
621  if (_discipline->point_loads().size()) {
622 
624  loads = _discipline->point_loads();
625 
626  vec = RealVectorX::Zero(_system->n_vars());
627 
628  MAST::PointLoadSetType::const_iterator
629  it = loads.begin(),
630  end = loads.end();
631 
632  const libMesh::dof_id_type
633  first_dof = dof_map.first_dof(nonlin_sys.comm().rank()),
634  end_dof = dof_map.end_dof(nonlin_sys.comm().rank());
635 
636  for ( ; it != end; it++) {
637 
638  // get the point load function
640  &func = (*it)->get<MAST::FieldFunction<RealVectorX>>("load");
641 
642  // get the nodes on which this object defines the load
643  const std::set<const libMesh::Node*>
644  nodes = (*it)->get_nodes();
645 
646  std::set<const libMesh::Node*>::const_iterator
647  n_it = nodes.begin(),
648  n_end = nodes.end();
649 
650  for (; n_it != n_end; n_it++) {
651 
652  // load at the node
653  vec.setZero();
654  func.derivative(f, **n_it, nonlin_sys.time, vec);
655  vec *= -1.;
656 
657  dof_map.dof_indices(*n_it, dof_indices);
658 
659  libmesh_assert_equal_to(dof_indices.size(), vec.rows());
660 
661  // zero the components of the vector if they do not
662  // belong to this processor
663  for (unsigned int i=0; i<dof_indices.size(); i++)
664  if (dof_indices[i] < first_dof ||
665  dof_indices[i] >= end_dof)
666  vec(i) = 0.;
667 
668  DenseRealVector v;
669  MAST::copy(v, vec);
670 
671  dof_map.constrain_element_vector(v, dof_indices);
672  sensitivity_rhs.add_vector(v, dof_indices);
673  dof_indices.clear();
674  }
675  }
676  }
677 
678  // if a solution function is attached, initialize it
679  if (_sol_function)
680  _sol_function->clear();
681 
682  if (close_vector)
683  sensitivity_rhs.close();
684 
685  return true;
686 }
687 
688 
MAST::AssemblyElemOperations * _elem_ops
provides assembly elem operations for use by this class
virtual void set_elem_perturbed_solution(const RealVectorX &sol)
sets the element perturbed solution
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
virtual void residual_and_jacobian(const libMesh::NumericVector< Real > &X, libMesh::NumericVector< Real > *R, libMesh::SparseMatrix< Real > *J, libMesh::NonlinearImplicitSystem &S)
function that assembles the matrices and vectors quantities for nonlinear solution ...
libMesh::DenseMatrix< Real > DenseRealMatrix
Real _res_l2_norm
L2 norm of the last-assembled residual.
This class implements a system for solution of nonlinear systems.
virtual void set_elem_solution_sensitivity(const RealVectorX &sol)
sets the element solution sensitivity
virtual void second_derivative_dot_solution_assembly(const libMesh::NumericVector< Real > &X, bool if_localize_sol, const libMesh::NumericVector< Real > &dX, bool if_localize_sol_sens, libMesh::SparseMatrix< Real > &d_JdX_dX, libMesh::NonlinearImplicitSystem &S)
calculates .
const MAST::PointLoadSetType & point_loads() const
bool close_matrix
flag to control the closing fo the Jacobian after assembly
virtual void set_elem_solution(const RealVectorX &sol)
sets the element solution
virtual void derivative(const MAST::FunctionBase &f, ValType &v) const
calculates the value of the function derivative and returns it in v.
virtual void linearized_jacobian_solution_product(const libMesh::NumericVector< Real > &X, const libMesh::NumericVector< Real > &dX, libMesh::NumericVector< Real > &JdX, libMesh::NonlinearImplicitSystem &S)
calculates the product of the Jacobian and a perturbation in solution vector .
std::set< unsigned int > diagonal_elem_subdomain_id
subdomain ids for which residuakl and Jacobian contributions will not be computed.
Definition: assembly_base.h:71
MAST::SystemInitialization * _system
System for which this assembly is performed.
virtual void elem_sensitivity_calculations(const MAST::FunctionBase &f, RealVectorX &vec)=0
performs the element sensitivity calculations over elem, and returns the element residual sensitivity...
virtual bool is_topology_parameter() const
Definition: function_base.h:97
virtual void elem_calculations(bool if_jac, RealVectorX &vec, RealMatrixX &mat)=0
performs the element calculations over elem, and returns the element vector and matrix quantities in ...
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 post_assembly(const libMesh::NumericVector< Real > &X, libMesh::NumericVector< Real > *R, libMesh::SparseMatrix< Real > *J, libMesh::NonlinearImplicitSystem &S)=0
libMesh::DenseVector< Real > DenseRealVector
virtual void elem_second_derivative_dot_solution_assembly(RealMatrixX &mat)=0
calculates over elem, and returns the matrix in vec .
NonlinearImplicitAssembly()
constructor associates this assembly object with the system
MAST::NonlinearImplicitAssembly::PostAssemblyOperation * _post_assembly
this object, if non-NULL is user-provided to perform actions after assembly and before returning to t...
Matrix< Real, Dynamic, Dynamic > RealMatrixX
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...
void copy(DenseRealMatrix &m1, const RealMatrixX &m2)
Definition: utility.h:167
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.
virtual void elem_topology_sensitivity_calculations(const MAST::FunctionBase &f, RealVectorX &vec)=0
performs the element topology sensitivity calculations over elem, and returns the element residual se...
void clear()
clear the solution
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.
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
Definition: geom_elem.h:59
user-provided object to perform actions after assembly and before returning to the solver...
MAST::AssemblyBase::ElemParameterDependence * _param_dependence
If provided by user, this object is used by sensitiivty analysis to check for whether or the current ...
std::set< MAST::PointLoadCondition * > PointLoadSetType
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.
Definition: geom_elem.cpp:134
virtual void elem_linearized_jacobian_solution_product(RealVectorX &vec)=0
performs the element calculations over elem, and returns the element vector quantity in vec...
void set_post_assembly_operation(MAST::NonlinearImplicitAssembly::PostAssemblyOperation &post)
sets the PostAssemblyOperation object for use after assembly.
MAST::MeshFieldFunction * _sol_function
system solution that will be initialized before each solution
virtual ~NonlinearImplicitAssembly()
destructor resets the association of this assembly object with the system