Debian Codegraph @

packages/nox/test/epetra/LOCA_Brusselator_xyzt/Brusselator.H

raw
1 // @HEADER
2 // *****************************************************************************
3 // LOCA: Library of Continuation Algorithms Package
4 //
5 // Copyright 2001-2005 NTESS and the LOCA contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 // Finite Element Problem Class
11 /* Provides function (F) and Jacobian evaluations for the following equation
12 * via a 1D linear finite element discretization with Epetra objects.
13 *
14 * d2u
15 * --- - k * u**2 = 0
16 * dx2
17 *
18 * subject to @ x=0, u=1
19 */
20
21 #ifndef _NOX_EXAMPLE_EPETRA_NONLINEAR_FINITEELEMENTPROBLEM_H
22 #define _NOX_EXAMPLE_EPETRA_NONLINEAR_FINITEELEMENTPROBLEM_H
23
24 // This is needed to get the FillType enum values from NOX_Epetra_Interface
25 #include "NOX_Epetra.H"
26
27 // Forward Declarations
28 class Epetra_Comm;
29 class Epetra_Map;
30 class Epetra_Vector;
31 class Epetra_Import;
32 class Epetra_CrsGraph;
33 class Epetra_CrsMatrix;
34
35 // Flag to tell the evaluate routine what objects to fill
36 enum FillType { F_ONLY, MATRIX_ONLY, ALL };
37
38 // Flag to tell how to order the unknowns - Currently not used
39 enum StoreUnknowns {Interleaved, Staggered};
40
41 // Finite Element Problem Class
42 class Brusselator {
43
44 public:
45
46 // Flag to tell the evaluate routine how to ghost shared information
47 enum OverlapType { NODES, ELEMENTS };
48
49 // Constructor
50 Brusselator( int NumGlobalUnknowns, Epetra_Comm& Comm,
51 OverlapType OType = ELEMENTS );
52
53 // Destructor
54 ~Brusselator();
55
56 // Reset problem for next parameter (time) step.
57 // For now, this simply updates oldsoln with the given Epetra_Vector
58 void setxDot(const Epetra_Vector& xdot);
59
60 // Set initial condition for solution vector
61 void initializeSoln();
62
63 // Set parameters alpha, beta
64 void setParameters(const double alpha_, const double beta_);
65
66 // Evaluates the function (F) and/or the Jacobian using the solution
67 // values in solnVector.
68 bool evaluate(NOX::Epetra::Interface::Required::FillType fType,
69 const Epetra_Vector *solnVector,
70 Epetra_Vector *rhsVector, Epetra_RowMatrix *matrix,
71 double jac_coeff, double mass_coeff);
72
73 // Return a reference to the Epetra_Vector with the initial guess
74 // that is generated by the Brusselator class.
75 Epetra_Vector& getSolution();
76
77 // Return a reference to the Epetra_Vector with the Jacobian
78 // that is generated by the Brusselator class.
79 Epetra_CrsMatrix& getJacobian();
80
81 // Return a reference to the Epetra_Vector with the mesh positions
82 Epetra_Vector& getMesh();
83
84 // Return a reference to the Epetra_Vector with the old solution
85 Epetra_Vector& getSolnDot();
86
87 // Return a reference to the Epetra_CrsGraph that is generated by
88 // the Brusselator problem class.
89 Epetra_CrsGraph& getGraph();
90
91 private:
92
93 // inserts the global column indices into the Graph
94 Epetra_CrsGraph& generateGraphUsingNodes(Epetra_CrsGraph& AA);
95
96 // inserts the global column indices into the Graph
97 Epetra_CrsGraph& generateGraphUsingElements(Epetra_CrsGraph& AA);
98
99 // Private to prohibit copying
100 Brusselator(const Brusselator&);
101 Brusselator& operator=(const Brusselator&);
102
103 private:
104
105 double xmin;
106 double xmax;
107 Epetra_Comm *Comm;
108 OverlapType overlapType;
109 int NumGlobalNodes; // Total Number of nodes
110 Epetra_Import *ColumnToOverlapImporter;
111 Epetra_CrsGraph *AA;
112 Epetra_CrsMatrix *A;
113 double alpha, beta; // Model Parameters
114
115 // Default initialization for these
116 double dx;
117 FillType flag;
118 Epetra_Map *StandardNodeMap;
119 Epetra_Map *OverlapNodeMap;
120 Epetra_Map *StandardMap;
121 Epetra_Map *OverlapMap;
122 Epetra_Import *Importer;
123 Epetra_Import *nodeImporter;
124 Epetra_Vector *xptr;
125 Epetra_Vector *initialSolution;
126 Epetra_Vector *solnDot;
127 Epetra_Vector *rhs;
128
129 int MyPID; // Process number
130 int NumProc; // Total number of processes
131
132 int NumSpecies; // Number of unknowns owned by this process
133 enum { NUMSPECIES = 2}; // Needed for SGI build
134 int NumMyNodes; // Number of nodes owned by this process
135 int NumMyUnknowns; // Number of unknowns owned by this process
136 int NumGlobalUnknowns; // Total Number of unknowns
137
138 };
139 #endif
140
141
142
143