Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MedApp] more geom types and other minor improvements #11684

Merged
merged 13 commits into from
Oct 17, 2023
62 changes: 56 additions & 6 deletions applications/MedApplication/custom_io/med_model_part_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ std::function<void(std::vector<T>&)> GetReorderFunction(const med_geometry_type
};

case MED_TRIA6:
return [](auto& rConnectivities) -> void {
return [](auto& rConnectivities){
CheckConnectivitiesSize(6, rConnectivities);
std::swap(rConnectivities[1], rConnectivities[2]);
std::swap(rConnectivities[3], rConnectivities[5]);
Expand All @@ -99,28 +99,78 @@ std::function<void(std::vector<T>&)> GetReorderFunction(const med_geometry_type
};

case MED_QUAD8:
KRATOS_ERROR << "MED_QUAD8 is med_quad8 is not implemented!" << std::endl;
return [](auto& Connectivities){
CheckConnectivitiesSize(8, Connectivities);
std::swap(Connectivities[1], Connectivities[3]);
std::swap(Connectivities[4], Connectivities[7]);
std::swap(Connectivities[5], Connectivities[6]);
};

case MED_QUAD9:
return [](auto& Connectivities){
CheckConnectivitiesSize(9, Connectivities);
std::swap(Connectivities[1], Connectivities[3]);
std::swap(Connectivities[4], Connectivities[7]);
std::swap(Connectivities[5], Connectivities[6]);
};

case MED_QUAD9: // should be same as MED_QUAD8
KRATOS_ERROR << "MED_QUAD9 is not implemented!" << std::endl;
case MED_TETRA4:
return [](auto& rConnectivities){
CheckConnectivitiesSize(4, rConnectivities);
std::swap(rConnectivities[2], rConnectivities[3]);
};

case MED_TETRA10:
return [](auto& rConnectivities) -> void {
return [](auto& rConnectivities){
CheckConnectivitiesSize(10, rConnectivities);
std::swap(rConnectivities[1], rConnectivities[2]);
std::swap(rConnectivities[4], rConnectivities[6]);
std::swap(rConnectivities[8], rConnectivities[9]);
};

case MED_HEXA8:
return [](auto& rConnectivities){
CheckConnectivitiesSize(8, rConnectivities);
std::swap(rConnectivities[1], rConnectivities[4]);
std::swap(rConnectivities[2], rConnectivities[7]);
};

case MED_HEXA20:
KRATOS_ERROR << "MED_HEXA20 is not implemented!" << std::endl;
return [](auto& rConnectivities){
CheckConnectivitiesSize(20, rConnectivities);
std::swap(rConnectivities[1], rConnectivities[4]);
std::swap(rConnectivities[2], rConnectivities[7]);
};

case MED_HEXA27:
KRATOS_ERROR << "MED_HEXA27 is not implemented!" << std::endl;
return [](auto& rConnectivities){
CheckConnectivitiesSize(27, rConnectivities);
std::swap(rConnectivities[1], rConnectivities[4]);
std::swap(rConnectivities[2], rConnectivities[7]);
};

case MED_PYRA5:
KRATOS_ERROR << "MED_PYRA5 is not implemented!" << std::endl;

case MED_PYRA13:
KRATOS_ERROR << "MED_PYRA13 is not implemented!" << std::endl;

case MED_PENTA6:
KRATOS_ERROR << "MED_PENTA6 is not implemented!" << std::endl;

case MED_PENTA15:
KRATOS_ERROR << "MED_PENTA15 is not implemented!" << std::endl;

default:
return [](auto& Connectivities){
// does nothing if no reordering is needed
/*
- MED_POINT1
- MED_SEG2
- MED_SEG3
*/
};
}
}
Expand Down Expand Up @@ -446,7 +496,7 @@ void MedModelPartIO::ReadModelPart(ModelPart& rThisModelPart)
KRATOS_ERROR_IF(std::numeric_limits<decltype(num_geometries_total)>::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++,
++num_geometries_total,
geom_node_ids);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ double ComputeGeometricalQuantity(
const ModelPart& rModelPart,
const QuantityType Quantity)
{
std::function<double(const ModelPart::GeometryType&)> access_function;
std::function<double(const GeometryType&)> access_function;

switch (Quantity)
{
Expand Down
16 changes: 13 additions & 3 deletions applications/MedApplication/med_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,24 @@ namespace Kratos {
KratosMedApplication::KratosMedApplication():
KratosApplication("MedApplication")
{
// check if the library that was used to compile is the same as the one that is loaded at runtime
// they must match, otherwise random errors can occur
// logging information about the used library for debugging purposes
med_int v_med_major, v_med_minor, v_med_release;
MEDlibraryNumVersion(&v_med_major, &v_med_minor, &v_med_release);

med_int v_hdf_major, v_hdf_minor, v_hdf_release;
MEDlibraryHdfNumVersion(&v_hdf_major, &v_hdf_minor, &v_hdf_release);

// Note: the detail severity must be explicitly enabled, it is not shown by default
KRATOS_DETAIL("MedApplication") << "Version of MED-library used during compilation: " << MED_MAJOR_NUM << "." << MED_NUM_MINEUR << "." << MED_NUM_RELEASE << std::endl;
KRATOS_DETAIL("MedApplication") << "Version of MED-library loaded at runtime: " << v_med_major << "." << v_med_minor << "." << v_med_release << std::endl;
KRATOS_DETAIL("MedApplication") << "Version of HDF-library used during compilation: " << H5_VERS_MAJOR << "." << H5_VERS_MINOR << "." << H5_VERS_RELEASE << std::endl;
KRATOS_DETAIL("MedApplication") << "Version of HDF-library loaded at runtime: " << v_hdf_major << "." << v_hdf_minor << "." << v_hdf_release << std::endl;

// check if the library that was used to compile is the same as the one that is loaded at runtime
// they must match, otherwise random errors can occur
KRATOS_ERROR_IF(v_med_major != MED_MAJOR_NUM ||
v_med_minor != MED_NUM_MINEUR ||
v_med_release != MED_NUM_RELEASE) << "The MED library that was used during compilation (v" << v_med_major << "." << v_med_minor << "." << v_med_release << ") is different from the one loaded at runtime (v" << MED_MAJOR_NUM << "." << MED_NUM_MINEUR << "." << MED_NUM_RELEASE << ")!\nThis causes problems with reading/writing MED files, please check your paths for loading the library (e.g. \"PATH\" or \"LD_LIBRARY_PATH\")" << std::endl;
v_med_release != MED_NUM_RELEASE) << "The MED library that was used during compilation (v" << MED_MAJOR_NUM << "." << MED_NUM_MINEUR << "." << MED_NUM_RELEASE << ") is different from the one loaded at runtime (v" << v_med_major << "." << v_med_minor << "." << v_med_release << ")!\nThis causes problems with reading/writing MED files, please check your paths for loading the library (e.g. \"PATH\" or \"LD_LIBRARY_PATH\")" << std::endl;
}

void KratosMedApplication::Register()
Expand Down
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Loading
Loading