1 #ifndef BIHARMONIC_H
2 #define BIHARMONIC_H
3 
4 #include "libmesh/equation_systems.h"
5 #include "libmesh/replicated_mesh.h"
6 #include "libmesh/exodusII_io.h"
7 #include "libmesh/mesh_refinement.h"
8 
9 // Bring in bits from the libMesh namespace.
10 // Just the bits we're using, since this is a header.
11 using libMesh::EquationSystems;
12 using libMesh::ExodusII_IO;
13 using libMesh::Point;
14 using libMesh::Real;
15 using libMesh::ReplicatedMesh;
16 
17 #ifdef LIBMESH_ENABLE_AMR
18 using libMesh::MeshRefinement;
19 #endif
20 
21 /**
22  * The Biharmonic class encapsulates most of the data structures
23  * necessary to calculate the biharmonic residual and Jacobian,
24  * auxiliary quantities, to take a timestep, and to output the state --
25  * biharmonic solution and vectors of auxiliary quantities.
26  *
27  * The main reason for this design is to have a data structure that
28  * has all of the necessary data in one place, where all of the
29  * calculation subroutines can access these data. Currently these data
30  * are split up among several interdependent objects with no clear
31  * hierarchy between them: mesh, equation system, equation system
32  * bundle, residual/Jacobian calculator.
33  *
34  * Since no object contains all others and the data are distributed
35  * among many objects, the natural control and data flow resides outside
36  * of these objects and is typically implemented in main().  We,
37  * however, would like to split the calculation into natural chunks --
38  * subroutines -- while retaining these subroutines access to the common
39  * necessary data -- biharmonic parameters, mesh and time interval
40  * sizes, etc. Thus, class Biharmonic.  Finally, making Biharmonic
41  * inherit from EquationSystems makes it possible to include it in the
42  * most common callbacks that do not pass back a user context, but only
43  * an EquationSystems object.
44  */
45 class Biharmonic : public EquationSystems
46 {
47 public:
48   // Initial state enumeration
49   enum InitialStateEnum {STRIP = 0,
50                          ROD   = 1,
51                          BALL  = 2};
52 
53   // Free energy enumeration
54   enum FreeEnergyEnum {DOUBLE_WELL         = 1,
55                        DOUBLE_OBSTACLE     = 2,
56                        LOG_DOUBLE_WELL     = 3,
57                        LOG_DOUBLE_OBSTACLE = 4};
58 
59   /**
60    * Constructor retrieves command-line options, setting  defaults, if necessary.
61    * It then builds the mesh using these options, then the equations systems around it,
62    * and, finally, sets up the output.
63    * We recommend that this be used through the factory Create function, which allocates
64    * the mesh. In that case don't forget to call Destroy at the end, to free the mesh up.
65    */
66   Biharmonic(ReplicatedMesh & mesh);
67 
68 
69   /**
70    * Destructor
71    */
~Biharmonic()72   ~Biharmonic()
73   {
74     // delete _meshRefinement;
75   }
76 
77 
78   // Misc. getters
verbose()79   bool verbose()         { return _verbose; }
dt0()80   Real dt0()             { return _dt0; }
dt()81   Real dt()              { return _dt; }
82 
83 
84   // Public interface functions
85   void viewParameters();
86   void init();
87   void step(const Real & dt = -1.0);
88   void output(int timestep, const Real & t, Real & o_t, bool force = false);
89   void run();
90 
91 private:
92   unsigned int  _dim, _N;
93   Real _kappa, _theta, _theta_c;
94   Real _tol;
95   bool _growth, _degenerate, _cahn_hillard, _netforce;
96   FreeEnergyEnum  _energy;
97   int _log_truncation;
98   bool _verbose;
99   InitialStateEnum  _initialState;
100   Point _initialCenter;
101   Real _initialWidth;
102   Real _dt0, _dt, _t0, _T, _t1;
103   Real _cnWeight;
104   //
105   std::string  _ofile_base, _ofile;
106   std::unique_ptr<ExodusII_IO> _exio;
107   Real    _o_dt;
108   int     _o_count;
109   //
110   friend class JR;
111   class JR;       // forward
112   ReplicatedMesh & _mesh;
113   JR * _jr;
114 };
115 
116 #endif // BIHARMONIC_H
117