23#include "libmesh/dirichlet_boundaries.h"
24#include "libmesh/dof_map.h"
25#include "libmesh/fe_base.h"
26#include "libmesh/fe_interface.h"
27#include "libmesh/fem_context.h"
28#include "libmesh/getpot.h"
29#include "libmesh/mesh.h"
30#include "libmesh/parallel.h"
31#include "libmesh/quadrature.h"
32#include "libmesh/string_to_enum.h"
33#include "libmesh/zero_function.h"
56 { libmesh_not_implemented(); }
70 virtual std::unique_ptr<FunctionBase<Number>>
clone()
const
83 GetPot infile(
"coupled_system.in");
84 Peclet = infile(
"Peclet", 1.);
85 unsigned int pressure_p = infile(
"pressure_p", 1);
86 std::string fe_family = infile(
"fe_family", std::string(
"LAGRANGE"));
93 FEFamily fefamily = Utility::string_to_enum<FEFamily>(fe_family);
127 std::set<boundary_id_type> right_inlet_bdy;
128 right_inlet_bdy.insert(right_inlet_id);
131 std::set<boundary_id_type> outlets_bdy;
132 outlets_bdy.insert(outlets_id);
142 int velocity_sign = 1;
146#ifdef LIBMESH_ENABLE_DIRICHLET
171 FEMSystem::init_data();
176 FEMContext & c = cast_ref<FEMContext &>(context);
182 FEBase * u_elem_fe =
nullptr;
189 FEBase * p_elem_fe =
nullptr;
193 FEBase * side_fe =
nullptr;
201 FEBase * p_side_fe =
nullptr;
210 FEMContext & c = cast_ref<FEMContext &>(context);
214 FEBase * u_elem_fe =
nullptr;
218 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
221 const std::vector<std::vector<Real>> & phi = u_elem_fe->
get_phi();
225 const std::vector<std::vector<RealGradient>> & dphi = u_elem_fe->
get_dphi();
229 FEBase * p_elem_fe =
nullptr;
232 const std::vector<std::vector<Real>> & psi = p_elem_fe->
get_phi();
241 std::reference_wrapper<DenseSubMatrix<Number>> Kdiag[2] =
250 std::reference_wrapper<DenseSubMatrix<Number>>
B[2] =
259 std::reference_wrapper<DenseSubVector<Number>> F[2] =
268 std::reference_wrapper<DenseSubMatrix<Number>> C[2] =
292 for (
unsigned int qp=0; qp != n_qpoints; qp++)
306 for (
unsigned int i=0; i != n_u_dofs; i++)
309 for (
unsigned int d=0; d<2; ++d)
312 (grad_uv[d]*dphi[i][qp]));
316 ((U*grad_C)*phi[i][qp] +
317 (1./
Peclet)*(grad_C*dphi[i][qp]));
326 for (
unsigned int j=0; j != n_u_dofs; j++)
328 for (
unsigned int d=0; d<2; ++d)
331 Kdiag[d](i,j) += JxW[qp] * (-(dphi[i][qp]*dphi[j][qp]));
334 C[d](i,j) += JxW[qp] * ((phi[j][qp]*grad_C(d))*phi[i][qp]);
339 ((U*dphi[j][qp])*phi[i][qp] +
340 (1./
Peclet)*(dphi[j][qp]*dphi[i][qp]));
344 for (
unsigned int j=0; j != n_p_dofs; j++)
345 for (
unsigned int d=0; d<2; ++d)
346 B[d](i,j) += JxW[qp]*psi[j][qp]*dphi[i][qp](d);
351 return request_jacobian;
358 FEMContext & c = cast_ref<FEMContext &>(context);
362 FEBase * u_elem_fe =
nullptr;
365 FEBase * p_elem_fe =
nullptr;
369 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
373 const std::vector<std::vector<RealGradient>> & dphi = u_elem_fe->
get_dphi();
377 const std::vector<std::vector<Real>> & psi = p_elem_fe->
get_phi();
385 std::reference_wrapper<DenseSubMatrix<Number>>
B[2] =
400 for (
unsigned int qp=0; qp != n_qpoints; qp++)
408 for (
unsigned int i=0; i != n_p_dofs; i++)
410 for (
unsigned int d=0; d<2; ++d)
411 Fp(i) += JxW[qp] * psi[i][qp] * grad_uv[d](d);
417 for (
unsigned int j=0; j != n_u_dofs; j++)
418 for (
unsigned int d=0; d<2; ++d)
419 B[d](i,j) += JxW[qp]*psi[i][qp]*dphi[j][qp](d);
424 return request_jacobian;
469 libmesh_error_msg(
"Wrong variable number " \
471 <<
" passed to CoupledFEMFunctionsx object! Quitting!");
502 libmesh_error_msg(
"Wrong variable number " \
504 <<
" passed to CoupledFEMFunctionsy object! Quitting!");
virtual Number operator()(const Point &, const Real=0)
virtual std::unique_ptr< FunctionBase< Number > > clone() const
const unsigned int _u_var
BdyFunction(unsigned int u_var, unsigned int v_var, int sign)
const unsigned int _v_var
virtual void operator()(const FEMContext &, const Point &, const Real, DenseVector< Number > &)
Evaluation function for time-dependent vector-valued functions.
virtual void operator()(const FEMContext &, const Point &, const Real, DenseVector< Number > &)
Evaluation function for time-dependent vector-valued functions.
virtual void init_context(DiffContext &context)
virtual bool element_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on elem to elem_residual.
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
virtual bool element_constraint(bool request_jacobian, DiffContext &context)
Adds the constraint contribution on elem to elem_residual.
virtual void postprocess()
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
Function that returns a single value that never changes.
Defines a dense submatrix for use in Finite Element-type computations.
Defines a dense subvector for use in finite element computations.
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
virtual void zero() override final
Set every element in the vector to 0.
This class provides all data required for a physics package (e.g.
Real elem_solution_derivative
The derivative of elem_solution with respect to the current nonlinear solution.
unsigned int n_dof_indices() const
Total number of dof indices on the element.
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
virtual void time_evolving(unsigned int var, unsigned int order)
Tells the DiffSystem that variable var is evolving with respect to time.
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
virtual_for_inffe const std::vector< Real > & get_JxW() const
virtual_for_inffe const std::vector< Point > & get_xyz() const
This class forms the foundation from which generic finite elements may be derived.
const std::vector< std::vector< OutputShape > > & get_phi() const
const std::vector< std::vector< OutputGradient > > & get_dphi() const
This class provides all data required for a physics package (e.g.
void get_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge/face (2D/3D) finite element object for variable var for the largest dimension in th...
Gradient interior_gradient(unsigned int var, unsigned int qp) const
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
Number interior_value(unsigned int var, unsigned int qp) const
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.
Number point_value(unsigned int var, const Point &p) const
Gradient point_gradient(unsigned int var, const Point &p) const
Real verify_analytic_jacobians
If verify_analytic_jacobian is equal to zero (as it is by default), no numeric jacobians will be calc...
Base class for functors that can be evaluated at a point and (optionally) time.
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
A Point defines a location in LIBMESH_DIM dimensional Real space.
unsigned int n_points() const
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Number get_qoi_value(unsigned int qoi_index) const
const DofMap & get_dof_map() const
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
ConstFunction that simply returns 0.
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real