escript  Revision_
ElementFile.h
Go to the documentation of this file.
00001 
00002 /*****************************************************************************
00003 *
00004 * Copyright (c) 2003-2014 by University of Queensland
00005 * http://www.uq.edu.au
00006 *
00007 * Primary Business: Queensland, Australia
00008 * Licensed under the Open Software License version 3.0
00009 * http://www.opensource.org/licenses/osl-3.0.php
00010 *
00011 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
00012 * Development 2012-2013 by School of Earth Sciences
00013 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
00014 *
00015 *****************************************************************************/
00016 
00017 #ifndef __FINLEY_ELEMENTFILE_H__
00018 #define __FINLEY_ELEMENTFILE_H__
00019 
00020 #include "Finley.h"
00021 #include "NodeFile.h"
00022 #include "ReferenceElementSets.h"
00023 #include "Util.h"
00024 
00025 namespace finley {
00026 
00027 struct ElementFile_Jacobians {
00028     ElementFile_Jacobians(const_ShapeFunction_ptr basis);
00029     ~ElementFile_Jacobians();
00030 
00032     int status;
00034     int numDim;
00036     const_ShapeFunction_ptr BasisFunctions;
00039     int numQuadTotal;
00041     int numSides;
00043     const int* offsets;
00045     int numSub;
00047     int numShapesTotal;
00050     const int* node_selection;
00052     int numElements;
00054     double* volume;
00057     double* DSDX;
00058 };
00059 
00060 class ElementFile
00061 {
00062 public:
00063     ElementFile(const_ReferenceElementSet_ptr refElementSet,
00064                 Esys_MPIInfo *mpiInfo);
00065     ~ElementFile();
00066 
00067     void allocTable(int numElements);
00068     void freeTable();
00069 
00070     void distributeByRankOfDOF(const std::vector<int>& mpiRankOfDOF, int *Id);
00071     void createColoring(const std::vector<int>& dofMap);
00073     void optimizeOrdering();
00075     void relabelNodes(const std::vector<int>& newNode, int offset);
00076     void markNodes(std::vector<short>& mask, int offset, bool useLinear);
00077     void scatter(int* index, const ElementFile* in);
00078     void gather(int* index, const ElementFile* in);
00079     void copyTable(int offset, int nodeOffset, int idOffset,
00080                    const ElementFile* in);
00081 
00082     void markDOFsConnectedToRange(int* mask, int offset, int marker,
00083                                   int firstDOF, int lastDOF,
00084                                   const int *dofIndex, bool useLinear);
00085 
00086     void setTags(const int newTag, const escript::Data& mask);
00087     ElementFile_Jacobians* borrowJacobians(const NodeFile*, bool, bool) const;
00090     inline std::pair<int,int> getNodeRange() const;
00091 
00094     inline void updateTagList();
00095 
00096 private:
00097     void swapTable(ElementFile* other);
00098 
00099 public:
00100     Esys_MPIInfo *MPIInfo;
00101 
00103     const_ReferenceElementSet_ptr referenceElementSet;
00105     int numElements;
00109     int *Id;
00111     int *Tag;
00113     int *Owner;
00115     std::vector<int> tagsInUse;
00117     int numNodes;
00122     int *Nodes;
00127     int *Color;
00129     int minColor;
00131     int maxColor;
00133     ElementFile_Jacobians* jacobians;
00136     ElementFile_Jacobians* jacobians_reducedS;
00139     ElementFile_Jacobians* jacobians_reducedQ;
00142     ElementFile_Jacobians* jacobians_reducedS_reducedQ;
00143 };
00144 
00145 inline std::pair<int,int> ElementFile::getNodeRange() const
00146 {
00147     return util::getMinMaxInt(numNodes, numElements, Nodes);
00148 }
00149 
00150 
00151 inline void ElementFile::updateTagList()
00152 {
00153     util::setValuesInUse(Tag, numElements, tagsInUse, MPIInfo);
00154 }
00155 
00156 } // namespace finley
00157 
00158 #endif // __FINLEY_ELEMENTFILE_H__
00159