escript  Revision_
FinleyElements.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 __WEIPA_FINLEYELEMENTS_H__
00018 #define __WEIPA_FINLEYELEMENTS_H__
00019 
00020 #include <weipa/ElementData.h>
00021 #include <weipa/FinleyNodes.h>
00022 
00023 #include <dudley/ElementType.h> // for Dudley_ElementTypeId
00024 #include <finley/ReferenceElements.h> // for finley::ElementTypeId
00025 
00026 class DBfile;
00027 class NcFile;
00028 
00029 struct Dudley_ElementFile;
00030 
00031 namespace finley {
00032     class ElementFile;
00033 }
00034 
00035 namespace weipa {
00036  
00039 struct FinleyElementInfo
00040 {
00041     ZoneType elementType, reducedElementType;
00042     int elementFactor;
00043     int elementSize, reducedElementSize;
00044     const size_t* multiCellIndices;
00045     bool useQuadNodes;
00046     int quadDim;
00047 };
00048 
00049 class FinleyElements;
00050 typedef boost::shared_ptr<FinleyElements> FinleyElements_ptr;
00051 
00061 class FinleyElements : public ElementData
00062 {
00063 public:
00064 
00066     FinleyElements(const std::string& elementName, FinleyNodes_ptr nodes);
00067 
00069     FinleyElements(const FinleyElements& e);
00070 
00072     virtual ~FinleyElements() {}
00073 
00075     bool initFromDudley(const Dudley_ElementFile* dudleyFile);
00076 
00078     bool initFromFinley(const finley::ElementFile* finleyFile);
00079 
00081     bool readFromNc(NcFile* ncfile);
00082 
00085     void reorderGhostZones(int ownIndex);
00086 
00088     void removeGhostZones(int ownIndex);
00089 
00091     virtual void writeConnectivityVTK(std::ostream& os);
00092 
00098     bool writeToSilo(DBfile* dbfile, const std::string& siloPath,
00099                      const StringVec& labels, const StringVec& units,
00100                      bool writeMeshData);
00101 
00103     virtual StringVec getMeshNames() const;
00104 
00106     virtual StringVec getVarNames() const;
00107 
00109     virtual int getNumElements() const { return numElements; }
00110 
00112     virtual int getNodesPerElement() const { return nodesPerElement; }
00113 
00115     virtual int getGhostCount() const { return numGhostElements; }
00116 
00118     virtual ZoneType getType() const { return type; }
00119 
00121     finley::ElementTypeId getFinleyTypeId() const { return finleyTypeId; }
00122 
00124     virtual const IntVec& getNodeList() const { return nodes; }
00125 
00127     virtual const IntVec& getIDs() const { return ID; }
00128 
00132     virtual const IntVec& getVarDataByName(const std::string varName) const;
00133 
00135     virtual NodeData_ptr getNodes() const { return nodeMesh; }
00136 
00138     virtual ElementData_ptr getReducedElements() const { return reducedElements; }
00139  
00141     virtual const QuadMaskInfo& getQuadMask(int functionSpace) const;
00142  
00146     virtual int getElementFactor() const { return elementFactor; }
00147 
00148 private:
00149     FinleyElements() {}
00150     FinleyElementInfo getDudleyTypeInfo(Dudley_ElementTypeId typeId);
00151     FinleyElementInfo getFinleyTypeInfo(finley::ElementTypeId typeId);
00152     void buildMeshes();
00153     void buildReducedElements(const FinleyElementInfo& f);
00154     IntVec prepareGhostIndices(int ownIndex);
00155     void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
00156     QuadMaskInfo buildQuadMask(const CoordArray& quadNodes, int numQNodes);
00157 
00158     FinleyElements_ptr reducedElements;
00159     FinleyNodes_ptr nodeMesh;
00160     FinleyNodes_ptr originalMesh;
00161     std::string name;
00162     int numElements;
00163     int numGhostElements;
00164     int nodesPerElement;
00165     ZoneType type;
00166     finley::ElementTypeId finleyTypeId;
00167     IntVec nodes;
00168     IntVec color, ID, tag;
00169     IntVec owner;
00170     QuadMaskInfo quadMask, reducedQuadMask;
00171     int elementFactor;
00172 };
00173 
00174 } // namespace weipa
00175 
00176 #endif // __WEIPA_FINLEYELEMENTS_H__
00177