libMesh
L-shaped.h
Go to the documentation of this file.
1 #include "libmesh/enum_fe_family.h"
2 #include "libmesh/fem_system.h"
3 #include "libmesh/parameter_vector.h"
4 #include "libmesh/qoi_set.h"
5 #include "libmesh/system.h"
6 #include "libmesh/parameter_pointer.h"
7 
8 #include <memory>
9 
10 // Bring in everything from the libMesh namespace
11 using namespace libMesh;
12 
13 // FEMSystem, TimeSolver and NewtonSolver will handle most tasks,
14 // but we must specify element residuals
15 class LaplaceSystem : public FEMSystem
16 {
17 public:
18  // Constructor
20  const std::string & name_in,
21  const unsigned int number_in)
22  : FEMSystem(es, name_in, number_in),
23  _fe_family("LAGRANGE"),
24  _fe_order(1),
25  _analytic_jacobians(true)
26  {}
27 
28  std::string & fe_family() { return _fe_family; }
29  unsigned int & fe_order() { return _fe_order; }
30  bool & analytic_jacobians() { return _analytic_jacobians; }
31 
32  Number & get_parameter_value(unsigned int parameter_index)
33  {
34  return parameters[parameter_index];
35  }
36 
38  {
39  parameter_vector.clear();
40  for (std::size_t i = 0; i != parameters.size(); ++i)
41  parameter_vector.push_back(std::make_unique<ParameterPointer<Number>>(&parameters[i]));
42 
43  return parameter_vector;
44  }
45 
46 protected:
47  // System initialization
48  virtual void init_data ();
49 
50  // Context initialization
51  virtual void init_context (DiffContext & context);
52 
53  // Element residual and jacobian calculations
54  // Time dependent parts
55  virtual bool element_time_derivative (bool request_jacobian,
56  DiffContext & context);
57 
58  // Constraint parts
59  virtual bool side_constraint (bool request_jacobian,
60  DiffContext & context);
61 
62  Number exact_solution (const Point &);
63 
64  // Parameters associated with the system
65  std::vector<Number> parameters;
66 
67  // The ParameterVector object that will contain pointers to
68  // the system parameters
70 
71  // The FE type to use
72  std::string _fe_family;
73  unsigned int _fe_order;
74 
75  // Calculate Jacobians analytically or not?
76  bool _analytic_jacobians;
77 };
This is the EquationSystems class.
This class provides all data required for a physics package (e.g.
Definition: diff_context.h:55
std::vector< Number > parameters
Definition: L-shaped.h:65
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
Accessor object allowing reading and modification of the independent variables in a parameter sensiti...
Number(* exact_solution)(const Point &p, const Parameters &, const std::string &, const std::string &)
std::string & fe_family()
Definition: L-shaped.h:28
LaplaceSystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Definition: L-shaped.h:19
bool & analytic_jacobians()
Definition: L-shaped.h:30
The libMesh namespace provides an interface to certain functionality in the library.
ParameterVector parameter_vector
Definition: L-shaped.h:69
This class provides a specific system class.
Definition: fem_system.h:53
Number & get_parameter_value(unsigned int parameter_index)
Definition: L-shaped.h:32
void clear()
Resets to "no parameters".
unsigned int & fe_order()
Definition: L-shaped.h:29
ParameterVector & get_parameter_vector()
Definition: L-shaped.h:37
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39