4#include "libmesh/getpot.h"
5#include "libmesh/boundary_info.h"
6#include "libmesh/dirichlet_boundaries.h"
7#include "libmesh/dof_map.h"
8#include "libmesh/fe_base.h"
9#include "libmesh/fe_interface.h"
10#include "libmesh/fem_context.h"
11#include "libmesh/fem_system.h"
12#include "libmesh/quadrature.h"
13#include "libmesh/string_to_enum.h"
14#include "libmesh/mesh.h"
15#include "libmesh/parallel.h"
16#include "libmesh/quadrature.h"
17#include "libmesh/fem_context.h"
18#include "libmesh/zero_function.h"
38 { libmesh_not_implemented(); }
48 output(
_T_var) = -x * (1 - x);
51 virtual std::unique_ptr<FunctionBase<Number>>
clone()
const
52 {
return std::make_unique<BdyFunction>(
_T_var); }
62 Utility::string_to_enum<FEFamily>(
_fe_family));
64 GetPot infile(
"poisson.in");
66 alpha = infile(
"alpha", 100.0);
71#ifdef LIBMESH_ENABLE_DIRICHLET
88 FEMSystem::init_data();
93 FEMContext & c = cast_ref<FEMContext &>(context);
104 FEBase* side_fe =
nullptr;
114#define optassert(X) {if (!(X)) libmesh_error_msg("Assertion " #X " failed.");}
123 FEMContext & c = cast_ref<FEMContext &>(context);
127 FEBase* elem_fe =
nullptr;
131 const std::vector<Real> & JxW = elem_fe->
get_JxW();
134 const std::vector<std::vector<Real>> & phi = elem_fe->
get_phi();
135 const std::vector<std::vector<RealGradient>> & dphi = elem_fe->
get_dphi();
138 const std::vector<Point > & q_point = elem_fe->
get_xyz();
155 for (
unsigned int qp=0; qp != n_qpoints; qp++)
161 const Real x = q_point[qp](0);
162 const Real y = q_point[qp](1);
168 for (
unsigned int i=0; i != n_T_dofs; i++)
169 F(i) += JxW[qp] * ( (f * phi[i][qp]) -
alpha*(grad_T * dphi[i][qp]) ) ;
171 for (
unsigned int i=0; i != n_T_dofs; i++)
172 for (
unsigned int j=0; j != n_T_dofs; ++j)
174 K(i,j) += JxW[qp] * ( -
alpha*(dphi[i][qp] * dphi[j][qp]) );
187 FEMSystem::postprocess();
virtual Number operator()(const Point &, const Real=0)
virtual std::unique_ptr< FunctionBase< Number > > clone() const
const unsigned int _T_var
BdyFunction(unsigned int T_var)
virtual void init_context(DiffContext &context)
virtual void postprocess(void)
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
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.
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.
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.
void add_adjoint_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary, unsigned int q)
Adds a copy of the specified Dirichlet boundary to the system, corresponding to the adjoint problem d...
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.
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.
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...
const Parallel::Communicator & comm() const
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.
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
void compute_jacobian(const NumericVector< Number > &, SparseMatrix< Number > &J, NonlinearImplicitSystem &system)