Debian Codegraph @

packages/nox/test/epetra/LOCA_Brusselator/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 // Finite Element Problem Class
39 class Brusselator {
40
41 public:
42
43 // Constructor
44 Brusselator( int NumGlobalUnknowns, Epetra_Comm& Comm);
45
46 // Destructor
47 ~Brusselator();
48
49 // Reset problem for next parameter (time) step.
50 // For now, this simply updates oldsoln with the given Epetra_Vector
51 void reset(const Epetra_Vector& x);
52
53 // Set initial condition for solution vector
54 void initializeSoln();
55
56 // Set parameters alpha, beta
57 void setParameters(double alpha_, double beta_, double D1_, double D2_);
58
59 // Evaluates the function (F) and/or the Jacobian using the solution
60 // values in solnVector.
61 bool evaluate(FillType fType,
62 const Epetra_Vector *solnVector,
63 Epetra_Vector *rhsVector, Epetra_RowMatrix *matrix,
64 double jac_coeff = 1.0,
65 double mass_coeff = 0.0);
66
67 // Return a reference to the Epetra_Vector with the initial guess
68 // that is generated by the Brusselator class.
69 Epetra_Vector& getSolution();
70
71 // Return a reference to the Epetra_Vector with the Jacobian
72 // that is generated by the Brusselator class.
73 Epetra_CrsMatrix& getJacobian();
74
75 // Return a reference to the Epetra_Vector with the mesh positions
76 Epetra_Vector& getMesh();
77
78 // Return a reference to the Epetra_CrsGraph that is generated by
79 // the Brusselator problem class.
80 Epetra_CrsGraph& getGraph();
81
82 private:
83
84 // inserts the global column indices into the Graph
85 Epetra_CrsGraph& generateGraph(Epetra_CrsGraph& AA);
86
87 // Private to prohibit copying
88 Brusselator(const Brusselator&);
89 Brusselator& operator=(const Brusselator&);
90
91 private:
92
93 double xmin;
94 double xmax;
95 Epetra_Comm *Comm;
96 int NumGlobalNodes; // Total Number of nodes
97 Epetra_Import *ColumnToOverlapImporter;
98 Epetra_CrsGraph *AA;
99 Epetra_CrsMatrix *A;
100 double alpha, beta, D1, D2; // Model Parameters
101
102 // Default initialization for these
103 double dx;
104 Epetra_Map *StandardNodeMap;
105 Epetra_Map *OverlapNodeMap;
106 Epetra_Map *StandardMap;
107 Epetra_Map *OverlapMap;
108 Epetra_Import *Importer;
109 Epetra_Import *nodeImporter;
110 Epetra_Vector *xptr;
111 Epetra_Vector *initialSolution;
112 Epetra_Vector *rhs;
113
114 int MyPID; // Process number
115 int NumProc; // Total number of processes
116
117 static constexpr int NumSpecies = 2;
118 int NumMyNodes; // Number of nodes owned by this process
119 int NumMyUnknowns; // Number of unknowns owned by this process
120 int NumGlobalUnknowns; // Total Number of unknowns
121
122 };
123 #endif
124
125
126
127