Skip to content

Commit

Permalink
merge with main; bump to v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Jul 21, 2024
2 parents e3a1b20 + fb9cf68 commit 6ee0766
Show file tree
Hide file tree
Showing 4 changed files with 463 additions and 309 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ description = "Pythonic interface to MAPDL archive files."
name = "mapdl-archive"
readme = "README.rst"
requires-python = ">=3.8"
version = "0.2.0"
version = "0.2.1"

[project.urls]
Repository = "https://github.com/akaszynski/mapdl-archive"
Expand Down
149 changes: 71 additions & 78 deletions src/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
#include <stdint.h>
#endif

// Standard VTK int size
#if defined(__linux__) || defined(__APPLE__)
typedef int64_t vtk_int;
#else
typedef int32_t vtk_int;
#endif

// VTK cell types
#define VTK_TRIANGLE 5
#define VTK_QUAD 9
Expand Down Expand Up @@ -137,8 +130,8 @@ void WriteEblock(
const NDArray<const int, 1> rcon_arr, // real constant ID array
const NDArray<const int, 1> elem_nnodes_arr, // number of nodes per element
const NDArray<const uint8_t, 1> celltypes_arr, // VTK celltypes array
const NDArray<const vtk_int, 1> offset_arr, // VTK offset array
const NDArray<const vtk_int, 1> cells_arr, // VTK cell connectivity array
const NDArray<const int64_t, 1> offset_arr, // VTK offset array
const NDArray<const int64_t, 1> cells_arr, // VTK cell connectivity array
const NDArray<const int, 1> typenum_arr, // ANSYS type number (e.g. 187 for SOLID187)
const NDArray<const int, 1> nodenum_arr, // ANSYS node numbering
std::string &mode) {
Expand All @@ -151,8 +144,8 @@ void WriteEblock(
const int *rcon = rcon_arr.data();
const int *elem_nnodes = elem_nnodes_arr.data();
const uint8_t *celltypes = celltypes_arr.data();
const vtk_int *offset = offset_arr.data();
const vtk_int *cells = cells_arr.data();
const int64_t *offset = offset_arr.data();
const int64_t *cells = cells_arr.data();
const int *typenum = typenum_arr.data();
const int *nodenum = nodenum_arr.data();

Expand Down Expand Up @@ -431,17 +424,17 @@ NDArray<int, 1> CmblockItems(const NDArray<const int, 1> array) {
// Resets the midside nodes of the tetrahedral starting at index c.
// midside nodes between
// (0,1), (1,2), (2,0), (0,3), (1,3), and (2,3)
template <typename T> inline void ResetMidTet(const vtk_int *cells, T *points) {
vtk_int ind0 = cells[0] * 3;
vtk_int ind1 = cells[1] * 3;
vtk_int ind2 = cells[2] * 3;
vtk_int ind3 = cells[3] * 3;
vtk_int ind4 = cells[4] * 3;
vtk_int ind5 = cells[5] * 3;
vtk_int ind6 = cells[6] * 3;
vtk_int ind7 = cells[7] * 3;
vtk_int ind8 = cells[8] * 3;
vtk_int ind9 = cells[9] * 3;
template <typename T> inline void ResetMidTet(const int64_t *cells, T *points) {
int64_t ind0 = cells[0] * 3;
int64_t ind1 = cells[1] * 3;
int64_t ind2 = cells[2] * 3;
int64_t ind3 = cells[3] * 3;
int64_t ind4 = cells[4] * 3;
int64_t ind5 = cells[5] * 3;
int64_t ind6 = cells[6] * 3;
int64_t ind7 = cells[7] * 3;
int64_t ind8 = cells[8] * 3;
int64_t ind9 = cells[9] * 3;

for (size_t j = 0; j < 3; j++) {
points[ind4 + j] = (points[ind0 + j] + points[ind1 + j]) * 0.5;
Expand All @@ -462,20 +455,20 @@ template <typename T> inline void ResetMidTet(const vtk_int *cells, T *points) {
// 10(1, 4)
// 11(2, 4)
// 12(3, 4)
template <typename T> inline void ResetMidPyr(const vtk_int *cells, T *points) {
vtk_int ind0 = cells[0] * 3;
vtk_int ind1 = cells[1] * 3;
vtk_int ind2 = cells[2] * 3;
vtk_int ind3 = cells[3] * 3;
vtk_int ind4 = cells[4] * 3;
vtk_int ind5 = cells[5] * 3;
vtk_int ind6 = cells[6] * 3;
vtk_int ind7 = cells[7] * 3;
vtk_int ind8 = cells[8] * 3;
vtk_int ind9 = cells[9] * 3;
vtk_int ind10 = cells[10] * 3;
vtk_int ind11 = cells[11] * 3;
vtk_int ind12 = cells[12] * 3;
template <typename T> inline void ResetMidPyr(const int64_t *cells, T *points) {
int64_t ind0 = cells[0] * 3;
int64_t ind1 = cells[1] * 3;
int64_t ind2 = cells[2] * 3;
int64_t ind3 = cells[3] * 3;
int64_t ind4 = cells[4] * 3;
int64_t ind5 = cells[5] * 3;
int64_t ind6 = cells[6] * 3;
int64_t ind7 = cells[7] * 3;
int64_t ind8 = cells[8] * 3;
int64_t ind9 = cells[9] * 3;
int64_t ind10 = cells[10] * 3;
int64_t ind11 = cells[11] * 3;
int64_t ind12 = cells[12] * 3;

for (size_t j = 0; j < 3; j++) {
points[ind5 + j] = (points[ind0 + j] + points[ind1 + j]) * 0.5;
Expand All @@ -489,7 +482,7 @@ template <typename T> inline void ResetMidPyr(const vtk_int *cells, T *points) {
}
}

template <typename T> inline void ResetMidWeg(const vtk_int *cells, T *points) {
template <typename T> inline void ResetMidWeg(const int64_t *cells, T *points) {
// Reset midside nodes of a wedge cell:
// 6 (0,1)
// 7 (1,2)
Expand All @@ -500,21 +493,21 @@ template <typename T> inline void ResetMidWeg(const vtk_int *cells, T *points) {
// 12 (0,3)
// 13 (1,4)
// 14 (2,5)
vtk_int ind0 = cells[0] * 3;
vtk_int ind1 = cells[1] * 3;
vtk_int ind2 = cells[2] * 3;
vtk_int ind3 = cells[3] * 3;
vtk_int ind4 = cells[4] * 3;
vtk_int ind5 = cells[5] * 3;
vtk_int ind6 = cells[6] * 3;
vtk_int ind7 = cells[7] * 3;
vtk_int ind8 = cells[8] * 3;
vtk_int ind9 = cells[9] * 3;
vtk_int ind10 = cells[10] * 3;
vtk_int ind11 = cells[11] * 3;
vtk_int ind12 = cells[12] * 3;
vtk_int ind13 = cells[13] * 3;
vtk_int ind14 = cells[14] * 3;
int64_t ind0 = cells[0] * 3;
int64_t ind1 = cells[1] * 3;
int64_t ind2 = cells[2] * 3;
int64_t ind3 = cells[3] * 3;
int64_t ind4 = cells[4] * 3;
int64_t ind5 = cells[5] * 3;
int64_t ind6 = cells[6] * 3;
int64_t ind7 = cells[7] * 3;
int64_t ind8 = cells[8] * 3;
int64_t ind9 = cells[9] * 3;
int64_t ind10 = cells[10] * 3;
int64_t ind11 = cells[11] * 3;
int64_t ind12 = cells[12] * 3;
int64_t ind13 = cells[13] * 3;
int64_t ind14 = cells[14] * 3;

for (size_t j = 0; j < 3; j++) {
points[ind6 + j] = (points[ind0 + j] + points[ind1 + j]) * 0.5;
Expand Down Expand Up @@ -542,27 +535,27 @@ template <typename T> inline void ResetMidWeg(const vtk_int *cells, T *points) {
// 17 (1,5)
// 18 (2,6)
// 19 (3,7)
template <typename T> inline void ResetMidHex(const vtk_int *cells, T *points) {
vtk_int ind0 = cells[0] * 3;
vtk_int ind1 = cells[1] * 3;
vtk_int ind2 = cells[2] * 3;
vtk_int ind3 = cells[3] * 3;
vtk_int ind4 = cells[4] * 3;
vtk_int ind5 = cells[5] * 3;
vtk_int ind6 = cells[6] * 3;
vtk_int ind7 = cells[7] * 3;
vtk_int ind8 = cells[8] * 3;
vtk_int ind9 = cells[9] * 3;
vtk_int ind10 = cells[10] * 3;
vtk_int ind11 = cells[11] * 3;
vtk_int ind12 = cells[12] * 3;
vtk_int ind13 = cells[13] * 3;
vtk_int ind14 = cells[14] * 3;
vtk_int ind15 = cells[15] * 3;
vtk_int ind16 = cells[16] * 3;
vtk_int ind17 = cells[17] * 3;
vtk_int ind18 = cells[18] * 3;
vtk_int ind19 = cells[19] * 3;
template <typename T> inline void ResetMidHex(const int64_t *cells, T *points) {
int64_t ind0 = cells[0] * 3;
int64_t ind1 = cells[1] * 3;
int64_t ind2 = cells[2] * 3;
int64_t ind3 = cells[3] * 3;
int64_t ind4 = cells[4] * 3;
int64_t ind5 = cells[5] * 3;
int64_t ind6 = cells[6] * 3;
int64_t ind7 = cells[7] * 3;
int64_t ind8 = cells[8] * 3;
int64_t ind9 = cells[9] * 3;
int64_t ind10 = cells[10] * 3;
int64_t ind11 = cells[11] * 3;
int64_t ind12 = cells[12] * 3;
int64_t ind13 = cells[13] * 3;
int64_t ind14 = cells[14] * 3;
int64_t ind15 = cells[15] * 3;
int64_t ind16 = cells[16] * 3;
int64_t ind17 = cells[17] * 3;
int64_t ind18 = cells[18] * 3;
int64_t ind19 = cells[19] * 3;

for (size_t j = 0; j < 3; j++) {
points[ind8 + j] = (points[ind0 + j] + points[ind1 + j]) * 0.5;
Expand All @@ -583,18 +576,18 @@ template <typename T> inline void ResetMidHex(const vtk_int *cells, T *points) {
template <typename T>
void ResetMidside(
NDArray<const uint8_t, 1> celltypes_arr,
NDArray<const vtk_int, 1> cells_arr,
NDArray<const vtk_int, 1> offset_arr,
NDArray<const int64_t, 1> cells_arr,
NDArray<const int64_t, 1> offset_arr,
NDArray<T, 2> points_arr) {

int n_cells = celltypes_arr.size();
const vtk_int *cells = cells_arr.data();
const vtk_int *offset = offset_arr.data();
const int64_t *cells = cells_arr.data();
const int64_t *offset = offset_arr.data();
const uint8_t *celltypes = celltypes_arr.data();
T *points = points_arr.data();

for (int i = 0; i < n_cells; i++) {
vtk_int c = offset[i];
int64_t c = offset[i];

switch (celltypes[i]) {
case VTK_QUADRATIC_TETRA:
Expand Down
Loading

0 comments on commit 6ee0766

Please sign in to comment.