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" 52 { this->_initialized =
true; }
56 { libmesh_not_implemented(); }
58 virtual void operator() (
const Point & p,
66 output(_u_var) = (_sign)*((y-2) * (y-3));
70 virtual std::unique_ptr<FunctionBase<Number>>
clone()
const 71 {
return std::make_unique<BdyFunction>(_u_var, _v_var,
int(_sign)); }
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);
97 u_var = this->add_variable (
"u", static_cast<Order>(pressure_p+1),
99 v_var = this->add_variable (
"v", static_cast<Order>(pressure_p+1),
105 p_var = this->add_variable (
"p", static_cast<Order>(pressure_p),
110 C_var = this->add_variable (
"C", static_cast<Order>(pressure_p+1),
116 this->time_evolving(u_var, 1);
117 this->time_evolving(v_var, 1);
118 this->time_evolving(C_var, 1);
121 this->verify_analytic_jacobians = infile(
"verify_analytic_jacobians", 0.);
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;
143 BdyFunction inflow_left(u_var, v_var, -velocity_sign);
144 BdyFunction inflow_right(u_var, v_var, velocity_sign);
146 #ifdef LIBMESH_ENABLE_DIRICHLET 148 this->get_dof_map().add_dirichlet_boundary
153 this->get_dof_map().add_dirichlet_boundary
155 this->get_dof_map().add_dirichlet_boundary
160 this->get_dof_map().add_dirichlet_boundary
162 this->get_dof_map().add_dirichlet_boundary
164 #endif // LIBMESH_ENABLE_DIRICHLET 176 FEMContext & c = cast_ref<FEMContext &>(context);
182 FEBase * u_elem_fe =
nullptr;
184 u_elem_fe->get_JxW();
185 u_elem_fe->get_phi();
186 u_elem_fe->get_dphi();
187 u_elem_fe->get_xyz();
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;
432 computed_QoI = this->get_qoi_value(0);
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!");
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
Number interior_value(unsigned int var, unsigned int qp) const
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used...
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...
virtual void zero() override final
Set every element in the vector to 0.
ConstFunction that simply returns 0.
void resize(const unsigned int n)
Resize the vector.
virtual bool element_constraint(bool request_jacobian, DiffContext &context)
Adds the constraint contribution on elem to elem_residual.
unsigned int n_dof_indices() const
Total number of dof indices on the element.
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
virtual void postprocess()
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides...
const unsigned int _v_var
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
Number point_value(unsigned int var, const Point &p) const
Defines a dense subvector for use in finite element computations.
BdyFunction(unsigned int u_var, unsigned int v_var, int sign)
Gradient interior_gradient(unsigned int var, unsigned int qp) const
virtual std::unique_ptr< FunctionBase< Number > > clone() const
virtual void init_context(DiffContext &context)
Defines a dense submatrix for use in Finite Element-type computations.
Real elem_solution_derivative
The derivative of elem_solution with respect to the current nonlinear solution.
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.
unsigned int n_points() const
virtual_for_inffe const std::vector< Point > & get_xyz() const
virtual void operator()(const FEMContext &, const Point &, const Real, DenseVector< Number > &)
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual bool element_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on elem to elem_residual.
Function that returns a single value that never changes.
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...
FEFamily
defines an enum for finite element families.
Gradient point_gradient(unsigned int var, const Point &p) const
Base class for functors that can be evaluated at a point and (optionally) time.
A Point defines a location in LIBMESH_DIM dimensional Real space.
void ErrorVector unsigned int
This class forms the foundation from which generic finite elements may be derived.
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
const std::vector< std::vector< OutputShape > > & get_phi() const
virtual void operator()(const FEMContext &, const Point &, const Real, DenseVector< Number > &)