Skip to content

Commit

Permalink
Merge branch 'hdf-char' into 'master'
Browse files Browse the repository at this point in the history
[IO] Disabled char-based data types on xdmf / hdf5.

See merge request ogs/ogs!4712
  • Loading branch information
bilke committed Sep 1, 2023
2 parents 4a5ce09 + 728f80c commit 189e75b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion MeshLib/IO/XDMF/HdfData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ static hid_t meshPropertyType2HdfType(MeshPropertyDataType const ogs_data_type)
{MeshPropertyDataType::uint32, H5T_NATIVE_UINT32},
{MeshPropertyDataType::uint64, H5T_NATIVE_UINT64},
{MeshPropertyDataType::int8, H5T_NATIVE_INT8},
{MeshPropertyDataType::uint8, H5T_NATIVE_UINT8}};
{MeshPropertyDataType::uint8, H5T_NATIVE_UINT8},
{MeshPropertyDataType::char_native, H5T_NATIVE_CHAR}};
try
{
return ogs_to_hdf_type.at(ogs_data_type);
Expand Down
2 changes: 2 additions & 0 deletions MeshLib/IO/XDMF/MeshPropertyDataType.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ enum class MeshPropertyDataType
uint64,
int8,
uint8,
char_native,
uchar,
enum_length
};
6 changes: 2 additions & 4 deletions MeshLib/IO/XDMF/transformData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,13 @@ std::optional<XdmfHdfData> transformAttribute(
}
else if constexpr (std::is_same_v<char, decltype(basic_type)>)
{
static_assert((std::numeric_limits<char>::digits == 7),
"Signed char has 8-1 bits");
data_type = MeshPropertyDataType::int8;
data_type = MeshPropertyDataType::char_native;
}
else if constexpr (std::is_same_v<unsigned char, decltype(basic_type)>)
{
static_assert((std::numeric_limits<unsigned char>::digits == 8),
"Unsigned char has 8 bits");
data_type = MeshPropertyDataType::uint8;
data_type = MeshPropertyDataType::uchar;
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions MeshLib/IO/XDMF/writeXdmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ static auto meshPropertyDatatypeString()
ogs_to_xdmf_type[to_underlying(MeshPropertyDataType::uint64)] = "UInt";
ogs_to_xdmf_type[to_underlying(MeshPropertyDataType::int8)] = "Int";
ogs_to_xdmf_type[to_underlying(MeshPropertyDataType::uint8)] = "UInt";
ogs_to_xdmf_type[to_underlying(MeshPropertyDataType::char_native)] = "Char";
ogs_to_xdmf_type[to_underlying(MeshPropertyDataType::uchar)] = "UChar";
return ogs_to_xdmf_type;
}

Expand Down

0 comments on commit 189e75b

Please sign in to comment.