14#include "arcane/utils/Iostream.h"
15#include "arcane/utils/StdHeader.h"
16#include "arcane/utils/HashTableMap.h"
17#include "arcane/utils/ValueConvert.h"
18#include "arcane/utils/ScopedPtr.h"
19#include "arcane/utils/ArcanePrecomp.h"
20#include "arcane/utils/ITraceMng.h"
21#include "arcane/utils/Real3.h"
22#include "arcane/utils/PlatformUtils.h"
23#include "arcane/utils/FatalErrorException.h"
24#include "arcane/utils/NotSupportedException.h"
25#include "arcane/utils/CheckedConvert.h"
27#include "arcane/core/IMeshReader.h"
28#include "arcane/core/ISubDomain.h"
29#include "arcane/core/IIOMng.h"
30#include "arcane/core/IParallelMng.h"
31#include "arcane/core/IPrimaryMesh.h"
32#include "arcane/core/Item.h"
33#include "arcane/core/ItemTypeMng.h"
34#include "arcane/core/ItemGroup.h"
35#include "arcane/core/ArcaneException.h"
36#include "arcane/core/Service.h"
37#include "arcane/core/Timer.h"
39#include "arcane/core/ServiceInfo.h"
40#include "arcane/core/CaseOptionsMain.h"
43#include "arcane/core/VariableTypes.h"
44#include "arcane/core/ServiceBuildInfo.h"
45#include "arcane/core/XmlNodeList.h"
46#include "arcane/core/IXmlDocumentHolder.h"
47#include "arcane/core/IItemFamily.h"
48#include "arcane/core/FactoryService.h"
49#include "arcane/core/AbstractService.h"
51#include "arcane/core/LimaCutInfosReader.h"
52#include "arcane/core/internal/LimaUtils.h"
54#include <Lima/lima++.h>
69template<
typename LimaMaliReader>
81 Real v1 =
math::matDet((n[6] - n[1]) + (n[7] - n[0]), n[6] - n[3], n[2] - n[0]);
82 Real v2 =
math::matDet(n[7] - n[0], (n[6] - n[3]) + (n[5] - n[0]), n[6] - n[4]);
83 Real v3 =
math::matDet(n[6] - n[1], n[5] - n[0], (n[6] - n[4]) + (n[2] - n[0]));
85 Real res = (v1 + v2 + v3) / 12.0;
92 return math::matDet(n[1] - n[0], n[3] - n[0], n[4] - n[0]) +
100 Real x2 = n[2].
x - n[1].
x;
101 Real y2 = n[2].
y - n[1].
y;
102 Real surface = x1 * y2 - y1 * x2;
104 x1 = n[2].
x - n[0].
x;
105 y1 = n[2].
y - n[0].
y;
106 x2 = n[3].
x - n[2].
x;
107 y2 = n[3].
y - n[2].
y;
109 surface += x1 * y2 - y1 * x2;
116 Real x1 = n[1].
x - n[0].
x;
117 Real y1 = n[1].
y - n[0].
y;
118 Real x2 = n[2].
x - n[1].
x;
119 Real y2 = n[2].
y - n[1].
y;
121 return x1 * y2 - y1 * x2;
134template<
typename LimaMaliReader>
135class LimaMalippMeshBase
141 virtual ~LimaMalippMeshBase() =
default;
146 const String& filename,
Real length_multiplier) = 0;
155 Int64 current_unique_id);
169template <
typename ReaderWrapper>
170class LimaMalippReaderT
171:
public LimaMalippMeshBase<typename ReaderWrapper::LimaMaliReaderType>
177 typedef typename ReaderWrapper::LimaMaliReaderType LimaMaliReader;
180 : LimaMalippMeshBase<LimaMaliReader>(pm->
traceMng()),
184 ~LimaMalippReaderT()
override
186 delete m_cut_infos_reader;
191 bool readMeshPart(
ITimerMng* timer_mng,LimaMaliReader* reader,
193 Real length_multiplier)
override;
197 ReaderWrapper m_wrapper;
200 const String& filename,
Real length_multiplier);
206template<
typename LimaMaliReader>
207class LimaMalippReaderWrapper
210 typedef LimaMaliReader LimaMaliReaderType;
211 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
214 LimaMalippReaderWrapper()
217 void setReader(LimaMaliReader* reader)
219 m_mali_reader = reader;
221 LimaMaliReader* reader()
223 return m_mali_reader;
228 _readGroup(
typename LimaMaliReader::SurfaceReader reader,
229 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
231 return reader.lire_mailles_ids(begin, n, buffer);
234 _readGroup(
typename LimaMaliReader::VolumeReader reader,
235 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
237 return reader.lire_mailles_ids(begin, n, buffer);
240 _readGroup(
typename LimaMaliReader::LigneReader reader,
241 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
243 return reader.lire_bras_ids(begin, n, buffer);
247 _readGroup(
typename LimaMaliReader::NuageReader reader,
248 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
250 return reader.lire_noeuds_ids(begin, n, buffer);
253 double* allocateNodesCoordsBuffer(Lima::size_type buf_size)
255 return m_mali_reader->allouer_tampon_coords(buf_size);
257 Lima::size_type* allocateNodesIdBuffer(Lima::size_type buf_size)
259 return m_mali_reader->allouer_tampon_ids(buf_size);
261 Lima::size_type readNodes(Lima::size_type begin, Lima::size_type count,
262 Lima::size_type* ids,
double* coords)
264 return m_mali_reader->lire_noeuds(begin, count, ids, coords);
267 template <
typename LimaGroupReader>
270 using namespace Lima;
274 const Integer nb_item = CheckedConvert::toInteger(reader.composition().nb_elements);
275 items_unique_id.
resize(nb_item);
276 const Integer step_size = nb_item > 10000 ? nb_item / 10 : nb_item;
277 buffer = reader.allouer_tampon_ids(step_size);
279 for (
Integer i = 0; i * step_size < nb_item; ++i) {
280 const Integer count = CheckedConvert::toInteger(_readGroup(reader, (
size_type)(i * step_size), (
size_type)step_size, buffer));
282 for (
Integer n = 0; n < count; ++n) {
284 items_unique_id[begin + n] = lima_id - 1;
294 LimaMaliReader* m_mali_reader;
303template<
typename LimaMaliReader>
310 virtual ~LimaGroupReader() {}
316 std::vector<std::string> groups;
317 _getGroupsName(groups);
318 m_groups_name.clear();
319 for (
size_t i = 0, is = groups.size(); i < is; ++i)
320 m_groups_name.add(
String(groups[i]));
321 return m_groups_name;
325 virtual void _getGroupsName(std::vector<std::string>& groups) = 0;
334template<
typename LimaMaliReader>
336:
public LimaGroupReader<LimaMaliReader>
340 : LimaGroupReader<LimaMaliReader>(wrapper)
344 typename LimaMaliReader::NuageReader r = this->m_wrapper->reader()->nuage(name.
localstr());
345 this->m_wrapper->readGroup(r, items_unique_id);
347 virtual void _getGroupsName(std::vector<std::string>& groups)
349 this->m_wrapper->reader()->liste_nuages(groups);
355template<
typename LimaMaliReader>
357:
public LimaGroupReader<LimaMaliReader>
361 : LimaGroupReader<LimaMaliReader>(wrapper)
365 typename LimaMaliReader::LigneReader r = this->m_wrapper->reader()->ligne(name.
localstr());
366 this->m_wrapper->readGroup(r, items_unique_id);
368 virtual void _getGroupsName(std::vector<std::string>& groups)
370 this->m_wrapper->reader()->liste_lignes(groups);
376template<
typename LimaMaliReader>
378:
public LimaGroupReader<LimaMaliReader>
382 : LimaGroupReader<LimaMaliReader>(wrapper)
387 typename LimaMaliReader::SurfaceReader r = this->m_wrapper->reader()->surface(name.
localstr());
388 this->m_wrapper->readGroup(r, items_unique_id);
390 virtual void _getGroupsName(std::vector<std::string>& groups)
392 this->m_wrapper->reader()->liste_surfaces(groups);
396template<
typename LimaMaliReader>
398:
public LimaGroupReader<LimaMaliReader>
402 : LimaGroupReader<LimaMaliReader>(wrapper)
407 typename LimaMaliReader::VolumeReader r = this->m_wrapper->reader()->volume(name.
localstr());
408 this->m_wrapper->readGroup(r, items_unique_id);
410 virtual void _getGroupsName(std::vector<std::string>& groups)
412 this->m_wrapper->reader()->liste_volumes(groups);
421template<
typename LimaMaliReader>
423:
public LimaMalippReaderWrapper<LimaMaliReader>
425 typedef LimaMalippReaderWrapper<LimaMaliReader> BaseClass;
426 using BaseClass::m_mali_reader;
427 using BaseClass::m_cell_group_reader;
428 using BaseClass::m_node_group_reader;
429 using BaseClass::m_face_group_reader;
431 typedef Lima::Composition LimaComposition;
432 typedef typename LimaMaliReader::SurfaceReader LimaCellGroup;
433 typedef typename LimaMaliReader::LigneReader LimaFaceGroup;
434 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
436 LimaComposition cells()
438 return m_mali_reader->composition_polygones();
441 LimaComposition faces()
443 return m_mali_reader->composition_bras();
446 LimaComposition nodes()
448 return m_mali_reader->composition_noeuds();
451 std::vector<std::string> cellGroups()
453 std::vector<std::string> groups;
454 m_mali_reader->liste_surfaces(groups);
460 if (!m_cell_group_reader.get())
462 return m_cell_group_reader.get();
467 if (!m_node_group_reader.get())
469 return m_node_group_reader.get();
474 if (!m_face_group_reader.get())
476 return m_face_group_reader.get();
479 std::vector<std::string> faceGroups()
481 std::vector<std::string> groups;
482 m_mali_reader->liste_lignes(groups);
486 std::vector<std::string> nodeGroups()
488 std::vector<std::string> groups;
489 m_mali_reader->liste_nuages(groups);
493 LimaCellGroup cellGroup(
const string& name)
495 return m_mali_reader->surface(name);
498 LimaFaceGroup faceGroup(
const string& name)
500 return m_mali_reader->ligne(name);
503 LimaNodeGroup nodeGroup(
const string& name)
505 return m_mali_reader->nuage(name);
508 Lima::size_type* allocateCellsBuffer(Lima::size_type buf_size)
510 return m_mali_reader->allouer_tampon_polygones(buf_size);
512 Lima::size_type readCells(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
514 return m_mali_reader->lire_polygones(begin, count, buffer);
516 Integer facesBufferSize(Lima::size_type buf_size)
522 return CheckedConvert::toInteger(8 * buf_size);
524 Lima::size_type readFaces(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
526 return m_mali_reader->lire_bras(begin, count, buffer);
537 const char* strDimension()
541 Real3 readNodeCoords(
const double* ptr)
543 return Real3(ptr[0], ptr[1], 0.0);
566template<
typename LimaMaliReader>
568:
public LimaMalippReaderWrapper<LimaMaliReader>
570 typedef LimaMalippReaderWrapper<LimaMaliReader> BaseClass;
571 using BaseClass::m_mali_reader;
572 using BaseClass::m_cell_group_reader;
573 using BaseClass::m_node_group_reader;
574 using BaseClass::m_face_group_reader;
576 typedef typename LimaMaliReader::VolumeReader LimaCellGroup;
577 typedef typename LimaMaliReader::SurfaceReader LimaFaceGroup;
578 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
579 typedef Lima::Composition LimaComposition;
582 LimaComposition cells()
584 return m_mali_reader->composition_polyedres();
586 LimaComposition faces()
588 return m_mali_reader->composition_polygones();
590 LimaComposition nodes()
592 return m_mali_reader->composition_noeuds();
598 typedef Lima::Polyedre LimaCell;
600 typedef Lima::Polygone LimaFace;
604 if (!m_cell_group_reader.get())
606 return m_cell_group_reader.get();
611 if (!m_face_group_reader.get())
613 return m_face_group_reader.get();
618 if (!m_node_group_reader.get())
620 return m_node_group_reader.get();
623 std::vector<std::string> cellGroups()
625 std::vector<std::string> groups;
626 m_mali_reader->liste_volumes(groups);
630 std::vector<std::string> faceGroups()
632 std::vector<std::string> groups;
633 m_mali_reader->liste_surfaces(groups);
637 std::vector<std::string> nodeGroups()
639 std::vector<std::string> groups;
640 m_mali_reader->liste_nuages(groups);
644 LimaCellGroup cellGroup(
const string& name)
646 return m_mali_reader->volume(name);
648 LimaFaceGroup faceGroup(
const string& name)
650 return m_mali_reader->surface(name);
652 LimaNodeGroup nodeGroup(
const string& name)
654 return m_mali_reader->nuage(name);
656 Lima::size_type* allocateCellsBuffer(Lima::size_type buf_size)
658 return m_mali_reader->allouer_tampon_polyedres(buf_size);
660 Lima::size_type readCells(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
662 return m_mali_reader->lire_polyedres(begin, count, buffer);
664 Integer facesBufferSize(Lima::size_type buf_size)
670 return CheckedConvert::toInteger(14 * buf_size);
672 Lima::size_type readFaces(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
674 return m_mali_reader->lire_polygones(begin, count, buffer);
685 const char* strDimension()
689 Real3 readNodeCoords(
const double* ptr)
691 return Real3(ptr[0], ptr[1], ptr[2]);
697 return IT_Tetraedron4;
701 return IT_Pentaedron6;
703 return IT_Hexaedron8;
705 return IT_Heptaedron10;
707 return IT_Octaedron12;
720template<
typename LimaMaliReader>
721class LimaMalippReader
731 const String& file_name,
Real length_multiplier);
738template<
typename LimaMaliReader>
741 const String& filename,
Real length_multiplier)
753 reader =
new LimaMaliReader(filename.
localstr(), 1);
755 catch (
const Lima::erreur& ex) {
756 ARCANE_FATAL(
"Impossible de lire le fichier MLI Lima <{0}> :",filename,ex.what());
759 ARCANE_FATAL(
"Impossible de lire le fichier MLI Lima <{0}>",filename);
761 dimension = reader->dimension();
767 if (dimension == Lima::D3) {
768 info() <<
"Maillage 3D";
769 mesh->setDimension(3);
772 else if (dimension == Lima::D2) {
773 info() <<
"Maillage 2D";
774 mesh->setDimension(2);
781 log() <<
"Dimension du maillage non reconnue par lima";
784 bool ret = lm->readMeshPart(timer_mng,reader.
get(),
mesh, filename, length_multiplier);
793template <
typename ReaderWrapper>
796 const String& filename,
Real length_multiplier)
798 return _readMeshPart(timer_mng, reader,
mesh, filename, length_multiplier);
808template <
typename ReaderWrapper>
811 const String& file_name,
Real length_multiplier)
823 this->
pwarning() <<
"Chargement Lima du fichier USING MALIPP avec partitionnement '" << file_name <<
'"';
824 if (basic_step < 100000)
825 this->
pwarning() <<
"Small basic_step value=" << basic_step;
827 const char* version = Lima::lima_version();
828 info() <<
"Utilisation de la version " << version <<
" de Lima";
832 this->
log() <<
"Début lecture fichier " << file_name;
834 ReaderWrapper wrapper;
835 wrapper.setReader(reader);
837 if (reader && reader->dimension() != wrapper.limaDimension())
838 ARCANE_FATAL(
"Le fichier n'est pas un maillage {0}",wrapper.strDimension());
840 bool is_3d = (
mesh->dimension() == 3);
842 Int64 mesh_nb_node = 0;
843 Int64 mesh_nb_cell = 0;
844 Int64 mesh_nb_face = 0;
848 Lima::Composition lima_cells = wrapper.cells();
849 Lima::Composition lima_nodes = wrapper.nodes();
850 Lima::Composition lima_faces = wrapper.faces();
852 mesh_nb_node = (
Int64)lima_nodes.nb_elements;
853 mesh_nb_cell = (
Int64)lima_cells.nb_elements;
854 mesh_nb_face = (
Int64)lima_faces.nb_elements;
856 nb_items[0] = mesh_nb_node;
857 nb_items[1] = mesh_nb_cell;
858 nb_items[2] = mesh_nb_face;
861 info() <<
"Unité de longueur du fichier: " << reader->unite_longueur();
862 if (length_multiplier == 0.0)
863 length_multiplier = 1.0;
865 length_multiplier *= reader->unite_longueur();
866 pm->broadcast(
RealArrayView(1, &length_multiplier), master_rank);
871 mesh_nb_node = nb_items[0];
872 mesh_nb_cell = nb_items[1];
873 mesh_nb_face = nb_items[2];
874 pm->broadcast(
RealArrayView(1, &length_multiplier), master_rank);
880 info() <<
"-- Informations sur le maillage (Lima):";
881 info() <<
"Nombre de noeuds " << mesh_nb_node;
882 info() <<
"Nombre d'arêtes " << nb_edge;
883 info() <<
"Nombre de faces " << mesh_nb_face;
884 info() <<
"Nombre de mailles " << mesh_nb_cell;
885 if (mesh_nb_node == 0) {
886 ARCANE_FATAL(
"Pas de noeuds dans le fichier de maillage.");
891 Int64 uid_to_add = 0;
894 info() <<
"WARNING: UniqueId begin at 1";
897 Integer average_nb_cell = CheckedConvert::toInteger(mesh_nb_cell / nb_rank);
906 cells_infos.
reserve(average_nb_cell * 2);
908 Integer cell_step = average_nb_cell;
910 ARCANE_FATAL(
"Number of cells is less than number of sub domains");
913 size_type* buffer = wrapper.allocateCellsBuffer(cell_step + nb_rank);
914 Int64 total_nb_cell = mesh_nb_cell;
918 for (
Integer i = 0; total_count < total_nb_cell; ++i) {
920 ARCANE_FATAL(
"Too many count reading cells i={0} nrank=",i,nb_rank);
921 Int64 wanted_count = cell_step;
923 if ((i + 1) == nb_rank)
924 wanted_count = mesh_nb_cell;
925 Integer count = CheckedConvert::toInteger(wrapper.readCells(i * cell_step, wanted_count, buffer));
927 Integer p = (i * 20) / nb_rank;
928 if (p > last_print) {
930 info() <<
"Reading cells rank=" << i <<
" n=" << wanted_count <<
" count=" << count
931 <<
" (" << (p * 5) <<
"%)";
933 current_nb_cell = count;
934 total_count += count;
937 for (
Integer p = 0; p < count; ++p) {
938 Integer cell_local_id = CheckedConvert::toInteger(*ptr++);
939 const Lima::size_type nodeCount = *ptr++;
940 Integer n = CheckedConvert::toInteger(nodeCount);
941 Integer ct = ReaderWrapper::cellToType(n);
942 if (ct == IT_NullType)
947 cells_infos.
add(uid_to_add + cell_local_id - 1);
949 for (Lima::size_type z = 0; z < nodeCount; ++z) {
950 Int64 node_local_id = *ptr++;
951 cells_infos.
add(uid_to_add + node_local_id - 1);
954 if (i != master_rank) {
956 nb_cells_infos[0] = current_nb_cell;
957 nb_cells_infos[1] = cells_infos.
size();
959 pm->send(cells_infos, i);
962 own_nb_cell = current_nb_cell;
963 own_cells_infos = cells_infos;
971 own_nb_cell = nb_cells_infos[0];
972 own_cells_infos.
resize(nb_cells_infos[1]);
973 pm->
recv(own_cells_infos, master_rank);
977 info() <<
" READ COORDINATES 1";
983 for (
Integer i = 0; i < own_nb_cell; ++i) {
990 for (
Integer z = 0; z < current_nb_node; ++z) {
991 Int64 node_uid = own_cells_infos[cell_index + z];
992 nodes_coords.
add(node_uid,
Real3());
994 cell_index += current_nb_node;
998 info() <<
" READ COORDINATES 2";
1002 size_type step_size = (lima_nb_node > basic_step) ? basic_step : mesh_nb_node;
1004 size_type* idBuffer = reader->allouer_tampon_ids(step_size);
1005 double* coordsBuffer = reader->allouer_tampon_coords(step_size);
1006 Integer dim_step = reader->dimension();
1008 for (
Integer i = 0; i < mesh_nb_node;) {
1009 Integer count = CheckedConvert::toInteger(reader->lire_noeuds(i, step_size, idBuffer, coordsBuffer));
1010 current_coords.
clear();
1011 for (
Integer n = 0; n < count; ++n, ++nodeCount) {
1016 coord.
x = coordsBuffer[n];
1019 coord.
x = coordsBuffer[2 * n];
1020 coord.
y = coordsBuffer[(2 * n) + 1];
1023 coord.
x = coordsBuffer[3 * n];
1024 coord.
y = coordsBuffer[(3 * n) + 1];
1025 coord.
z = coordsBuffer[(3 * n) + 2];
1028 if (length_multiplier != 1.0)
1029 current_coords.
add(coord * length_multiplier);
1031 current_coords.
add(coord);
1034 sizes_info[0] = count;
1037 pm->broadcast(current_coords, master_rank);
1038 this->_setCoords(current_coords, nodes_coords, i + uid_to_add);
1042 delete[] coordsBuffer;
1046 for (
Int64 i = 0; i < mesh_nb_node;) {
1049 Integer count = sizes_info[0];
1050 current_coords.
resize(count);
1052 pm->broadcast(current_coords, master_rank);
1053 this->_setCoords(current_coords, nodes_coords, i + uid_to_add);
1058 info() <<
" READ CELLS";
1069 for (
Integer i = 0; i < own_nb_cell; ++i) {
1072 Int64 cell_uid = own_cells_infos[cell_index];
1076 local_coords.
resize(current_nb_node);
1077 for (
Integer z = 0; z < current_nb_node; ++z)
1078 local_coords[z] = nodes_coords.
lookupValue(own_cells_infos[cell_index + z]);
1079 if (type_id == IT_Hexaedron8) {
1080 Real volume = LimaVolume::Hexaedron8Volume(local_coords.
data());
1082 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1083 std::swap(own_cells_infos[cell_index + 3], own_cells_infos[cell_index + 2]);
1084 std::swap(own_cells_infos[cell_index + 4], own_cells_infos[cell_index + 5]);
1085 std::swap(own_cells_infos[cell_index + 7], own_cells_infos[cell_index + 6]);
1086 info() <<
"Volume negatif Hexaedron8 uid=" << cell_uid <<
" v=" << volume;
1090 else if (type_id == IT_Pyramid5) {
1091 Real volume = LimaVolume::Pyramid5Volume(local_coords.
data());
1093 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1094 std::swap(own_cells_infos[cell_index + 2], own_cells_infos[cell_index + 3]);
1095 info() <<
"Volume negatif Pyramid5 uid=" << cell_uid <<
" v=" << volume;
1099 else if (type_id == IT_Quad4) {
1100 Real surface = LimaVolume::Quad4Surface(local_coords.
data());
1101 if (surface < 0.0) {
1102 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1103 std::swap(own_cells_infos[cell_index + 2], own_cells_infos[cell_index + 3]);
1104 info() <<
"Surface negative Quad4 uid=" << cell_uid <<
" v=" << surface;
1108 else if (type_id == IT_Triangle3) {
1109 Real surface = LimaVolume::Triangle3Surface(local_coords.
data());
1110 if (surface < 0.0) {
1111 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1112 info() <<
"Surface negative Triangle3 uid=" << cell_uid <<
" v=" << surface;
1117 cell_index += current_nb_node;
1119 info() <<
"NB reoriented cell = " << nb_reoriented;
1122 logdate() <<
"Début allocation du maillage";
1123 mesh->allocateCells(own_nb_cell, own_cells_infos,
false);
1124 logdate() <<
"Fin allocation du maillage";
1128 for (
Integer i = 0, is = cells.
size(); i < is; ++i)
1129 cells[i]->setOwner(sid, sid);
1131 mesh->endAllocate();
1136 mesh->setOwnersFromCells();
1138 this->_createGroups(
mesh,
IK_Cell, wrapper.cellGroupReader(), 0);
1139 this->_createGroups(
mesh,
IK_Node, wrapper.nodeGroupReader(), 0);
1151 face_nodes_index.
reserve(100);
1156 size_type step_size = (mesh_nb_face > (
Int64)face_basic_step) ? face_basic_step : mesh_nb_face;
1159 Int64 current_nb_face = 0;
1160 Integer nb_lima_face_in_sub_domain = 0;
1161 info() <<
"Total_nb_face2=" << total_nb_face;
1165 for (
size_type i = 0; (i * step_size) < total_nb_face; ++i) {
1168 count = CheckedConvert::toInteger(wrapper.readFaces(i * step_size, step_size, buffer.
data()));
1170 pm->broadcast(buffer, master_rank);
1174 pm->broadcast(buffer, master_rank);
1177 info() <<
" Read Face2 N=" << i <<
" count=" << count <<
" step_size=" << step_size;
1178 orig_nodes_id.
clear();
1179 faces_first_node_unique_id.
clear();
1180 faces_nb_node.
resize(count);
1181 faces_nodes_unique_id.
clear();
1183 for (
Integer p = 0; p < count; ++p) {
1186 nodeCount = CheckedConvert::toInteger(*ptr++);
1191 faces_nb_node[p] = n;
1193 face_nodes_index.
resize(n);
1194 for (
Integer z = 0; z < nodeCount; ++z) {
1195 Integer node_local_id = CheckedConvert::toInteger(*ptr++);
1197 orig_nodes_id[z] = node_local_id - 1;
1201 for (
Integer z = 0; z < n; ++z)
1202 faces_nodes_unique_id.
add(orig_nodes_id[face_nodes_index[z]]);
1203 faces_first_node_unique_id.
add(orig_nodes_id[face_nodes_index[0]]);
1207 mesh->nodeFamily()->itemsUniqueIdToLocalId(faces_first_node_local_id, faces_first_node_unique_id,
false);
1209 Integer faces_nodes_unique_id_index = 0;
1210 for (
Integer i_face = 0; i_face < count; ++i_face) {
1211 Integer n = faces_nb_node[i_face];
1212 Int64ConstArrayView face_nodes_id(n, &faces_nodes_unique_id[faces_nodes_unique_id_index]);
1213 Int32 first_node_id = faces_first_node_local_id[i_face];
1215 if (first_node_id != NULL_ITEM_ID) {
1216 Node current_node(mesh_nodes[first_node_id]);
1217 Face face = mesh_utils::getFaceFromNodesUnique(current_node, face_nodes_id);
1221 faces_local_id.
add(current_nb_face + i_face, face.
localId());
1222 ++nb_lima_face_in_sub_domain;
1225 faces_nodes_unique_id_index += n;
1227 current_nb_face += count;
1229 info() <<
"NB LIMA FACE IN SUB-DOMAIN =" << nb_lima_face_in_sub_domain;
1232 this->_createGroups(
mesh,
IK_Face, wrapper.faceGroupReader(), &faces_local_id);
1238 const Node& node = *i;
1242 nodes_coord_var.synchronize();
1245 logdate() <<
"Fin de lecture du fichier";
1252template <
typename LimaMaliReader>
1255 Int64 current_unique_id)
1257 for (
Integer i = 0, is = coords.
size(); i < is; ++i) {
1258 Int64 uid = current_unique_id + i;
1261 d->value() = coords[i];
1268template <
typename LimaMaliReader>
1274 Integer master_rank = pm->masterIORank();
1275 Integer is_master_io = pm->isMasterIO();
1285 Integer nb_group = groups_name.size();
1287 sizes_infos[0] = nb_group;
1289 for (
Integer i = 0; i < nb_group; ++i) {
1291 String group_name = groups_name[i];
1292 pm->broadcastString(group_name, master_rank);
1295 lima_group_reader->read(group_name, unique_ids);
1296 Integer nb_item_in_group = unique_ids.size();
1297 sizes_infos[0] = nb_item_in_group;
1299 pm->broadcast(unique_ids, master_rank);
1301 _createGroupFromHashTable(
mesh, group_name, item_kind, unique_ids, *converter);
1303 _createGroupFromUniqueIds(
mesh, group_name, item_kind, unique_ids);
1309 Integer nb_group = sizes_infos[0];
1310 for (
Integer i = 0; i < nb_group; ++i) {
1312 pm->broadcastString(group_name, master_rank);
1315 Integer nb_item_in_group = sizes_infos[0];
1316 unique_ids.resize(nb_item_in_group);
1317 pm->broadcast(unique_ids, master_rank);
1319 _createGroupFromHashTable(
mesh, group_name, item_kind, unique_ids, *converter);
1321 _createGroupFromUniqueIds(
mesh, group_name, item_kind, unique_ids);
1329template <
typename LimaMaliReader>
1334 Integer nb_item_in_group = unique_ids.size();
1337 family->itemsUniqueIdToLocalId(local_ids, unique_ids,
false);
1339 for (
Integer i = 0; i < nb_item_in_group; ++i) {
1340 if (local_ids[i] != NULL_ITEM_ID)
1341 group_ids.add(local_ids[i]);
1343 info() <<
"Group Name <" << name <<
"> (" << nb_item_in_group <<
" elements)";
1350template <
typename LimaMaliReader>
1356 Integer nb_item_in_group = unique_ids.size();
1360 for (
Integer i = 0; i < nb_item_in_group; ++i) {
1363 group_ids.add(data->value());
1365 info() <<
"Group Name <" << name <<
"> (" << nb_item_in_group <<
" elements)";
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Fonctions mathématiques diverses.
Fonctions utilitaires sur le maillage.
bool reorderNodesOfFace2(Int64ConstArrayView nodes_unique_id, Int32ArrayView new_index)
Réordonne les noeuds d'une face.
Ce fichier contient les différentes fabriques de services et macro pour enregistrer les services.
Integer size() const
Nombre d'éléments du vecteur.
void clear()
Supprime les éléments du tableau.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
void reserve(Int64 new_capacity)
Réserve le mémoire pour new_capacity éléments.
const T * data() const
Accès à la racine du tableau hors toute protection.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Table de hachage pour tableaux associatifs.
Data * lookup(KeyTypeConstRef id)
Recherche la valeur correspondant à la clé id.
ValueType & lookupValue(KeyTypeConstRef id)
Recherche la valeur correspondant à la clé id.
bool add(KeyTypeConstRef id, const ValueType &value)
Ajoute la valeur value correspondant à la clé id.
Interface d'une famille d'entités.
eReturnType
Types des codes de retour d'une lecture ou écriture.
@ RTIrrelevant
Non concerné par l'opération. Cela signifie que le format de fichier ne correspond pas à ce lecteur o...
@ RTError
Erreur lors de l'opération.
@ RTOk
Opération effectuée avec succès.
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual ITraceMng * traceMng() const =0
Gestionnaire de traces.
virtual Int32 commRank() const =0
Rang de cette instance dans le communicateur.
virtual void recv(ArrayView< char > values, Int32 rank)=0
virtual bool isMasterIO() const =0
true si l'instance est un gestionnaire maître des entrées/sorties.
virtual Int32 commSize() const =0
Nombre d'instance dans le communicateur.
virtual Integer masterIORank() const =0
Rang de l'instance gérant les entrées/sorties (pour laquelle isMasterIO() est vrai)
Interface d'un gestionnaire de timer.
Interface du gestionnaire de traces.
Infos sur un type d'entité du maillage.
Integer nbLocalNode() const
Nombre de noeuds de l'entité
Gestionnaire des types d'entités d'un maillage.
ItemTypeInfo * typeFromId(Integer id) const
Type correspondant au numéro id.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
constexpr bool null() const
true si l'entité est nul (i.e. non connecté au maillage)
Construction d'un maillage 3D.
Lecteur des fichiers de maillage via la bibliothèque LIMA pour fichier '.mli' ou 'mli2'.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
TraceMessage logdate() const
Flot pour un message de log précédé de la date.
TraceMessage log() const
Flot pour un message de log.
TraceMessage info() const
Flot pour un message d'information.
bool _readMeshPart(ITimerMng *timer_mng, LimaMaliReader *reader, IPrimaryMesh *mesh, const String &filename, Real length_multiplier)
Lecture du maillage. Seul le proc maitre a une instance de reader non nulle. Les autres ne doivent pa...
Lecteur des fichiers de maillage via la bibliothèque LIMA.
static void createGroup(IItemFamily *family, const String &name, Int32ArrayView local_ids)
Créé un groupe d'entités.
Exception lorsqu'une opération n'est pas supportée.
T * get() const
Retourne l'objet référé par l'instance.
Classe gérant un vecteur de réel de dimension 3.
Encapsulation d'un pointeur qui se détruit automatiquement.
Chaîne de caractères unicode.
bool null() const
Retourne true si la chaîne est nulle.
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
bool empty() const
Vrai si la chaîne est vide (nulle ou "")
@ TimerReal
Timer utilisant le temps réel.
TraceAccessor(ITraceMng *m)
Construit un accesseur via le gestionnaire de trace m.
TraceMessage logdate() const
Flot pour un message de log précédé de la date.
TraceMessage log() const
Flot pour un message de log.
TraceMessage info() const
Flot pour un message d'information.
TraceMessage pwarning() const
Vecteur 1D de données avec sémantique par valeur (style STL).
Exception lorsqu'une entité du maillage n'est pas d'un type connu.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
__host__ __device__ double log(double v)
Logarithme népérien de v.
__host__ __device__ Real matDet(Real3 u, Real3 v, Real3 w)
Déterminant de la matrice u,v,w.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Array< Int64 > Int64Array
Tableau dynamique à une dimension d'entiers 64 bits.
ArrayView< Int64 > Int64ArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
ConstArrayView< Real3 > Real3ConstArrayView
Equivalent C d'un tableau à une dimension de Real3.
UniqueArray< Int64 > Int64UniqueArray
Tableau dynamique à une dimension d'entiers 64 bits.
ConstArrayView< String > StringConstArrayView
Equivalent C d'un tableau à une dimension de chaînes de caractères.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
UniqueArray< Real3 > Real3UniqueArray
Tableau dynamique à une dimension de vecteurs de rang 3.
ArrayView< Integer > IntegerArrayView
Equivalent C d'un tableau à une dimension d'entiers.
ConstArrayView< ItemInternal * > ItemInternalList
Type de la liste interne des entités.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à 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.
double Real
Type représentant un réel.
UniqueArray< String > StringUniqueArray
Tableau dynamique à une dimension de chaînes de caractères.
UniqueArray< Integer > IntegerUniqueArray
Tableau dynamique à une dimension d'entiers.
ConstArrayView< Integer > IntegerConstArrayView
Equivalent C d'un tableau à une dimension d'entiers.
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