FEI Version of the Day
PoissonData.hpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 #ifndef _PoissonData_h_
00044 #define _PoissonData_h_
00045 
00046 #include <fei_base.hpp>
00047 //
00048 //This is a class for use in exercising FEI implementations.
00049 //
00050 //This class sets up test data for the Poisson equation on a 2D square,
00051 //and provides query functions for obtaining that data.
00052 //
00053 //The calling program (the 'user' of PoissonData) is left
00054 //with the task of calling the FEI functions.
00055 //
00056 //Also note:
00057 //
00058 // 1. This class only provides 1 element-block per processor currently.
00059 // 2. The function calculateBCs() must be called before the boundary
00060 //    condition data is requested.
00061 //
00062 // Alan Williams 12-20-2000
00063 //
00064 
00065 class PoissonData {
00066   public:
00067     //constructor -- see PoissonData.cpp for descriptions of these
00068     //parameters.
00069     PoissonData(int L,
00070                int numProcs, int localProc, int outputLevel);
00071 
00072     //destructor.
00073     ~PoissonData();
00074 
00075     int getElemFormat() {return(elemFormat_); };
00076 
00077     //hardwired for only 1 field...
00078     int getNumFields() { return(1);};
00079     int* getFieldSizes() { return(&fieldSize_);};
00080     int* getFieldIDs() { return(&fieldIDs_[0][0]);};
00081 
00082     GlobalID getElemBlockID() { return(elemBlockID_); };
00083 
00084     int getNumLocalElements() { return(numLocalElements_); };
00085     GlobalID* getLocalElementIDs() { return(elemIDs_); };
00086     int getNumNodesPerElement() { return(elem_->numElemNodes()); };
00087 
00088     int* getNumFieldsPerNodeList() { return( numFields_ ); };
00089     int** getNodalFieldIDsTable() { return( fieldIDs_ ); };
00090 
00091     GlobalID* getElementConnectivity(GlobalID elemID);
00092 
00093     double** getElemStiffness(GlobalID elemID);
00094     double* getElemLoad(GlobalID elemID);
00095 
00096     void addBCNode(GlobalID nodeID, double x, double y);
00097 
00098     void calculateBCs();
00099 
00100     int getNumBCNodes() { return( BCNodeIDs_.size() ); }
00101     GlobalID* getBCNodeIDs() { return( &BCNodeIDs_[0] ); }
00102     int getBCFieldID() { return( fieldIDs_[0][0] ); }
00103     double* getBCValues() { return( &BCValues_[0] ); }
00104     
00105 
00106     void getLeftSharedNodes(int& numShared, GlobalID* sharedNodeIDs,
00107                                      int* numProcsPerSharedNode,
00108                                      int** sharingProcs);
00109     void getRightSharedNodes(int& numShared, GlobalID* sharedNodeIDs,
00110                                      int* numProcsPerSharedNode,
00111                                      int** sharingProcs);
00112     void getTopSharedNodes(int& numShared, GlobalID* sharedNodeIDs,
00113                                      int* numProcsPerSharedNode,
00114                                      int** sharingProcs);
00115     void getBottomSharedNodes(int& numShared, GlobalID* sharedNodeIDs,
00116                                      int* numProcsPerSharedNode,
00117                                      int** sharingProcs);
00118   private:
00119     void check1();
00120     void calculateDistribution();
00121 
00122     void messageAbort(const char* message);
00123 
00124     void calculateConnectivity(GlobalID* conn, int size, GlobalID elemID);
00125     void initializeFieldStuff();
00126     void deleteFieldArrays();
00127 
00128     void printSharedNodes(const char* str,
00129         int numShared,
00130         GlobalID* nodeIDs,
00131                           int** shareProcs,
00132         int* numShareProcs);
00133 
00134     Poisson_Elem* elem_; //we're only going to have 1 element instance!!
00135     int numLocalElements_;
00136     int startElement_;
00137 
00138     int numProcs_;
00139     int localProc_;
00140     int outputLevel_;
00141 
00142     int L_;
00143     int procX_, procY_;
00144     int maxProcX_, maxProcY_;
00145 
00146     int numElemBlocks_;
00147     int solveType_;
00148 
00149     int nodesPerElement_;
00150     int fieldsPerNode_;
00151     GlobalID elemBlockID_;
00152     int elemSetID_;
00153     int elemFormat_;
00154 
00155     //*************** field description variables *********
00156     int fieldSize_;
00157     int* numFields_;
00158     int** fieldIDs_;
00159     bool fieldArraysAllocated_;
00160 
00161     //************* element IDs and connectivities ********
00162     GlobalID* elemIDs_;
00163     bool elemIDsAllocated_;
00164 
00165     //************* boundary condition stuff **************
00166     std::vector<GlobalID> BCNodeIDs_;
00167     std::vector<double> BCValues_;
00168 };
00169 
00170 int init_elem_connectivities(FEI* fei, PoissonData& poissonData);
00171 
00172 int init_elem_connectivities(fei::MatrixGraph* matrixGraph,
00173            PoissonData& poissonData);
00174 
00175 int set_shared_nodes(FEI* fei, PoissonData& poissonData);
00176 
00177 int set_shared_nodes(fei::VectorSpace* nodeSpace, PoissonData& poissonData);
00178 
00179 int load_elem_data(FEI* fei, PoissonData& poissonData);
00180 
00181 int load_elem_data_putrhs(FEI* fei, PoissonData& poissonData);
00182 
00183 int load_elem_data(fei::MatrixGraph* matrixGraph,
00184        fei::Matrix* mat, fei::Vector* rhs,
00185        PoissonData& poissonData);
00186 
00187 int load_BC_data(FEI* fei, PoissonData& poissonData);
00188 
00189 int load_BC_data(fei::LinearSystem* linSys, PoissonData& poissonData);
00190 
00191 #endif
00192 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends