FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fei_FEI_Impl.hpp
Go to the documentation of this file.
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 #ifndef _fei_FEI_Impl_hpp_
10 #define _fei_FEI_Impl_hpp_
11 
12 #include <fei_macros.hpp>
13 #include <fei_mpi.h>
14 #include <FEI.hpp>
15 #include <fei_Factory.hpp>
16 
17 #include <set>
18 #include <vector>
19 #include <map>
20 
21 namespace fei {
22 
33  class FEI_Impl : public FEI, private fei::Logger {
34  public:
38  MPI_Comm comm,
39  int masterRank=0);
40 
43  FEI_Impl(const fei::Factory* factory,
44  MPI_Comm comm,
45  int masterRank=0);
46 
49  virtual ~FEI_Impl();
50 
56 
57  int parameters(int numParams,
58  const char *const* paramStrings);
59 
60  int setIDLists(int numMatrices,
61  const int* matrixIDs,
62  int numRHSs,
63  const int* rhsIDs);
64 
65  int setSolveType(int solveType);
66 
67  int initFields(int numFields,
68  const int *fieldSizes,
69  const int *fieldIDs,
70  const int *fieldTypes=NULL);
71 
72  int initElemBlock(GlobalID elemBlockID,
73  int numElements,
74  int numNodesPerElement,
75  const int* numFieldsPerNode,
76  const int* const* nodalFieldIDs,
77  int numElemDofFieldsPerElement,
78  const int* elemDOFFieldIDs,
79  int interleaveStrategy);
80 
81  int initElem(GlobalID elemBlockID,
82  GlobalID elemID,
83  const GlobalID* elemConn);
84 
85  int initSlaveVariable(GlobalID slaveNodeID,
86  int slaveFieldID,
87  int offsetIntoSlaveField,
88  int numMasterNodes,
89  const GlobalID* masterNodeIDs,
90  const int* masterFieldIDs,
91  const double* weights,
92  double rhsValue);
93 
94  int deleteMultCRs();
95 
96  int initSharedNodes(int numSharedNodes,
97  const GlobalID *sharedNodeIDs,
98  const int* numProcsPerNode,
99  const int *const *sharingProcIDs);
100 
101  int initCRMult(int numCRNodes,
102  const GlobalID* CRNodeIDs,
103  const int *CRFieldIDs,
104  int& CRID);
105 
106  int initCRPen(int numCRNodes,
107  const GlobalID* CRNodeIDs,
108  const int *CRFieldIDs,
109  int& CRID);
110 
112  int initComplete();
113 
114  int setCurrentMatrix(int matrixID);
115 
116  int setCurrentRHS(int rhsID);
117 
118  int resetSystem(double s=0.0);
119 
120  int resetMatrix(double s=0.0);
121 
122  int resetRHSVector(double s=0.0);
123 
124  int resetInitialGuess(double s=0.0);
125 
126  int loadNodeBCs(int numNodes,
127  const GlobalID *nodeIDs,
128  int fieldID,
129  const int* offsetsIntoField,
130  const double* prescribedValues);
131 
132  int loadElemBCs(int numElems,
133  const GlobalID* elemIDs,
134  int fieldID,
135  const double *const *alpha,
136  const double *const *beta,
137  const double *const *gamma);
138 
139  int sumInElem(GlobalID elemBlockID,
140  GlobalID elemID,
141  const GlobalID* elemConn,
142  const double* const* elemStiffness,
143  const double* elemLoad,
144  int elemFormat);
145 
146  int sumInElemMatrix(GlobalID elemBlockID,
147  GlobalID elemID,
148  const GlobalID* elemConn,
149  const double* const* elemStiffness,
150  int elemFormat);
151 
152  int sumInElemRHS(GlobalID elemBlockID,
153  GlobalID elemID,
154  const GlobalID* elemConn,
155  const double* elemLoad);
156 
157  int loadCRMult(int CRMultID,
158  int numCRNodes,
159  const GlobalID* CRNodeIDs,
160  const int* CRFieldIDs,
161  const double* CRWeights,
162  double CRValue);
163 
164  int loadCRPen(int CRPenID,
165  int numCRNodes,
166  const GlobalID* CRNodeIDs,
167  const int* CRFieldIDs,
168  const double* CRWeights,
169  double CRValue,
170  double penValue);
171 
174  int putIntoRHS(int IDType,
175  int fieldID,
176  int numIDs,
177  const GlobalID* IDs,
178  const double* coefficients);
179 
182  int sumIntoRHS(int IDType,
183  int fieldID,
184  int numIDs,
185  const GlobalID* IDs,
186  const double* coefficients);
187 
188  int setMatScalars(int numScalars,
189  const int* IDs,
190  const double* scalars);
191 
192  int setRHSScalars(int numScalars,
193  const int* IDs,
194  const double* scalars);
195 
196  int loadComplete(bool applyBCs=true,
197  bool globalAssemble=true);
198 
200  int residualNorm(int whichNorm,
201  int numFields,
202  int* fieldIDs,
203  double* norms);
204 
206  int solve(int& status);
207 
211  int iterations(int& itersTaken) const;
212 
213  int version(const char*& versionString);
214 
216  int cumulative_cpu_times(double& initTime,
217  double& loadTime,
218  double& solveTime,
219  double& solnReturnTime);
220 
222  int getBlockNodeSolution(GlobalID elemBlockID,
223  int numNodes,
224  const GlobalID *nodeIDs,
225  int *offsets,
226  double *results);
227 
229  int getNodalSolution(int numNodes,
230  const GlobalID* nodeIDs,
231  int* offsets,
232  double* results);
233 
235  int getBlockFieldNodeSolution(GlobalID elemBlockID,
236  int fieldID,
237  int numNodes,
238  const GlobalID *nodeIDs,
239  double *results);
240 
242  int getBlockElemSolution(GlobalID elemBlockID,
243  int numElems,
244  const GlobalID *elemIDs,
245  int& numElemDOFPerElement,
246  double *results);
247 
249  int getNumCRMultipliers(int& numMultCRs);
250 
252  int getCRMultIDList(int numMultCRs, int* multIDs);
253 
255  int getCRMultipliers(int numCRs,
256  const int* CRIDs,
257  double *multipliers);
258 
259 // associated "puts" paralleling the solution return services.
260 //
261 // the int sizing parameters are passed for error-checking purposes, so
262 // that the interface implementation can tell if the passed estimate
263 // vectors make sense -before- an attempt is made to utilize them as
264 // initial guesses by unpacking them into the solver's native solution
265 // vector format (these parameters include lenNodeIDList, lenElemIDList,
266 // numElemDOF, and numMultCRs -- all other passed params are either
267 // vectors or block/constraint-set IDs)
268 
270  int putBlockNodeSolution(GlobalID elemBlockID,
271  int numNodes,
272  const GlobalID *nodeIDs,
273  const int *offsets,
274  const double *estimates);
275 
277  int putBlockFieldNodeSolution(GlobalID elemBlockID,
278  int fieldID,
279  int numNodes,
280  const GlobalID *nodeIDs,
281  const double *estimates);
282 
284  int putBlockElemSolution(GlobalID elemBlockID,
285  int numElems,
286  const GlobalID *elemIDs,
287  int dofPerElem,
288  const double *estimates);
289 
291  int putCRMultipliers(int numMultCRs,
292  const int* CRIDs,
293  const double* multEstimates);
294 
295 // utility functions that aid in integrating the FEI calls..............
296 
297 // support methods for the "gets" and "puts" of the soln services.
298 
299 
301  int getBlockNodeIDList(GlobalID elemBlockID,
302  int numNodes,
303  GlobalID *nodeIDs);
304 
306  int getBlockElemIDList(GlobalID elemBlockID,
307  int numElems,
308  GlobalID* elemIDs);
309 
310 // miscellaneous self-explanatory "read-only" query functions............
311 
313  int getNumSolnParams(GlobalID nodeID, int& numSolnParams) const;
314 
316  int getNumElemBlocks(int& numElemBlocks) const;
317 
319  int getNumBlockActNodes(GlobalID blockID, int& numNodes) const;
320 
322  int getNumBlockActEqns(GlobalID blockID, int& numEqns) const;
323 
326  int getNumNodesPerElement(GlobalID blockID, int& nodesPerElem) const;
327 
330  int getNumEqnsPerElement(GlobalID blockID, int& numEqns) const;
331 
333  int getNumBlockElements(GlobalID blockID, int& numElems) const;
334 
336  int getNumBlockElemDOF(GlobalID blockID, int& DOFPerElem) const;
337 
338 
342  int getParameters(int& numParams, char**& paramStrings);
343 
344  //And now a couple of non-FEI query functions that Sandia applications
345  //need to augment the matrix-access functions. I (Alan Williams) will
346  //argue to have these included in the FEI 2.1 specification update.
347 
352  int getFieldSize(int fieldID, int& numScalars);
353 
366  int getEqnNumbers(GlobalID ID,
367  int idType,
368  int fieldID,
369  int& numEqns,
370  int* eqnNumbers);
371 
385  int getNodalFieldSolution(int fieldID,
386  int numNodes,
387  const GlobalID* nodeIDs,
388  double* results);
389 
395  int getNumLocalNodes(int& numNodes);
396 
408  int getLocalNodeIDList(int& numNodes,
409  GlobalID* nodeIDs,
410  int lenNodeIDs);
411 
428  int putNodalFieldData(int fieldID,
429  int numNodes,
430  const GlobalID* nodeIDs,
431  const double* nodeData);
432 
433  private: //methods
434  void basic_initializations();
435 
436  int inputRHS(int IDType,
437  int fieldID,
438  int numIDs,
439  const GlobalID* IDs,
440  const double* rhsEntries,
441  bool sumInto);
442 
443  int fillNodeset(int blockID) const;
444 
445  int aggregateSystem();
446 
448 
449  private: //attributes
450 
451  std::vector<fei::SharedPtr<LibraryWrapper> > wrapper_;
452 
456 
457  std::vector<fei::SharedPtr<fei::Factory> > factory_;
461 
463  std::vector<fei::SharedPtr<fei::Vector> > b_;
464  std::vector<fei::SharedPtr<fei::Matrix> > A_;
466 
467  bool newData_;
468 
471 
476 
479 
480  std::vector<int> matrixIDs_;
481  std::vector<int> rhsIDs_;
482 
483  std::vector<double> matScalars_;
485  std::vector<double> rhsScalars_;
487 
489 
493 
496 
499 
502 
504 
506 
507  std::vector<int> iwork_;
508 
509  mutable std::set<int> nodeset_;
510  mutable bool nodeset_filled_;
511  mutable int nodeset_blockid_;
512 
513  mutable std::map<int,int> block_dof_per_elem_;
515  };//class FEI_Impl
516 
517 }//namespace fei
518 
519 #endif
520 
bool setSolveTypeCalled_
int setSolveType(int solveType)
int getNumLocalNodes(int &numNodes)
int putNodalFieldData(int fieldID, int numNodes, const GlobalID *nodeIDs, const double *nodeData)
int sumIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *coefficients)
int getNumCRMultipliers(int &numMultCRs)
std::vector< double > rhsScalars_
int iterations(int &itersTaken) const
int version(const char *&versionString)
int fillNodeset(int blockID) const
int GlobalID
Definition: fei_defs.h:60
std::vector< fei::SharedPtr< fei::Vector > > b_
int setIDLists(int numMatrices, const int *matrixIDs, int numRHSs, const int *rhsIDs)
fei::SharedPtr< fei::MatrixGraph > matGraph_
fei::SharedPtr< fei::LinearSystem > getLinearSystem()
int getBlockElemSolution(GlobalID elemBlockID, int numElems, const GlobalID *elemIDs, int &numElemDOFPerElement, double *results)
int getParameters(int &numParams, char **&paramStrings)
int initCRPen(int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, int &CRID)
fei::SharedPtr< fei::Vector > x_
int aggregateSystem_LinSysCore()
std::vector< int > iwork_
int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)
virtual ~FEI_Impl()
int getFieldSize(int fieldID, int &numScalars)
int getNumSolnParams(GlobalID nodeID, int &numSolnParams) const
int getBlockNodeIDList(GlobalID elemBlockID, int numNodes, GlobalID *nodeIDs)
fei::SharedPtr< fei::VectorSpace > rowSpace_
std::set< int > nodeset_
int putBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, const double *estimates)
int setCurrentMatrix(int matrixID)
int getCRMultipliers(int numCRs, const int *CRIDs, double *multipliers)
int cumulative_cpu_times(double &initTime, double &loadTime, double &solveTime, double &solnReturnTime)
int setCurrentRHS(int rhsID)
#define MPI_Comm
Definition: fei_mpi.h:56
int putBlockNodeSolution(GlobalID elemBlockID, int numNodes, const GlobalID *nodeIDs, const int *offsets, const double *estimates)
bool any_blocks_have_elem_dof_
int parameters(int numParams, const char *const *paramStrings)
Definition: FEI.hpp:144
int resetSystem(double s=0.0)
int loadComplete(bool applyBCs=true, bool globalAssemble=true)
int getBlockNodeSolution(GlobalID elemBlockID, int numNodes, const GlobalID *nodeIDs, int *offsets, double *results)
int getEqnNumbers(GlobalID ID, int idType, int fieldID, int &numEqns, int *eqnNumbers)
int getNodalSolution(int numNodes, const GlobalID *nodeIDs, int *offsets, double *results)
int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDOFFieldIDs, int interleaveStrategy)
std::vector< int > rhsIDs_
int putCRMultipliers(int numMultCRs, const int *CRIDs, const double *multEstimates)
int getCRMultIDList(int numMultCRs, int *multIDs)
int getNumNodesPerElement(GlobalID blockID, int &nodesPerElem) const
int sumInElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, const double *elemLoad, int elemFormat)
int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)
std::vector< fei::SharedPtr< LibraryWrapper > > wrapper_
Data * soln_fei_vector_
Data * soln_fei_matrix_
int index_current_rhs_row_
int getNumBlockElemDOF(GlobalID blockID, int &DOFPerElem) const
int sumInElemMatrix(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, int elemFormat)
int putBlockElemSolution(GlobalID elemBlockID, int numElems, const GlobalID *elemIDs, int dofPerElem, const double *estimates)
void basic_initializations()
int resetInitialGuess(double s=0.0)
int resetRHSVector(double s=0.0)
int setMatScalars(int numScalars, const int *IDs, const double *scalars)
int initSlaveVariable(GlobalID slaveNodeID, int slaveFieldID, int offsetIntoSlaveField, int numMasterNodes, const GlobalID *masterNodeIDs, const int *masterFieldIDs, const double *weights, double rhsValue)
int getNumElemBlocks(int &numElemBlocks) const
fei::SharedPtr< fei::LinearSystem > linSys_
int getNumBlockActNodes(GlobalID blockID, int &numNodes) const
int residualNorm(int whichNorm, int numFields, int *fieldIDs, double *norms)
std::map< int, int > block_dof_per_elem_
int solve(int &status)
std::vector< fei::SharedPtr< fei::Matrix > > A_
int inputRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *rhsEntries, bool sumInto)
int putIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *coefficients)
std::vector< int > matrixIDs_
double solnReturnTime_
std::vector< double > matScalars_
int resetMatrix(double s=0.0)
std::vector< fei::SharedPtr< fei::Factory > > factory_
int loadCRPen(int CRPenID, int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, const double *CRWeights, double CRValue, double penValue)
int getNumBlockActEqns(GlobalID blockID, int &numEqns) const
int initCRMult(int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, int &CRID)
int loadCRMult(int CRMultID, int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, const double *CRWeights, double CRValue)
int getNumEqnsPerElement(GlobalID blockID, int &numEqns) const
int getNumBlockElements(GlobalID blockID, int &numElems) const
int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)
int getBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)
int loadNodeBCs(int numNodes, const GlobalID *nodeIDs, int fieldID, const int *offsetsIntoField, const double *prescribedValues)
char ** paramStrings_
int setRHSScalars(int numScalars, const int *IDs, const double *scalars)
int getLocalNodeIDList(int &numNodes, GlobalID *nodeIDs, int lenNodeIDs)
int loadElemBCs(int numElems, const GlobalID *elemIDs, int fieldID, const double *const *alpha, const double *const *beta, const double *const *gamma)
int getBlockElemIDList(GlobalID elemBlockID, int numElems, GlobalID *elemIDs)
int getNodalFieldSolution(int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)
bool aggregateSystemFormed_
bool initPhaseIsComplete_
int sumInElemRHS(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *elemLoad)
FEI_Impl(fei::SharedPtr< LibraryWrapper > wrapper, MPI_Comm comm, int masterRank=0)