FEI Version of the Day
PoissonData.hpp
00001 #ifndef _PoissonData_h_
00002 #define _PoissonData_h_
00003 /*--------------------------------------------------------------------*/
00004 /*    Copyright 2005 Sandia Corporation.                              */
00005 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00006 /*    non-exclusive license for use of this work by or on behalf      */
00007 /*    of the U.S. Government.  Export of this program may require     */
00008 /*    a license from the United States Government.                    */
00009 /*--------------------------------------------------------------------*/
00010 
00011 #include <fei_base.hpp>
00012 //
00013 //This is a class for use in exercising FEI implementations.
00014 //
00015 //This class sets up test data for the Poisson equation on a 2D square,
00016 //and provides query functions for obtaining that data.
00017 //
00018 //The calling program (the 'user' of PoissonData) is left
00019 //with the task of calling the FEI functions.
00020 //
00021 //Also note:
00022 //
00023 // 1. This class only provides 1 element-block per processor currently.
00024 // 2. The function calculateBCs() must be called before the boundary
00025 //    condition data is requested.
00026 //
00027 // Alan Williams 12-20-2000
00028 //
00029 
00030 class PoissonData {
00031   public:
00032     //constructor -- see PoissonData.cpp for descriptions of these
00033     //parameters.
00034     PoissonData(int L,
00035                int numProcs, int localProc, int outputLevel);
00036 
00037     //destructor.
00038     ~PoissonData();
00039 
00040     int getElemFormat() {return(elemFormat_); };
00041 
00042     //hardwired for only 1 field...
00043     int getNumFields() { return(1);};
00044     int* getFieldSizes() { return(&fieldSize_);};
00045     int* getFieldIDs() { return(&fieldIDs_[0][0]);};
00046 
00047     GlobalID getElemBlockID() { return(elemBlockID_); };
00048 
00049     int getNumLocalElements() { return(numLocalElements_); };
00050     GlobalID* getLocalElementIDs() { return(elemIDs_); };
00051     int getNumNodesPerElement() { return(elem_->numElemNodes()); };
00052 
00053     int* getNumFieldsPerNodeList() { return( numFields_ ); };
00054     int** getNodalFieldIDsTable() { return( fieldIDs_ ); };
00055 
00056     GlobalID* getElementConnectivity(GlobalID elemID);
00057 
00058     double** getElemStiffness(GlobalID elemID);
00059     double* getElemLoad(GlobalID elemID);
00060 
00061     void addBCNode(GlobalID nodeID, double x, double y);
00062 
00063     void calculateBCs();
00064 
00065     int getNumBCNodes() { return( BCNodeIDs_.size() ); }
00066     GlobalID* getBCNodeIDs() { return( &BCNodeIDs_[0] ); }
00067     int getBCFieldID() { return( fieldIDs_[0][0] ); }
00068     double* getBCValues() { return( &BCValues_[0] ); }
00069     
00070 
00071     void getLeftSharedNodes(int& numShared, GlobalID* sharedNodeIDs,
00072                                      int* numProcsPerSharedNode,
00073                                      int** sharingProcs);
00074     void getRightSharedNodes(int& numShared, GlobalID* sharedNodeIDs,
00075                                      int* numProcsPerSharedNode,
00076                                      int** sharingProcs);
00077     void getTopSharedNodes(int& numShared, GlobalID* sharedNodeIDs,
00078                                      int* numProcsPerSharedNode,
00079                                      int** sharingProcs);
00080     void getBottomSharedNodes(int& numShared, GlobalID* sharedNodeIDs,
00081                                      int* numProcsPerSharedNode,
00082                                      int** sharingProcs);
00083   private:
00084     void check1();
00085     void calculateDistribution();
00086 
00087     void messageAbort(const char* message);
00088 
00089     void calculateConnectivity(GlobalID* conn, int size, GlobalID elemID);
00090     void initializeFieldStuff();
00091     void deleteFieldArrays();
00092 
00093     void printSharedNodes(const char* str,
00094         int numShared,
00095         GlobalID* nodeIDs,
00096                           int** shareProcs,
00097         int* numShareProcs);
00098 
00099     Poisson_Elem* elem_; //we're only going to have 1 element instance!!
00100     int numLocalElements_;
00101     int startElement_;
00102 
00103     int numProcs_;
00104     int localProc_;
00105     int outputLevel_;
00106 
00107     int L_;
00108     int procX_, procY_;
00109     int maxProcX_, maxProcY_;
00110 
00111     int numElemBlocks_;
00112     int solveType_;
00113 
00114     int nodesPerElement_;
00115     int fieldsPerNode_;
00116     GlobalID elemBlockID_;
00117     int elemSetID_;
00118     int elemFormat_;
00119 
00120     //*************** field description variables *********
00121     int fieldSize_;
00122     int* numFields_;
00123     int** fieldIDs_;
00124     bool fieldArraysAllocated_;
00125 
00126     //************* element IDs and connectivities ********
00127     GlobalID* elemIDs_;
00128     bool elemIDsAllocated_;
00129 
00130     //************* boundary condition stuff **************
00131     std::vector<GlobalID> BCNodeIDs_;
00132     std::vector<double> BCValues_;
00133 };
00134 
00135 int init_elem_connectivities(FEI* fei, PoissonData& poissonData);
00136 
00137 int init_elem_connectivities(fei::MatrixGraph* matrixGraph,
00138            PoissonData& poissonData);
00139 
00140 int set_shared_nodes(FEI* fei, PoissonData& poissonData);
00141 
00142 int set_shared_nodes(fei::VectorSpace* nodeSpace, PoissonData& poissonData);
00143 
00144 int load_elem_data(FEI* fei, PoissonData& poissonData);
00145 
00146 int load_elem_data_putrhs(FEI* fei, PoissonData& poissonData);
00147 
00148 int load_elem_data(fei::MatrixGraph* matrixGraph,
00149        fei::Matrix* mat, fei::Vector* rhs,
00150        PoissonData& poissonData);
00151 
00152 int load_BC_data(FEI* fei, PoissonData& poissonData);
00153 
00154 int load_BC_data(fei::LinearSystem* linSys, PoissonData& poissonData);
00155 
00156 #endif
00157 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends