1 |
|
2 |
/******************************************************* |
3 |
* |
4 |
* Copyright (c) 2003-2009 by University of Queensland |
5 |
* Earth Systems Science Computational Center (ESSCC) |
6 |
* http://www.uq.edu.au/esscc |
7 |
* |
8 |
* Primary Business: Queensland, Australia |
9 |
* Licensed under the Open Software License version 3.0 |
10 |
* http://www.opensource.org/licenses/osl-3.0.php |
11 |
* |
12 |
*******************************************************/ |
13 |
|
14 |
#ifndef __FINLEYMESH_H__ |
15 |
#define __FINLEYMESH_H__ |
16 |
|
17 |
#include <escriptexport/escriptexport.h> |
18 |
#include <escript/AbstractDomain.h> |
19 |
|
20 |
class DBfile; |
21 |
struct Finley_Mesh; |
22 |
|
23 |
namespace escriptexport { |
24 |
|
25 |
class ElementData; |
26 |
class NodeData; |
27 |
|
28 |
/// \brief Represents a full Finley domain including nodes and elements. |
29 |
/// |
30 |
/// This class represents a Finley domain including nodes, cells, face elements |
31 |
/// and contact elements. It provides functionality to read a domain from a |
32 |
/// NetCDF file (generated by the domain's dump() method) or directly |
33 |
/// through an instance of Finley_Mesh. |
34 |
/// |
35 |
/// Once initialised, the domain can be saved in the Silo file format or |
36 |
/// its nodes and elements accessed through the respective methods. |
37 |
/// |
38 |
/// Note that this class is not MPI aware, that is if domain decomposition |
39 |
/// was used only one 'chunk' of the domain can be read per instance of this |
40 |
/// class. See MPDataSet for how to process full domains. |
41 |
class FinleyMesh |
42 |
{ |
43 |
public: |
44 |
/// \brief Default constructor. |
45 |
ESCRIPTEXPORT_DLL_API |
46 |
FinleyMesh(); |
47 |
|
48 |
/// \brief Copy constructor. |
49 |
ESCRIPTEXPORT_DLL_API |
50 |
FinleyMesh(const FinleyMesh& m); |
51 |
|
52 |
/// \brief Virtual destructor. |
53 |
ESCRIPTEXPORT_DLL_API |
54 |
virtual ~FinleyMesh(); |
55 |
|
56 |
/// \brief Initialises the mesh using an escript domain instance. |
57 |
/// \note Finley_Mesh is the only supported domain. |
58 |
ESCRIPTEXPORT_DLL_API |
59 |
bool initFromEscript(escript::const_Domain_ptr escriptDomain); |
60 |
|
61 |
/// \brief Reads the mesh from a NetCDF file |
62 |
ESCRIPTEXPORT_DLL_API |
63 |
bool initFromNetCDF(const std::string& filename); |
64 |
|
65 |
/// \brief Writes the mesh to a Silo file |
66 |
ESCRIPTEXPORT_DLL_API |
67 |
bool writeToSilo(DBfile* dbfile, const std::string& pathInSilo); |
68 |
|
69 |
/// \brief Reorders elements so that 'ghost' elements appear last |
70 |
ESCRIPTEXPORT_DLL_API |
71 |
void reorderGhostZones(int ownIndex); |
72 |
|
73 |
/// \brief Removes 'ghost' elements and nodes |
74 |
ESCRIPTEXPORT_DLL_API |
75 |
void removeGhostZones(int ownIndex); |
76 |
|
77 |
/// \brief Returns the names of all meshes |
78 |
ESCRIPTEXPORT_DLL_API |
79 |
StringVec getMeshNames() const; |
80 |
|
81 |
/// \brief Returns the names of all 'special' Finley mesh variables |
82 |
ESCRIPTEXPORT_DLL_API |
83 |
StringVec getVarNames() const; |
84 |
|
85 |
/// \brief Returns element data with given name |
86 |
ESCRIPTEXPORT_DLL_API |
87 |
ElementData_ptr getElementsByName(const std::string& name) const; |
88 |
|
89 |
/// \brief Returns node data with given name |
90 |
ESCRIPTEXPORT_DLL_API |
91 |
NodeData_ptr getMeshByName(const std::string& name) const; |
92 |
|
93 |
/// \brief Returns mesh variable data |
94 |
ESCRIPTEXPORT_DLL_API |
95 |
const IntVec& getVarDataByName(const std::string& name) const; |
96 |
|
97 |
/// \brief Returns the node mesh for given function space |
98 |
ESCRIPTEXPORT_DLL_API |
99 |
NodeData_ptr getMeshForFinleyFS(int functionSpace) const; |
100 |
|
101 |
/// \brief Returns the element data for given function space |
102 |
ESCRIPTEXPORT_DLL_API |
103 |
ElementData_ptr getElementsForFinleyFS(int functionSpace) const; |
104 |
|
105 |
/// \brief Returns a pointer to the nodes. |
106 |
ESCRIPTEXPORT_DLL_API |
107 |
NodeData_ptr getNodes() const { return nodes; } |
108 |
|
109 |
/// \brief Returns a pointer to the elements. |
110 |
ESCRIPTEXPORT_DLL_API |
111 |
ElementData_ptr getElements() { return cells; } |
112 |
|
113 |
/// \brief Returns a pointer to the face elements. |
114 |
ESCRIPTEXPORT_DLL_API |
115 |
ElementData_ptr getFaceElements() { return faces; } |
116 |
|
117 |
/// \brief Returns a pointer to the contact elements. |
118 |
ESCRIPTEXPORT_DLL_API |
119 |
ElementData_ptr getContactElements() { return contacts; } |
120 |
|
121 |
/// \brief Returns the absolute path within Silo file if writeToSilo() |
122 |
/// or setSiloPath() was called before, the empty string otherwise. |
123 |
ESCRIPTEXPORT_DLL_API |
124 |
std::string getSiloPath() const { return siloPath; } |
125 |
|
126 |
/// \brief Sets the silo path to be used when saving to a Silo file. |
127 |
ESCRIPTEXPORT_DLL_API |
128 |
void setSiloPath(const std::string& path) { siloPath = path; } |
129 |
|
130 |
private: |
131 |
void cleanup(); |
132 |
|
133 |
bool initialized; |
134 |
const Finley_Mesh* finleyMesh; |
135 |
NodeData_ptr nodes; |
136 |
ElementData_ptr cells; |
137 |
ElementData_ptr faces; |
138 |
ElementData_ptr contacts; |
139 |
std::string siloPath; |
140 |
}; |
141 |
|
142 |
} // namespace escriptexport |
143 |
|
144 |
#endif // __FINLEYMESH_H__ |
145 |
|