/[escript]/branches/trilinos_from_5897/dudley/src/ElementFile.h
ViewVC logotype

Diff of /branches/trilinos_from_5897/dudley/src/ElementFile.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6078 by caltinay, Wed Mar 2 04:13:26 2016 UTC revision 6079 by caltinay, Mon Mar 21 12:22:38 2016 UTC
# Line 20  Line 20 
20  #include "Dudley.h"  #include "Dudley.h"
21  #include "NodeFile.h"  #include "NodeFile.h"
22  #include "ElementType.h"  #include "ElementType.h"
23    #include "Util.h"
24    
25  namespace dudley {  namespace dudley {
26    
27  typedef struct {  struct ElementFile_Jacobians
28      Dudley_Status_t status;     /* status of mesh when jacobians where updated last time */  {
29      dim_t numDim;               /* spatial dimension */      ElementFile_Jacobians();
30      dim_t numQuad;              /* number of quadrature nodes used to calculate jacobians */      ~ElementFile_Jacobians();
31      dim_t numShapes;            /* number of shape functions */  
32      dim_t numElements;          /* number of elements */      /// status of mesh when jacobians where updated last time
33      double *absD;               /* used to compute volume */      int status;
34      double quadweight;          /* used to compute volume */      /// number of spatial dimensions
35      double *DSDX;               /* derivatives of shape functions in global coordinates at quadrature points */      dim_t numDim;
36  } Dudley_ElementFile_Jacobians;      /// number of quadrature nodes used to calculate jacobians
37        dim_t numQuad;
38        /// number of shape functions
39        dim_t numShapes;
40        /// number of elements
41        dim_t numElements;
42        /// used to compute volume
43        double *absD;
44        /// used to compute volume
45        double quadweight;
46        /// derivatives of shape functions in global coordinates at quadrature
47        /// points
48        double* DSDX;
49    };
50    
51    class ElementFile
52    {
53    public:
54        ElementFile(ElementTypeId etype, escript::JMPI MPIInfo);
55        ~ElementFile();
56    
57        /// allocates the element table within an element file to hold NE elements
58        void allocTable(dim_t numElements);
59    
60        /// deallocates the element table within an element file
61        void freeTable();
62    
63        /// copies element file `in` into this element file starting from `offset`.
64        /// The elements `offset` to in->numElements+offset-1 will be overwritten.
65        void copyTable(index_t offset, index_t nodeOffset, index_t idOffset,
66                       const ElementFile* in);
67    
68        /// redistributes the elements including overlap by rank
69        void distributeByRankOfDOF(const int* mpiRankOfDOF,
70                                   const index_t* nodesId);
71    
72        /// Tries to reduce the number of colors used to color elements in this
73        /// ElementFile
74        void createColoring(dim_t numNodes, const index_t* degreeOfFreedom);
75    
76        /// reorders the elements so that they are stored close to the nodes
77        void optimizeOrdering();
78    
79        /// assigns new node reference numbers to the elements.
80        /// If k is the old node, the new node is newNode[k-offset].
81        void relabelNodes(const index_t* newNode, index_t offset);
82    
83        void markNodes(std::vector<short>& mask, index_t offset) const;
84    
85        /// gathers the elements from the element file `in` using
86        /// index[0:out->elements-1]. `index` has to be between 0 and
87        /// in->numElements-1. A conservative assumption on the colouring is made.
88        void gather(const index_t* index, const ElementFile* in);
89    
90        /// sets element tags to newTag where mask > 0
91        void setTags(int newTag, const escript::Data& mask);
92    
93        ElementFile_Jacobians* borrowJacobians(const NodeFile* nodes,
94                                               bool reducedOrder) const;
95    
96        /// returns the minimum and maximum node reference number of nodes
97        /// describing the elements
98        inline std::pair<index_t,index_t> getNodeRange() const;
99    
100        void updateTagList();
101    
102    private:
103        void swapTable(ElementFile* other);
104    
105  struct Dudley_ElementFile {  public:
106      escript::JMPI MPIInfo;      escript::JMPI MPIInfo;
     int *Owner;  
107    
108      dim_t numElements;          /* number of elements. */      /// number of elements
109        dim_t numElements;
110    
111        /// Id[i] is the id number of node i. this number is used when elements
112        /// are resorted. In the entire code the term 'element id' refers to i and
113        /// not to Id[i] unless explicitly stated otherwise.
114        index_t* Id;
115    
116        /// Tag[i] is the tag of element i
117        int* Tag;
118    
119        /// Owner[i] contains the rank that owns element i
120        int* Owner;
121    
122        /// array of tags which are actually used
123        std::vector<int> tagsInUse;
124    
125        /// number of nodes per element
126        int numNodes;
127    
128        /// Nodes[INDEX(k, i, numNodes)] is the k-th node in the i-the element.
129        index_t* Nodes;
130    
131        /// assigns each element a color. Elements with the same color don't share
132        /// a node so they can be processed simultaneously. At any time Color must
133        /// provide a valid value. In any case one can set Color[e]=e for all e.
134        index_t* Color;
135    
136        /// minimum color value
137        index_t minColor;
138    
139        /// maximum color value
140        index_t maxColor;
141    
142        /// number of spatial dimensions of the domain
143        dim_t numDim;
144    
145        /// dimension of the element e.g. 2 for a line in 2D or 3D
146        dim_t numLocalDim;
147    
148        /// element type ID
149        ElementTypeId etype;
150    
151        /// name of element type
152        const char *ename;
153    
154        /// number of shape functions
155        dim_t numShapes;
156    
157        /// jacobians of the shape function used for solution approximation
158        ElementFile_Jacobians* jacobians;
159    
160      index_t *Id;                /* Id[i] is the id nmber of      /// jacobians of the shape function used for solution approximation for
161                                     node i. this number is not      /// reduced integration order
162                                     used but useful when      ElementFile_Jacobians* jacobians_reducedQ;
                                    elements are resorted. in  
                                    the entire code the term  
                                    'element id' refers to i  
                                    but nor to Id[i] if not  
                                    explicitly stated  
                                    otherwise. */  
   
     index_t *Tag;               /* Tag[i] is the tag of element i. */  
   
     index_t *tagsInUse;         /* array of tags which are actually used */  
     dim_t numTagsInUse;         /* number of tags used */  
   
     dim_t numNodes;             /* number of nodes per element */  
     index_t *Nodes;             /* Nodes[INDEX(k, i, numNodes)]  
                                    is the k-the node in the  
                                    i-the element. note that  
                                    in the way the nodes are  
                                    ordered Nodes[INDEX(k, i, numNodes)  
                                    is k-the node of element i  
                                    when refering to the  
                                    linear version of the  
                                    mesh. */  
     index_t minColor;           /* minimum color */  
     index_t maxColor;           /* maximum color */  
     index_t *Color;             /* assigns each element a color. elements with the same color      
                                    are don't share a node so they can be processed simultaneously  
                                    at anytime Color must provide a valid value. In any case one can set    
                                    Color[e]=e  for all e */  
   
     Dudley_ElementFile_Jacobians *jacobians;    /* jacobians of the shape function used for solution approximation */  
     Dudley_ElementFile_Jacobians *jacobians_reducedQ;   /* jacobians of the shape function used for solution approximation for reduced integration order */  
     dim_t numDim;               /* spatial dimension of the domain */  
     dim_t numLocalDim;          /* dimension of the element eg 2 for A line in 2D or 3D */  
     Dudley_ElementTypeId etype; /* element type */  
     const char *ename;          /* name of element type */  
     dim_t numShapes;            /* number of shape functions */  
163  };  };
164    
165  typedef struct Dudley_ElementFile Dudley_ElementFile;  inline void ElementFile::updateTagList()
166  Dudley_ElementFile *Dudley_ElementFile_alloc(Dudley_ElementTypeId etype, escript::JMPI& MPIInfo);  {
167  void Dudley_ElementFile_free(Dudley_ElementFile *);      util::setValuesInUse(Tag, numElements, tagsInUse, MPIInfo);
168  void Dudley_ElementFile_allocTable(Dudley_ElementFile *, dim_t);  }
169  void Dudley_ElementFile_freeTable(Dudley_ElementFile *);  
170  void Dudley_ElementFile_setElementDistribution(Dudley_ElementFile * in, dim_t * distribution);  inline std::pair<index_t,index_t> ElementFile::getNodeRange() const
171  dim_t Dudley_ElementFile_getGlobalNumElements(Dudley_ElementFile * in);  {
172  dim_t Dudley_ElementFile_getMyNumElements(Dudley_ElementFile * in);      return util::getMinMaxInt(numNodes, numElements, Nodes);
173  index_t Dudley_ElementFile_getFirstElement(Dudley_ElementFile * in);  }
 void Dudley_ElementFile_distributeByRankOfDOF(Dudley_ElementFile * self, int * mpiRankOfDOF, index_t * Id);  
   
 void Dudley_ElementFile_createColoring(Dudley_ElementFile * in, dim_t numNodes, dim_t * degreeOfFreedom);  
 void Dudley_ElementFile_optimizeOrdering(Dudley_ElementFile ** in);  
 void Dudley_ElementFile_setNodeRange(dim_t *, dim_t *, Dudley_ElementFile *);  
 void Dudley_ElementFile_relableNodes(dim_t *, dim_t, Dudley_ElementFile *);  
 void Dudley_ElementFile_markNodes(dim_t *, dim_t, dim_t, Dudley_ElementFile *, bool);  
 void Dudley_ElementFile_scatter(dim_t *, Dudley_ElementFile *, Dudley_ElementFile *);  
 void Dudley_ElementFile_gather(dim_t *, Dudley_ElementFile *, Dudley_ElementFile *);  
 void Dudley_ElementFile_copyTable(dim_t, Dudley_ElementFile *, dim_t, dim_t, Dudley_ElementFile *);  
 void Dudley_ElementFile_markDOFsConnectedToRange(index_t * mask, index_t offset, index_t marker, index_t firstDOF,  
                                                  index_t lastDOF, index_t * dofIndex, Dudley_ElementFile * in,  
                                                  bool useLinear);  
   
 void Dudley_ElementFile_setTags(Dudley_ElementFile *, const int, const escript::Data *);  
 Dudley_ElementFile_Jacobians *Dudley_ElementFile_Jacobians_alloc(void);  
 void Dudley_ElementFile_Jacobians_dealloc(Dudley_ElementFile_Jacobians *);  
 Dudley_ElementFile_Jacobians *Dudley_ElementFile_borrowJacobians(const Dudley_ElementFile*, const Dudley_NodeFile*, bool);  
 void Dudley_ElementFile_setTagsInUse(Dudley_ElementFile * in);  
174    
175  } // namespace dudley  } // namespace dudley
176    

Legend:
Removed from v.6078  
changed lines
  Added in v.6079

  ViewVC Help
Powered by ViewVC 1.1.26