Debian Codegraph @

packages/nox/test/epetra/1Dfem/1DfemInterface.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 TEST_EPETRA_1DFEM_INTERFACE_EPETRANEW_H
22 #define TEST_EPETRA_1DFEM_INTERFACE_EPETRANEW_H
23
24 #include "NOX_Epetra_Interface_Required.H" // base class
25 #include "NOX_Epetra_Interface_Jacobian.H" // base class
26 #include "NOX_Epetra_Interface_Preconditioner.H" // base class
27 #include "Teuchos_RCP.hpp"
28
29 // Forward Declarations
30 class Epetra_Comm;
31 class Epetra_Map;
32 class Epetra_Vector;
33 class Epetra_Import;
34 class Epetra_Operator;
35 class Epetra_CrsGraph;
36 class Epetra_RowMatrix;
37 class Epetra_CrsMatrix;
38 namespace NOX {
39 namespace Parameter {
40 class List;
41 }
42 }
43
44 // Finite Element Problem Class
45 class Interface : public NOX::Epetra::Interface::Required,
46 public NOX::Epetra::Interface::Jacobian,
47 public NOX::Epetra::Interface::Preconditioner {
48
49 public:
50
51 // Constructor
52 Interface(int NumGlobalElements, Epetra_Comm& Comm, double xmin = 0.0,
53 double xmax = 1.0 );
54
55 // Destructor
56 virtual ~Interface();
57
58 virtual bool computeF(const Epetra_Vector& x, Epetra_Vector& FVec,
59 FillType fillType = Residual);
60 virtual bool computeJacobian(const Epetra_Vector& x, Epetra_Operator& Jac);
61 virtual bool computePreconditioner(const Epetra_Vector& x,
62 Epetra_Operator& Prec,
63 Teuchos::ParameterList* precParams = 0);
64
65
66 // Return a reference to the Epetra_Vector with the initial guess
67 // that is generated by the Interface class.
68 Teuchos::RCP<Epetra_Vector> getSolution();
69
70 // Return a reference to the Epetra_Vector holding the mesh data
71 Teuchos::RCP<Epetra_Vector> getMesh();
72
73 // Return a reference to the Epetra_CrsMatrix with the Jacobian
74 // that is generated by the Interface class.
75 Teuchos::RCP<Epetra_CrsMatrix> getJacobian();
76
77 // Set PDE factor
78 bool setPDEfactor(double value) { factor = value; return true; };
79
80 protected:
81
82 // Evaluates the function (F) and/or the Jacobian using the solution
83 // values in solnVector.
84 virtual bool evaluate(FillType f, const Epetra_Vector *solnVector,
85 Epetra_Vector *rhsVector, Epetra_RowMatrix *matrix);
86
87 // Inserts the global column indices into the Graph
88 virtual bool createGraph();
89
90 // Set initial condition for solution vector
91 virtual bool initializeSoln();
92
93 protected:
94
95 enum TargetObjectType {FUNCTION, JACOBIAN};
96
97 int NumGlobalElements; // Total Number of elements
98 int NumMyElements; // Number of elements owned by this process
99 int MyPID; // Process number
100 int NumProc; // Total number of processes
101
102 double xmin;
103 double xmax;
104 double factor; // PDE factor
105
106 Epetra_Comm* Comm;
107 Epetra_Map* StandardMap;
108 Epetra_Map* OverlapMap;
109 Epetra_Import* Importer;
110 Teuchos::RCP<Epetra_Vector> initialSolution;
111 Epetra_Vector* rhs;
112 Epetra_CrsGraph* Graph;
113 Teuchos::RCP<Epetra_CrsMatrix> jacobian;
114 Teuchos::RCP<Epetra_Vector> xptr;
115
116 };
117
118 //==================================================================
119 // Finite Element Basis Object
120 class Basis {
121
122 public:
123 // Constructor
124 Basis();
125
126 // Destructor
127 ~Basis();
128
129 // Calculates the values of u and x at the specified gauss point
130 void computeBasis(int gp, double *x, double *u, double *uold = 0);
131
132 public:
133 // Variables that are calculated at the gauss point
134 double *phi, *dphide;
135 double uu, xx, duu, eta, wt;
136 double dx;
137 // These are only needed for transient
138 double uuold, duuold;
139 };
140
141 #endif
142
143
144
145