Debian Codegraph @

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

raw
1 // @HEADER
2 // *****************************************************************************
3 // NOX: An Object-Oriented Nonlinear Solver Package
4 //
5 // Copyright 2002 NTESS and the NOX 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 #include "Teuchos_RCP.hpp"
27
28 // Forward Declarations
29 class Epetra_Comm;
30 class Epetra_Map;
31 class Epetra_Vector;
32 class Epetra_Import;
33 class Epetra_CrsGraph;
34 class Epetra_CrsMatrix;
35
36 // Flag to tell the evaluate routine what objects to fill
37 enum FillType { F_ONLY, MATRIX_ONLY, ALL };
38
39 // Flag to tell how to order the unknowns - Currently not used
40 enum StoreUnknowns {Interleaved, Staggered};
41
42 // Finite Element Problem Class
43 class Brusselator {
44
45 public:
46
47 // Flag to tell the evaluate routine how to ghost shared information
48 enum OverlapType { NODES, ELEMENTS };
49
50 // Constructor
51 Brusselator( int NumGlobalUnknowns, Epetra_Comm& Comm,
52 OverlapType OType = ELEMENTS );
53
54 // Destructor
55 ~Brusselator();
56
57 // Reset problem for next parameter (time) step.
58 // For now, this simply updates oldsoln with the given Epetra_Vector
59 void reset(const Epetra_Vector& x);
60
61 // Set initial condition for solution vector
62 void initializeSoln();
63
64 // Evaluates the function (F) and/or the Jacobian using the solution
65 // values in solnVector.
66 bool evaluate(NOX::Epetra::Interface::Required::FillType fType,
67 const Epetra_Vector *solnVector,
68 Epetra_Vector *rhsVector, Epetra_RowMatrix *matrix);
69
70 // Return a reference to the Epetra_Vector with the initial guess
71 // that is generated by the Brusselator class.
72 Teuchos::RCP<Epetra_Vector> getSolution();
73
74 // Return a reference to the Epetra_Vector with the Jacobian
75 // that is generated by the Brusselator class.
76 Teuchos::RCP<Epetra_CrsMatrix> getJacobian();
77
78 // Return a reference to the Epetra_Vector with the mesh positions
79 Teuchos::RCP<Epetra_Vector> getMesh();
80
81 // Accesor function for time step
82 double getdt();
83
84 // Return a reference to the Epetra_Vector with the old solution
85 Epetra_Vector& getOldSoln();
86
87 // Return a reference to the Epetra_CrsGraph that is generated by
88 // the Brusselator problem class.
89 Teuchos::RCP<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:
100
101 double xmin;
102 double xmax;
103 double dx;
104 double dt;
105
106 FillType flag;
107 OverlapType overlapType;
108 Epetra_Map *StandardNodeMap;
109 Epetra_Map *OverlapNodeMap;
110 Epetra_Map *StandardMap;
111 Epetra_Map *OverlapMap;
112 Epetra_Import *Importer;
113 Epetra_Import *nodeImporter;
114 Epetra_Import *ColumnToOverlapImporter;
115 Teuchos::RCP<Epetra_Vector> xptr;
116 Teuchos::RCP<Epetra_Vector> initialSolution;
117 Epetra_Vector *oldSolution;
118 Epetra_Vector *rhs;
119 Teuchos::RCP<Epetra_CrsGraph> AA;
120 Teuchos::RCP<Epetra_CrsMatrix> A;
121 Epetra_Comm *Comm;
122
123 int MyPID; // Process number
124 int NumProc; // Total number of processes
125
126 int NumSpecies; // Number of unknowns owned by this process
127 enum { NUMSPECIES = 2}; // Needed for SGI build
128 int NumMyNodes; // Number of nodes owned by this process
129 int NumGlobalNodes; // Total Number of nodes
130 int NumMyUnknowns; // Number of unknowns owned by this process
131 int NumGlobalUnknowns; // Total Number of unknowns
132
133 };
134 #endif
135
136
137
138