14#include "arcane/utils/Collection.h"
15#include "arcane/utils/Enumerator.h"
16#include "arcane/utils/HashTableMap.h"
17#include "arcane/utils/IOException.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/Iostream.h"
20#include "arcane/utils/OStringStream.h"
21#include "arcane/utils/ScopedPtr.h"
22#include "arcane/utils/StdHeader.h"
23#include "arcane/utils/String.h"
24#include "arcane/utils/ValueConvert.h"
25#include "arcane/utils/Real3.h"
26#include "arcane/utils/CheckedConvert.h"
28#include "arcane/core/BasicService.h"
29#include "arcane/core/FactoryService.h"
30#include "arcane/core/ICaseMeshReader.h"
31#include "arcane/core/IItemFamily.h"
32#include "arcane/core/IPrimaryMesh.h"
33#include "arcane/core/IMeshBuilder.h"
34#include "arcane/core/IMeshReader.h"
35#include "arcane/core/IMeshUtilities.h"
36#include "arcane/core/IMeshWriter.h"
37#include "arcane/core/IParallelMng.h"
38#include "arcane/core/IVariableAccessor.h"
39#include "arcane/core/IXmlDocumentHolder.h"
40#include "arcane/core/Item.h"
42#include "arcane/core/IVariableMng.h"
43#include "arcane/core/VariableTypes.h"
44#include "arcane/core/XmlNode.h"
45#include "arcane/core/XmlNodeList.h"
46#include "arcane/core/UnstructuredMeshAllocateBuildInfo.h"
48#include "arcane/core/internal/IVariableMngInternal.h"
49#include "arcane/core/internal/VtkCellTypes.h"
61using namespace Arcane::VtkUtils;
102class VtkMeshIOService
120 VTK_MT_StructuredGrid,
121 VTK_MT_UnstructuredGrid
160 const String& dir_name,
bool use_internal_partition);
173 static const int BUFSIZE = 10000;
177 explicit VtkFile(std::istream* stream)
192 const String& expected_value1,
193 const String& expected_value2);
299 bool is_comment =
true;
302 for (
int i = 0; i < BUFSIZE &&
m_buf[i] !=
'\0'; ++i) {
303 if (!isspace(
m_buf[i]) &&
m_buf[i] !=
'#' && is_comment) {
306 if (
m_buf[i] ==
'#') {
315 for (
int i = 0; i < BUFSIZE &&
m_buf[i] !=
'\0'; ++i) {
316 if (
m_buf[i] ==
'\r') {
370 bool is_comment =
true;
378 for (
int i = 0; i < BUFSIZE &&
m_buf[i] !=
'\0'; ++i) {
379 if (!isspace(
m_buf[i]) &&
m_buf[i] !=
'#' && is_comment) {
382 if (
m_buf[i] ==
'#') {
391 for (
int i = 0; i < BUFSIZE &&
m_buf[i] !=
'\0'; ++i) {
392 if (
m_buf[i] ==
'\r') {
419 (*m_stream) >> ws >> v;
443 (*m_stream) >> ws >> v;
467 (*m_stream) >> ws >> v;
487 constexpr size_t sizeofT =
sizeof(T);
490 Byte big_endian[sizeofT];
491 Byte little_endian[sizeofT];
494 m_stream->read((
char*)big_endian, sizeofT);
497 for (
size_t i = 0; i < sizeofT; i++) {
498 little_endian[sizeofT - 1 - i] = big_endian[i];
502 T* conv =
new (little_endian) T;
522 String expected_value_low = expected_value.
lower();
524 if (current_value_low != expected_value_low) {
526 expected_value, current_value);
546 String expected_value1_low = expected_value1.
lower();
547 String expected_value2_low = expected_value2.
lower();
549 if (current_value_low != expected_value1_low && current_value_low != expected_value2_low) {
551 expected_value1, expected_value2, current_value);
570 String expected_value_low = expected_value.
lower();
571 return (current_value_low == expected_value_low);
592 std::ifstream ifile(file_name.
localstr(), std::ifstream::binary);
595 error() <<
"Unable to read file '" << file_name <<
"'";
608 info() <<
"Titre du fichier VTK : " << title.
localstr();
616 vtk_file.setIsBinaryFile(
true);
619 eMeshType mesh_type = VTK_MT_Unknown;
627 std::istringstream mesh_type_line(buf);
628 std::string dataset_str;
629 std::string mesh_type_str;
631 mesh_type_line >> ws >> dataset_str >> ws >> mesh_type_str;
636 mesh_type = VTK_MT_StructuredGrid;
640 mesh_type = VTK_MT_UnstructuredGrid;
643 if (mesh_type == VTK_MT_Unknown) {
644 error() <<
"Support exists only for 'STRUCTURED_GRID' and 'UNSTRUCTURED_GRID' formats (format=" << mesh_type_str <<
"')";
648 debug() <<
"Lecture en-tête OK";
652 case VTK_MT_StructuredGrid:
656 case VTK_MT_UnstructuredGrid:
658 debug() <<
"Lecture _readUnstructuredGrid OK";
662 debug() <<
"Lecture _readFacesMesh OK";
692 const char* buf =
nullptr;
698 std::istringstream iline(buf);
699 std::string dimension_str;
700 iline >> ws >> dimension_str >> ws >> nb_node_x >> ws >> nb_node_y >> ws >> nb_node_z;
703 error() <<
"Syntax error while reading grid dimensions";
708 if (nb_node_x <= 1 || nb_node_y <= 1 || nb_node_z <= 1) {
709 error() <<
"Invalid dimensions: x=" << nb_node_x <<
" y=" << nb_node_y <<
" z=" << nb_node_z;
713 info() <<
" Infos: " << nb_node_x <<
" " << nb_node_y <<
" " << nb_node_z;
714 Integer nb_node = nb_node_x * nb_node_y * nb_node_z;
717 std::string float_str;
720 std::istringstream iline(buf);
721 std::string points_str;
723 iline >> ws >> points_str >> ws >> nb_node_read >> ws >> float_str;
725 error() <<
"Syntax error while reading grid dimensions";
729 if (nb_node_read != nb_node) {
730 error() <<
"Number of invalid nodes: expected=" << nb_node <<
" found=" << nb_node_read;
735 Int32 rank =
mesh->parallelMng()->commRank();
737 Integer nb_cell_x = nb_node_x - 1;
738 Integer nb_cell_y = nb_node_y - 1;
739 Integer nb_cell_z = nb_node_z - 1;
741 if (use_internal_partition && rank != 0) {
750 const Integer nb_node_yz = nb_node_y * nb_node_z;
751 const Integer nb_node_xy = nb_node_x * nb_node_y;
753 Integer nb_cell = nb_cell_x * nb_cell_y * nb_cell_z;
760 info() <<
" NODE YZ = " << nb_node_yz;
765 for (
Integer x = 0; x < nb_node_x; ++x) {
766 for (
Integer z = 0; z < nb_node_z; ++z) {
767 for (
Integer y = 0; y < nb_node_y; ++y) {
769 Integer node_unique_id = y + (z)*nb_node_y + x * nb_node_y * nb_node_z;
771 nodes_unique_id[node_local_id] = node_unique_id;
799 for (
Integer z = 0; z < nb_cell_z; ++z) {
800 for (
Integer y = 0; y < nb_cell_y; ++y) {
801 for (
Integer x = 0; x < nb_cell_x; ++x) {
802 Integer current_cell_nb_node = 8;
805 Int64 cell_unique_id = x + y * nb_cell_x + z * nb_cell_x * nb_cell_y;
807 cells_infos[cells_infos_index] = IT_Hexaedron8;
810 cells_infos[cells_infos_index] = cell_unique_id;
814 Integer base_id = x + y * nb_node_x + z * nb_node_xy;
815 cells_infos[cells_infos_index + 0] = nodes_unique_id[base_id];
816 cells_infos[cells_infos_index + 1] = nodes_unique_id[base_id + 1];
817 cells_infos[cells_infos_index + 2] = nodes_unique_id[base_id + nb_node_x + 1];
818 cells_infos[cells_infos_index + 3] = nodes_unique_id[base_id + nb_node_x + 0];
819 cells_infos[cells_infos_index + 4] = nodes_unique_id[base_id + nb_node_xy];
820 cells_infos[cells_infos_index + 5] = nodes_unique_id[base_id + nb_node_xy + 1];
821 cells_infos[cells_infos_index + 6] = nodes_unique_id[base_id + nb_node_xy + nb_node_x + 1];
822 cells_infos[cells_infos_index + 7] = nodes_unique_id[base_id + nb_node_xy + nb_node_x + 0];
823 cells_infos_index += current_cell_nb_node;
824 cells_local_id[cell_local_id] = cell_local_id;
831 mesh->setDimension(3);
832 mesh->allocateCells(nb_cell, cells_infos,
false);
840 for (
Integer z = 0; z < nb_node_z; ++z) {
841 for (
Integer y = 0; y < nb_node_y; ++y) {
842 for (
Integer x = 0; x < nb_node_x; ++x) {
846 Integer node_unique_id = x + y * nb_node_x + z * nb_node_xy;
847 coords[node_unique_id] =
Real3(nx, ny, nz);
853 for (
Integer z = 0; z < nb_node_z; ++z) {
854 for (
Integer y = 0; y < nb_node_y; ++y) {
855 for (
Integer x = 0; x < nb_node_x; ++x) {
859 Integer node_unique_id = x + y * nb_node_x + z * nb_node_xy;
860 coords[node_unique_id] =
Real3(nx, ny, nz);
866 for (
Integer z = 0; z < nb_node_z; ++z) {
867 for (
Integer y = 0; y < nb_node_y; ++y) {
868 for (
Integer x = 0; x < nb_node_x; ++x) {
872 Integer node_unique_id = x + y * nb_node_x + z * nb_node_xy;
873 coords[node_unique_id] =
Real3(nx, ny, nz);
885 nodes_coord_var[inode] = coords[node.
uniqueId().asInt32()];
909 Int64 node_unique_id = node.uniqueId().asInt64();
910 Int64 node_z = node_unique_id / nb_node_xy;
911 Int64 node_y = (node_unique_id - node_z * nb_node_xy) / nb_node_x;
912 Int64 node_x = node_unique_id - node_z * nb_node_xy - node_y * nb_node_x;
915 if (node_x != (nb_node_x - 1))
919 if (node_y != (nb_node_y - 1))
923 if (node_z != (nb_node_z - 1))
927 xmin_surface_lid.
add(face_local_id);
929 xmax_surface_lid.
add(face_local_id);
931 ymin_surface_lid.
add(face_local_id);
933 ymax_surface_lid.
add(face_local_id);
935 zmin_surface_lid.
add(face_local_id);
937 zmax_surface_lid.
add(face_local_id);
973 std::istringstream iline(buf);
974 std::string points_str;
975 std::string data_type_str;
978 iline >> ws >> points_str >> ws >> nb_node >> ws >> data_type_str;
988 info() <<
"VTK file : number of nodes = " << nb_node;
991 node_coords.
resize(nb_node);
994 for (
Integer i = 0; i < nb_node; ++i) {
998 node_coords[i] =
Real3(nx, ny, nz);
1002 for (
Integer i = 0; i < nb_node; ++i) {
1006 node_coords[i] =
Real3(nx, ny, nz);
1010 for (
Integer i = 0; i < nb_node; ++i) {
1014 node_coords[i] =
Real3(nx, ny, nz);
1044 ARCANE_UNUSED(
mesh);
1048 std::istringstream iline(buf);
1049 std::string cells_str;
1050 Int32 i64_nb_cell = 0;
1051 Int32 i64_nb_cell_node = 0;
1053 iline >> ws >> cells_str >> ws >> i64_nb_cell >> ws >> i64_nb_cell_node;
1060 info() <<
"VTK file : nb_cell = " << i64_nb_cell <<
" nb_cell_node=" << i64_nb_cell_node;
1062 if (i64_nb_cell < 0 || i64_nb_cell_node < 0) {
1064 i64_nb_cell, i64_nb_cell_node);
1067 Int32 nb_cell = CheckedConvert::toInt32(i64_nb_cell);
1068 Int32 nb_cell_node = CheckedConvert::toInt32(i64_nb_cell_node);
1070 cells_nb_node.
resize(nb_cell);
1071 cells_type.
resize(nb_cell);
1072 cells_connectivity.
resize(nb_cell_node);
1075 Integer connectivity_index = 0;
1076 for (
Integer i = 0; i < nb_cell; ++i) {
1078 cells_nb_node[i] = n;
1079 for (
Integer j = 0; j < n; ++j) {
1081 cells_connectivity[connectivity_index] = id;
1082 ++connectivity_index;
1092 std::istringstream iline(buf);
1093 std::string cell_types_str;
1095 iline >> ws >> cell_types_str >> ws >> nb_cell_type;
1101 vtk_file.
checkString(cell_types_str,
"CELL_TYPES");
1102 if (nb_cell_type != nb_cell) {
1104 nb_cell_type, nb_cell);
1108 for (
Integer i = 0; i < nb_cell; ++i) {
1110 Int16 it = vtkToArcaneCellType(vtk_ct, cells_nb_node[i]);
1128 ARCANE_UNUSED(
mesh);
1132 if (vtk_file.isEof())
1139 vtk_file.reReadSameLine();
1239 Int32 sid =
mesh->parallelMng()->commRank();
1244 bool need_read =
true;
1246 if (use_internal_partition)
1247 need_read = (sid == 0);
1249 std::array<Int64, 4> nb_cell_by_dimension = {};
1250 Int32 mesh_dimension = -1;
1257 debug() <<
"Lecture _readNodesUnstructuredGrid OK";
1258 nb_node = node_coords.
size();
1266 debug() <<
"Lecture _readCellsUnstructuredGrid OK";
1268 nb_cell = cells_nb_node.
size();
1269 nb_cell_node = cells_connectivity.
size();
1270 cells_local_id.
resize(nb_cell);
1273 mesh_build_info.
preAllocate(nb_cell, nb_cell_node);
1276 Int32 connectivity_index = 0;
1277 for (
Integer i = 0; i < nb_cell; ++i) {
1278 Int32 current_cell_nb_node = cells_nb_node[i];
1279 Int64 cell_unique_id = i;
1281 cells_local_id[i] = i;
1284 if (cell_dim >= 0 && cell_dim <= 3)
1285 ++nb_cell_by_dimension[cell_dim];
1287 auto cell_nodes = cells_connectivity.
subView(connectivity_index, current_cell_nb_node);
1288 mesh_build_info.
addCell(cells_type[i], cell_unique_id, cell_nodes);
1289 connectivity_index += current_cell_nb_node;
1293 Int32 nb_different_dim = 0;
1294 for (
Int32 i = 0; i < 4; ++i)
1295 if (nb_cell_by_dimension[i] != 0) {
1299 if (nb_different_dim > 1)
1300 ARCANE_FATAL(
"The mesh contains cells of different dimension. nb0={0} nb1={1} nb2={2} nb3={3}",
1301 nb_cell_by_dimension[0], nb_cell_by_dimension[1], nb_cell_by_dimension[2], nb_cell_by_dimension[3]);
1306 Integer wanted_dimension = mesh_dimension;
1319 nodes_coord_var[inode] = node_coords[node.
uniqueId().asInt32()];
1325 debug() <<
"Lecture _readData OK";
1343 bool use_internal_partition)
1345 ARCANE_UNUSED(dir_name);
1347 std::ifstream ifile(file_name.
localstr(), std::ifstream::binary);
1349 info() <<
"No face descriptor file found '" << file_name <<
"'";
1354 const char* buf = 0;
1358 info() <<
"Reading VTK file '" << file_name <<
"'";
1359 info() <<
"Title of VTK file: " << title;
1363 vtk_file.setIsBinaryFile(
true);
1366 eMeshType mesh_type = VTK_MT_Unknown;
1372 std::istringstream mesh_type_line(buf);
1373 std::string dataset_str;
1374 std::string mesh_type_str;
1375 mesh_type_line >> ws >> dataset_str >> ws >> mesh_type_str;
1379 mesh_type = VTK_MT_UnstructuredGrid;
1382 if (mesh_type == VTK_MT_Unknown) {
1383 error() <<
"Face descriptor file type must be 'UNSTRUCTURED_GRID' (format=" << mesh_type_str <<
"')";
1396 bool need_read =
true;
1397 if (use_internal_partition)
1398 need_read = (sid == 0);
1415 nb_face = faces_nb_node.
size();
1419 faces_local_id.
resize(nb_face);
1462 if ((sid == 0) && vtk_file.isEof())
1466 pm->broadcast(bb, 0);
1473 created_infos_str() <<
"<?xml version='1.0' ?>\n";
1474 created_infos_str() <<
"<infos>";
1477 const char* buf = 0;
1480 bool reading_node =
false;
1481 bool reading_cell =
false;
1482 while (((buf = vtk_file.
getNextLine()) != 0) && !vtk_file.isEof()) {
1483 debug() <<
"Read line";
1484 std::istringstream iline(buf);
1485 std::string data_str;
1491 iline >> ws >> nb_item;
1492 reading_node =
false;
1493 reading_cell =
true;
1494 if (nb_item != nb_cell_kind)
1495 error() <<
"Size expected = " << nb_cell_kind <<
" found = " << nb_item;
1501 iline >> ws >> nb_item;
1502 reading_node =
true;
1503 reading_cell =
false;
1504 if (nb_item != nb_node)
1505 error() <<
"Size expected = " << nb_node <<
" found = " << nb_item;
1510 std::string name_str;
1513 iline >> ws >> name_str >> ws >> nb_fields;
1516 std::string type_str;
1517 std::string s_name_str;
1518 int nb_component = 1;
1519 bool is_group =
false;
1521 for (
Integer i = 0; i < nb_fields; i++) {
1523 std::istringstream iline(buf);
1524 iline >> ws >> s_name_str >> ws >> nb_component >> ws >> nb_item >> ws >> type_str;
1526 if (nb_item != nb_cell_kind && reading_cell && !reading_node)
1527 error() <<
"Size expected = " << nb_cell_kind <<
" found = " << nb_item;
1529 if (nb_item != nb_node && !reading_cell && reading_node)
1530 error() <<
"Size expected = " << nb_node <<
" found = " << nb_item;
1532 String name_str = s_name_str;
1535 if (cstr ==
"GROUP_") {
1538 debug() <<
"** ** ** GROUP ! name=" << new_name;
1539 name_str = new_name;
1544 error() <<
"Group type must be 'int', found=" << type_str;
1549 created_infos_str() <<
"<node-group name='" << name_str <<
"'/>";
1554 created_infos_str() <<
"<cell-group name='" << name_str <<
"'/>";
1562 error() <<
"Expecting 'float' or 'double' data type, found=" << type_str;
1567 fatal() <<
"Unable to read POINT_DATA: feature not implemented";
1570 created_infos_str() <<
"<cell-variable name='" << name_str <<
"'/>";
1573 throw IOException(
"Unable to read face variables: feature not supported");
1583 if (reading_node || reading_cell) {
1584 std::string type_str;
1585 std::string s_name_str;
1587 bool is_group =
false;
1588 int nb_component = 1;
1590 iline >> ws >> s_name_str >> ws >> type_str >> ws >> nb_component;
1591 debug() <<
"** ** ** READNAME: name=" << s_name_str <<
" type=" << type_str;
1593 String name_str = s_name_str;
1596 if (cstr ==
"GROUP_") {
1599 info() <<
"** ** ** GROUP ! name=" << new_name;
1600 name_str = new_name;
1604 error() <<
"Expecting 'SCALARS' data type, found=" << data_str;
1610 error() <<
"Group type must be 'int', found=" << type_str;
1618 created_infos_str() <<
"<node-group name='" << name_str <<
"'/>";
1623 created_infos_str() <<
"<cell-group name='" << name_str <<
"'/>";
1629 error() <<
"Expecting 'float' or 'double' data type, found=" << type_str;
1636 fatal() <<
"Unable to read POINT_DATA: feature not implemented";
1639 created_infos_str() <<
"<cell-variable name='" << name_str <<
"'/>";
1642 throw IOException(
"Unable to read face variables: feature not supported");
1649 error() <<
"Expecting value CELL_DATA or POINT_DATA, found='" << data_str <<
"'";
1655 created_infos_str() <<
"</infos>";
1656 if (use_internal_partition) {
1659 String str = created_infos_str.str();
1669 String str = String::fromUtf8(bytes);
1670 info() <<
"FOUND STR=" << bytes.
size() <<
" " << str;
1672 XmlNode doc_node = doc->documentNode();
1678 String name = xnode.attrValue(
"name");
1679 info() <<
"Building variable: " << name;
1690 String name = xnode.attrValue(
"name");
1691 info() <<
"Building group: " << name;
1701 String name = xnode.attrValue(
"name");
1702 info() <<
"Create node group: " << name;
1724 info() <<
"Building face group '" << name <<
"'"
1725 <<
" size=" << faces_lid.
size();
1727 mesh->faceFamily()->createGroup(name, faces_lid);
1744 info() <<
"Reading values for variable: " << var_name <<
" n=" << nb_cell;
1746 mesh->variableMng()->_internalApi()->addAutoDestroyVariable(var);
1748 for (
Integer i = 0; i < nb_cell; ++i) {
1753 info() <<
"Variable build finished: " << vtk_file.isEof();
1773 info() <<
"Reading group info for group: " << name;
1776 for (
Integer i = 0; i < nb_item; ++i) {
1779 ids.
add(local_id[i]);
1781 info() <<
"Building group: " << name <<
" nb_element=" << ids.
size();
1802 info() <<
"Lecture infos groupes de noeuds pour le groupe: " << name;
1805 for (
Integer i = 0; i < nb_item; ++i) {
1810 info() <<
"Création groupe: " << name <<
" nb_element=" << ids.
size();
1823class VtkLegacyMeshWriter
1824:
public BasicService
1844 void _saveGroups(
IItemFamily* family, std::ostream& ofile);
1873 String fname = file_name;
1876 fname = fname +
".vtk";
1893 std::ofstream ofile(file_name.
localstr());
1896 throw IOException(
"VtkMeshIOService::writeMeshToFile(): Unable to open file");
1897 ofile <<
"# vtk DataFile Version 2.0\n";
1898 ofile <<
"Maillage Arcane\n";
1900 ofile <<
"DATASET UNSTRUCTURED_GRID\n";
1902 nodes_local_id_to_current.
fill(NULL_ITEM_ID);
1910 ofile <<
"POINTS " << nb_node <<
" double\n";
1915 nodes_local_id_to_current[node.
localId()] = node_index;
1916 Real3 xyz = coords[inode];
1917 ofile << xyz.
x <<
' ' << xyz.
y <<
' ' << xyz.
z <<
'\n';
1924 Integer nb_node_cell_kind = nb_cell_kind;
1925 ENUMERATE_ITEMWITHNODES(iitem, cell_kind_family->
allItems())
1927 nb_node_cell_kind += (*iitem).nbNode();
1929 ofile <<
"CELLS " << nb_cell_kind <<
' ' << nb_node_cell_kind <<
"\n";
1930 ENUMERATE_ITEMWITHNODES(iitem, cell_kind_family->
allItems())
1934 ofile << item_nb_node;
1935 for (NodeLocalId node_id : item.
nodes()) {
1936 ofile <<
' ' << nodes_local_id_to_current[node_id];
1941 ofile <<
"CELL_TYPES " << nb_cell_kind <<
"\n";
1943 int type = arcaneToVtkCellType(iitem->typeInfo());
1944 ofile << type <<
'\n';
1950 ofile <<
"POINT_DATA " << nb_node <<
"\n";
1955 ofile <<
"CELL_DATA " << nb_cell_kind <<
"\n";
1956 _saveGroups(
mesh->itemFamily(cell_kind), ofile);
1962void VtkLegacyMeshWriter::
1963_saveGroups(
IItemFamily* family, std::ostream& ofile)
1965 info() <<
"Saving groups for family name=" << family->
name();
1973 if (group.
name() ==
"OuterFaces")
1975 ofile <<
"SCALARS GROUP_" << group.
name() <<
" int 1\n";
1976 ofile <<
"LOOKUP_TABLE default\n";
1977 in_group_list.fill(
'0');
1979 in_group_list[(*iitem).localId()] =
'1';
1982 ofile << in_group_list[(*iitem).localId()] <<
'\n';
2007 const String& dir_name,
bool use_internal_partition)
override
2010 ARCANE_UNUSED(mesh_node);
2012 bool ret = vtk_service.
readMesh(
mesh, file_name, dir_name, use_internal_partition);
2035class VtkLegacyCaseMeshReader
2048 , m_read_info(read_info)
2055 ARCANE_UNUSED(build_info);
2060 String fname = m_read_info.fileName();
2061 m_trace_mng->info() <<
"VtkLegacy Reader (ICaseMeshReader) file_name=" << fname;
2062 bool ret = vtk_service.
readMesh(pm, fname, m_read_info.directoryName(), m_read_info.isParallelRead());
2084 if (read_info.format() ==
"vtk")
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ARCANE_REGISTER_SUB_DOMAIN_FACTORY(aclass, ainterface, aname)
Enregistre un service de fabrique pour la classe aclass.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro pour déclarer une interface lors de l'enregistrement d'un service.
Integer size() const
Nombre d'éléments du vecteur.
Classe de base d'un service.
AbstractService(const ServiceBuildInfo &)
Constructeur à partir d'un ServiceBuildInfo.
Tableau d'items de types quelconques.
void fill(const DataType &data)
Remplissage du tableau.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
ArrayView< T > subView(Int64 abegin, Integer asize)
Sous-vue à partir de l'élément abegin et contenant asize éléments.
void copy(Span< const T > rhs)
Copie les valeurs de rhs dans l'instance.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Informations nécessaires pour la lecture d'un fichier de maillage.
EnumeratorT< ItemGroup > Enumerator
Vue constante d'un tableau de type T.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Informations sur le type flottant.
Interface du service de lecture du maillage à partir du jeu de données.
Interface d'une famille d'entités.
virtual ItemGroupCollection groups() const =0
Liste des groupes de cette famille.
virtual ItemGroup allItems() const =0
Groupe de toutes les entités.
virtual ItemGroup createGroup(const String &name, Int32ConstArrayView local_ids, bool do_override=false)=0
Créé un groupe d'entités de nom name contenant les entités local_ids.
virtual Int32 maxLocalId() const =0
virtual String name() const =0
Nom de la famille.
virtual Integer nbItem() const =0
Nombre d'entités.
Interface d'un service de création/lecture du maillage.
Interface du service gérant la lecture d'un maillage.
eReturnType
Types des codes de retour d'une lecture ou écriture.
@ RTError
Erreur lors de l'opération.
@ RTOk
Opération effectuée avec succès.
Interface d'une classe proposant des fonctions utilitaires sur maillage.
virtual void getFacesLocalIdFromConnectivity(ConstArrayView< ItemTypeId > items_type, ConstArrayView< Int64 > items_connectivity, ArrayView< Int32 > local_ids, bool allow_null=false)=0
Recherche les identifiants locaux des faces à partir de leur connectivité.
Interface d'un service d'écriture d'un maillage.
Exception lorsqu'une erreur d'entrée/sortie est détectée.
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual Int32 commRank() const =0
Rang de cette instance dans le communicateur.
virtual void broadcastMemoryBuffer(ByteArray &bytes, Int32 rank)=0
Effectue un broadcast d'une zone mémoire.
Interface du gestionnaire de traces.
virtual void addAutoDestroyVariable(VariableRef *var)=0
Ajoute la variable à la liste des variables qui sont conservées jusqu'à la fin de l'exécution.
Interface du gestionnaire de variables.
virtual IVariableMngInternal * _internalApi()=0
API interne à Arcane.
static IXmlDocumentHolder * loadFromBuffer(Span< const Byte > buffer, const String &name, ITraceMng *tm)
Charge un document XML.
Groupe d'entités de maillage.
const String & name() const
Nom du groupe.
Type d'une entité (Item).
Int16 dimension() const
Dimension de l'élément (<0 si inconnu)
Gestionnaire des types d'entités d'un maillage.
ItemTypeInfo * typeFromId(Integer id) const
Type correspondant au numéro id.
Elément de maillage s'appuyant sur des noeuds (Edge,Face,Cell).
NodeConnectedListViewType nodes() const
Liste des noeuds de l'entité
Int32 nbNode() const
Nombre de noeuds de l'entité
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
Paramètres nécessaires à la construction d'un maillage.
Flot de sortie lié à une String.
Classe gérant un vecteur de réel de dimension 3.
Référence à une instance.
Encapsulation d'un pointeur qui se détruit automatiquement.
Structure contenant les informations pour créer un service.
Propriétés de création d'un service.
Chaîne de caractères unicode.
String lower() const
Transforme tous les caractères de la chaîne en minuscules.
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
ByteConstArrayView utf8() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
bool endsWith(const String &s) const
Indique si la chaîne se termine par les caractères de s.
String substring(Int64 pos) const
Sous-chaîne commençant à la position pos.
TraceAccessor(ITraceMng *m)
Construit un accesseur via le gestionnaire de trace m.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flot pour un message de debug.
TraceMessage fatal() const
Flot pour un message d'erreur fatale.
TraceMessage info() const
Flot pour un message d'information.
TraceMessage error() const
Flot pour un message d'erreur.
ITraceMng * traceMng() const
Gestionnaire de trace.
Vecteur 1D de données avec sémantique par valeur (style STL).
Informations pour allouer les entités d'un maillage non structuré.
void allocateMesh()
Alloue le maillage avec les mailles ajoutées lors de l'appel à addCell().
void setMeshDimension(Int32 v)
Positionne la dimension du maillage.
void preAllocate(Int32 nb_cell, Int64 nb_connectivity_node)
Pre-alloue la mémoire.
void addCell(ItemTypeId type_id, Int64 cell_uid, SmallSpan< const Int64 > nodes_uid)
Ajoute une maille au maillage.
Paramètres nécessaires à la construction d'une variable.
const char * getCurrentLine()
Permet de retourner la ligne présente dans le buffer.
bool isEmptyNextLine()
Permet de voir si la prochaine ligne est vide.
bool m_is_init
Y'a-t-il eu au moins une ligne lue.
std::istream * m_stream
Le stream.
static bool isEqualString(const String ¤t_value, const String &expected_value)
Permet de vérifier si expected_value == current_value.
double getDouble()
Permet de récupérer le double qui suit.
bool m_is_eof
Est-on à la fin du fichier.
char m_buf[BUFSIZE]
Le buffer contenant la ligne lue.
void getBinary(T &type)
Permet de récupérer le nombre binaire qui suit.
int getInt()
Permet de récupérer le int qui suit.
void checkString(const String ¤t_value, const String &expected_value)
Permet de vérifier si expected_value == current_value.
bool m_is_binary_file
Est-ce un fichier contenant des données en binaire.
bool m_need_reread_current_line
Doit-on relire la même ligne.
const char * getNextLine()
Permet de récupérer la prochaine ligne du fichier.
float getFloat()
Permet de récupérer le float qui suit.
void allocateMeshItems(IPrimaryMesh *pm) override
Alloue les entités du maillage géré par ce service.
void fillMeshBuildInfo(MeshBuildInfo &build_info) override
Remplit build_info avec les informations nécessaires pour créer le maillage.
Ref< IMeshBuilder > createBuilder(const CaseMeshReaderReadInfo &read_info) const override
Retourne un builder pour créer et lire le maillage dont les informations sont spécifiées dans read_in...
bool writeMeshToFile(IMesh *mesh, const String &file_name) override
Ecriture du maillage au Vtk.
void _writeMeshToFile(IMesh *mesh, const String &file_name, eItemKind cell_kind)
Ecrit le maillage au format Vtk.
void build() override
Construction de niveau build du service.
Lecteur des fichiers de maillage au format Vtk historique (legacy).
void _createFaceGroup(IMesh *mesh, const String &name, Int32ConstArrayView faces_lid)
Permet de créer un groupe de face de nom "name" et composé des faces ayant les ids inclus dans "faces...
bool _readMetadata(IMesh *mesh, VtkFile &vtk_file)
Lecture des metadata.
void _readCellVariable(IMesh *mesh, VtkFile &vtk_file, const String &name_str, Integer nb_cell)
Permet de créer une variable aux mailles à partir des infos du fichier vtk.
bool _readStructuredGrid(IPrimaryMesh *mesh, VtkFile &, bool use_internal_partition)
Permet de lire un fichier vtk contenant une STRUCTURED_GRID.
void _readNodesUnstructuredGrid(IMesh *mesh, VtkFile &vtk_file, Array< Real3 > &node_coords)
Lecture des noeuds et de leur coordonnées.
void _readItemGroup(IMesh *mesh, VtkFile &vtk_file, const String &name_str, Integer nb_item, eItemKind ik, ConstArrayView< Int32 > local_id)
Permet de créer un groupe d'item.
void _readCellsUnstructuredGrid(IMesh *mesh, VtkFile &vtk_file, Array< Int32 > &cells_nb_node, Array< ItemTypeId > &cells_type, Array< Int64 > &cells_connectivity)
Lecture des mailles et de leur connectivité.
void _readFacesMesh(IMesh *mesh, const String &file_name, const String &dir_name, bool use_internal_partition)
Permet de lire le fichier truc.vtkfaces.vtk (s'il existe).
bool _readData(IMesh *mesh, VtkFile &vtk_file, bool use_internal_partition, eItemKind cell_kind, Int32ConstArrayView local_id, Integer nb_node)
Permet de lire les données complémentaires (POINT_DATA / CELL_DATA).
bool readMesh(IPrimaryMesh *mesh, const String &file_name, const String &dir_name, bool use_internal_partition)
Permet de débuter la lecture d'un fichier vtk.
void _readNodeGroup(IMesh *mesh, VtkFile &vtk_file, const String &name, Integer nb_item)
Permet de créer un groupe de node.
bool _readUnstructuredGrid(IPrimaryMesh *mesh, VtkFile &vtk_file, bool use_internal_partition)
Permet de lire un fichier vtk contenant une UNSTRUCTURED_GRID.
eReturnType readMeshFromFile(IPrimaryMesh *mesh, const XmlNode &mesh_node, const String &file_name, const String &dir_name, bool use_internal_partition) override
Lit un maillage à partir d'un fichier.
bool allowExtension(const String &str) override
Vérifie si le service supporte les fichiers avec l'extension str.
Liste de noeuds d'un arbre DOM.
XmlNode documentElement() const
Retourne le noeud élément du document.
XmlNodeList children(const String &name) const
Ensemble des noeuds fils de ce noeud ayant pour nom name.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro pour enregistrer un service.
MeshVariableScalarRefT< Cell, Real > VariableCellReal
Grandeur au centre des mailles de type réel.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
@ ReduceMax
Maximum des valeurs.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
ArrayView< Byte > ByteArrayView
Equivalent C d'un tableau à une dimension de caractères.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
@ ST_SubDomain
Le service s'utilise au niveau du sous-domaine.
UniqueArray< Byte > ByteUniqueArray
Tableau dynamique à une dimension de caractères.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
eItemKind
Genre d'entité de maillage.
@ IK_Node
Entité de maillage de genre noeud.
@ IK_Cell
Entité de maillage de genre maille.
@ IK_Face
Entité de maillage de genre face.
std::int16_t Int16
Type entier signé sur 16 bits.
double Real
Type représentant un réel.
ConstArrayView< Byte > ByteConstArrayView
Equivalent C d'un tableau à une dimension de caractères.
unsigned char Byte
Type d'un octet.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
ArrayView< Real > RealArrayView
Equivalent C d'un tableau à une dimension de réels.
std::int32_t Int32
Type entier signé sur 32 bits.
Real y
deuxième composante du triplet
Real z
troisième composante du triplet
Real x
première composante du triplet