Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion applications/HDF5Application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set( KRATOS_HDF5_APPLICATION_CORE
${CMAKE_CURRENT_SOURCE_DIR}/hdf5_application_variables.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_file.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_nd_data_io.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_points_data.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_connectivities_data.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_data_value_container_io.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_container_component_io.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void ConnectivitiesData<TContainerType>::Write(
{
KRATOS_TRY;

if (mpFile->GetDataCommunicator().SumAll(rEntities.size()) == 0) {
if (mpFile->GetDataCommunicator().SumAll(static_cast<unsigned int>(rEntities.size())) == 0) {
// do nothing if the all the ranks have no entities.
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ bool ContainerComponentIO<TContainerType, TContainerDataIO, TComponents...>::Wri
std::vector<int> shape(value_type_traits::Dimension);

// first we have to check the availability
Vector<unsigned char> availability(rLocalContainer.size(), 1);
Vector<char> availability(rLocalContainer.size(), 1);
Internals::DataAvailabilityStatesList container_data_availability = TContainerDataIO::DataAvailability;

// check for the availability. Here we do not check for the case CONSISTENTLY_UNAVAILABLE
Expand All @@ -260,11 +260,12 @@ bool ContainerComponentIO<TContainerType, TContainerDataIO, TComponents...>::Wri
if constexpr(TContainerDataIO::DataAvailability == Internals::DataAvailabilityStatesList::INCONCLUSIVE) {
// the entities in the rContainer may or may not contain the rComponent. Hence, for this
// type we need to compute the availability.
const auto availability_local_counts_pair = IndexPartition<IndexType>(rLocalContainer.size()).for_each<CombinedReduction<SumReduction<IndexType>, SumReduction<IndexType>>>([&rContainerDataIO, &rLocalContainer, &r_component, &availability](const auto Index) {
const std::tuple<char, char> availability_local_counts_pair = IndexPartition<IndexType>(rLocalContainer.size()).for_each<CombinedReduction<SumReduction<IndexType>, SumReduction<IndexType>>>([&rContainerDataIO, &rLocalContainer, &r_component, &availability](const auto Index) {
availability[Index] = rContainerDataIO.HasValue(*(rLocalContainer.begin() + Index), r_component);
return std::make_tuple<IndexType, IndexType>(availability[Index] == true, availability[Index] == false);
return std::make_tuple<char, char>(static_cast<char>(availability[Index] == 1), static_cast<char>(availability[Index] == 0));
});
const auto& availability_global_counts_pair = mpFile->GetDataCommunicator().SumAll(std::vector<IndexType>{std::get<0>(availability_local_counts_pair), std::get<1>(availability_local_counts_pair), rLocalContainer.size()});

const auto& availability_global_counts_pair = mpFile->GetDataCommunicator().SumAll(std::vector<char>{std::get<0>(availability_local_counts_pair), std::get<1>(availability_local_counts_pair)});

KRATOS_ERROR_IF(availability_global_counts_pair[1] == availability_global_counts_pair[2])
<< "None of the entities in the container have \"" << rComponentName << "\" defined.";
Expand All @@ -290,7 +291,7 @@ bool ContainerComponentIO<TContainerType, TContainerDataIO, TComponents...>::Wri
value_type value_prototype{};

// identifying the shape of the component by looking at the first entity which has the component defined.
auto first_available_pos = std::find(availability.begin(), availability.end(), true);
auto first_available_pos = std::find(availability.begin(), availability.end(), 1);
if (first_available_pos != availability.end()) {
// if the value type is not static, then we need to get the shape
// of the first element assuming all the entities will have the same
Expand Down
2 changes: 1 addition & 1 deletion applications/HDF5Application/custom_io/hdf5_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ void File::SetFileDriver(const std::string& rDriver, hid_t FaplId) const
KRATOS_CATCH("");
}

template<File::DataTransferMode TDataTransferMode, class TDataType, class TIntegerType = unsigned int>
template<File::DataTransferMode TDataTransferMode, class TDataType, class TIntegerType>
void File::WriteDataSetImpl(
const std::string& rPath,
TDataType const * pData,
Expand Down
105 changes: 0 additions & 105 deletions applications/HDF5Application/custom_io/hdf5_points_data.cpp

This file was deleted.

58 changes: 55 additions & 3 deletions applications/HDF5Application/custom_io/hdf5_points_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// Application includes
#include "custom_io/hdf5_file.h"
#include "hdf5_application_define.h"
#include "custom_utilities/hdf5_data_set_partition_utility.h"

namespace Kratos
{
Expand Down Expand Up @@ -57,20 +58,71 @@ class PointsData

PointsData(
const std::string& rPrefix,
File::Pointer mpFile);
File::Pointer pFile)
: mpFile(pFile),
mPrefix(rPrefix)
{

}

///@}
///@name Operations
///@{

Parameters Read(
typename TContainerDataIO::ContainerType& rContainer,
const TContainerDataIO& rContainerDataIO);
const TContainerDataIO& rContainerDataIO)
{
KRATOS_TRY;

IndexType start_index, block_size;
std::tie(start_index, block_size) = StartIndexAndBlockSize(*mpFile, mPrefix);

Vector<int> ids;
Vector<array_1d<double, 3>> coords;

mpFile->ReadDataSet(mPrefix + "/Ids", ids, start_index, block_size);
mpFile->ReadDataSet(mPrefix + "/Coordinates", coords, start_index, block_size);
auto attributes = mpFile->ReadAttribute(mPrefix);

const unsigned num_new_nodes = ids.size();
rContainer.reserve(rContainer.size() + num_new_nodes);

for (unsigned i = 0; i < num_new_nodes; ++i) {
rContainerDataIO.AddPoint(rContainer, ids[i], coords[i]);
}

return attributes;

KRATOS_CATCH("");
}

void Write(
const typename TContainerDataIO::ContainerType& rContainer,
const TContainerDataIO& rContainerDataIO,
const Parameters Attributes);
const Parameters Attributes)
{
KRATOS_TRY;

const unsigned num_nodes = rContainer.size();

Vector<int> ids(num_nodes);
Vector<array_1d<double, 3>> coords(num_nodes);

IndexPartition<IndexType>(num_nodes).for_each([&rContainer, &rContainerDataIO, &ids, &coords](const auto Index) {
const auto& r_point = *(rContainer.begin() + Index);
rContainerDataIO.GetData(ids[Index], coords[Index], r_point);
});

WriteInfo info;
mpFile->WriteDataSet(mPrefix + "/Ids", ids, info);
mpFile->WriteDataSet(mPrefix + "/Coordinates", coords, info);
mpFile->WriteAttribute(mPrefix, Attributes);

WritePartitionTable(*mpFile, mPrefix, info);

KRATOS_CATCH("");
}

///@}

Expand Down
4 changes: 2 additions & 2 deletions applications/HDF5Application/custom_io/hdf5_properties_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ namespace Kratos::HDF5::Internals
///@addtogroup HDF5Application
///@{

void ReadProperties(
void KRATOS_API(HDF5_APPLICATION) ReadProperties(
File& rFile,
const std::string& rPrefix,
PropertiesContainerType& rProperties);

void WriteProperties(
void KRATOS_API(HDF5_APPLICATION) WriteProperties(
File& rFile,
const std::string& rPrefix,
const PropertiesContainerType& rProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace HDF5

namespace Internals
{
std::string AddMissingAndGetPrefix(Parameters Settings)
std::string AddMissingAndGetPrefix(Parameters & Settings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, otherwise the copy contructor implicitly calls Get<>

{
Parameters default_params(R"(
{
Expand All @@ -44,7 +44,7 @@ VertexContainerCoordinateIO::VertexContainerCoordinateIO(
{
KRATOS_TRY

const std::string prefix = Settings["prefix"].Get<std::string>();
const std::string prefix = Settings["prefix"].GetString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious: Was the previous causing problems?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getstd::string is not exposed, hence cannot be called.

KRATOS_ERROR_IF(!prefix.empty() && prefix.back() == '/')
<< "The prefix for vertex coordinates assumed to be a group hence no need to have an ending \"/\" [ prefix = \""
<< Settings["prefix"].GetString() << "\" ].\n";
Expand Down
Loading