libMesh
side_qoi_derivative.C
Go to the documentation of this file.
1 // General libMesh includes
2 #include "libmesh/libmesh_common.h"
3 #include "libmesh/elem.h"
4 #include "libmesh/fe_base.h"
5 #include "libmesh/fem_context.h"
6 #include "libmesh/point.h"
7 #include "libmesh/quadrature.h"
8 
9 // Local includes
10 #include "L-shaped.h"
11 
12 // Bring in everything from the libMesh namespace
13 using namespace libMesh;
14 
15 // We only have one QoI, so we don't bother checking the qois argument
16 // to see if it was requested from us
18  const QoISet & /* qois */)
19 {
20  FEMContext & c = cast_ref<FEMContext &>(context);
21 
22  // First we get some references to cell-specific data that
23  // will be used to assemble the linear system.
24  FEBase * side_fe = nullptr;
25  c.get_side_fe(0, side_fe);
26 
27  // Element Jacobian * quadrature weights for interior integration
28  const std::vector<Real> & JxW = side_fe->get_JxW();
29 
30  // Basis Functions
31  const std::vector<std::vector<RealGradient>> & dphi = side_fe->get_dphi();
32 
33  // The side quadrature points
34  const std::vector<Point> & q_point = side_fe->get_xyz();
35 
36  // Get the normal to the side at each qp
37  const std::vector<Point> & face_normals = side_fe->get_normals();
38 
39  // The number of local degrees of freedom in each variable
40  const unsigned int n_T_dofs = c.n_dof_indices(0);
41  unsigned int n_qpoints = c.get_side_qrule().n_points();
42 
43  // Fill the QoI RHS corresponding to this QoI. Since this is QoI 1
44  // we fill in the [1][i] subderivatives, i corresponding to the variable index.
45  // Our system has only one variable, so we only have to fill the [1][0] subderivative
47 
48  const Real TOL = 1.e-5;
49 
50  for (unsigned int qp=0; qp != n_qpoints; qp++)
51  {
52  const Real x = q_point[qp](0);
53  const Real y = q_point[qp](1);
54 
55  // If on the sides where the boundary QoI is supported, add contributions
56  // to the adjoint rhs
57  if (std::abs(y - 1.0) <= TOL && x > 0.0)
58  for (unsigned int i=0; i != n_T_dofs; i++)
59  Q1(i) += JxW[qp] * (dphi[i][qp] * face_normals[qp]) * x * (x - 1.);
60 
61  } // end of the quadrature point qp-loop
62 }
libMesh::FEAbstract::get_xyz
const std::vector< Point > & get_xyz() const
Definition: fe_abstract.h:237
LaplaceSystem::side_qoi_derivative
virtual void side_qoi_derivative(DiffContext &context, const QoISet &qois)
Does any work that needs to be done on side of elem in a quantity of interest derivative assembly loo...
Definition: side_qoi_derivative.C:17
libMesh::FEAbstract::get_normals
const std::vector< Point > & get_normals() const
Definition: fe_abstract.h:380
libMesh::QBase::n_points
unsigned int n_points() const
Definition: quadrature.h:126
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::FEGenericBase
This class forms the foundation from which generic finite elements may be derived.
Definition: exact_error_estimator.h:39
libMesh::FEAbstract::get_JxW
const std::vector< Real > & get_JxW() const
Definition: fe_abstract.h:244
libMesh::FEGenericBase::get_dphi
const std::vector< std::vector< OutputGradient > > & get_dphi() const
Definition: fe_base.h:214
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::DiffContext::get_qoi_derivatives
const std::vector< DenseVector< Number > > & get_qoi_derivatives() const
Const accessor for QoI derivatives.
Definition: diff_context.h:331
libMesh::QoISet
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
Definition: qoi_set.h:45
libMesh::DiffContext::n_dof_indices
unsigned int n_dof_indices() const
Total number of dof indices on the element.
Definition: diff_context.h:399
libMesh::DiffContext
This class provides all data required for a physics package (e.g.
Definition: diff_context.h:55
libMesh::DenseSubVector< Number >
libMesh::FEMContext::get_side_qrule
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem.
Definition: fem_context.h:797
libMesh::FEMContext::get_side_fe
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...
Definition: fem_context.h:312
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::FEMContext
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:62