20 #include "libmesh/dof_map.h" 21 #include "libmesh/elem.h" 22 #include "libmesh/equation_systems.h" 23 #include "libmesh/fe_base.h" 24 #include "libmesh/fem_context.h" 25 #include "libmesh/fem_system.h" 26 #include "libmesh/libmesh_logging.h" 27 #include "libmesh/mesh_base.h" 28 #include "libmesh/numeric_vector.h" 29 #include "libmesh/parallel_algebra.h" 30 #include "libmesh/parallel_ghost_sync.h" 31 #include "libmesh/quadrature.h" 32 #include "libmesh/sparse_matrix.h" 33 #include "libmesh/time_solver.h" 34 #include "libmesh/unsteady_solver.h" 35 #include "libmesh/fe_interface.h" 46 femsystem_mutex assembly_mutex;
48 void assemble_unconstrained_element_system(
const FEMSystem & _sys,
49 const bool _get_jacobian,
50 const bool _constrain_heterogeneously,
75 const bool need_jacobian =
76 (_get_jacobian || _constrain_heterogeneously);
78 bool jacobian_computed =
79 _sys.
time_solver->element_residual(need_jacobian, _femcontext);
82 if (need_jacobian && !jacobian_computed)
92 if (need_jacobian && jacobian_computed &&
101 Real analytic_norm = analytic_jacobian.l1_norm();
109 Real error_norm = analytic_jacobian.l1_norm();
111 Real relative_error = error_norm /
112 std::max(analytic_norm, numerical_norm);
117 <<
" detected in analytic jacobian on element " 118 << _femcontext.
get_elem().
id() <<
'!' << std::endl;
126 << analytic_jacobian << std::endl;
130 libmesh_error_msg(
"Relative error too large, exiting!");
135 for (_femcontext.
side = 0; _femcontext.
side != n_sides;
157 #endif // ifndef DEBUG 164 _sys.
time_solver->side_residual(need_jacobian, _femcontext);
167 if (need_jacobian && !jacobian_computed)
175 if (old_jacobian.
m())
192 else if (need_jacobian && jacobian_computed &&
201 Real analytic_norm = analytic_jacobian.l1_norm();
209 Real error_norm = analytic_jacobian.l1_norm();
211 Real relative_error = error_norm /
212 std::max(analytic_norm, numerical_norm);
217 <<
" detected in analytic jacobian on element " 220 <<
static_cast<unsigned int>(_femcontext.
side) <<
'!' << std::endl;
228 << analytic_jacobian << std::endl;
231 libmesh_error_msg(
"Relative error too large, exiting!");
245 #endif // ifdef DEBUG 249 void add_element_system(
FEMSystem & _sys,
250 const bool _get_residual,
251 const bool _get_jacobian,
252 const bool _constrain_heterogeneously,
253 const bool _no_constraints,
256 #ifdef LIBMESH_ENABLE_CONSTRAINTS 285 if (_get_residual && _get_jacobian)
287 if (constrain_in_solver)
289 if (_constrain_heterogeneously)
294 else if (!_no_constraints)
300 else if (!_no_constraints)
308 else if (_get_residual)
310 if (constrain_in_solver)
312 if (_constrain_heterogeneously)
317 else if (!_no_constraints)
322 else if (!_no_constraints)
329 else if (_get_jacobian)
334 if (!_no_constraints)
337 !constrain_in_solver);
341 #endif // #ifdef LIBMESH_ENABLE_CONSTRAINTS 368 femsystem_mutex::scoped_lock lock(assembly_mutex);
381 class AssemblyContributions
390 bool constrain_heterogeneously,
391 bool no_constraints) :
393 _get_residual(get_residual),
394 _get_jacobian(get_jacobian),
395 _constrain_heterogeneously(constrain_heterogeneously),
396 _no_constraints(no_constraints) {}
404 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
407 for (
const auto & elem : range)
412 assemble_unconstrained_element_system
413 (_sys, _get_jacobian, _constrain_heterogeneously, _femcontext);
416 (_sys, _get_residual, _get_jacobian,
417 _constrain_heterogeneously, _no_constraints, _femcontext);
425 const bool _get_residual, _get_jacobian, _constrain_heterogeneously, _no_constraints;
428 class PostprocessContributions
435 PostprocessContributions(
FEMSystem & sys) : _sys(sys) {}
443 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
446 for (
const auto & elem : range)
457 for (_femcontext.
side = 0; _femcontext.
side != n_sides;
480 class QoIContributions
489 const QoISet & qoi_indices) :
490 qoi(sys.n_qois(), 0.), _sys(sys), _diff_qoi(diff_qoi),_qoi_indices(qoi_indices) {}
495 QoIContributions(
const QoIContributions & other,
497 qoi(other._sys.n_qois(), 0.), _sys(other._sys), _diff_qoi(other._diff_qoi) {}
505 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
506 _diff_qoi.init_context(_femcontext);
508 bool have_some_heterogenous_qoi_bc =
false;
509 #ifdef LIBMESH_ENABLE_CONSTRAINTS 510 std::vector<bool> have_heterogenous_qoi_bc(_sys.
n_qois(),
false);
512 if (_qoi_indices.has_index(q) &&
515 have_heterogenous_qoi_bc[q] =
true;
516 have_some_heterogenous_qoi_bc =
true;
520 if (have_some_heterogenous_qoi_bc)
523 for (
const auto & elem : range)
529 bool elem_has_some_heterogenous_qoi_bc =
false;
531 #ifdef LIBMESH_ENABLE_CONSTRAINTS 532 const unsigned int n_dofs =
535 std::vector<bool> elem_has_heterogenous_qoi_bc(_sys.
n_qois(),
false);
536 if (have_some_heterogenous_qoi_bc)
540 if (have_heterogenous_qoi_bc[q])
546 elem_has_some_heterogenous_qoi_bc =
true;
547 elem_has_heterogenous_qoi_bc[q] =
true;
555 if (_diff_qoi.assemble_qoi_elements ||
556 elem_has_some_heterogenous_qoi_bc)
559 if (_diff_qoi.assemble_qoi_elements)
560 _diff_qoi.element_qoi(_femcontext, _qoi_indices);
565 #ifdef LIBMESH_ENABLE_CONSTRAINTS 566 if (elem_has_some_heterogenous_qoi_bc)
568 _sys.
time_solver->element_residual(
false, _femcontext);
572 if (elem_has_heterogenous_qoi_bc[q])
584 for (_femcontext.
side = 0; _femcontext.
side != n_sides;
588 if (!_diff_qoi.assemble_qoi_sides ||
589 (!_diff_qoi.assemble_qoi_internal_sides &&
595 _diff_qoi.side_qoi(_femcontext, _qoi_indices);
599 this->_diff_qoi.thread_join( this->qoi, _femcontext.
get_qois(), _qoi_indices );
602 void join (
const QoIContributions & other)
604 libmesh_assert_equal_to (this->qoi.size(), other.qoi.size());
605 this->_diff_qoi.thread_join( this->qoi, other.qoi, _qoi_indices );
608 std::vector<Number> qoi;
615 const QoISet _qoi_indices;
618 class QoIDerivativeContributions
624 QoIDerivativeContributions(
FEMSystem & sys,
625 const QoISet & qoi_indices,
627 bool include_liftfunc,
628 bool apply_constraints) :
630 _qoi_indices(qoi_indices),
632 _include_liftfunc(include_liftfunc),
633 _apply_constraints(apply_constraints) {}
641 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
642 _qoi.init_context(_femcontext);
644 bool have_some_heterogenous_qoi_bc =
false;
645 #ifdef LIBMESH_ENABLE_CONSTRAINTS 646 std::vector<bool> have_heterogenous_qoi_bc(_sys.
n_qois(),
false);
647 if (_include_liftfunc || _apply_constraints)
649 if (_qoi_indices.has_index(q) &&
652 have_heterogenous_qoi_bc[q] =
true;
653 have_some_heterogenous_qoi_bc =
true;
657 if (have_some_heterogenous_qoi_bc)
660 for (
const auto & elem : range)
666 bool elem_has_some_heterogenous_qoi_bc =
false;
668 #ifdef LIBMESH_ENABLE_CONSTRAINTS 669 const unsigned int n_dofs =
672 std::vector<bool> elem_has_heterogenous_qoi_bc(_sys.
n_qois(),
false);
673 if (have_some_heterogenous_qoi_bc)
677 if (have_heterogenous_qoi_bc[q])
683 elem_has_some_heterogenous_qoi_bc =
true;
684 elem_has_heterogenous_qoi_bc[q] =
true;
697 if (_qoi.assemble_qoi_elements ||
698 ((_include_liftfunc || _apply_constraints) &&
699 elem_has_some_heterogenous_qoi_bc))
702 if (_qoi.assemble_qoi_elements)
703 _qoi.element_qoi_derivative(_femcontext, _qoi_indices);
705 #ifdef LIBMESH_ENABLE_CONSTRAINTS 709 if ((_include_liftfunc || _apply_constraints) &&
710 elem_has_some_heterogenous_qoi_bc)
712 bool jacobian_computed = _sys.
time_solver->element_residual(
true, _femcontext);
715 if (!jacobian_computed)
727 if (_include_liftfunc && elem_has_some_heterogenous_qoi_bc)
731 if (elem_has_heterogenous_qoi_bc[q])
738 if (liftfunc_val !=
Number(0))
753 for (_femcontext.
side = 0; _femcontext.
side != n_sides;
757 if (!_qoi.assemble_qoi_sides ||
758 (!_qoi.assemble_qoi_internal_sides &&
764 _qoi.side_qoi_derivative(_femcontext, _qoi_indices);
771 #ifdef LIBMESH_ENABLE_CONSTRAINTS 772 std::vector<dof_id_type> original_dofs = _femcontext.
get_dof_indices();
776 femsystem_mutex::scoped_lock lock(assembly_mutex);
778 #ifdef LIBMESH_ENABLE_CONSTRAINTS 782 if (_apply_constraints)
787 if (_qoi_indices.has_index(i))
789 #ifdef LIBMESH_ENABLE_CONSTRAINTS 790 if (_apply_constraints)
793 bool has_heterogenous_constraint =
false;
798 has_heterogenous_constraint =
true;
804 bool has_heterogenous_constraint =
805 elem_has_heterogenous_qoi_bc[i];
810 if (has_heterogenous_constraint)
816 (elem_jacobian_transpose);
819 (elem_jacobian_transpose,
842 const QoISet & _qoi_indices;
844 bool _include_liftfunc, _apply_constraints;
859 const std::string & name_in,
860 const unsigned int number_in)
861 :
Parent(es, name_in, number_in),
862 fe_reinit_during_postprocess(true),
864 verify_analytic_jacobians(0.0)
881 bool apply_heterogeneous_constraints,
882 bool apply_no_constraints)
887 #ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING 888 const char * log_name;
889 if (get_residual && get_jacobian)
890 log_name =
"assembly()";
891 else if (get_residual)
892 log_name =
"assembly(get_residual)";
894 log_name =
"assembly(get_jacobian)";
896 LOG_SCOPE(log_name,
"FEMSystem");
917 <<
"];" << std::endl;
931 libMesh::err <<
"WARNING! verify_analytic_jacobians was set " 932 <<
"to absurdly large value of " 946 (elem_range.
reset(
mesh.active_local_elements_begin(),
947 mesh.active_local_elements_end()),
948 AssemblyContributions(*
this, get_residual, get_jacobian,
949 apply_heterogeneous_constraints,
950 apply_no_constraints));
953 bool have_scalar =
false;
968 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
972 bool jacobian_computed =
973 this->
time_solver->nonlocal_residual(get_jacobian, _femcontext);
981 if (get_jacobian && !jacobian_computed)
991 if (get_jacobian && jacobian_computed &&
1000 Real analytic_norm = analytic_jacobian.l1_norm();
1008 Real error_norm = analytic_jacobian.l1_norm();
1010 Real relative_error = error_norm /
1011 std::max(analytic_norm, numerical_norm);
1016 <<
" detected in analytic jacobian on nonlocal dofs!" 1025 << analytic_jacobian << std::endl;
1029 libmesh_error_msg(
"Relative error too large, exiting!");
1034 (*
this, get_residual, get_jacobian,
1035 apply_heterogeneous_constraints, apply_no_constraints, _femcontext);
1096 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
1100 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1122 (this->
comm(), mesh.nodes_begin(),
mesh.nodes_end(), sync_object);
1129 LOG_SCOPE(
"postprocess()",
"FEMSystem");
1141 mesh.active_local_elements_end()),
1142 PostprocessContributions(*
this));
1149 LOG_SCOPE(
"assemble_qoi()",
"FEMSystem");
1155 const unsigned int Nq = this->
n_qois();
1159 for (
unsigned int i=0; i != Nq; ++i)
1165 QoIContributions qoi_contributions(*
this, *(this->
get_qoi()), qoi_indices);
1169 mesh.active_local_elements_end()),
1174 this->
set_qoi(std::move(global_qoi));
1180 bool include_liftfunc,
1181 bool apply_constraints)
1183 LOG_SCOPE(
"assemble_qoi_derivative()",
"FEMSystem");
1197 mesh.active_local_elements_end()),
1198 QoIDerivativeContributions(*
this, qoi_indices,
1201 apply_constraints));
1223 Real numerical_point_h = 0.;
1227 const unsigned int n_dofs =
1248 const unsigned int total_j = j + j_offset;
1255 Real * coord =
nullptr;
1274 ((*time_solver).*(res))(
false, context);
1288 ((*time_solver).*(res))(
false, context);
1299 numeric_jacobian(i,total_j) =
1301 2. / numerical_point_h;
1308 numeric_jacobian(i,total_j) =
1324 LOG_SCOPE(
"numerical_elem_jacobian()",
"FEMSystem");
1332 LOG_SCOPE(
"numerical_side_jacobian()",
"FEMSystem");
1340 LOG_SCOPE(
"numerical_nonlocal_jacobian()",
"FEMSystem");
1348 auto fc = std::make_unique<FEMContext>(*this);
1360 fc->set_deltat_pointer( &
deltat );
1384 FEMContext & context = cast_ref<FEMContext &>(c);
1395 FEBase * elem_fe =
nullptr;
1416 libmesh_error_msg(
"Unrecognized field type!");
1427 libmesh_error_msg_if(!
_mesh_sys,
"_mesh_sys was nullptr!");
1431 libmesh_not_implemented();
1437 FEMContext & _femcontext = cast_ref<FEMContext &>(*con);
1441 for (
const auto & elem :
mesh.active_local_element_ptr_range())
FEFamily family
The type of finite element.
virtual std::unique_ptr< DiffContext > build_context() override
Builds a FEMContext object with enough information to do evaluations on each element.
const DifferentiableQoI * get_qoi() const
virtual bool side_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics side_time_derivative(), side_constraint(), and side_mass_residual() to build a full residual on an element's side.
unsigned int get_mesh_x_var() const
This is the EquationSystems class.
const std::vector< Number > & get_qois() const
Const accessor for QoI vector.
virtual void parallel_op(const Parallel::Communicator &communicator, std::vector< Number > &sys_qoi, std::vector< Number > &local_qoi, const QoISet &qoi_indices)
Method to populate system qoi data structure with process-local qoi.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
Real verify_analytic_jacobians
If verify_analytic_jacobian is equal to zero (as it is by default), no numeric jacobians will be calc...
void elem_position_set(Real theta)
Uses the coordinate data specified by mesh_*_position configuration to set the geometry of elem to th...
This class provides all data required for a physics package (e.g.
virtual void zero() override final
Set every element in the vector to 0.
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
Runs a qoi derivative assembly loop over all elements, and if assemble_qoi_sides is true over all sid...
std::streamsize precision() const
Get the associated write precision.
void constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix and vector.
const DenseVector< Number > & get_elem_fixed_solution() const
Accessor for element fixed solution.
virtual void zero() override final
Sets all elements of the matrix to 0 and resets any decomposition flag which may have been previously...
void parallel_for(const Range &range, const Body &body)
Execute the provided function object in parallel on the specified range.
static constexpr Real TOLERANCE
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
bool print_jacobian_norms
Set print_jacobian_norms to true to print |J| whenever it is assembled.
const Elem & get_elem() const
Accessor for current Elem object.
unsigned int n_qois() const
Number of currently active quantities of interest.
virtual void init_context(DiffContext &) override
Real numerical_jacobian_h
If calculating numeric jacobians is required, the FEMSystem will perturb each solution vector entry b...
Number has_heterogenous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Backwards compatibility with misspelling.
Dummy "splitting object" used to distinguish splitting constructors from copy constructors.
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
unsigned int n_variable_groups() const
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
const System * get_mesh_system() const
void numerical_elem_jacobian(FEMContext &context) const
Uses the results of multiple element_residual() calls to numerically differentiate the corresponding ...
static FEFieldType field_type(const FEType &fe_type)
NumericVector< Number > * rhs
The system matrix.
const Parallel::Communicator & comm() const
auto l1_norm() const -> decltype(std::abs(T(0)))
bool postprocess_sides
If postprocess_sides is true (it is false by default), the postprocessing loop will loop over all sid...
The StoredRange class defines a contiguous, divisible set of objects.
void elem_position_get()
Uses the geometry of elem to set the coordinate data specified by mesh_*_position configuration...
The libMesh namespace provides an interface to certain functionality in the library.
bool print_jacobians
Set print_jacobians to true to print J whenever it is assembled.
const MeshBase & get_mesh() const
This class provides a specific system class.
virtual bool nonlocal_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics nonlocal_time_derivative(), nonlocal_constraint(), and nonlocal_mass_residual() to build a full residual of non-local terms.
dof_id_type n_dofs() const
This is the MeshBase class.
virtual void zero()=0
Set all entries to zero.
virtual void elem_fe_reinit(const std::vector< Point > *const pts=nullptr)
Reinitializes interior FE objects on the current geometric element.
bool print_element_residuals
Set print_element_residuals to true to print each R_elem contribution.
void heterogenously_constrain_element_vector(const DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
bool print_element_solutions
Set print_element_solutions to true to print each U_elem input.
virtual bool get_constrain_in_solver()
bool has_index(std::size_t) const
Return whether or not this index is in the set to be calculated.
virtual bool element_residual(bool request_jacobian, DiffContext &)=0
This method uses the DifferentiablePhysics element_time_derivative(), element_constraint(), and mass_residual() to build a full residual on an element.
bool print_solution_norms
Set print_residual_norms to true to print |U| whenever it is used in an assembly() call...
unsigned int get_mesh_y_var() const
processor_id_type n_processors() const
void set_is_adjoint(bool _is_adjoint_value)
Accessor for setting whether we need to do a primal or adjoint solve.
void libmesh_ignore(const Args &...)
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
const DenseVector< Number > & get_elem_solution() const
Accessor for element solution.
virtual void zero()=0
Set all entries to 0.
bool print_residual_norms
Set print_residual_norms to true to print |F| whenever it is assembled.
virtual void side_fe_reinit()
Reinitializes side FE objects on the current geometric element.
virtual void side_postprocess(DiffContext &)
Does any work that needs to be done on side of elem in a postprocessing loop.
virtual Real hmin() const
bool fe_reinit_during_postprocess
If fe_reinit_during_postprocess is true (it is true by default), FE objects will be reinit()ed with t...
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time...
bool use_fixed_solution
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e...
bool is_adjoint() const
Accessor for querying whether we need to do a primal or adjoint solve.
void get_transpose(DenseMatrix< T > &dest) const
Put the tranposed matrix into dest.
void numerical_nonlocal_jacobian(FEMContext &context) const
Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jac...
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseMatrix< T3 > &mat)
Adds factor times mat to this matrix.
System * _mesh_sys
System from which to acquire moving mesh information.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
bool print_residuals
Set print_residuals to true to print F whenever it is assembled.
virtual void init_data() override
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used...
virtual_for_inffe const std::vector< Real > & get_JxW() const
This class provides all data required for a physics package (e.g.
FEMSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
void sync_dofobject_data_by_id(const Communicator &comm, const Iterator &range_begin, const Iterator &range_end, SyncFunctor &sync)
Request data about a range of ghost dofobjects uniquely identified by their id.
virtual void element_postprocess(DiffContext &)
Does any work that needs to be done on elem in a postprocessing loop.
virtual void postprocess() override
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides...
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
virtual Real l1_norm() const =0
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
bool print_solutions
Set print_solutions to true to print U whenever it is used in an assembly() call. ...
const DifferentiablePhysics * get_physics() const
void numerical_side_jacobian(FEMContext &context) const
Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jac...
This class provides a specific system class.
virtual unsigned int n_sides() const =0
const Elem * neighbor_ptr(unsigned int i) const
void heterogenously_constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
This class provides a specific system class.
bool compute_internal_sides
compute_internal_sides is false by default, indicating that side_* computations will only be done on ...
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
virtual void init_data() override
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used...
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Backwards compatibility with misspelling.
virtual void assemble_qoi(const QoISet &indices=QoISet()) override
Runs a qoi assembly loop over all elements, and if assemble_qoi_sides is true over all sides...
const FEType & variable_type(const unsigned int i) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
StoredRange< iterator_type, object_type > & reset(const iterator_type &first, const iterator_type &last)
Resets the StoredRange to contain [first,last).
void constrain_element_vector(DenseVector< Number > &rhs, std::vector< dof_id_type > &dofs, bool asymmetric_constraint_rows=true) const
Constrains the element vector.
unsigned char side
Current side for side_* to examine.
SparseMatrix< Number > * matrix
The system matrix.
void mesh_position_set()
Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom co...
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
bool print_element_jacobians
Set print_element_jacobians to true to print each J_elem contribution.
void parallel_reduce(const Range &range, Body &body)
Execute the provided reduction operation in parallel on the specified range.
virtual unsigned int size() const override final
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
unsigned int get_mesh_z_var() const
void set_deltat_pointer(Real *dt)
Points the _deltat member of this class at a timestep value stored in the creating System...
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh...
virtual void solve() override
Invokes the solver associated with the system.
void set_qoi(unsigned int qoi_index, Number qoi_value)
void heterogeneously_constrain_element_residual(DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
Constrains the element residual.
Real numerical_jacobian_h_for_var(unsigned int var_num) const
If numerical_jacobian_h_for_var(var_num) is changed from its default value (numerical_jacobian_h), the FEMSystem will perturb solution vector entries for variable var_num by that amount when calculating finite differences with respect to that variable.
virtual void solve() override
Invokes the solver associated with the system.
bool is_time_evolving(unsigned int var) const
void heterogeneously_constrain_element_jacobian_and_residual(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
Constrains the element Jacobian and residual.
virtual Real l1_norm() const =0
unsigned int n_vars() const
unsigned int n_vars() const
Number of variables in solution.
void numerical_jacobian(TimeSolverResPtr res, FEMContext &context) const
Uses the results of multiple res calls to numerically differentiate the corresponding jacobian...
virtual void assembly(bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false) override
Prepares matrix or rhs for matrix assembly.
processor_id_type processor_id() const
void mesh_position_get()
Tells the FEMSystem to set the degree of freedom coefficients which should correspond to mesh nodal c...
const std::vector< DenseVector< Number > > & get_qoi_derivatives() const
Const accessor for QoI derivatives.
bool has_elem() const
Test for current Elem object.
const DofMap & get_dof_map() const
const Point & point(const unsigned int i) const
const SparseMatrix< Number > & get_system_matrix() const
bool has_children() const
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
This class forms the foundation from which generic finite elements may be derived.
void constrain_nothing(std::vector< dof_id_type > &dofs) const
Does not actually constrain anything, but modifies dofs in the same way as any of the constrain funct...
const std::set< unsigned char > & elem_dimensions() const
virtual void finalize_derivative(NumericVector< Number > &derivatives, std::size_t qoi_index)
Method to finalize qoi derivatives which require more than just a simple sum of element contributions...
std::vector< Number > get_qoi_values() const
Returns a copy of qoi, not a reference.
const std::vector< std::vector< OutputShape > > & get_phi() const
TimeSolver & get_time_solver()
const FEType & type() const
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
void constrain_element_matrix(DenseMatrix< Number > &matrix, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix.
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...