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"
52#include "arcane/lima/LimaCutInfosReader.h"
53#include "arcane/lima/internal/LimaUtils.h"
55#include <Lima/lima++.h>
70template<
typename LimaMaliReader>
82 Real v1 =
math::matDet((n[6] - n[1]) + (n[7] - n[0]), n[6] - n[3], n[2] - n[0]);
83 Real v2 =
math::matDet(n[7] - n[0], (n[6] - n[3]) + (n[5] - n[0]), n[6] - n[4]);
84 Real v3 =
math::matDet(n[6] - n[1], n[5] - n[0], (n[6] - n[4]) + (n[2] - n[0]));
86 Real res = (v1 + v2 + v3) / 12.0;
93 return math::matDet(n[1] - n[0], n[3] - n[0], n[4] - n[0]) +
100 Real y1 = n[1].
y - n[0].
y;
101 Real x2 = n[2].
x - n[1].
x;
102 Real y2 = n[2].
y - n[1].
y;
103 Real surface = x1 * y2 - y1 * x2;
105 x1 = n[2].
x - n[0].
x;
106 y1 = n[2].
y - n[0].
y;
107 x2 = n[3].
x - n[2].
x;
108 y2 = n[3].
y - n[2].
y;
110 surface += x1 * y2 - y1 * x2;
117 Real x1 = n[1].
x - n[0].
x;
118 Real y1 = n[1].
y - n[0].
y;
119 Real x2 = n[2].
x - n[1].
x;
120 Real y2 = n[2].
y - n[1].
y;
122 return x1 * y2 - y1 * x2;
135template<
typename LimaMaliReader>
136class LimaMalippMeshBase
142 virtual ~LimaMalippMeshBase() =
default;
147 const String& filename,
Real length_multiplier) = 0;
156 Int64 current_unique_id);
170template <
typename ReaderWrapper>
171class LimaMalippReaderT
172:
public LimaMalippMeshBase<typename ReaderWrapper::LimaMaliReaderType>
178 typedef typename ReaderWrapper::LimaMaliReaderType LimaMaliReader;
181 : LimaMalippMeshBase<LimaMaliReader>(pm->
traceMng()),
185 ~LimaMalippReaderT()
override
187 delete m_cut_infos_reader;
192 bool readMeshPart(
ITimerMng* timer_mng,LimaMaliReader* reader,
194 Real length_multiplier)
override;
198 ReaderWrapper m_wrapper;
201 const String& filename,
Real length_multiplier);
207template<
typename LimaMaliReader>
208class LimaMalippReaderWrapper
211 typedef LimaMaliReader LimaMaliReaderType;
212 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
215 LimaMalippReaderWrapper()
218 void setReader(LimaMaliReader* reader)
220 m_mali_reader = reader;
222 LimaMaliReader* reader()
224 return m_mali_reader;
229 _readGroup(
typename LimaMaliReader::SurfaceReader reader,
230 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
232 return reader.lire_mailles_ids(begin, n, buffer);
235 _readGroup(
typename LimaMaliReader::VolumeReader reader,
236 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
238 return reader.lire_mailles_ids(begin, n, buffer);
241 _readGroup(
typename LimaMaliReader::LigneReader reader,
242 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
244 return reader.lire_bras_ids(begin, n, buffer);
248 _readGroup(
typename LimaMaliReader::NuageReader reader,
249 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
251 return reader.lire_noeuds_ids(begin, n, buffer);
254 double* allocateNodesCoordsBuffer(Lima::size_type buf_size)
256 return m_mali_reader->allouer_tampon_coords(buf_size);
258 Lima::size_type* allocateNodesIdBuffer(Lima::size_type buf_size)
260 return m_mali_reader->allouer_tampon_ids(buf_size);
262 Lima::size_type readNodes(Lima::size_type begin, Lima::size_type count,
263 Lima::size_type* ids,
double* coords)
265 return m_mali_reader->lire_noeuds(begin, count, ids, coords);
268 template <
typename LimaGroupReader>
271 using namespace Lima;
275 const Integer nb_item = CheckedConvert::toInteger(reader.composition().nb_elements);
276 items_unique_id.
resize(nb_item);
277 const Integer step_size = nb_item > 10000 ? nb_item / 10 : nb_item;
278 buffer = reader.allouer_tampon_ids(step_size);
280 for (
Integer i = 0; i * step_size < nb_item; ++i) {
281 const Integer count = CheckedConvert::toInteger(_readGroup(reader, (
size_type)(i * step_size), (
size_type)step_size, buffer));
283 for (
Integer n = 0; n < count; ++n) {
285 items_unique_id[begin + n] = lima_id - 1;
295 LimaMaliReader* m_mali_reader;
304template<
typename LimaMaliReader>
311 virtual ~LimaGroupReader() {}
317 std::vector<std::string> groups;
318 _getGroupsName(groups);
319 m_groups_name.clear();
320 for (
size_t i = 0, is = groups.size(); i < is; ++i)
321 m_groups_name.add(
String(groups[i]));
322 return m_groups_name;
326 virtual void _getGroupsName(std::vector<std::string>& groups) = 0;
335template<
typename LimaMaliReader>
337:
public LimaGroupReader<LimaMaliReader>
341 : LimaGroupReader<LimaMaliReader>(wrapper)
345 typename LimaMaliReader::NuageReader r = this->m_wrapper->reader()->nuage(name.
localstr());
346 this->m_wrapper->readGroup(r, items_unique_id);
348 virtual void _getGroupsName(std::vector<std::string>& groups)
350 this->m_wrapper->reader()->liste_nuages(groups);
356template<
typename LimaMaliReader>
358:
public LimaGroupReader<LimaMaliReader>
362 : LimaGroupReader<LimaMaliReader>(wrapper)
366 typename LimaMaliReader::LigneReader r = this->m_wrapper->reader()->ligne(name.
localstr());
367 this->m_wrapper->readGroup(r, items_unique_id);
369 virtual void _getGroupsName(std::vector<std::string>& groups)
371 this->m_wrapper->reader()->liste_lignes(groups);
377template<
typename LimaMaliReader>
379:
public LimaGroupReader<LimaMaliReader>
383 : LimaGroupReader<LimaMaliReader>(wrapper)
388 typename LimaMaliReader::SurfaceReader r = this->m_wrapper->reader()->surface(name.
localstr());
389 this->m_wrapper->readGroup(r, items_unique_id);
391 virtual void _getGroupsName(std::vector<std::string>& groups)
393 this->m_wrapper->reader()->liste_surfaces(groups);
397template<
typename LimaMaliReader>
399:
public LimaGroupReader<LimaMaliReader>
403 : LimaGroupReader<LimaMaliReader>(wrapper)
408 typename LimaMaliReader::VolumeReader r = this->m_wrapper->reader()->volume(name.
localstr());
409 this->m_wrapper->readGroup(r, items_unique_id);
411 virtual void _getGroupsName(std::vector<std::string>& groups)
413 this->m_wrapper->reader()->liste_volumes(groups);
422template<
typename LimaMaliReader>
424:
public LimaMalippReaderWrapper<LimaMaliReader>
426 typedef LimaMalippReaderWrapper<LimaMaliReader> BaseClass;
427 using BaseClass::m_mali_reader;
428 using BaseClass::m_cell_group_reader;
429 using BaseClass::m_node_group_reader;
430 using BaseClass::m_face_group_reader;
432 typedef Lima::Composition LimaComposition;
433 typedef typename LimaMaliReader::SurfaceReader LimaCellGroup;
434 typedef typename LimaMaliReader::LigneReader LimaFaceGroup;
435 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
437 LimaComposition cells()
439 return m_mali_reader->composition_polygones();
442 LimaComposition faces()
444 return m_mali_reader->composition_bras();
447 LimaComposition nodes()
449 return m_mali_reader->composition_noeuds();
452 std::vector<std::string> cellGroups()
454 std::vector<std::string> groups;
455 m_mali_reader->liste_surfaces(groups);
461 if (!m_cell_group_reader.get())
463 return m_cell_group_reader.get();
468 if (!m_node_group_reader.get())
470 return m_node_group_reader.get();
475 if (!m_face_group_reader.get())
477 return m_face_group_reader.get();
480 std::vector<std::string> faceGroups()
482 std::vector<std::string> groups;
483 m_mali_reader->liste_lignes(groups);
487 std::vector<std::string> nodeGroups()
489 std::vector<std::string> groups;
490 m_mali_reader->liste_nuages(groups);
494 LimaCellGroup cellGroup(
const string& name)
496 return m_mali_reader->surface(name);
499 LimaFaceGroup faceGroup(
const string& name)
501 return m_mali_reader->ligne(name);
504 LimaNodeGroup nodeGroup(
const string& name)
506 return m_mali_reader->nuage(name);
509 Lima::size_type* allocateCellsBuffer(Lima::size_type buf_size)
511 return m_mali_reader->allouer_tampon_polygones(buf_size);
513 Lima::size_type readCells(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
515 return m_mali_reader->lire_polygones(begin, count, buffer);
517 Integer facesBufferSize(Lima::size_type buf_size)
523 return CheckedConvert::toInteger(8 * buf_size);
525 Lima::size_type readFaces(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
527 return m_mali_reader->lire_bras(begin, count, buffer);
538 const char* strDimension()
542 Real3 readNodeCoords(
const double* ptr)
544 return Real3(ptr[0], ptr[1], 0.0);
567template<
typename LimaMaliReader>
569:
public LimaMalippReaderWrapper<LimaMaliReader>
571 typedef LimaMalippReaderWrapper<LimaMaliReader> BaseClass;
572 using BaseClass::m_mali_reader;
573 using BaseClass::m_cell_group_reader;
574 using BaseClass::m_node_group_reader;
575 using BaseClass::m_face_group_reader;
577 typedef typename LimaMaliReader::VolumeReader LimaCellGroup;
578 typedef typename LimaMaliReader::SurfaceReader LimaFaceGroup;
579 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
580 typedef Lima::Composition LimaComposition;
583 LimaComposition cells()
585 return m_mali_reader->composition_polyedres();
587 LimaComposition faces()
589 return m_mali_reader->composition_polygones();
591 LimaComposition nodes()
593 return m_mali_reader->composition_noeuds();
599 typedef Lima::Polyedre LimaCell;
601 typedef Lima::Polygone LimaFace;
605 if (!m_cell_group_reader.get())
607 return m_cell_group_reader.get();
612 if (!m_face_group_reader.get())
614 return m_face_group_reader.get();
619 if (!m_node_group_reader.get())
621 return m_node_group_reader.get();
624 std::vector<std::string> cellGroups()
626 std::vector<std::string> groups;
627 m_mali_reader->liste_volumes(groups);
631 std::vector<std::string> faceGroups()
633 std::vector<std::string> groups;
634 m_mali_reader->liste_surfaces(groups);
638 std::vector<std::string> nodeGroups()
640 std::vector<std::string> groups;
641 m_mali_reader->liste_nuages(groups);
645 LimaCellGroup cellGroup(
const string& name)
647 return m_mali_reader->volume(name);
649 LimaFaceGroup faceGroup(
const string& name)
651 return m_mali_reader->surface(name);
653 LimaNodeGroup nodeGroup(
const string& name)
655 return m_mali_reader->nuage(name);
657 Lima::size_type* allocateCellsBuffer(Lima::size_type buf_size)
659 return m_mali_reader->allouer_tampon_polyedres(buf_size);
661 Lima::size_type readCells(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
663 return m_mali_reader->lire_polyedres(begin, count, buffer);
665 Integer facesBufferSize(Lima::size_type buf_size)
671 return CheckedConvert::toInteger(14 * buf_size);
673 Lima::size_type readFaces(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
675 return m_mali_reader->lire_polygones(begin, count, buffer);
686 const char* strDimension()
690 Real3 readNodeCoords(
const double* ptr)
692 return Real3(ptr[0], ptr[1], ptr[2]);
698 return IT_Tetraedron4;
702 return IT_Pentaedron6;
704 return IT_Hexaedron8;
706 return IT_Heptaedron10;
708 return IT_Octaedron12;
721template<
typename LimaMaliReader>
722class LimaMalippReader
732 const String& file_name,
Real length_multiplier);
739template<
typename LimaMaliReader>
742 const String& filename,
Real length_multiplier)
754 reader =
new LimaMaliReader(filename.
localstr(), 1);
756 catch (
const Lima::erreur& ex) {
757 ARCANE_FATAL(
"Impossible de lire le fichier MLI Lima <{0}> :",filename,ex.what());
760 ARCANE_FATAL(
"Impossible de lire le fichier MLI Lima <{0}>",filename);
762 dimension = reader->dimension();
768 if (dimension == Lima::D3) {
769 info() <<
"Maillage 3D";
770 mesh->setDimension(3);
773 else if (dimension == Lima::D2) {
774 info() <<
"Maillage 2D";
775 mesh->setDimension(2);
782 log() <<
"Dimension du maillage non reconnue par lima";
785 bool ret = lm->readMeshPart(timer_mng,reader.
get(),
mesh, filename, length_multiplier);
794template <
typename ReaderWrapper>
797 const String& filename,
Real length_multiplier)
799 return _readMeshPart(timer_mng, reader,
mesh, filename, length_multiplier);
809template <
typename ReaderWrapper>
812 const String& file_name,
Real length_multiplier)
824 this->
pwarning() <<
"Chargement Lima du fichier USING MALIPP avec partitionnement '" << file_name <<
'"';
825 if (basic_step < 100000)
826 this->
pwarning() <<
"Small basic_step value=" << basic_step;
828 const char* version = Lima::lima_version();
829 info() <<
"Utilisation de la version " << version <<
" de Lima";
833 this->
log() <<
"Début lecture fichier " << file_name;
835 ReaderWrapper wrapper;
836 wrapper.setReader(reader);
838 if (reader && reader->dimension() != wrapper.limaDimension())
839 ARCANE_FATAL(
"Le fichier n'est pas un maillage {0}",wrapper.strDimension());
841 bool is_3d = (
mesh->dimension() == 3);
843 Int64 mesh_nb_node = 0;
844 Int64 mesh_nb_cell = 0;
845 Int64 mesh_nb_face = 0;
849 Lima::Composition lima_cells = wrapper.cells();
850 Lima::Composition lima_nodes = wrapper.nodes();
851 Lima::Composition lima_faces = wrapper.faces();
853 mesh_nb_node = (
Int64)lima_nodes.nb_elements;
854 mesh_nb_cell = (
Int64)lima_cells.nb_elements;
855 mesh_nb_face = (
Int64)lima_faces.nb_elements;
857 nb_items[0] = mesh_nb_node;
858 nb_items[1] = mesh_nb_cell;
859 nb_items[2] = mesh_nb_face;
862 info() <<
"Unité de longueur du fichier: " << reader->unite_longueur();
863 if (length_multiplier == 0.0)
864 length_multiplier = 1.0;
866 length_multiplier *= reader->unite_longueur();
867 pm->broadcast(
RealArrayView(1, &length_multiplier), master_rank);
872 mesh_nb_node = nb_items[0];
873 mesh_nb_cell = nb_items[1];
874 mesh_nb_face = nb_items[2];
875 pm->broadcast(
RealArrayView(1, &length_multiplier), master_rank);
881 info() <<
"-- Informations sur le maillage (Lima):";
882 info() <<
"Nombre de noeuds " << mesh_nb_node;
883 info() <<
"Nombre d'arêtes " << nb_edge;
884 info() <<
"Nombre de faces " << mesh_nb_face;
885 info() <<
"Nombre de mailles " << mesh_nb_cell;
886 if (mesh_nb_node == 0) {
887 ARCANE_FATAL(
"Pas de noeuds dans le fichier de maillage.");
892 Int64 uid_to_add = 0;
895 info() <<
"WARNING: UniqueId begin at 1";
898 Integer average_nb_cell = CheckedConvert::toInteger(mesh_nb_cell / nb_rank);
907 cells_infos.
reserve(average_nb_cell * 2);
909 Integer cell_step = average_nb_cell;
911 ARCANE_FATAL(
"Number of cells is less than number of sub domains");
914 size_type* buffer = wrapper.allocateCellsBuffer(cell_step + nb_rank);
915 Int64 total_nb_cell = mesh_nb_cell;
919 for (
Integer i = 0; total_count < total_nb_cell; ++i) {
921 ARCANE_FATAL(
"Too many count reading cells i={0} nrank=",i,nb_rank);
922 Int64 wanted_count = cell_step;
924 if ((i + 1) == nb_rank)
925 wanted_count = mesh_nb_cell;
926 Integer count = CheckedConvert::toInteger(wrapper.readCells(i * cell_step, wanted_count, buffer));
928 Integer p = (i * 20) / nb_rank;
929 if (p > last_print) {
931 info() <<
"Reading cells rank=" << i <<
" n=" << wanted_count <<
" count=" << count
932 <<
" (" << (p * 5) <<
"%)";
934 current_nb_cell = count;
935 total_count += count;
938 for (
Integer p = 0; p < count; ++p) {
939 Integer cell_local_id = CheckedConvert::toInteger(*ptr++);
940 const Lima::size_type nodeCount = *ptr++;
941 Integer n = CheckedConvert::toInteger(nodeCount);
942 Integer ct = ReaderWrapper::cellToType(n);
943 if (ct == IT_NullType)
948 cells_infos.
add(uid_to_add + cell_local_id - 1);
950 for (Lima::size_type z = 0; z < nodeCount; ++z) {
951 Int64 node_local_id = *ptr++;
952 cells_infos.
add(uid_to_add + node_local_id - 1);
955 if (i != master_rank) {
957 nb_cells_infos[0] = current_nb_cell;
958 nb_cells_infos[1] = cells_infos.
size();
960 pm->send(cells_infos, i);
963 own_nb_cell = current_nb_cell;
964 own_cells_infos = cells_infos;
972 own_nb_cell = nb_cells_infos[0];
973 own_cells_infos.
resize(nb_cells_infos[1]);
974 pm->
recv(own_cells_infos, master_rank);
978 info() <<
" READ COORDINATES 1";
984 for (
Integer i = 0; i < own_nb_cell; ++i) {
991 for (
Integer z = 0; z < current_nb_node; ++z) {
992 Int64 node_uid = own_cells_infos[cell_index + z];
993 nodes_coords.
add(node_uid,
Real3());
995 cell_index += current_nb_node;
999 info() <<
" READ COORDINATES 2";
1003 size_type step_size = (lima_nb_node > basic_step) ? basic_step : mesh_nb_node;
1005 size_type* idBuffer = reader->allouer_tampon_ids(step_size);
1006 double* coordsBuffer = reader->allouer_tampon_coords(step_size);
1007 Integer dim_step = reader->dimension();
1009 for (
Integer i = 0; i < mesh_nb_node;) {
1010 Integer count = CheckedConvert::toInteger(reader->lire_noeuds(i, step_size, idBuffer, coordsBuffer));
1011 current_coords.
clear();
1012 for (
Integer n = 0; n < count; ++n, ++nodeCount) {
1017 coord.
x = coordsBuffer[n];
1020 coord.
x = coordsBuffer[2 * n];
1021 coord.
y = coordsBuffer[(2 * n) + 1];
1024 coord.
x = coordsBuffer[3 * n];
1025 coord.
y = coordsBuffer[(3 * n) + 1];
1026 coord.
z = coordsBuffer[(3 * n) + 2];
1029 if (length_multiplier != 1.0)
1030 current_coords.
add(coord * length_multiplier);
1032 current_coords.
add(coord);
1035 sizes_info[0] = count;
1038 pm->broadcast(current_coords, master_rank);
1039 this->_setCoords(current_coords, nodes_coords, i + uid_to_add);
1043 delete[] coordsBuffer;
1047 for (
Int64 i = 0; i < mesh_nb_node;) {
1050 Integer count = sizes_info[0];
1051 current_coords.
resize(count);
1053 pm->broadcast(current_coords, master_rank);
1054 this->_setCoords(current_coords, nodes_coords, i + uid_to_add);
1059 info() <<
" READ CELLS";
1070 for (
Integer i = 0; i < own_nb_cell; ++i) {
1073 Int64 cell_uid = own_cells_infos[cell_index];
1077 local_coords.
resize(current_nb_node);
1078 for (
Integer z = 0; z < current_nb_node; ++z)
1079 local_coords[z] = nodes_coords.
lookupValue(own_cells_infos[cell_index + z]);
1080 if (type_id == IT_Hexaedron8) {
1081 Real volume = LimaVolume::Hexaedron8Volume(local_coords.
data());
1083 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1084 std::swap(own_cells_infos[cell_index + 3], own_cells_infos[cell_index + 2]);
1085 std::swap(own_cells_infos[cell_index + 4], own_cells_infos[cell_index + 5]);
1086 std::swap(own_cells_infos[cell_index + 7], own_cells_infos[cell_index + 6]);
1087 info() <<
"Volume negatif Hexaedron8 uid=" << cell_uid <<
" v=" << volume;
1091 else if (type_id == IT_Pyramid5) {
1092 Real volume = LimaVolume::Pyramid5Volume(local_coords.
data());
1094 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1095 std::swap(own_cells_infos[cell_index + 2], own_cells_infos[cell_index + 3]);
1096 info() <<
"Volume negatif Pyramid5 uid=" << cell_uid <<
" v=" << volume;
1100 else if (type_id == IT_Quad4) {
1101 Real surface = LimaVolume::Quad4Surface(local_coords.
data());
1102 if (surface < 0.0) {
1103 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1104 std::swap(own_cells_infos[cell_index + 2], own_cells_infos[cell_index + 3]);
1105 info() <<
"Surface negative Quad4 uid=" << cell_uid <<
" v=" << surface;
1109 else if (type_id == IT_Triangle3) {
1110 Real surface = LimaVolume::Triangle3Surface(local_coords.
data());
1111 if (surface < 0.0) {
1112 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1113 info() <<
"Surface negative Triangle3 uid=" << cell_uid <<
" v=" << surface;
1118 cell_index += current_nb_node;
1120 info() <<
"NB reoriented cell = " << nb_reoriented;
1123 logdate() <<
"Début allocation du maillage";
1124 mesh->allocateCells(own_nb_cell, own_cells_infos,
false);
1125 logdate() <<
"Fin allocation du maillage";
1129 for (
Integer i = 0, is = cells.
size(); i < is; ++i)
1130 cells[i]->setOwner(sid, sid);
1132 mesh->endAllocate();
1137 mesh->setOwnersFromCells();
1139 this->_createGroups(
mesh,
IK_Cell, wrapper.cellGroupReader(), 0);
1140 this->_createGroups(
mesh,
IK_Node, wrapper.nodeGroupReader(), 0);
1152 face_nodes_index.
reserve(100);
1157 size_type step_size = (mesh_nb_face > (
Int64)face_basic_step) ? face_basic_step : mesh_nb_face;
1160 Int64 current_nb_face = 0;
1161 Integer nb_lima_face_in_sub_domain = 0;
1162 info() <<
"Total_nb_face2=" << total_nb_face;
1166 for (
size_type i = 0; (i * step_size) < total_nb_face; ++i) {
1169 count = CheckedConvert::toInteger(wrapper.readFaces(i * step_size, step_size, buffer.
data()));
1171 pm->broadcast(buffer, master_rank);
1175 pm->broadcast(buffer, master_rank);
1178 info() <<
" Read Face2 N=" << i <<
" count=" << count <<
" step_size=" << step_size;
1179 orig_nodes_id.
clear();
1180 faces_first_node_unique_id.
clear();
1181 faces_nb_node.
resize(count);
1182 faces_nodes_unique_id.
clear();
1184 for (
Integer p = 0; p < count; ++p) {
1187 nodeCount = CheckedConvert::toInteger(*ptr++);
1192 faces_nb_node[p] = n;
1194 face_nodes_index.
resize(n);
1195 for (
Integer z = 0; z < nodeCount; ++z) {
1196 Integer node_local_id = CheckedConvert::toInteger(*ptr++);
1198 orig_nodes_id[z] = node_local_id - 1;
1202 for (
Integer z = 0; z < n; ++z)
1203 faces_nodes_unique_id.
add(orig_nodes_id[face_nodes_index[z]]);
1204 faces_first_node_unique_id.
add(orig_nodes_id[face_nodes_index[0]]);
1208 mesh->nodeFamily()->itemsUniqueIdToLocalId(faces_first_node_local_id, faces_first_node_unique_id,
false);
1210 Integer faces_nodes_unique_id_index = 0;
1211 for (
Integer i_face = 0; i_face < count; ++i_face) {
1212 Integer n = faces_nb_node[i_face];
1213 Int64ConstArrayView face_nodes_id(n, &faces_nodes_unique_id[faces_nodes_unique_id_index]);
1214 Int32 first_node_id = faces_first_node_local_id[i_face];
1216 if (first_node_id != NULL_ITEM_ID) {
1217 Node current_node(mesh_nodes[first_node_id]);
1218 Face face = mesh_utils::getFaceFromNodesUnique(current_node, face_nodes_id);
1222 faces_local_id.
add(current_nb_face + i_face, face.
localId());
1223 ++nb_lima_face_in_sub_domain;
1226 faces_nodes_unique_id_index += n;
1228 current_nb_face += count;
1230 info() <<
"NB LIMA FACE IN SUB-DOMAIN =" << nb_lima_face_in_sub_domain;
1233 this->_createGroups(
mesh,
IK_Face, wrapper.faceGroupReader(), &faces_local_id);
1239 const Node& node = *i;
1243 nodes_coord_var.synchronize();
1246 logdate() <<
"Fin de lecture du fichier";
1253template <
typename LimaMaliReader>
1256 Int64 current_unique_id)
1258 for (
Integer i = 0, is = coords.
size(); i < is; ++i) {
1259 Int64 uid = current_unique_id + i;
1262 d->value() = coords[i];
1269template <
typename LimaMaliReader>
1275 Integer master_rank = pm->masterIORank();
1276 Integer is_master_io = pm->isMasterIO();
1286 Integer nb_group = groups_name.size();
1288 sizes_infos[0] = nb_group;
1290 for (
Integer i = 0; i < nb_group; ++i) {
1292 String group_name = groups_name[i];
1293 pm->broadcastString(group_name, master_rank);
1296 lima_group_reader->read(group_name, unique_ids);
1297 Integer nb_item_in_group = unique_ids.size();
1298 sizes_infos[0] = nb_item_in_group;
1300 pm->broadcast(unique_ids, master_rank);
1302 _createGroupFromHashTable(
mesh, group_name, item_kind, unique_ids, *converter);
1304 _createGroupFromUniqueIds(
mesh, group_name, item_kind, unique_ids);
1310 Integer nb_group = sizes_infos[0];
1311 for (
Integer i = 0; i < nb_group; ++i) {
1313 pm->broadcastString(group_name, master_rank);
1316 Integer nb_item_in_group = sizes_infos[0];
1317 unique_ids.resize(nb_item_in_group);
1318 pm->broadcast(unique_ids, master_rank);
1320 _createGroupFromHashTable(
mesh, group_name, item_kind, unique_ids, *converter);
1322 _createGroupFromUniqueIds(
mesh, group_name, item_kind, unique_ids);
1330template <
typename LimaMaliReader>
1335 Integer nb_item_in_group = unique_ids.size();
1338 family->itemsUniqueIdToLocalId(local_ids, unique_ids,
false);
1340 for (
Integer i = 0; i < nb_item_in_group; ++i) {
1341 if (local_ids[i] != NULL_ITEM_ID)
1342 group_ids.add(local_ids[i]);
1344 info() <<
"Group Name <" << name <<
"> (" << nb_item_in_group <<
" elements)";
1351template <
typename LimaMaliReader>
1357 Integer nb_item_in_group = unique_ids.size();
1361 for (
Integer i = 0; i < nb_item_in_group; ++i) {
1364 group_ids.add(data->value());
1366 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