| 1 |
// Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 2 |
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
// NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
// |
| 5 |
// See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
#pragma once |
| 8 |
|
| 9 |
#include "iocatalyst_export.h" |
| 10 |
#include <array> |
| 11 |
#include <vector> |
| 12 |
|
| 13 |
namespace Iocatalyst { |
| 14 |
|
| 15 |
class IOCATALYST_EXPORT BlockMesh |
| 16 |
{ |
| 17 |
public: |
| 18 |
struct Partition |
| 19 |
{ |
| 20 |
int id; |
| 21 |
int size; |
| 22 |
}; |
| 23 |
|
| 24 |
struct Point |
| 25 |
{ |
| 26 |
double x; |
| 27 |
double y; |
| 28 |
double z; |
| 29 |
}; |
| 30 |
|
| 31 |
struct Extent |
| 32 |
{ |
| 33 |
unsigned int i; |
| 34 |
unsigned int j; |
| 35 |
unsigned int k; |
| 36 |
}; |
| 37 |
|
| 38 |
using BlockConn = std::array<int, 8>; |
| 39 |
using IDList = std::vector<int>; |
| 40 |
using ID = unsigned int; |
| 41 |
static const unsigned int BLOCK_OFFSET = 0; |
| 42 |
static const unsigned int POINT_OFFSET = 1; |
| 43 |
static constexpr double BLOCK_LENGTH = 1.0; |
| 44 |
|
| 45 |
static const unsigned int I_GLOBAL = 1000; |
| 46 |
static const unsigned int J_GLOBAL = 1000; |
| 47 |
static const unsigned int K_GLOBAL = 1000; |
| 48 |
|
| 49 |
BlockMesh(); |
| 50 |
~BlockMesh(); |
| 51 |
|
| 52 |
void init(const Partition &part, const Extent &numBlocks, const Extent &origin); |
| 53 |
|
| 54 |
const Partition &getPartition() const { return partition; } |
| 55 |
|
| 56 |
const Extent &getOrigin() const { return origin; } |
| 57 |
|
| 58 |
const Extent &getExtents() const { return extents; } |
| 59 |
|
| 60 |
const Extent &getPartitionExtents() const { return partitionExtents; } |
| 61 |
const Extent &getPartitionStart() const { return partitionStart; } |
| 62 |
|
| 63 |
ID getID() const; |
| 64 |
|
| 65 |
bool isPartitionEmpty() const; |
| 66 |
|
| 67 |
int getNumBlocks() const; |
| 68 |
int getNumPartitionBlocks() const; |
| 69 |
IDList getPartitionBlockIDs() const; |
| 70 |
BlockConn getBlockConnectivityPointIDs(ID blockID) const; |
| 71 |
static Extent getGlobalBlockExtents() { return {I_GLOBAL, J_GLOBAL, K_GLOBAL}; }; |
| 72 |
ID getGlobalIDForBlockID(ID blockID); |
| 73 |
|
| 74 |
int getNumPoints() const; |
| 75 |
int getNumPartitionPoints() const; |
| 76 |
IDList getPartitionPointIDs() const; |
| 77 |
ID getPointIDfromCoords(unsigned int i, unsigned int j, unsigned int k) const; |
| 78 |
Point getPointCoordsForPointID(ID pointID) const; |
| 79 |
static Extent getGlobalPointExtents() { return {I_GLOBAL + 1, J_GLOBAL + 1, K_GLOBAL + 1}; }; |
| 80 |
ID getGlobalIDForPointID(ID pointID); |
| 81 |
|
| 82 |
static Extent getCoordsForID(ID id, Extent bounds); |
| 83 |
static ID getIDfromCoords(Extent coords, Extent bounds); |
| 84 |
|
| 85 |
void addTransientCellField(std::string f_name, double f_value); |
| 86 |
void addTransientPointField(std::string f_name, double f_value); |
| 87 |
|
| 88 |
std::map<std::string, double> *getTransientCellFieldMap(); |
| 89 |
std::map<std::string, double> *getTransientPointFieldMap(); |
| 90 |
|
| 91 |
private: |
| 92 |
Partition partition; |
| 93 |
Extent origin; |
| 94 |
Extent extents; |
| 95 |
Extent partitionExtents; |
| 96 |
Extent partitionStart; |
| 97 |
Extent globalBlockExtents; |
| 98 |
void splitBlock(); |
| 99 |
void fillExtents(int *ext); |
| 100 |
void setPartitionFromExtents(int ext[6]); |
| 101 |
void setPartitionEmpty(); |
| 102 |
IDList getPartitionIDs(unsigned int offset) const; |
| 103 |
int getNumInPartition(unsigned int offset) const; |
| 104 |
int getNumInBlockMesh(unsigned int offset) const; |
| 105 |
ID id; |
| 106 |
static ID _id; |
| 107 |
|
| 108 |
std::map<std::string, double> transientCellFields; |
| 109 |
std::map<std::string, double> transientPointFields; |
| 110 |
}; |
| 111 |
|
| 112 |
} // namespace Iocatalyst |