Debian Codegraph @

packages/nox/test/epetra/MultiPhysics/GenericEpetraProblem.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 // A pure virtual problem class to be used (via encapsulation) in
11 // NOX_Epetra_Interface.H
12
13 #ifndef _NOX_GENERIC_PROBLEM_H
14 #define _NOX_GENERIC_PROBLEM_H
15
16 #include "NOX.H"
17 #include "NOX_Epetra.H"
18
19 // This is needed to get the FillType enum values from NOX_Epetra_Interface
20 #include "NOX_Epetra_Interface_Required.H"
21 #include "NOX_Epetra_Interface_Jacobian.H"
22 #include "NOX_Epetra_Interface_Preconditioner.H"
23
24 //#include "Problem_Manager.H"
25 class Problem_Manager;
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 class XferOp;
36
37 // Flag to tell the evaluate routine what objects to fill
38 enum FillType {F_ONLY, MATRIX_ONLY, ALL};
39
40 // Finite Element Problem Class
41 class GenericEpetraProblem {
42
43 friend class Problem_Manager;
44
45 public:
46
47 // Constructor
48 GenericEpetraProblem(const Epetra_Comm& Comm, int NumGlobalElements = 0,
49 std::string name = "");
50
51 // Destructor
52 virtual ~GenericEpetraProblem();
53
54 // Pure virtual methods
55
56 // Evaluates the function (RHS) and/or the Jacobian using the solution
57 // values in solnVector.
58 virtual bool evaluate( NOX::Epetra::Interface::Required::FillType fill,
59 const Epetra_Vector *solnVector,
60 Epetra_Vector *rhsVector ) = 0;
61
62 // Virtual methods with defaults provided
63
64 // Allow a reset capability, eg for time dependent or parameter
65 // continuation problems.
66 virtual void reset() { /* default no-op */ };
67
68 virtual void reset(const Epetra_Vector& x) { /* default no-op */ };
69
70 // Set the unique int id for this problem
71 virtual void setId(const int id_) { myId = id_; };
72
73 // Query the unique int id for this problem
74 virtual int getId() const { return myId; };
75
76 // Query the name for this problem
77 virtual std::string getName() const { return myName; };
78
79 // Set the name for this problem
80 virtual void setName(std::string name_) { myName = name_; };
81
82 // Set the problem Manager with which this problem interacts
83 // (ie for transfers)
84 virtual void setManager(Problem_Manager* manager_)
85 { myManager = manager_; };
86
87 // Add a problem to the list of that this one depends on
88 virtual void addProblemDependence(const GenericEpetraProblem& problemB);
89
90 // Add a transfer operator to get fields from another problem
91 virtual void addTransferOp(const GenericEpetraProblem& problemB);
92
93 // Signal whether the problem directly provides off-block structural info,
94 // ie global composite indices
95 virtual bool suppliesOffBlockStructure()
96 { return false; }
97
98 // Signal whether the problem directly provides off-block structural info for a
99 // particular dependent problem
100 virtual bool suppliesOffBlockStructure(int depID)
101 { return false; }
102
103 // Default no-op method that allows a child to provide off-block structural info,
104 virtual void getOffBlockIndices( map<int, std::vector<int> > & )
105 { return; }
106
107 // Do pre-transfer stuff, eg compute fluxes
108 virtual void prepare_data_for_transfer()
109 { /* default no-op */ };
110
111 // Do transfers from each problem to this
112 virtual void doTransfer();
113
114 // Do post-transfer stuff
115 virtual void process_transferred_data()
116 { /* default no-op */ };
117
118 // Set the solution vector (initialSolution)
119 virtual void setSolution(const Epetra_Vector&);
120
121 // Create storage for dependent data received from other problems via
122 // transfer operations
123 virtual void createDependentVectors();
124
125 virtual void initialize() { return; } // default no-op
126
127 // Create Standard and Overlap (ghost) maps
128 virtual void createMaps();
129
130 // Method needed to satisfy Problem_Interface.
131 virtual bool computePrecMatrix(const Epetra_Vector& solnVector,
132 Epetra_RowMatrix& matrix);
133
134 // Method needed to satisfy Problem_Interface.
135 virtual bool computePreconditioner(const Epetra_Vector& solnVector,
136 Epetra_Operator& precOperator);
137
138 // Return a reference to the mesh for this problem
139 virtual Epetra_Vector& getMesh();
140
141 // Return a reference to the Epetra_Vector with the initial guess
142 // that is generated by this class.
143 virtual Teuchos::RCP<Epetra_Vector> getSolution();
144
145 // Return a reference to the Epetra_CrsMatrix if one is used
146 virtual Teuchos::RCP<Epetra_CrsMatrix> getJacobian();
147
148 // Return a reference to the Epetra_CrsGraph if one is valid
149 virtual Teuchos::RCP<Epetra_CrsGraph> & getGraph()
150 { return AA; }
151
152 // Output results
153 virtual void outputResults(const NOX::Solver::Generic& solver,
154 Teuchos::ParameterList& printParams);
155
156 // Output problem description
157 virtual void outputStatus( std::ostream & os )
158 { return; }
159
160 // Output current solution state
161 virtual void outputSolutionStatus( std::ostream & os ) const;
162
163 // Provide for transient inherited problems
164 virtual void setdt( double dt );
165
166 // Provide for transient inherited problems
167 virtual double getdt() const;
168
169 // Accessor for container of dependent problems
170 virtual std::vector<int> & getDependentProblems()
171 { return depProblems; }
172
173 protected:
174
175 // inserts the global column indices into the Graph
176 virtual void generateGraph() { };
177
178 protected:
179
180 int myId ; // My unique integer id
181 std::string myName ;
182 Problem_Manager * myManager ; // Problem Manager with which this problem interacts
183 Epetra_Map * OverlapMap ;
184 Epetra_Import * Importer ;
185 Teuchos::RCP<Epetra_Vector> xptr ; // Mesh data
186 Teuchos::RCP<Epetra_Vector> initialSolution ;
187 Teuchos::RCP<Epetra_CrsGraph> AA ;
188 Teuchos::RCP<Epetra_CrsMatrix> A ;
189 std::vector<int> depProblems ; // List of problems that this one depends on
190 map<string, int> nameToMyIndex ;
191 map<int, Epetra_Vector*> depSolutions ; // Solutions from other Problems needed by this Problem
192 map<int, XferOp*> xferOperators ; // Container of transfer operators
193
194 public: // for now
195
196 const Epetra_Comm * Comm ;
197 Epetra_Map * StandardMap ;
198 int MyPID ; // Process number
199 int NumProc ; // Total number of processes
200
201 int NumMyNodes ; // Number of nodes (dofs) owned by this process for this problem
202 int NumGlobalNodes ; // Total Number of nodes (dofs) for this problem
203
204 };
205 #endif