38 #include "libmesh/composite_function.h"
39 #include "libmesh/getpot.h"
40 #include "libmesh/parameter_multiaccessor.h"
46 const std::string& name,
47 const unsigned int number )
48 : FEMSystem(es, name, number),
49 _use_numerical_jacobians_only(false)
63 this->verify_analytic_jacobians = input(
"linear-nonlinear-solver/verify_analytic_jacobians", 0.0 );
64 this->print_solution_norms = input(
"screen-options/print_solution_norms",
false );
65 this->print_solutions = input(
"screen-options/print_solutions",
false );
66 this->print_residual_norms = input(
"screen-options/print_residual_norms",
false );
70 this->print_residuals = input(
"screen-options/print_residual",
false );
71 if (this->print_residuals)
74 this->print_residuals = input(
"screen-options/print_residuals", this->print_residuals );
75 this->print_jacobian_norms = input(
"screen-options/print_jacobian_norms",
false );
76 this->print_jacobians = input(
"screen-options/print_jacobians",
false );
77 this->print_element_solutions = input(
"screen-options/print_element_solutions",
false );
78 this->print_element_residuals = input(
"screen-options/print_element_residuals",
false );
79 this->print_element_jacobians = input(
"screen-options/print_element_jacobians",
false );
83 numerical_jacobian_h =
84 input(
"linear-nonlinear-solver/numerical_jacobian_h",
85 numerical_jacobian_h);
87 const unsigned int n_numerical_jacobian_h_values =
88 input.vector_variable_size
89 (
"linear-nonlinear-solver/numerical_jacobian_h_values");
91 if (n_numerical_jacobian_h_values !=
92 input.vector_variable_size
93 (
"linear-nonlinear-solver/numerical_jacobian_h_variables"))
95 std::cerr <<
"Error: found " << n_numerical_jacobian_h_values
96 <<
" numerical_jacobian_h_values" << std::endl;
98 << input.vector_variable_size
99 (
"linear-nonlinear-solver/numerical_jacobian_h_variables")
100 <<
" numerical_jacobian_h_variables" << std::endl;
106 for (
unsigned int i=0; i != n_numerical_jacobian_h_values; ++i)
109 input(
"linear-nonlinear-solver/numerical_jacobian_h_variables",
112 input(
"linear-nonlinear-solver/numerical_jacobian_h_values",
113 libMesh::Real(0), i);
122 use_fixed_solution =
true;
133 (physics_iter->second)->init_variables(
this );
142 this->attach_constraint_object(*this->
_constraint);
148 unsigned int var_num =
150 this->set_numerical_jacobian_h_for_var
159 (physics_iter->second)->set_time_evolving_vars(
this );
165 (
_physics_list.begin()->second)->set_is_steady((this->time_solver)->is_steady());
169 libMesh::FEMSystem::init_data();
179 (physics_iter->second)->init_ics(
this, ic_function );
182 if (ic_function.n_subfunctions())
184 this->project_solution(&ic_function);
192 (physics_iter->second)->auxiliary_init( *
this );
202 libMesh::UniquePtr<libMesh::DiffContext> ap(context);
204 libMesh::DifferentiablePhysics* phys = libMesh::FEMSystem::get_physics();
206 libmesh_assert(phys);
209 context->set_mesh_system(phys->get_mesh_system());
210 context->set_mesh_x_var(phys->get_mesh_x_var());
211 context->set_mesh_y_var(phys->get_mesh_y_var());
212 context->set_mesh_z_var(phys->get_mesh_z_var());
214 ap->set_deltat_pointer( &deltat );
217 ap->is_adjoint() = this->get_time_solver().is_adjoint();
236 (
const std::string & param_name,
241 physics_iter != _physics_list.end();
244 (physics_iter->second)->register_parameter( param_name,
248 for (
unsigned int bc=0; bc<_neumann_bcs.size(); bc++)
249 _neumann_bcs[bc]->get_func()->register_parameter(param_name, param_pointer);
271 bool apply_heterogeneous_constraints,
272 bool apply_no_constraints )
278 (physics_iter->second)->preassembly(*
this);
281 libMesh::FEMSystem::assembly(get_residual,get_jacobian,
282 apply_heterogeneous_constraints,
283 apply_no_constraints);
295 (physics_iter->second)->reinit(*
this);
298 if (this->qoi.size() > 0)
300 libMesh::DifferentiableQoI* diff_qoi = this->get_qoi();
301 CompositeQoI* qoi = libMesh::cast_ptr<CompositeQoI*>(diff_qoi);
307 libMesh::DiffContext& context,
309 CacheFuncType cachefunc)
313 bool compute_jacobian =
true;
324 ((*(physics_iter->second)).*cachefunc)( c );
334 if( (physics_iter->second)->enabled_on_elem( &c.get_elem() ) )
336 ((*(physics_iter->second)).*resfunc)( compute_jacobian, c );
341 ((*(physics_iter->second)).*resfunc)( compute_jacobian, c );
351 return compute_jacobian;
355 libMesh::DiffContext& context )
365 libMesh::DiffContext& context )
370 jacobian_computed = jacobian_computed &&
377 return jacobian_computed;
381 libMesh::DiffContext& context )
391 libMesh::DiffContext& context )
401 libMesh::DiffContext& context )
411 libMesh::DiffContext& context )
421 libMesh::DiffContext& context )
431 libMesh::DiffContext& context )
441 libMesh::DiffContext& context )
454 std::cerr <<
"Error: Could not find physics " << physics_name << std::endl;
473 const libMesh::Point& point,
474 libMesh::Real& value )
481 if( (physics_iter->second)->enabled_on_elem( &context.get_elem() ) )
490 const std::vector<SharedPtr<NeumannBCContainer> >& neumann_bcs,
491 std::vector<SharedPtr<NeumannBCContainer> >& active_neumann_bcs )
494 for( std::vector<SharedPtr<NeumannBCContainer> >::const_iterator it = neumann_bcs.begin();
495 it < neumann_bcs.end(); ++it )
496 if( (*it)->has_bc_id( bc_id ) )
497 active_neumann_bcs.push_back( *it );
501 libMesh::DiffContext& context )
504 libMesh::cast_ref<AssemblyContext&>( context );
506 std::vector<BoundaryID> ids;
507 assembly_context.side_boundary_ids(ids);
509 bool compute_jacobian = request_jacobian;
512 for( std::vector<BoundaryID>::const_iterator it = ids.begin();
513 it != ids.end(); it++ )
517 libmesh_assert_not_equal_to(bc_id, libMesh::BoundaryInfo::invalid_id);
520 std::vector<SharedPtr<NeumannBCContainer> > active_neumann_bcs;
523 if( !active_neumann_bcs.empty() )
525 typedef std::vector<SharedPtr<NeumannBCContainer> >::iterator BCIt;
527 for( BCIt container = active_neumann_bcs.begin(); container < active_neumann_bcs.end(); ++container )
529 SharedPtr<NeumannBCAbstract>& func = (*container)->get_func();
533 func->eval_flux( compute_jacobian, assembly_context,
539 return compute_jacobian;
virtual void compute_element_constraint_cache(AssemblyContext &)
static bool is_axisymmetric()
CachedValues & get_cached_values()
virtual void compute_mass_residual_cache(AssemblyContext &)
bool _use_numerical_jacobians_only
bool has_physics(const std::string physics_name) const
Query to check if a particular physics has been enabled.
static void build_boundary_conditions(const GetPot &input, MultiphysicsSystem &system, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
void attach_physics_list(PhysicsList physics_list)
PhysicsList gets built by GRINS::PhysicsFactory and attached here.
std::vector< std::string > _numerical_jacobian_h_variables
std::vector< SharedPtr< NeumannBCContainer > > _neumann_bcs
Neumann boundary conditions.
virtual void compute_element_time_derivative_cache(AssemblyContext &)
virtual void init_data()
System initialization. Calls each physics implementation of init_variables()
virtual void compute_damping_residual_cache(AssemblyContext &)
void register_postprocessing_vars(const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
Each Physics will register their postprocessed quantities with this call.
virtual void side_time_derivative(bool, AssemblyContext &)
Time dependent part(s) of physics for boundaries of elements on the domain boundary.
virtual bool side_constraint(bool request_jacobian, libMesh::DiffContext &context)
Boundary contributions to which do not have time varying components.
libMesh::boundary_id_type BoundaryID
More descriptive name of the type used for boundary ids.
virtual bool damping_residual(bool request_jacobian, libMesh::DiffContext &context)
Contributions to .
virtual void element_time_derivative(bool, AssemblyContext &)
Time dependent part(s) of physics for element interiors.
SharedPtr< GRINS::Physics > get_physics(const std::string physics_name)
libMesh::UniquePtr< libMesh::System::Constraint > _constraint
Constraint application object.
PhysicsList _physics_list
Container of pointers to GRINS::Physics classes requested at runtime.
virtual void nonlocal_constraint(bool, AssemblyContext &)
Constraint part(s) of physics for scalar variables.
virtual bool nonlocal_time_derivative(bool request_jacobian, libMesh::DiffContext &context)
Contributions to on SCALAR variables which have time varying components.
virtual void compute_side_constraint_cache(AssemblyContext &)
virtual void compute_postprocessed_quantity(unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
virtual void nonlocal_mass_residual(bool, AssemblyContext &)
Mass matrix part(s) for scalar variables.
libMesh::Real neumann_bc_sign() const
void register_parameter(const std::string ¶m_name, libMesh::ParameterMultiAccessor< libMesh::Number > ¶m_pointer)
Each Physics will register its copy(s) of an independent variable.
virtual void side_constraint(bool, AssemblyContext &)
Constraint part(s) of physics for boundaries of elements on the domain boundary.
virtual bool nonlocal_mass_residual(bool request_jacobian, libMesh::DiffContext &context)
Contributions to on SCALAR variables.
virtual bool element_time_derivative(bool request_jacobian, libMesh::DiffContext &context)
Element interior contributions to which have time varying components.
virtual void reinit()
Override FEMSystem::reinit.
virtual libMesh::UniquePtr< libMesh::DiffContext > build_context()
Override FEMSystem::build_context in order to use our own AssemblyContext.
virtual bool nonlocal_constraint(bool request_jacobian, libMesh::DiffContext &context)
Contributions to on SCALAR variables which do not have time varying components.
virtual void element_constraint(bool, AssemblyContext &)
Constraint part(s) of physics for element interiors.
virtual void compute_nonlocal_time_derivative_cache(AssemblyContext &)
virtual void mass_residual(bool, AssemblyContext &)
Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part...
virtual void compute_nonlocal_constraint_cache(AssemblyContext &)
void get_active_neumann_bcs(BoundaryID bc_id, const std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs, std::vector< SharedPtr< NeumannBCContainer > > &active_neumann_bcs)
Extract the bcs from neumann_bcs that are active on bc_id and return them in active_neumann_bcs.
static libMesh::UniquePtr< libMesh::System::Constraint > build_constraint_object(const GetPot &input, MultiphysicsSystem &system)
std::map< std::string, SharedPtr< GRINS::Physics > > PhysicsList
Container for GRINS::Physics object pointers.
std::vector< libMesh::Real > _numerical_jacobian_h_values
virtual void assembly(bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false)
Override FEMSystem::assembly.
virtual void compute_nonlocal_mass_residual_cache(AssemblyContext &)
bool _general_residual(bool request_jacobian, libMesh::DiffContext &context, ResFuncType resfunc, CacheFuncType cachefunc)
virtual bool element_constraint(bool request_jacobian, libMesh::DiffContext &context)
virtual void compute_side_time_derivative_cache(AssemblyContext &)
virtual bool mass_residual(bool request_jacobian, libMesh::DiffContext &context)
Contributions to .
virtual void damping_residual(bool, AssemblyContext &)
Damping matrix part(s) for element interiors. All boundary terms lie within the time_derivative part...
bool apply_neumann_bcs(bool request_jacobian, libMesh::DiffContext &context)
Applies the subset of _neumann_bcs that are active on the current element side.
virtual void nonlocal_time_derivative(bool, AssemblyContext &)
Time dependent part(s) of physics for scalar variables.
MultiphysicsSystem(libMesh::EquationSystems &es, const std::string &name, const unsigned int number)
Constructor. Will be called by libMesh only.
virtual bool side_time_derivative(bool request_jacobian, libMesh::DiffContext &context)
Boundary contributions to which have time varying components.
std::map< std::string, SharedPtr< GRINS::Physics > >::const_iterator PhysicsListIter
Iterator for PhysicsList.
virtual void init_context(libMesh::DiffContext &context)
Context initialization. Calls each physics implementation of init_context()
virtual void read_input_options(const GetPot &input)
Reads input options for this class and all physics that are enabled.
virtual void reinit(MultiphysicsSystem &system)
Reinitialize qoi.
const GetPot * _input
Cached for helping build boundary conditions.