44 #include <deal2lkit/dof_utilities.h>
45 #include <deal2lkit/parsed_finite_element.h>
46 #include <deal2lkit/any_data.h>
47 #include <deal2lkit/parsed_function.h>
48 #include <deal2lkit/parsed_mapped_functions.h>
49 #include <deal2lkit/parsed_dirichlet_bcs.h>
51 #include "data/assembly.h"
55 template <
int dim,
int spacedim=dim,
int n_components=1,
typename LAC=LATrilinos>
56 class Interface :
public ParsedFiniteElement<dim,spacedim>
58 typedef FEValuesCache<dim,spacedim> Scratch;
59 typedef Assembly::CopyData::piDoMUSPreconditioner<dim,dim> CopyPreconditioner;
60 typedef Assembly::CopyData::piDoMUSSystem<dim,dim> CopySystem;
67 const std::string &default_fe=
"FE_Q(1)",
68 const std::string &default_component_names=
"u",
69 const std::string &default_coupling=
"",
70 const std::string &default_preconditioner_coupling=
"",
71 const std::string &default_differential_components=
"") :
72 ParsedFiniteElement<dim,spacedim>(name, default_fe, default_component_names,
73 n_components, default_coupling, default_preconditioner_coupling),
74 forcing_terms(
"Forcing terms", default_component_names,
"0=ALL"),
75 neumann_bcs(
"Neumann boundary conditions", default_component_names,
"0=ALL"),
76 dirichlet_bcs(
"Dirichlet boundary conditions", default_component_names,
"0=ALL"),
88 virtual void set_time (
const double &
t)
const;
111 template<
typename Number>
115 std::vector<Number> &local_residual)
const;
127 template<
typename Number>
131 std::vector<Number> &local_residual)
const;
149 const double alpha)
const;
183 CopyPreconditioner &,
234 std::vector<Sdouble> &local_residual)
const;
250 std::vector<double> &local_residual)
const;
265 CopyPreconditioner &data,
266 std::vector<Sdouble> &local_residual)
const;
280 const std::vector<shared_ptr<typename LAC::BlockMatrix> >,
287 CopySystem &data)
const;
291 CopyPreconditioner &data)
const;
312 template<
typename Number>
315 FEValuesCache<dim,spacedim> &fe_cache)
const;
318 template<
typename Number>
321 const unsigned int face_no,
322 FEValuesCache<dim,spacedim> &fe_cache)
const;
330 CopyPreconditioner &data,
331 std::vector<std::vector<double> > &local_residuals)
const;
335 CopyPreconditioner &data,
336 std::vector<std::vector<Sdouble> > &local_residuals)
const;
340 CopyPreconditioner &data)
const;
399 template <
int dim,
int spacedim,
int n_components,
typename LAC>
400 template<
typename Number>
407 std::vector<Number> &local_residual)
const
412 for (
unsigned int face=0; face < GeometryInfo<dim>::faces_per_cell; ++face)
414 unsigned int face_id = cell->face(face)->boundary_id();
415 if (cell->face(face)->at_boundary() && neumann_bcs.acts_on_id(face_id))
417 this->reinit(dummy, cell, face, scratch);
419 auto &fev = scratch.get_current_fe_values();
420 auto &q_points = scratch.get_quadrature_points();
421 auto &JxW = scratch.get_JxW_values();
423 for (
unsigned int q=0; q<q_points.size(); ++q)
426 neumann_bcs.get_mapped_function(face_id)->vector_value(q_points[q], T);
428 for (
unsigned int i=0; i<local_residual.size(); ++i)
429 for (
unsigned int c=0; c<n_components; ++c)
430 local_residual[i] -= T[c]*fev.shape_value_component(i,q,c)*JxW[q];
438 template <
int dim,
int spacedim,
int n_components,
typename LAC>
439 template<
typename Number>
445 std::vector<Number> &local_residual)
const
447 unsigned cell_id = cell->material_id();
448 if (forcing_terms.acts_on_id(cell_id))
451 this->reinit(dummy, cell, scratch);
453 auto &fev = scratch.get_current_fe_values();
454 auto &q_points = scratch.get_quadrature_points();
455 auto &JxW = scratch.get_JxW_values();
456 for (
unsigned int q=0; q<q_points.size(); ++q)
457 for (
unsigned int i=0; i<local_residual.size(); ++i)
458 for (
unsigned int c=0; c<n_components; ++c)
460 double B = forcing_terms.get_mapped_function(cell_id)->value(q_points[q],c);
461 local_residual[i] -= B*fev.shape_value_component(i,q,c)*JxW[q];
467 template <
int dim,
int spacedim,
int n_components,
typename LAC>
468 template<
typename Number>
472 FEValuesCache<dim,spacedim> &fe_cache)
const
474 fe_cache.reinit(cell);
475 fe_cache.cache_local_solution_vector(
"old_solution", this->old_solution, alpha);
476 fe_cache.cache_local_solution_vector(
"solution", *this->solution, alpha);
477 fe_cache.cache_local_solution_vector(
"solution_dot", *this->solution_dot, alpha);
478 this->fix_solution_dot_derivative(fe_cache, alpha);
482 template <
int dim,
int spacedim,
int n_components,
typename LAC>
483 template<
typename Number>
487 const unsigned int face_no,
488 FEValuesCache<dim,spacedim> &fe_cache)
const
490 fe_cache.reinit(cell, face_no);
491 fe_cache.cache_local_solution_vector(
"old_solution", this->old_solution, alpha);
492 fe_cache.cache_local_solution_vector(
"solution", *this->solution, alpha);
493 fe_cache.cache_local_solution_vector(
"solution_dot", *this->solution_dot, alpha);
494 this->fix_solution_dot_derivative(fe_cache, alpha);
virtual void apply_dirichlet_bcs(const DoFHandler< dim, spacedim > &dof_handler, ConstraintMatrix &constraints) const
Applies Dirichlet boundary conditions.
ParsedMappedFunctions< spacedim, n_components > forcing_terms
Definition: old_interface.h:359
virtual void get_aux_matrix_residuals(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Scratch &scratch, CopyPreconditioner &data, std::vector< std::vector< double > > &local_residuals) const
void apply_neumann_bcs(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Scratch &scratch, CopySystem &data, std::vector< Number > &local_residual) const
Applies Neumann boundary conditions.
Definition: old_interface.h:403
virtual void get_system_energy(const typename DoFHandler< dim, spacedim >::active_cell_iterator &, Scratch &, CopySystem &, Sdouble &) const
Build the energy needed to get the system matrix in the case it is required two derivatives.
ParsedDirichletBCs< dim, spacedim, n_components > dirichlet_bcs
Definition: old_interface.h:361
virtual void get_system_residual(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Scratch &scratch, CopySystem &data, std::vector< Sdouble > &local_residual) const
Build the residual needed to get the system matrix in the case it is required two derivatives...
double old_t
Previous time step.
Definition: old_interface.h:389
const std::vector< unsigned int > get_differential_blocks() const
virtual ~Interface()
Definition: old_interface.h:64
virtual UpdateFlags get_face_flags() const
virtual void initialize_data(const typename LAC::VectorType &solution, const typename LAC::VectorType &solution_dot, const double t, const double alpha) const
Initialize all data required for the system.
ActiveSelector::active_cell_iterator active_cell_iterator
virtual void assemble_local_preconditioner(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Scratch &scratch, CopyPreconditioner &data) const
virtual UpdateFlags get_jacobian_flags() const
std::string str_diff_comp
Definition: old_interface.h:363
Interface.
Definition: old_interface.h:56
virtual void compute_system_operators(const DoFHandler< dim, spacedim > &, const typename LAC::BlockMatrix &, const typename LAC::BlockMatrix &, const std::vector< shared_ptr< typename LAC::BlockMatrix > >, LinearOperator< typename LAC::VectorType > &, LinearOperator< typename LAC::VectorType > &) const
Compute linear operators needed by the problem.
std::vector< unsigned int > _diff_comp
Definition: old_interface.h:364
void fix_solution_dot_derivative(FEValuesCache< dim, spacedim > &, double) const
virtual void assemble_local_aux_matrices(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Scratch &scratch, CopyPreconditioner &data) const
const LAC::VectorType * solution_dot
Time derivative solution vector evaluated at time t.
Definition: old_interface.h:379
virtual void parse_parameters_call_back()
const LAC::VectorType * solution
Solution vector evaluated at time t.
Definition: old_interface.h:369
virtual void get_preconditioner_energy(const typename DoFHandler< dim, spacedim >::active_cell_iterator &, Scratch &, CopySystem &, Sdouble &) const
Build the energy needed to get the preconditioner in the case it is required just one derivative...
unsigned int n_q_points
Definition: old_interface.h:393
virtual UpdateFlags get_residual_flags() const
virtual void postprocess_newly_created_triangulation(Triangulation< dim, spacedim > &tria) const
This function is used to modify triangulation using boundary_id or manifold_id.
virtual void assemble_local_system(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Scratch &scratch, CopySystem &data) const
LAC::VectorType old_solution
Solution vector evaluated at time t-dt.
Definition: old_interface.h:374
const Table< 2, DoFTools::Coupling > & get_aux_matrix_coupling(const unsigned int &i) const
void reinit(const Number &alpha, const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, FEValuesCache< dim, spacedim > &fe_cache) const
Definition: old_interface.h:470
virtual void set_time(const double &t) const
update time of all parsed mapped functions
UpdateFlags get_aux_matrix_flags(const unsigned int &i) const
std::vector< Table< 2, DoFTools::Coupling > > aux_matrix_coupling
Definition: old_interface.h:350
double alpha
Definition: old_interface.h:391
unsigned int n_face_q_points
Definition: old_interface.h:394
unsigned int dofs_per_cell
Definition: old_interface.h:392
virtual UpdateFlags get_jacobian_preconditioner_flags() const
void apply_forcing_terms(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Scratch &scratch, CopySystem &data, std::vector< Number > &local_residual) const
Applies CONSERVATIVE forcing terms.
Definition: old_interface.h:442
virtual void get_preconditioner_residual(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, Scratch &scratch, CopyPreconditioner &data, std::vector< Sdouble > &local_residual) const
Build the residual needed to get the preconditioner matrix in the case two derivatives are required...
ParsedMappedFunctions< spacedim, n_components > neumann_bcs
Definition: old_interface.h:360
std::vector< UpdateFlags > aux_matrix_update_flags
Definition: old_interface.h:349
virtual unsigned int get_number_of_aux_matrices() const
virtual void declare_parameters(ParameterHandler &prm)
Interface(const std::string &name="", const std::string &default_fe="FE_Q(1)", const std::string &default_component_names="u", const std::string &default_coupling="", const std::string &default_preconditioner_coupling="", const std::string &default_differential_components="")
Definition: old_interface.h:66
double t
Current time step.
Definition: old_interface.h:384
virtual shared_ptr< Mapping< dim, spacedim > > get_mapping(const DoFHandler< dim, spacedim > &, const typename LAC::VectorType &) const