22#include "libmesh/getpot.h"
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/mesh.h"
29#include "libmesh/quadrature.h"
30#include "libmesh/string_to_enum.h"
31#include "libmesh/zero_function.h"
32#include "libmesh/elem.h"
55 { libmesh_not_implemented(); }
62 const Real x=p(0), y=p(1), z=p(2);
68 virtual std::unique_ptr<FunctionBase<Number>>
clone()
const
83 GetPot infile(
"navier.in");
86 unsigned int pressure_p = infile(
"pressure_p", 1);
87 std::string fe_family = infile(
"fe_family", std::string(
"LAGRANGE"));
94 FEFamily fefamily = Utility::string_to_enum<FEFamily>(fe_family);
101 static_cast<Order>(pressure_p+1),
106 static_cast<Order>(pressure_p+1),
115 static_cast<Order>(pressure_p),
132#ifdef LIBMESH_ENABLE_DIRICHLET
135 std::set<boundary_id_type> top_bdys {
top_id };
138 std::set<boundary_id_type> all_bdys(all_ids, all_ids+(
dim*2));
140 std::set<boundary_id_type> nontop_bdys = all_bdys;
141 nontop_bdys.erase(
top_id);
173 FEMSystem::init_data();
180 FEMContext & c = cast_ref<FEMContext &>(context);
213 FEMContext & c = cast_ref<FEMContext &>(context);
225 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
228 const std::vector<std::vector<Real>> & phi = u_elem_fe->
get_phi();
232 const std::vector<std::vector<RealGradient>> & dphi = u_elem_fe->
get_dphi();
236 const std::vector<std::vector<Real>> & psi = p_elem_fe->
get_phi();
239 const std::vector<Point> & qpoint = u_elem_fe->
get_xyz();
252 std::reference_wrapper<DenseSubMatrix<Number>> K[3][3] =
263 std::reference_wrapper<DenseSubMatrix<Number>>
B[3] =
274 std::reference_wrapper<DenseSubVector<Number>> F[3] =
298 for (
unsigned int qp=0; qp != n_qpoints; qp++)
315 for (
unsigned int i=0; i != n_u_dofs; i++)
317 for (
unsigned int d = 0; d <
dim; ++d)
319 (-
Reynolds*(U*grad_uvw[d])*phi[i][qp] +
321 (grad_uvw[d]*dphi[i][qp]) +
331 for (
unsigned int j=0; j != n_u_dofs; j++)
332 for (
unsigned int k = 0; k <
dim; ++k)
333 for (
unsigned int l = 0; l <
dim; ++l)
337 K[k][k](i,j) += JxW[qp] *
338 (-
Reynolds*(U*dphi[j][qp])*phi[i][qp] -
339 (dphi[i][qp]*dphi[j][qp]));
342 K[k][l](i,j) += JxW[qp] * -
Reynolds*grad_uvw[k](l)*phi[i][qp]*phi[j][qp];
346 for (
unsigned int j=0; j != n_p_dofs; j++)
347 for (
unsigned int k = 0; k <
dim; ++k)
348 B[k](i,j) += JxW[qp]*psi[j][qp]*dphi[i][qp](k);
353 return request_jacobian;
361 FEMContext & c = cast_ref<FEMContext &>(context);
373 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
377 const std::vector<std::vector<RealGradient>> & dphi = u_elem_fe->
get_dphi();
381 const std::vector<std::vector<Real>> & psi = p_elem_fe->
get_phi();
392 std::reference_wrapper<DenseSubMatrix<Number>>
B[3] =
408 for (
unsigned int qp=0; qp != n_qpoints; qp++)
417 for (
unsigned int i=0; i != n_p_dofs; i++)
419 for (
unsigned int k = 0; k <
dim; ++k)
420 Fp(i) += JxW[qp] * psi[i][qp] * grad_uvw[k](k);
426 for (
unsigned int j=0; j != n_u_dofs; j++)
427 for (
unsigned int k = 0; k <
dim; ++k)
428 B[k](i,j) += JxW[qp]*psi[i][qp]*dphi[j][qp](k);
433 return request_jacobian;
441 FEMContext & c = cast_ref<FEMContext &>(context);
453 const Real penalty = 1.e9;
468 std::vector<Real> point_phi(n_p_dofs);
469 for (
unsigned int i=0; i != n_p_dofs; i++)
474 for (
unsigned int i=0; i != n_p_dofs; i++)
476 Fp(i) += penalty * (p - p_value) * point_phi[i];
481 for (
unsigned int j=0; j != n_p_dofs; j++)
482 Kpp(i,j) += penalty * point_phi[i] * point_phi[j];
487 return request_jacobian;
501 FEMContext & c = cast_ref<FEMContext &>(context);
511 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
514 const std::vector<std::vector<Real>> & phi = u_elem_fe->
get_phi();
517 std::reference_wrapper<DenseSubVector<Number>> F[3] =
525 std::reference_wrapper<DenseSubMatrix<Number>> Kdiag[3] =
538 std::array<Number, 3> accel;
540 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
549 for (
unsigned int k = 0; k <
dim; ++k)
552 for (
unsigned int i = 0; i != n_u_dofs; ++i)
554 for (
unsigned int k = 0; k <
dim; ++k)
555 F[k](i) -= accel[k] * phi[i][qp];
561 Number JxWxRexPhiI = JxWxRe * phi[i][qp];
562 Number JxWxRexPhiII = -JxWxRexPhiI * phi[i][qp];
563 for (
unsigned int k = 0; k <
dim; ++k)
564 Kdiag[k](i,i) += JxWxRexPhiII;
569 for (
unsigned int j = i+1; j != n_u_dofs; ++j)
571 Number Kij = -JxWxRexPhiI * phi[j][qp];
573 for (
unsigned int k = 0; k <
dim; ++k)
575 Kdiag[k](i,j) += Kij;
576 Kdiag[k](j,i) += Kij;
583 return request_jacobian;
592 Point p(1./3., 1./3.);
615 return Point(0.,0.,0.);
648 libmesh_assert_not_equal_to (1, this->
get_mesh().mesh_dimension());
649 const Real x=p(0), y=p(1), z=p(2);
665 libmesh_error_msg(
"Invalid application id = " <<
application);
virtual Number operator()(const Point &, const Real=0)
virtual std::unique_ptr< FunctionBase< Number > > clone() const
BdyFunction(unsigned int u_var, unsigned int v_var, unsigned int w_var, Real Reynolds)
const unsigned int _u_var
const unsigned int _w_var
const unsigned int _v_var
virtual void init_context(DiffContext &context)
virtual void postprocess()
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
virtual bool side_constraint(bool request_jacobian, DiffContext &context)
Adds the constraint contribution on side of elem to elem_residual.
virtual bool element_constraint(bool request_jacobian, DiffContext &context)
Adds the constraint contribution on elem to elem_residual.
virtual bool mass_residual(bool request_jacobian, DiffContext &context)
Subtracts a mass vector contribution on elem from elem_residual.
Point forcing(const Point &p)
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
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.
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.
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.
Real get_elem_solution_derivative() const
The derivative of the current elem_solution w.r.t.
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.
bool print_jacobians
Set print_jacobians to true to print J whenever it is assembled.
bool print_element_jacobians
Set print_element_jacobians to true to print each J_elem contribution.
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 bool contains_point(const Point &p, Real tol=TOLERANCE) const
virtual_for_inffe const std::vector< Real > & get_JxW() const
virtual_for_inffe const std::vector< Point > & get_xyz() const
FEType get_fe_type() 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
static Real shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
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
void interior_rate(unsigned int var, unsigned int qp, OutputType &u) 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
const Elem & get_elem() const
Accessor for current Elem object.
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
Real verify_analytic_jacobians
If verify_analytic_jacobian is equal to zero (as it is by default), no numeric jacobians will be calc...
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
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...
unsigned int mesh_dimension() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
unsigned int n_points() const
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) 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.
const DofMap & get_dof_map() const
const MeshBase & get_mesh() 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
const boundary_id_type top_id