Go to the documentation of this file.
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"
19 #include "libmesh/auto_ptr.h"
33 { this->_initialized =
true; }
36 { libmesh_not_implemented(); }
38 virtual void operator() (
const Point & p,
46 output(_T_var) = -x * (1 - x);
49 virtual std::unique_ptr<FunctionBase<Number>>
clone()
const
50 {
return libmesh_make_unique<BdyFunction>(_T_var); }
59 this->add_variable (
"T", static_cast<Order>(_fe_order),
60 Utility::string_to_enum<FEFamily>(_fe_family));
62 GetPot infile(
"poisson.in");
63 exact_QoI[0] = infile(
"QoI_0", 0.0);
64 alpha = infile(
"alpha", 100.0);
67 this->time_evolving(T_var, 1);
69 #ifdef LIBMESH_ENABLE_DIRICHLET
74 std::set<boundary_id_type> all_bdy(all_bdry_id, all_bdry_id+4);
78 std::set<boundary_id_type> bottom_bdry;
79 bottom_bdry.insert(bottom_bdry_id);
82 std::vector<unsigned int> T_only(1, T_var);
91 this->get_dof_map().add_adjoint_dirichlet_boundary(
DirichletBoundary (bottom_bdry, T_only, &bottom_adjoint), 0);
92 #endif // LIBMESH_ENABLE_DIRICHLET
100 FEMContext & c = cast_ref<FEMContext &>(context);
104 FEBase* elem_fe =
nullptr;
111 FEBase* side_fe =
nullptr;
121 #define optassert(X) {if (!(X)) libmesh_error_msg("Assertion " #X " failed.");}
130 FEMContext & c = cast_ref<FEMContext &>(context);
134 FEBase* elem_fe =
nullptr;
138 const std::vector<Real> & JxW = elem_fe->
get_JxW();
141 const std::vector<std::vector<Real>> & phi = elem_fe->
get_phi();
142 const std::vector<std::vector<RealGradient>> & dphi = elem_fe->
get_dphi();
145 const std::vector<Point > & q_point = elem_fe->
get_xyz();
162 for (
unsigned int qp=0; qp != n_qpoints; qp++)
168 const Real x = q_point[qp](0);
169 const Real y = q_point[qp](1);
172 Real f = -alpha * ( ( (- 4 * alpha * alpha) * exp(-alpha*x) * y * (1 - y) ) + ( -8 + ( 8 * exp(-alpha*x) ) + ( 8 * ( 1 - exp(-alpha) )* x) ) );
175 for (
unsigned int i=0; i != n_T_dofs; i++)
176 F(i) += JxW[qp] * ( (f * phi[i][qp]) - alpha*(grad_T * dphi[i][qp]) ) ;
178 for (
unsigned int i=0; i != n_T_dofs; i++)
179 for (
unsigned int j=0; j != n_T_dofs; ++j)
181 K(i,j) += JxW[qp] * ( -alpha*(dphi[i][qp] * dphi[j][qp]) );
192 computed_QoI[0] = 0.0;
196 this->comm().sum(computed_QoI[0]);
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
Base class for functors that can be evaluated at a point and (optionally) time.
const std::vector< Point > & get_xyz() const
virtual void postprocess(void)
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
void compute_jacobian(const NumericVector< Number > &, SparseMatrix< Number > &J, NonlinearImplicitSystem &system)
virtual void init_data() override
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.
unsigned int n_points() const
The libMesh namespace provides an interface to certain functionality in the library.
virtual void zero() override
Set every element in the vector to 0.
This class forms the foundation from which generic finite elements may be derived.
const std::vector< Real > & get_JxW() const
const std::vector< std::vector< OutputGradient > > & get_dphi() const
virtual void postprocess() override
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
const unsigned int _T_var
A Point defines a location in LIBMESH_DIM dimensional Real space.
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
virtual std::unique_ptr< FunctionBase< Number > > clone() const
unsigned int n_dof_indices() const
Total number of dof indices on the element.
ConstFunction that simply returns 0.
This class provides all data required for a physics package (e.g.
virtual bool element_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on elem to elem_residual.
BdyFunction(unsigned int T_var)
void resize(const unsigned int n)
Resize the vector.
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.
Gradient interior_gradient(unsigned int var, unsigned int qp) const
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
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...
const std::vector< std::vector< OutputShape > > & get_phi() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void init_context(DiffContext &context)
This class provides all data required for a physics package (e.g.