diff --git a/applications/MedApplication/README.md b/applications/MedApplication/README.md index a59748b918a0..16480f5d8eda 100644 --- a/applications/MedApplication/README.md +++ b/applications/MedApplication/README.md @@ -5,8 +5,17 @@ The Med Application an interface to the MED-library. This library writes med-fil ## Installation The MED-library is an external library, which must be installed before the application can be compiled +### Ubuntu + On Ubuntu, it can be installed with `sudo apt-get install libmedc-dev`. This installs all required dependencies, including HDF5 The source code is available on the Salome website for a manual installation. In this case also HDF5 needs to be installed separately. Use `MED_ROOT` to specify the path to the MED installation in the CMake of Kratos. + +### Arch / Manjaro + +Packages related to *Salome* and *MED* for arch-based distros can be installed from the [AUR](https://en.wikipedia.org/wiki/Arch_Linux#Arch_User_Repository_(AUR)). The MedApplication requires [med-serial](https://aur.archlinux.org/packages/med-serial) (for non-MPI builds) or [med-openmpi](https://archlinux.org/packages/extra/x86_64/med-openmpi/) (for MPI builds with OpenMPI). +``` +sudo pacman -S med-serial med-openmpi +``` diff --git a/applications/MedApplication/custom_io/med_model_part_io.cpp b/applications/MedApplication/custom_io/med_model_part_io.cpp index 6652e7482888..fd0bc2afbbbd 100644 --- a/applications/MedApplication/custom_io/med_model_part_io.cpp +++ b/applications/MedApplication/custom_io/med_model_part_io.cpp @@ -86,7 +86,11 @@ std::function&)> GetReorderFunction(const med_geometry_type }; case MED_TRIA6: - KRATOS_ERROR << "MED_TRIA6 is not implemented!" << std::endl; + return [](auto& rConnectivities) -> void { + CheckConnectivitiesSize(6, rConnectivities); + std::swap(rConnectivities[1], rConnectivities[2]); + std::swap(rConnectivities[3], rConnectivities[5]); + }; case MED_QUAD4: return [](auto& Connectivities){ @@ -100,6 +104,14 @@ std::function&)> GetReorderFunction(const med_geometry_type case MED_QUAD9: // should be same as MED_QUAD8 KRATOS_ERROR << "MED_QUAD9 is not implemented!" << std::endl; + case MED_TETRA10: + return [](auto& rConnectivities) -> void { + CheckConnectivitiesSize(10, rConnectivities); + std::swap(rConnectivities[1], rConnectivities[2]); + std::swap(rConnectivities[4], rConnectivities[6]); + std::swap(rConnectivities[8], rConnectivities[9]); + }; + case MED_PYRA5: KRATOS_ERROR << "MED_PYRA5 is not implemented!" << std::endl; @@ -311,11 +323,7 @@ class MedModelPartIO::MedFileHandler ~MedFileHandler() { - KRATOS_TRY - KRATOS_WARNING_IF("MedModelPartIO", MEDfileClose(mFileHandle) < 0) << "Closing of file " << mFileName << " failed!" << std::endl; - - KRATOS_CATCH("") } private: @@ -340,8 +348,6 @@ void MedModelPartIO::ReadModelPart(ModelPart& rThisModelPart) { KRATOS_TRY - using NodePointerType = ModelPart::NodeType::Pointer; - KRATOS_ERROR_IF_NOT(mpFileHandler->IsReadMode()) << "MedModelPartIO needs to be created in read mode to read a ModelPart!" << std::endl; // reading nodes @@ -430,16 +436,19 @@ void MedModelPartIO::ReadModelPart(ModelPart& rThisModelPart) std::vector geom_node_ids(num_nodes_geo_type); - for (std::size_t i=0; i(num_geometries); ++i) { for (int j=0; j::max() == num_geometries_total) + << "number of geometries read (" << num_geometries_total << ") exceeds the capacity of the index type"; + rThisModelPart.CreateNewGeometry(kratos_geo_name, + num_geometries_total++, + geom_node_ids); + } KRATOS_INFO("MedModelPartIO") << "Read " << num_geometries << " geometries of type " << kratos_geo_name << std::endl; } diff --git a/applications/MedApplication/med_inc.h b/applications/MedApplication/med_inc.h index d536de71fc45..db9d3fd53101 100644 --- a/applications/MedApplication/med_inc.h +++ b/applications/MedApplication/med_inc.h @@ -14,8 +14,10 @@ // Those dummy structs are necessary when the MED-library is compiled with MPI support. // Then the header also contains functions which use those MPI-types +#ifndef KRATOS_USING_MPI struct MPI_Comm; struct MPI_Info; +#endif // External includes #include "med.h" diff --git a/applications/MedApplication/tests/cpp_tests/test_med_model_part_io.cpp b/applications/MedApplication/tests/cpp_tests/test_med_model_part_io.cpp index 80a8cd6194b8..440825cd37e1 100644 --- a/applications/MedApplication/tests/cpp_tests/test_med_model_part_io.cpp +++ b/applications/MedApplication/tests/cpp_tests/test_med_model_part_io.cpp @@ -23,22 +23,22 @@ namespace Kratos::Testing { KRATOS_TEST_CASE_IN_SUITE(MedModelpartIO_NonExistingFile_read, KratosMedFastSuite) { const std::filesystem::path file_path(this->Name() + ".txt"); - KRATOS_CHECK_IS_FALSE(std::filesystem::exists(file_path)); // make sure there are no leftovers + KRATOS_EXPECT_FALSE(std::filesystem::exists(file_path)); // make sure there are no leftovers - KRATOS_CHECK_EXCEPTION_IS_THROWN( + KRATOS_EXPECT_EXCEPTION_IS_THROWN( MedModelPartIO dummy(file_path), "File \""+file_path.string()+"\" does not exist!"); - KRATOS_CHECK_IS_FALSE(std::filesystem::exists(file_path)); + KRATOS_EXPECT_FALSE(std::filesystem::exists(file_path)); } KRATOS_TEST_CASE_IN_SUITE(MedModelpartIO_NonExistingFile_write, KratosMedFastSuite) { const std::filesystem::path file_path(this->Name() + ".txt"); - KRATOS_CHECK_IS_FALSE(std::filesystem::exists(file_path)); // make sure there are no leftovers + KRATOS_EXPECT_FALSE(std::filesystem::exists(file_path)); // make sure there are no leftovers MedModelPartIO(file_path, IO::WRITE); - KRATOS_CHECK(std::filesystem::exists(file_path)); + KRATOS_EXPECT_TRUE(std::filesystem::exists(file_path)); std::filesystem::remove(file_path); // clean leftover } @@ -48,7 +48,7 @@ KRATOS_TEST_CASE_IN_SUITE(MedModelpartIO_TextFile, KratosMedFastSuite) const std::filesystem::path file_path(this->Name() + ".txt"); std::ofstream output(file_path); // create a dummy file (that is not a hdf file) - KRATOS_CHECK_EXCEPTION_IS_THROWN( + KRATOS_EXPECT_EXCEPTION_IS_THROWN( MedModelPartIO dummy(file_path), "A problem with HDF occured while trying to open file \""+file_path.string()+"\"!");