Hello,
UNV format is the go to for importing meshes from Salome to OpenFOAM. Before Salome was not able to export pyramids elements, so mix hex/pyr/tetra meshes were quite difficult to import from it. With a slight modification of the ideasUnvToFoam.C one can easily improve this reader to be able to read mixed element meshes.
before this, ideasUnvToFoam will simply crash if a mesh has pyramids elements.
Modification of ideasUnvToFoam.C file.
in ideasUnvToFoam.C file add the following lines:
line 255: const cellModel& pyr = *(cellModeller::lookup("pyr"));;
line 360 to 382:
else if (feID == 119 || feID == 312)
{
// Pyramid.
is.getLine(line);
labelList cVerts(5);
IStringStream lineStr(line);
lineStr >> cVerts[0] >> cVerts[1] >> cVerts[2] >> cVerts[3]
>> cVerts[4];
cellVerts.append(cellShape(pyr, cVerts, true));
cellMaterial.append(physProp);
if (cellVerts[cellVerts.size()-1].size() != cVerts.size())
{
Pout<< "Line:" << is.lineNumber()
<< " element:" << cellI
<< " type:" << feID
<< " collapsed from " << cVerts << nl
<< " to:" << cellVerts[cellVerts.size()-1]
<< endl;
}
}
in regards to the feID used, one can check three sources of information from where they where choosen:
https://github.com/SalomePlatform/smesh/commit/0c20bfddf127610706ffaa9f4b8fcdbc83ed98a9
page 12, first paragraph https://www.salome-platform.org/wp-content/uploads/2026/07/SALOME_9_16_0_Release_Notes.pdf
https://discourse.salome-platform.org/t/change-unv-pyr-to-type-119/3450/2?u=franco.ota
I am adding as file attachments, the modified file and a mixed element mesh.
After addition of pyramids compatibility,there was a remaining issue with the UNV importer. The eventual presence of 1D groups, these groups can be used in Salome for other applications but do not represent any interest in OpenFOAM (up to my knowledge at least). The current issue, is that if we export a mesh from salome that contains 1D groups, the importer will not recognize them correctly and will crash. the modification to the file will ignore them. previously, it was recommended to delete this groups before exporting, which would solve the issue, nevertheless this could lead to lose of information if we want to keep it for other applications. Moreover, there is a lot of users that if they ignore this problem will not understand the reason behaind the crashing of ideas, and will not know how to solve it.
I am uploading a new .C file with the modifications for importing pyramids and also ignore the 1D groups, also two meshes to compare the compatibility
all credits to Christophe Bourcier for this modification of the code https://discourse.salome-platform.org/t/change-unv-pyr-to-type-119/3450/6?u=franco.ota
Hi,
Ypur work is very much appreciated and I am happy to merge this in.
Can you make the converter read-and-ignore 1-D groups?
On 19/08/2026 13:13, franco otaola wrote:
Hello,
I did not done much, 99% was christophe.
sorry I do not understand you, in the comment (not the issue itself), I attached the .C file with the corresponding modification to read and ignore 1D groups.