/usr/lib/petscdir/3.4.2/include/petscdmmesh_formats.hh is in libpetsc3.4.2-dev 3.4.2.dfsg1-8.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | #if !defined(__PETSCDMMESH_FORMATS_HH)
#define __PETSCDMMESH_FORMATS_HH
#include <petscdmmesh.hh>
namespace ALE {
namespace PyLith {
class Builder {
public:
typedef PETSC_MESH_TYPE Mesh;
typedef Mesh::sieve_type sieve_type;
typedef Mesh::real_section_type real_section_type;
typedef Mesh::int_section_type int_section_type;
public:
Builder() {};
virtual ~Builder() {};
protected:
static inline void ignoreComments(char *buf, PetscInt bufSize, FILE *f);
public:
static void readConnectivity(MPI_Comm comm, const std::string& filename, int& corners, const bool useZeroBase, int& numElements, int *vertices[], int *materials[]);
static void readCoordinates(MPI_Comm comm, const std::string& filename, const int dim, int& numVertices, PetscReal *coordinates[]);
static void readSplit(MPI_Comm comm, const std::string& filename, const int dim, const bool useZeroBase, int& numSplit, int *splitInd[], int *loadHistory[], PetscReal *splitValues[]);
static void readTractions(MPI_Comm comm, const std::string& filename, const int dim, const int& corners, const bool useZeroBase, int& numTractions, int& vertsPerFace, int *tractionVertices[], double *tractionValues[]);
static void buildMaterials(const Obj<Mesh>& mesh, const Obj<int_section_type>& matField, const int materials[]);
#if 0
static void buildSplit(const Obj<pair_section_type>& splitField, const Obj<int_section_type>& loadField, int numCells, int numSplit, int splitInd[], int loadHist[], double splitVals[]);
#endif
static void buildTractions(const Obj<real_section_type>& tractionField, const Obj<Mesh>& boundaryMesh, int numCells, int numTractions, int vertsPerFace, int tractionVertices[], double tractionValues[]);
static Obj<Mesh> readMesh(MPI_Comm comm, const int dim, const std::string& basename, const bool useZeroBase, const bool interpolate, const int debug);
#if 0
static Obj<pair_section_type> createSplit(const Obj<Mesh>& mesh, const std::string& basename, const bool useZeroBase);
#endif
static Obj<Mesh> createTraction(const Obj<Mesh>& mesh, const std::string& basename, const bool useZeroBase);
static void createCohesiveElements(const Obj<Mesh>& mesh, const std::set<Mesh::point_type>& faultVertices);
};
class Viewer {
public:
typedef PETSC_MESH_TYPE Mesh;
public:
Viewer() {};
virtual ~Viewer() {};
public:
static PetscErrorCode writeVertices(const Obj<Mesh>& mesh, PetscViewer viewer);
static PetscErrorCode writeVerticesLocal(const Obj<Mesh>& mesh, PetscViewer viewer);
static PetscErrorCode writeElements(const Obj<Mesh>& mesh, const Obj<Builder::int_section_type>& materialField, PetscViewer viewer);
static PetscErrorCode writeElementsLocal(const Obj<Mesh>& mesh, const Obj<Builder::int_section_type>& materialField, PetscViewer viewer);
#if 0
static PetscErrorCode writeSplitLocal(const Obj<Mesh>& mesh, const Obj<Builder::pair_section_type>& splitField, PetscViewer viewer);
#endif
static PetscErrorCode writeTractionsLocal(const Obj<Mesh>& mesh, const Obj<Mesh>& tractionMesh, const Obj<Builder::real_section_type>& tractionField, PetscViewer viewer);
};
};
};
namespace ALE {
namespace LaGriT {
class Builder {
public:
typedef PETSC_MESH_TYPE Mesh;
typedef PETSC_MESH_TYPE::sieve_type sieve_type;
public:
static void readInpFile(MPI_Comm comm, const std::string& filename, const int dim, const int numCorners, int& numElements, int *vertices[], int& numVertices, PetscReal *coordinates[]);
static Obj<Mesh> readMesh(MPI_Comm comm, const int dim, const std::string& filename, const bool interpolate, const int debug);
static void readFault(Obj<Mesh> mesh, const std::string& filename);
};
}
}
namespace ALE {
namespace Bardhan {
class Builder {
public:
typedef PETSC_MESH_TYPE Mesh;
typedef PETSC_MESH_TYPE::sieve_type sieve_type;
public:
static void readInpFile(MPI_Comm comm, const std::string& filename, const int dim, const int numCorners, int& numElements, int *vertices[], int& numVertices, PetscReal *coordinates[], PetscReal *faceNormals[]);
static Obj<Mesh> readMesh(MPI_Comm comm, const int dim, const std::string& filename, const bool interpolate, const int debug);
static void readFault(Obj<Mesh> mesh, const std::string& filename);
};
}
}
namespace ALE {
namespace PCICE {
void fuseBoundary(const ALE::Obj<PETSC_MESH_TYPE>& mesh);
class Builder {
public:
typedef PETSC_MESH_TYPE Mesh;
typedef Mesh::sieve_type sieve_type;
typedef Mesh::real_section_type section_type;
public:
Builder() {};
virtual ~Builder() {};
public:
static void readConnectivity(MPI_Comm comm, const std::string& filename, int& corners, const bool useZeroBase, int& numElements, int *vertices[]);
static void readCoordinates(MPI_Comm comm, const std::string& filename, const int dim, int& numVertices, PetscReal *coordinates[]);
static Obj<Mesh> readMesh(MPI_Comm comm, const int dim, const std::string& basename, const bool useZeroBase, const bool interpolate, const int debug);
static Obj<Mesh> readMesh(MPI_Comm comm, const int dim, const std::string& coordFilename, const std::string& adjFilename, const bool useZeroBase, const bool interpolate, const int debug);
static void readBoundary(const Obj<Mesh>& mesh, const std::string& bcFilename);
static void outputVerticesLocal(const Obj<Mesh>& mesh, int *numVertices, int *dim, PetscReal *coordinates[], bool columnMajor);
static void outputElementsLocal(const Obj<Mesh>& mesh, int *numElements, int *numCorners, int *vertices[], bool columnMajor);
};
typedef struct {
ALE::Mesh<PetscInt,PetscScalar>::point_type vertex;
ALE::Mesh<PetscInt,PetscScalar>::real_section_type::value_type veln_x;
ALE::Mesh<PetscInt,PetscScalar>::real_section_type::value_type veln_y;
ALE::Mesh<PetscInt,PetscScalar>::real_section_type::value_type pn;
ALE::Mesh<PetscInt,PetscScalar>::real_section_type::value_type tn;
} RestartType;
class Viewer {
public:
typedef PETSC_MESH_TYPE Mesh;
public:
Viewer() {};
virtual ~Viewer() {};
public:
static PetscErrorCode writeVertices(const Obj<Mesh>& mesh, PetscViewer viewer);
static PetscErrorCode writeElements(const Obj<Mesh>& mesh, PetscViewer viewer);
static PetscErrorCode writeVerticesLocal(const Obj<Mesh>& mesh, PetscViewer viewer);
static PetscErrorCode writeRestart(const Obj<Mesh>& mesh, PetscViewer viewer);
};
};
};
#ifdef PETSC_HAVE_LIBXML2
#include <libxml/parser.h>
namespace ALE {
namespace Dolfin {
class XMLObject {
public:
XMLObject() {};
virtual ~XMLObject() {};
public:
/// Callback for start of XML element
virtual void startElement(const xmlChar* name, const xmlChar** attrs) = 0;
/// Callback for end of XML element
virtual void endElement(const xmlChar* name) = 0;
/// Callback for start of XML file (optional)
virtual void open(const std::string& filename) {};
/// Callback for end of XML file, should return true iff data is ok (optional)
virtual bool close() {return true;};
protected:
int parseInt(const xmlChar* name, const xmlChar** attrs, const char *attribute);
unsigned int parseUnsignedInt(const xmlChar* name, const xmlChar** attrs, const char *attribute);
double parseReal(const xmlChar* name, const xmlChar** attrs, const char* attribute);
std::string parseString(const xmlChar* name, const xmlChar** attrs, const char* attribute);
bool parseBool(const xmlChar* name, const xmlChar** attrs, const char* attribute);
void error(std::string msg, ...);
};
class XMLMesh : public XMLObject {
private:
enum ParserState {OUTSIDE, INSIDE_MESH, INSIDE_VERTICES, INSIDE_CELLS, DONE};
private:
const Obj<PETSC_MESH_TYPE>& mesh;
ParserState state;
double *coords; // The vertex coordinates
unsigned int embedDim; // The embedding dimension
unsigned int numCells; // The number of cells (co-dim 0)
public:
XMLMesh(const Obj<PETSC_MESH_TYPE>& mesh) : XMLObject(), mesh(mesh), state(OUTSIDE), coords(NULL), embedDim(0), numCells(0) {};
virtual ~XMLMesh() {};
public:
void startElement (const xmlChar* name, const xmlChar** attrs);
void endElement (const xmlChar* name);
void open(std::string filename) {};
bool close() {return state == DONE;};
private:
void readMesh (const xmlChar* name, const xmlChar** attrs);
void readVertices (const xmlChar* name, const xmlChar** attrs);
void readCells (const xmlChar* name, const xmlChar** attrs);
void readVertex (const xmlChar* name, const xmlChar** attrs);
void readInterval (const xmlChar* name, const xmlChar** attrs);
void readTriangle (const xmlChar* name, const xmlChar** attrs);
void readTetrahedron (const xmlChar* name, const xmlChar** attrs);
void closeMesh();
};
class Builder {
protected:
static void sax_start_document(void *ctx) {};
static void sax_end_document(void *ctx) {};
static void sax_start_element(void *ctx, const xmlChar *name, const xmlChar **attrs) {
((ALE::Dolfin::XMLObject *) ctx)->startElement(name, attrs);
};
static void sax_end_element(void *ctx, const xmlChar *name) {
((ALE::Dolfin::XMLObject *) ctx)->endElement(name);
};
static void sax_warning(void *ctx, const char *msg, ...) {
char buffer[2048];
va_list args;
va_start(args, msg);
vsnprintf(buffer, 2048, msg, args);
std::cout << "Incomplete XML data: " << buffer << std::endl;
va_end(args);
};
static void sax_error(void *ctx, const char *msg, ...) {
char buffer[2048];
va_list args;
va_start(args, msg);
vsnprintf(buffer, 2048, msg, args);
std::cerr << "Incomplete XML data: " << buffer << std::endl;
va_end(args);
};
static void sax_fatal_error(void *ctx, const char *msg, ...) {
char buffer[2048];
va_list args;
va_start(args, msg);
vsnprintf(buffer, 2048, msg, args);
std::cerr << "Illegal XML data: " << buffer << std::endl;
va_end(args);
};
public:
static void parseSAX(const std::string& filename, ALE::Dolfin::XMLObject *xmlObject) {
// Set up the sax handler. Note that it is important that we initialise
// all (24) fields, even the ones we don't use!
xmlSAXHandler sax = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
// Set up handlers for parser events
sax.startDocument = sax_start_document;
sax.endDocument = sax_end_document;
sax.startElement = sax_start_element;
sax.endElement = sax_end_element;
sax.warning = sax_warning;
sax.error = sax_error;
sax.fatalError = sax_fatal_error;
// Parse file
xmlSAXUserParseFile(&sax, (void *) xmlObject, filename.c_str());
};
static void readMesh(const Obj<PETSC_MESH_TYPE>& mesh, const std::string& filename) {
ALE::Dolfin::XMLObject *xmlObject;
xmlObject = new ALE::Dolfin::XMLMesh(mesh);
xmlObject->open(filename);
// Parse file using the SAX interface
parseSAX(filename, xmlObject);
if (!xmlObject->close()) {std::cerr << "Unable to find data in XML file." << std::endl;};
delete xmlObject;
};
};
}
}
#endif // PETSC_HAVE_LIBXML2
namespace ALE {
namespace PFLOTRAN {
void fuseBoundary(const ALE::Obj<PETSC_MESH_TYPE>& mesh);
class Builder {
public:
typedef PETSC_MESH_TYPE Mesh;
typedef Mesh::sieve_type sieve_type;
typedef Mesh::real_section_type section_type;
public:
Builder() {};
virtual ~Builder() {};
public:
static void readConnectivity(MPI_Comm comm, const std::string& filename, int& corners, const bool useZeroBase, int& numElements, int *vertices[]);
static void readCoordinates(MPI_Comm comm, const std::string& filename, const int dim, int& numVertices, double *coordinates[]);
static Obj<Mesh> readMesh(MPI_Comm comm, const int dim, const std::string& basename, const bool useZeroBase, const bool interpolate, const int debug);
static Obj<Mesh> readMesh(MPI_Comm comm, const int dim, const std::string& coordFilename, const std::string& adjFilename, const bool useZeroBase, const bool interpolate, const int debug);
static void readBoundary(const Obj<Mesh>& mesh, const std::string& bcFilename);
static void outputVerticesLocal(const Obj<Mesh>& mesh, int *numVertices, int *dim, double *coordinates[], bool columnMajor);
static void outputElementsLocal(const Obj<Mesh>& mesh, int *numElements, int *numCorners, int *vertices[], bool columnMajor);
};
typedef struct {
ALE::Mesh<PetscInt,PetscScalar>::point_type vertex;
ALE::Mesh<PetscInt,PetscScalar>::real_section_type::value_type veln_x;
ALE::Mesh<PetscInt,PetscScalar>::real_section_type::value_type veln_y;
ALE::Mesh<PetscInt,PetscScalar>::real_section_type::value_type pn;
ALE::Mesh<PetscInt,PetscScalar>::real_section_type::value_type tn;
} RestartType;
class Viewer {
public:
typedef PETSC_MESH_TYPE Mesh;
public:
Viewer() {};
virtual ~Viewer() {};
public:
static PetscErrorCode writeVertices(const Obj<Mesh>& mesh, PetscViewer viewer);
static PetscErrorCode writeElements(const Obj<Mesh>& mesh, PetscViewer viewer);
static PetscErrorCode writeVerticesLocal(const Obj<Mesh>& mesh, PetscViewer viewer);
static PetscErrorCode writeRestart(const Obj<Mesh>& mesh, PetscViewer viewer);
};
};
};
#endif // __PETSCDMMESH_FORMATS_HH
|