FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_FEDataFilter.hpp
1 #ifndef _fei_FEDataFilter_hpp_
2 #define _fei_FEDataFilter_hpp_
3 
4 /*--------------------------------------------------------------------*/
5 /* Copyright 2005 Sandia Corporation. */
6 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
7 /* non-exclusive license for use of this work by or on behalf */
8 /* of the U.S. Government. Export of this program may require */
9 /* a license from the United States Government. */
10 /*--------------------------------------------------------------------*/
11 
12 #include "fei_fwd.hpp"
13 #include "fei_defs.h"
14 #include "fei_Filter.hpp"
15 
26 class FEDataFilter : public Filter {
27 
28  public:
29  // Constructor.
30  FEDataFilter(FEI_Implementation* owner, MPI_Comm comm,
31  SNL_FEI_Structure* probStruct,
32  LibraryWrapper* wrapper,
33  int masterRank=0);
34 
35  //Destructor
36  virtual ~FEDataFilter();
37 
38 
39  // set a value (usually zeros) throughout the linear system
40  int resetSystem(double s);
41  int resetMatrix(double s);
42  int resetRHSVector(double s);
43  int resetInitialGuess(double s);
44 
45  int deleteMultCRs();
46 
47  int loadNodeBCs(int numNodes,
48  const GlobalID *nodeIDs,
49  int fieldID,
50  const int* offsetsIntoField,
51  const double* prescribedValues);
52 
53  int loadElemBCs(int numElems,
54  const GlobalID *elemIDs,
55  int fieldID,
56  const double *const *alpha,
57  const double *const *beta,
58  const double *const *gamma);
59 
60  int sumInElem(GlobalID elemBlockID,
61  GlobalID elemID,
62  const GlobalID* elemConn,
63  const double* const* elemStiffness,
64  const double* elemLoad,
65  int elemFormat);
66 
67  int sumInElemMatrix(GlobalID elemBlockID,
68  GlobalID elemID,
69  const GlobalID* elemConn,
70  const double* const* elemStiffness,
71  int elemFormat);
72 
73  int sumInElemRHS(GlobalID elemBlockID,
74  GlobalID elemID,
75  const GlobalID* elemConn,
76  const double* elemLoad);
77 
78  int loadCRMult(int CRMultID,
79  int numCRNodes,
80  const GlobalID* CRNodes,
81  const int* CRFields,
82  const double* CRWeights,
83  double CRValue);
84 
85  int loadCRPen(int CRPenID,
86  int numCRNodes,
87  const GlobalID* CRNodes,
88  const int *CRFields,
89  const double* CRWeights,
90  double CRValue,
91  double penValue);
92 
93  int putIntoRHS(int IDType,
94  int fieldID,
95  int numIDs,
96  const GlobalID* IDs,
97  const double* rhsEntries);
98 
99  int sumIntoRHS(int IDType,
100  int fieldID,
101  int numIDs,
102  const GlobalID* IDs,
103  const double* rhsEntries);
104 
105  int sumIntoMatrixDiagonal(int IDType,
106  int fieldID,
107  int numIDs,
108  const GlobalID* IDs,
109  const double* coefficients);
110 
111  int loadComplete();
112 
113  // set parameters associated with solver choice, etc.
114  int parameters(int numParams, const char *const* paramStrings);
115 
116  //get residual norms
117  int residualNorm(int whichNorm, int numFields,
118  int* fieldIDs, double* norms, double& residTime);
119 
120  // start iterative solution
121  int solve(int& status, double& sTime);
122 
123  // query function iterations performed.
124  int iterations() const {return(iterations_);};
125 
126 // Solution return services.......................................
127 
128  // return all nodal solution params on a block-by-block basis
129  int getBlockNodeSolution(GlobalID elemBlockID,
130  int numNodes,
131  const GlobalID *nodeIDs,
132  int *offsets,
133  double *results);
134 
135  int getNodalSolution(int numNodes,
136  const GlobalID *nodeIDs,
137  int *offsets,
138  double *results);
139 
140  // return nodal solution for one field on a block-by-block basis
141  int getBlockFieldNodeSolution(GlobalID elemBlockID,
142  int fieldID,
143  int numNodes,
144  const GlobalID *nodeIDs,
145  double *results);
146 
147  // return element solution params on a block-by-block basis
148  int getBlockElemSolution(GlobalID elemBlockID,
149  int numElems,
150  const GlobalID *elemIDs,
151  int& numElemDOFPerElement,
152  double *results);
153 
154  int getCRMultipliers(int numCRs, const int* CRIDs, double* multipliers);
155 
156 // associated "puts" paralleling the solution return services.
157 //
158 // the int sizing parameters are passed for error-checking purposes, so
159 // that the interface implementation can tell if the passed estimate
160 // vectors make sense -before- an attempt is made to utilize them as
161 // initial guesses by unpacking them into the solver's native solution
162 // vector format (these parameters include lenNodeIDList, lenElemIDList,
163 // numElemDOF, and numMultCRs -- all other passed params are either
164 // vectors or block/constraint-set IDs)
165 
166  // put nodal-based solution guess on a block-by-block basis
167  int putBlockNodeSolution(GlobalID elemBlockID,
168  int numNodes,
169  const GlobalID *nodeIDs,
170  const int *offsets,
171  const double *estimates);
172 
173  // put nodal-based guess for one field on a block-by-block basis
174  int putBlockFieldNodeSolution(GlobalID elemBlockID,
175  int fieldID,
176  int numNodes,
177  const GlobalID *nodeIDs,
178  const double *estimates);
179 
180  // put element-based solution guess on a block-by-block basis
181  int putBlockElemSolution(GlobalID elemBlockID,
182  int numElems,
183  const GlobalID *elemIDs,
184  int dofPerElem,
185  const double *estimates);
186 
187  int putCRMultipliers(int numMultCRs,
188  const int* CRIDs,
189  const double *multEstimates);
190 
191 //===== a couple of public non-FEI functions... ================================
192 //These are intended to be used by an 'outer-layer' class like
193 //FEI_Implementation.
194 //
195  public:
196  int getNodalFieldSolution(int fieldID,
197  int numNodes,
198  const GlobalID* nodeIDs,
199  double* results);
200 
201  int putNodalFieldData(int fieldID,
202  int numNodes,
203  const GlobalID* nodeIDs,
204  const double* nodeData);
205 
206  int putNodalFieldSolution(int fieldID,
207  int numNodes,
208  const GlobalID* nodeIDs,
209  const double* nodeData);
210 
211  int unpackSolution();
212 
213  void setEqnCommMgr(EqnCommMgr* eqnCommMgr);
214 
215  EqnCommMgr* getEqnCommMgr() {return(eqnCommMgr_);};
216 
217  int setNumRHSVectors(int numRHSs, int* rhsIDs);
218  int setCurrentRHS(int rhsID);
219 
220  int enforceEssentialBCs(const int* eqns, const double* alpha,
221  const double* gamma, int numEqns);
222 
223  int initialize();
224 
225 //==============================================================================
226 //private functions for internal implementation of FEDataFilter.
227 //==============================================================================
228  private:
229  FEDataFilter(const FEDataFilter& src);
230  FEDataFilter& operator=(const FEDataFilter& src);
231 
232  int initLinSysCore();
233 
234  int loadFEDataMultCR(int CRID,
235  int numCRNodes,
236  const GlobalID* CRNodes,
237  const int* CRFields,
238  const double* CRWeights,
239  double CRValue);
240 
241  int loadFEDataPenCR(int CRID,
242  int numCRNodes,
243  const GlobalID* CRNodes,
244  const int* CRFields,
245  const double* CRWeights,
246  double CRValue,
247  double penValue);
248 
249  int generalElemInput(GlobalID elemBlockID,
250  GlobalID elemID,
251  const double* const* elemStiffness,
252  const double* elemLoad,
253  int elemFormat);
254 
255  int generalElemInput(GlobalID elemBlockID,
256  GlobalID elemID,
257  const GlobalID* elemConn,
258  const double* const* elemStiffness,
259  const double* elemLoad,
260  int elemFormat);
261 
262  void allocElemStuff();
263 
264  int giveToMatrix(int numPtRows, const int* ptRows,
265  int numPtCols, const int* ptCols,
266  const double* const* values,
267  int mode);
268 
269  int giveToLocalReducedMatrix(int numPtRows, const int* ptRows,
270  int numPtCols, const int* ptCols,
271  const double* const* values,
272  int mode);
273 
274  int getFromMatrix(int numPtRows, const int* ptRows,
275  const int* rowColOffsets, const int* ptCols,
276  int numColsPerRow, double** values);
277 
278  int getEqnsFromMatrix(ProcEqns& procEqns, EqnBuffer& eqnData);
279 
280  int getEqnsFromRHS(ProcEqns& procEqns, EqnBuffer& eqnData);
281 
282  int giveToRHS(int num, const double* values,
283  const int* indices, int mode);
284 
285  int giveToLocalReducedRHS(int num, const double* values,
286  const int* indices, int mode);
287 
288  int getFromRHS(int num, double* values, const int* indices);
289 
290  int getEqnSolnEntry(int eqnNumber, double& solnValue);
291 
292  int getSharedRemoteSolnEntry(int eqnNumber, double& solnValue);
293 
294  int getReducedSolnEntry(int eqnNumber, double& solnValue);
295 
296  int formResidual(double* residValues, int numLocalEqns);
297 
298  int getRemoteSharedEqns(int numPtRows, const int* ptRows,
299  ProcEqns& remoteProcEqns);
300 
301  int resetTheMatrix(double s);
302  int resetTheRHSVector(double s);
303 
304  int assembleEqns(int numPtRows,
305  int numPtCols,
306  const int* rowNumbers,
307  const int* colIndices,
308  const double* const* coefs,
309  bool structurallySymmetric,
310  int mode);
311 
312  int assembleRHS(int numValues, const int* indices, const double* coefs, int mode);
313 
314  void debugOutput(const char* mesg);
315 
316  int createEqnCommMgr_put();
317 
318 //==============================================================================
319 //private FEDataFilter variables
320 //==============================================================================
321  private:
322 
323  LibraryWrapper* wrapper_;
325  bool useLookup_;
326 
327  int internalFei_;
328 
329  bool newData_;
330 
331  int localStartRow_, localEndRow_, numGlobalEqns_;
332  int reducedStartRow_, reducedEndRow_, numReducedRows_;
333 
334  int iterations_;
335  int numRHSs_;
336  int currentRHS_;
337  std::vector<int> rhsIDs_;
338 
339  int outputLevel_;
340 
341  MPI_Comm comm_;
342  int masterRank_;
343 
344  SNL_FEI_Structure* problemStructure_;
345 
346  std::vector<GlobalID> penCRIDs_;
347 
348  std::vector<int> rowIndices_;
349  std::vector<int> rowColOffsets_, colIndices_;
350 
351  EqnCommMgr* eqnCommMgr_; //equation communication manager
352  EqnCommMgr* eqnCommMgr_put_; //only created if users call
353  // the 'put' functions
354 
355  int maxElemRows_;
356 
357  double** eStiff_;
358  double* eStiff1D_;
359  double* eLoad_;
360 
361  int numRegularElems_;
362  std::vector<int> constraintBlocks_;
363  std::vector<int> constraintNodeOffsets_;
364  std::vector<int> packedFieldSizes_;
365 };
366 
367 #endif
368