FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FEI_Implementation.hpp
Go to the documentation of this file.
1 #ifndef _FEI_Implementation_hpp_
2 #define _FEI_Implementation_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_mpi.h>
14 #include <fei_SharedPtr.hpp>
15 #include <fei_defs.h>
16 
17 #include <FEI.hpp>
18 
50 class FEI_Implementation : public FEI {
51 
52  public:
63  MPI_Comm comm,
64  int masterRank=0);
65 
67  virtual ~FEI_Implementation();
68 
69 //public FEI functions:
70 
71 
80  int parameters(int numParams, const char *const* paramStrings);
81 
82 //Structural initialization functions.............................
83 
99  int setIDLists(int numMatrices,
100  const int* matrixIDs,
101  int numRHSs,
102  const int* rhsIDs);
103 
112  int setSolveType(int solveType);
113 
128  int initFields(int numFields,
129  const int *fieldSizes,
130  const int *fieldIDs,
131  const int *fieldTypes = NULL);
132 
154  int initElemBlock(GlobalID elemBlockID,
155  int numElements,
156  int numNodesPerElement,
157  const int* numFieldsPerNode,
158  const int* const* nodalFieldIDs,
159  int numElemDofFieldsPerElement,
160  const int* elemDOFFieldIDs,
161  int interleaveStrategy);
162 
171  int initElem(GlobalID elemBlockID,
172  GlobalID elemID,
173  const GlobalID* elemConn);
174 
222  int initSlaveVariable(GlobalID slaveNodeID,
223  int slaveFieldID,
224  int offsetIntoSlaveField,
225  int numMasterNodes,
226  const GlobalID* masterNodeIDs,
227  const int* masterFieldIDs,
228  const double* weights,
229  double rhsValue);
230 
235  int deleteMultCRs();
236 
238  int initSharedNodes(int numSharedNodes,
239  const GlobalID *sharedNodeIDs,
240  const int* numProcsPerNode,
241  const int *const *sharingProcIDs);
242 
251  int initCRMult(int numCRNodes,
252  const GlobalID* CRNodes,
253  const int *CRFields,
254  int& CRID);
255 
264  int initCRPen(int numCRNodes,
265  const GlobalID* CRNodes,
266  const int *CRFields,
267  int& CRID);
268 
270  int initComplete();
271 
272 // FEI data loading sequence..........................................
273 
276  int setCurrentMatrix(int matID);
277 
280  int setCurrentRHS(int rhsID);
281 
283  int resetSystem(double s=0.0);
284 
287  int resetMatrix(double s=0.0);
288 
292  int resetRHSVector(double s=0.0);
293 
299  int resetInitialGuess(double s=0.0);
300 
319  int loadNodeBCs(int numNodes,
320  const GlobalID *nodeIDs,
321  int fieldID,
322  const int* offsetsIntoField,
323  const double* prescribedValues);
324 
336  int loadElemBCs(int numElems,
337  const GlobalID* elemIDs,
338  int fieldID,
339  const double *const *alpha,
340  const double *const *beta,
341  const double *const *gamma);
342 
358  int sumInElem(GlobalID elemBlockID,
359  GlobalID elemID,
360  const GlobalID* elemConn,
361  const double* const* elemStiffness,
362  const double* elemLoad,
363  int elemFormat);
364 
379  int sumInElemMatrix(GlobalID elemBlockID,
380  GlobalID elemID,
381  const GlobalID* elemConn,
382  const double* const* elemStiffness,
383  int elemFormat);
384 
393  int sumInElemRHS(GlobalID elemBlockID,
394  GlobalID elemID,
395  const GlobalID* elemConn,
396  const double* elemLoad);
397 
407  int loadCRMult(int CRID,
408  int numCRNodes,
409  const GlobalID* CRNodes,
410  const int* CRFields,
411  const double* CRWeights,
412  double CRValue);
413 
424  int loadCRPen(int CRID,
425  int numCRNodes,
426  const GlobalID* CRNodes,
427  const int* CRFields,
428  const double* CRWeights,
429  double CRValue,
430  double penValue);
431 
433  int putIntoRHS(int IDType,
434  int fieldID,
435  int numIDs,
436  const GlobalID* IDs,
437  const double* rhsEntries);
438 
440  int sumIntoRHS(int IDType,
441  int fieldID,
442  int numIDs,
443  const GlobalID* IDs,
444  const double* rhsEntries);
445 
446  int sumIntoMatrixDiagonal(int IDType,
447  int fieldID,
448  int numIDs,
449  const GlobalID* IDs,
450  const double* coefficients);
451 
452 // Equation solution services.....................................
453 
456  int setMatScalars(int numScalars,
457  const int* IDs,
458  const double* scalars);
459 
461  int setRHSScalars(int numScalars,
462  const int* IDs,
463  const double* scalars);
464 
467  int loadComplete(bool applyBCs=true,
468  bool globalAssemble=true);
469 
471  int residualNorm(int whichNorm,
472  int numFields,
473  int* fieldIDs,
474  double* norms);
475 
477  int solve(int& status);
478 
482  int iterations(int& itersTaken) const;
483 
492  int version(const char*& versionString);
493 
495  int cumulative_cpu_times(double& initTime,
496  double& loadTime,
497  double& solveTime,
498  double& solnReturnTime);
499 
500 // Solution return services.......................................
501 
503  int getBlockNodeSolution(GlobalID elemBlockID,
504  int numNodes,
505  const GlobalID *nodeIDs,
506  int *offsets,
507  double *results);
508 
510  int getNodalSolution(int numNodes,
511  const GlobalID* nodeIDs,
512  int* offsets,
513  double* results);
514 
516  int getBlockFieldNodeSolution(GlobalID elemBlockID,
517  int fieldID,
518  int numNodes,
519  const GlobalID *nodeIDs,
520  double *results);
521 
523  int getBlockElemSolution(GlobalID elemBlockID,
524  int numElems,
525  const GlobalID *elemIDs,
526  int& numElemDOFPerElement,
527  double *results);
528 
530  int getNumCRMultipliers(int& numMultCRs);
531 
533  int getCRMultIDList(int numMultCRs, int* multIDs);
534 
536  int getCRMultipliers(int numCRs,
537  const int* CRIDs,
538  double *multipliers);
539 
540 
541 // associated "puts" paralleling the solution return services.
542 //
543 // the int sizing parameters are passed for error-checking purposes, so
544 // that the interface implementation can tell if the passed estimate
545 // vectors make sense -before- an attempt is made to utilize them as
546 // initial guesses by unpacking them into the solver's native solution
547 // vector format (these parameters include lenNodeIDList, lenElemIDList,
548 // numElemDOF, and numMultCRs -- all other passed params are either
549 // vectors or block/constraint-set IDs)
550 
552  int putBlockNodeSolution(GlobalID elemBlockID,
553  int numNodes,
554  const GlobalID *nodeIDs,
555  const int *offsets,
556  const double *estimates);
557 
559  int putBlockFieldNodeSolution(GlobalID elemBlockID,
560  int fieldID,
561  int numNodes,
562  const GlobalID *nodeIDs,
563  const double *estimates);
564 
566  int putBlockElemSolution(GlobalID elemBlockID,
567  int numElems,
568  const GlobalID *elemIDs,
569  int dofPerElem,
570  const double *estimates);
571 
573  int putCRMultipliers(int numMultCRs,
574  const int* CRIDs,
575  const double* multEstimates);
576 
577 // utility functions that aid in integrating the FEI calls..............
578 
579 // support methods for the "gets" and "puts" of the soln services.
580 
581 
583  int getBlockNodeIDList(GlobalID elemBlockID,
584  int numNodes,
585  GlobalID *nodeIDs);
586 
588  int getBlockElemIDList(GlobalID elemBlockID,
589  int numElems,
590  GlobalID* elemIDs);
591 
592 // miscellaneous self-explanatory "read-only" query functions............
593 
595  int getNumSolnParams(GlobalID nodeID, int& numSolnParams) const;
596 
598  int getNumElemBlocks(int& numElemBlocks) const;
599 
601  int getNumBlockActNodes(GlobalID blockID, int& numNodes) const;
602 
604  int getNumBlockActEqns(GlobalID blockID, int& numEqns) const;
605 
608  int getNumNodesPerElement(GlobalID blockID, int& nodesPerElem) const;
609 
612  int getNumEqnsPerElement(GlobalID blockID, int& numEqns) const;
613 
615  int getNumBlockElements(GlobalID blockID, int& numElems) const;
616 
618  int getNumBlockElemDOF(GlobalID blockID, int& DOFPerElem) const;
619 
620 
624  int getParameters(int& numParams, char**& paramStrings);
625 
626  //And now a couple of non-FEI query functions that Sandia applications
627  //need to augment the matrix-access functions. I (Alan Williams) will
628  //argue to have these included in the FEI 2.1 specification update.
629 
634  int getFieldSize(int fieldID, int& numScalars);
635 
648  int getEqnNumbers(GlobalID ID,
649  int idType,
650  int fieldID,
651  int& numEqns,
652  int* eqnNumbers);
653 
667  int getNodalFieldSolution(int fieldID,
668  int numNodes,
669  const GlobalID* nodeIDs,
670  double* results);
671 
677  int getNumLocalNodes(int& numNodes);
678 
690  int getLocalNodeIDList(int& numNodes,
691  GlobalID* nodeIDs,
692  int lenNodeIDs);
693 
710  int putNodalFieldData(int fieldID,
711  int numNodes,
712  const GlobalID* nodeIDs,
713  const double* nodeData);
714 
716  { return *problemStructure_; }
717 
719  { return *problemStructure_; }
720 
721  //============================================================================
722  private: //functions
723 
726 
727  void deleteIDs();
728  void deleteRHSScalars();
729 
730  int allocateInternalFEIs();
731 
732  void debugOut(const char* msg);
733  void debugOut(const char* msg, int whichFEI);
734 
735  void buildLinearSystem();
736  int aggregateSystem();
737 
738  void messageAbort(const char* msg);
739  void notAllocatedAbort(const char* name);
740  void needParametersAbort(const char* name);
741  void badParametersAbort(const char* name);
742 
743  void setDebugOutput(const char* path, const char* name);
744 
745  //============================================================================
746  private: //member variables
747 
750  std::vector<fei::SharedPtr<LinearSystemCore> > lscArray_;
755 
758 
759  std::vector<int> matrixIDs_;
760  std::vector<int> numRHSIDs_;
761  std::vector<int*> rhsIDs_;
762 
764 
765  std::vector<double> matScalars_;
767  std::vector<double*> rhsScalars_;
769 
773 
775 
778 
781 
784 
786 
790 
792 
795 #ifdef FEI_HAVE_IOSFWD
796  std::ostream* dbgOStreamPtr_;
797 #else
798  ostream* dbgOStreamPtr_;
799 #endif
801 #ifdef FEI_HAVE_IOSFWD
802  std::ofstream* dbgFStreamPtr_;
803 #else
804  ofstream* dbgFStreamPtr_;
805 #endif
806 
808 
811 };
812 
813 #endif
814 
void messageAbort(const char *msg)
int getBlockNodeSolution(GlobalID elemBlockID, int numNodes, const GlobalID *nodeIDs, int *offsets, double *results)
int resetSystem(double s=0.0)
int putBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, const double *estimates)
int getParameters(int &numParams, char **&paramStrings)
int setRHSScalars(int numScalars, const int *IDs, const double *scalars)
void debugOut(const char *msg)
int getNodalFieldSolution(int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)
int putBlockNodeSolution(GlobalID elemBlockID, int numNodes, const GlobalID *nodeIDs, const int *offsets, const double *estimates)
int GlobalID
Definition: fei_defs.h:60
int sumInElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, const double *elemLoad, int elemFormat)
int loadElemBCs(int numElems, const GlobalID *elemIDs, int fieldID, const double *const *alpha, const double *const *beta, const double *const *gamma)
FEI_Implementation(fei::SharedPtr< LibraryWrapper > libWrapper, MPI_Comm comm, int masterRank=0)
int loadNodeBCs(int numNodes, const GlobalID *nodeIDs, int fieldID, const int *offsetsIntoField, const double *prescribedValues)
std::ostream * dbgOStreamPtr_
int getNodalSolution(int numNodes, const GlobalID *nodeIDs, int *offsets, double *results)
const SNL_FEI_Structure & getProblemStructure() const
int initSlaveVariable(GlobalID slaveNodeID, int slaveFieldID, int offsetIntoSlaveField, int numMasterNodes, const GlobalID *masterNodeIDs, const int *masterFieldIDs, const double *weights, double rhsValue)
int iterations(int &itersTaken) const
int setIDLists(int numMatrices, const int *matrixIDs, int numRHSs, const int *rhsIDs)
int getBlockFieldNodeSolution(GlobalID elemBlockID, int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)
std::vector< int > numRHSIDs_
int getNumElemBlocks(int &numElemBlocks) const
int solve(int &status)
int sumInElemMatrix(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, int elemFormat)
int initCRPen(int numCRNodes, const GlobalID *CRNodes, const int *CRFields, int &CRID)
int version(const char *&versionString)
int initCRMult(int numCRNodes, const GlobalID *CRNodes, const int *CRFields, int &CRID)
int getEqnNumbers(GlobalID ID, int idType, int fieldID, int &numEqns, int *eqnNumbers)
int resetInitialGuess(double s=0.0)
int sumInElemRHS(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *elemLoad)
#define MPI_Comm
Definition: fei_mpi.h:56
int sumIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *rhsEntries)
int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDOFFieldIDs, int interleaveStrategy)
int setSolveType(int solveType)
Definition: FEI.hpp:144
int getNumBlockActEqns(GlobalID blockID, int &numEqns) const
int loadComplete(bool applyBCs=true, bool globalAssemble=true)
int getBlockNodeIDList(GlobalID elemBlockID, int numNodes, GlobalID *nodeIDs)
int getBlockElemSolution(GlobalID elemBlockID, int numElems, const GlobalID *elemIDs, int &numElemDOFPerElement, double *results)
int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)
int getCRMultIDList(int numMultCRs, int *multIDs)
std::vector< double * > rhsScalars_
void needParametersAbort(const char *name)
int setCurrentRHS(int rhsID)
std::vector< fei::SharedPtr< LinearSystemCore > > lscArray_
std::vector< int > matrixIDs_
int getNumEqnsPerElement(GlobalID blockID, int &numEqns) const
SNL_FEI_Structure * problemStructure_
int getBlockElemIDList(GlobalID elemBlockID, int numElems, GlobalID *elemIDs)
int cumulative_cpu_times(double &initTime, double &loadTime, double &solveTime, double &solnReturnTime)
int putBlockElemSolution(GlobalID elemBlockID, int numElems, const GlobalID *elemIDs, int dofPerElem, const double *estimates)
int putNodalFieldData(int fieldID, int numNodes, const GlobalID *nodeIDs, const double *nodeData)
int parameters(int numParams, const char *const *paramStrings)
int sumIntoMatrixDiagonal(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *coefficients)
int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)
std::vector< double > matScalars_
void setDebugOutput(const char *path, const char *name)
SNL_FEI_Structure & getProblemStructure()
fei::SharedPtr< LibraryWrapper > wrapper_
int getNumCRMultipliers(int &numMultCRs)
int getNumNodesPerElement(GlobalID blockID, int &nodesPerElem) const
fei::SharedPtr< LinearSystemCore > linSysCore_
int putIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *rhsEntries)
int loadCRPen(int CRID, int numCRNodes, const GlobalID *CRNodes, const int *CRFields, const double *CRWeights, double CRValue, double penValue)
int getCRMultipliers(int numCRs, const int *CRIDs, double *multipliers)
int getNumBlockElements(GlobalID blockID, int &numElems) const
int resetMatrix(double s=0.0)
int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)
int getNumSolnParams(GlobalID nodeID, int &numSolnParams) const
int getNumLocalNodes(int &numNodes)
int loadCRMult(int CRID, int numCRNodes, const GlobalID *CRNodes, const int *CRFields, const double *CRWeights, double CRValue)
void badParametersAbort(const char *name)
int getLocalNodeIDList(int &numNodes, GlobalID *nodeIDs, int lenNodeIDs)
int putCRMultipliers(int numMultCRs, const int *CRIDs, const double *multEstimates)
int setMatScalars(int numScalars, const int *IDs, const double *scalars)
FEI_Implementation & operator=(const FEI_Implementation &src)
std::ofstream * dbgFStreamPtr_
int resetRHSVector(double s=0.0)
int getFieldSize(int fieldID, int &numScalars)
int residualNorm(int whichNorm, int numFields, int *fieldIDs, double *norms)
int getNumBlockElemDOF(GlobalID blockID, int &DOFPerElem) const
std::vector< int * > rhsIDs_
int getNumBlockActNodes(GlobalID blockID, int &numNodes) const
void notAllocatedAbort(const char *name)
int setCurrentMatrix(int matID)