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
144 virtual ~LimaMalippMeshBase() =
default;
150 const String& filename,
Real length_multiplier) = 0;
160 Int64 current_unique_id);
175template <
typename ReaderWrapper>
176class LimaMalippReaderT
177:
public LimaMalippMeshBase<typename ReaderWrapper::LimaMaliReaderType>
185 typedef typename ReaderWrapper::LimaMaliReaderType LimaMaliReader;
190 : LimaMalippMeshBase<LimaMaliReader>(pm->
traceMng())
194 ~LimaMalippReaderT()
override
196 delete m_cut_infos_reader;
202 bool readMeshPart(
ITimerMng* timer_mng, LimaMaliReader* reader,
204 Real length_multiplier)
override;
209 ReaderWrapper m_wrapper;
212 const String& filename,
Real length_multiplier);
218template <
typename LimaMaliReader>
219class LimaMalippReaderWrapper
223 typedef LimaMaliReader LimaMaliReaderType;
224 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
228 LimaMalippReaderWrapper()
231 void setReader(LimaMaliReader* reader)
233 m_mali_reader = reader;
235 LimaMaliReader* reader()
237 return m_mali_reader;
243 _readGroup(
typename LimaMaliReader::SurfaceReader reader,
244 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
246 return reader.lire_mailles_ids(begin, n, buffer);
249 _readGroup(
typename LimaMaliReader::VolumeReader reader,
250 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
252 return reader.lire_mailles_ids(begin, n, buffer);
255 _readGroup(
typename LimaMaliReader::LigneReader reader,
256 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
258 return reader.lire_bras_ids(begin, n, buffer);
262 _readGroup(
typename LimaMaliReader::NuageReader reader,
263 Lima::size_type begin, Lima::size_type n, Lima::size_type* buffer)
265 return reader.lire_noeuds_ids(begin, n, buffer);
268 double* allocateNodesCoordsBuffer(Lima::size_type buf_size)
270 return m_mali_reader->allouer_tampon_coords(buf_size);
272 Lima::size_type* allocateNodesIdBuffer(Lima::size_type buf_size)
274 return m_mali_reader->allouer_tampon_ids(buf_size);
276 Lima::size_type readNodes(Lima::size_type begin, Lima::size_type count,
277 Lima::size_type* ids,
double* coords)
279 return m_mali_reader->lire_noeuds(begin, count, ids, coords);
282 template <
typename LimaGroupReader>
285 using namespace Lima;
289 const Integer nb_item = CheckedConvert::toInteger(reader.composition().nb_elements);
290 items_unique_id.
resize(nb_item);
291 const Integer step_size = nb_item > 10000 ? nb_item / 10 : nb_item;
292 buffer = reader.allouer_tampon_ids(step_size);
294 for (
Integer i = 0; i * step_size < nb_item; ++i) {
295 const Integer count = CheckedConvert::toInteger(_readGroup(reader, (
size_type)(i * step_size), (
size_type)step_size, buffer));
297 for (
Integer n = 0; n < count; ++n) {
299 items_unique_id[begin + n] = lima_id - 1;
310 LimaMaliReader* m_mali_reader;
319template <
typename LimaMaliReader>
327 virtual ~LimaGroupReader() {}
334 std::vector<std::string> groups;
335 _getGroupsName(groups);
336 m_groups_name.clear();
337 for (
size_t i = 0, is = groups.size(); i < is; ++i)
338 m_groups_name.add(
String(groups[i]));
339 return m_groups_name;
344 virtual void _getGroupsName(std::vector<std::string>& groups) = 0;
355template <
typename LimaMaliReader>
357:
public LimaGroupReader<LimaMaliReader>
362 : LimaGroupReader<LimaMaliReader>(wrapper)
366 typename LimaMaliReader::NuageReader r = this->m_wrapper->reader()->nuage(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_nuages(groups);
377template <
typename LimaMaliReader>
379:
public LimaGroupReader<LimaMaliReader>
384 : LimaGroupReader<LimaMaliReader>(wrapper)
388 typename LimaMaliReader::LigneReader r = this->m_wrapper->reader()->ligne(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_lignes(groups);
399template <
typename LimaMaliReader>
401:
public LimaGroupReader<LimaMaliReader>
406 : LimaGroupReader<LimaMaliReader>(wrapper)
411 typename LimaMaliReader::SurfaceReader r = this->m_wrapper->reader()->surface(name.
localstr());
412 this->m_wrapper->readGroup(r, items_unique_id);
414 virtual void _getGroupsName(std::vector<std::string>& groups)
416 this->m_wrapper->reader()->liste_surfaces(groups);
420template <
typename LimaMaliReader>
422:
public LimaGroupReader<LimaMaliReader>
427 : LimaGroupReader<LimaMaliReader>(wrapper)
432 typename LimaMaliReader::VolumeReader r = this->m_wrapper->reader()->volume(name.
localstr());
433 this->m_wrapper->readGroup(r, items_unique_id);
435 virtual void _getGroupsName(std::vector<std::string>& groups)
437 this->m_wrapper->reader()->liste_volumes(groups);
446template <
typename LimaMaliReader>
448:
public LimaMalippReaderWrapper<LimaMaliReader>
450 typedef LimaMalippReaderWrapper<LimaMaliReader> BaseClass;
451 using BaseClass::m_cell_group_reader;
452 using BaseClass::m_face_group_reader;
453 using BaseClass::m_mali_reader;
454 using BaseClass::m_node_group_reader;
458 typedef Lima::Composition LimaComposition;
459 typedef typename LimaMaliReader::SurfaceReader LimaCellGroup;
460 typedef typename LimaMaliReader::LigneReader LimaFaceGroup;
461 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
465 LimaComposition cells()
467 return m_mali_reader->composition_polygones();
470 LimaComposition faces()
472 return m_mali_reader->composition_bras();
475 LimaComposition nodes()
477 return m_mali_reader->composition_noeuds();
480 std::vector<std::string> cellGroups()
482 std::vector<std::string> groups;
483 m_mali_reader->liste_surfaces(groups);
489 if (!m_cell_group_reader.get())
491 return m_cell_group_reader.get();
496 if (!m_node_group_reader.get())
498 return m_node_group_reader.get();
503 if (!m_face_group_reader.get())
505 return m_face_group_reader.get();
508 std::vector<std::string> faceGroups()
510 std::vector<std::string> groups;
511 m_mali_reader->liste_lignes(groups);
515 std::vector<std::string> nodeGroups()
517 std::vector<std::string> groups;
518 m_mali_reader->liste_nuages(groups);
522 LimaCellGroup cellGroup(
const string& name)
524 return m_mali_reader->surface(name);
527 LimaFaceGroup faceGroup(
const string& name)
529 return m_mali_reader->ligne(name);
532 LimaNodeGroup nodeGroup(
const string& name)
534 return m_mali_reader->nuage(name);
537 Lima::size_type* allocateCellsBuffer(Lima::size_type buf_size)
539 return m_mali_reader->allouer_tampon_polygones(buf_size);
541 Lima::size_type readCells(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
543 return m_mali_reader->lire_polygones(begin, count, buffer);
545 Integer facesBufferSize(Lima::size_type buf_size)
551 return CheckedConvert::toInteger(8 * buf_size);
553 Lima::size_type readFaces(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
555 return m_mali_reader->lire_bras(begin, count, buffer);
566 const char* strDimension()
570 Real3 readNodeCoords(
const double* ptr)
572 return Real3(ptr[0], ptr[1], 0.0);
595template <
typename LimaMaliReader>
597:
public LimaMalippReaderWrapper<LimaMaliReader>
599 typedef LimaMalippReaderWrapper<LimaMaliReader> BaseClass;
600 using BaseClass::m_cell_group_reader;
601 using BaseClass::m_face_group_reader;
602 using BaseClass::m_mali_reader;
603 using BaseClass::m_node_group_reader;
607 typedef typename LimaMaliReader::VolumeReader LimaCellGroup;
608 typedef typename LimaMaliReader::SurfaceReader LimaFaceGroup;
609 typedef typename LimaMaliReader::NuageReader LimaNodeGroup;
610 typedef Lima::Composition LimaComposition;
614 LimaComposition cells()
616 return m_mali_reader->composition_polyedres();
618 LimaComposition faces()
620 return m_mali_reader->composition_polygones();
622 LimaComposition nodes()
624 return m_mali_reader->composition_noeuds();
631 typedef Lima::Polyedre LimaCell;
633 typedef Lima::Polygone LimaFace;
637 if (!m_cell_group_reader.get())
639 return m_cell_group_reader.get();
644 if (!m_face_group_reader.get())
646 return m_face_group_reader.get();
651 if (!m_node_group_reader.get())
653 return m_node_group_reader.get();
656 std::vector<std::string> cellGroups()
658 std::vector<std::string> groups;
659 m_mali_reader->liste_volumes(groups);
663 std::vector<std::string> faceGroups()
665 std::vector<std::string> groups;
666 m_mali_reader->liste_surfaces(groups);
670 std::vector<std::string> nodeGroups()
672 std::vector<std::string> groups;
673 m_mali_reader->liste_nuages(groups);
677 LimaCellGroup cellGroup(
const string& name)
679 return m_mali_reader->volume(name);
681 LimaFaceGroup faceGroup(
const string& name)
683 return m_mali_reader->surface(name);
685 LimaNodeGroup nodeGroup(
const string& name)
687 return m_mali_reader->nuage(name);
689 Lima::size_type* allocateCellsBuffer(Lima::size_type buf_size)
691 return m_mali_reader->allouer_tampon_polyedres(buf_size);
693 Lima::size_type readCells(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
695 return m_mali_reader->lire_polyedres(begin, count, buffer);
697 Integer facesBufferSize(Lima::size_type buf_size)
703 return CheckedConvert::toInteger(14 * buf_size);
705 Lima::size_type readFaces(Lima::size_type begin, Lima::size_type count, Lima::size_type* buffer)
707 return m_mali_reader->lire_polygones(begin, count, buffer);
718 const char* strDimension()
722 Real3 readNodeCoords(
const double* ptr)
724 return Real3(ptr[0], ptr[1], ptr[2]);
730 return IT_Tetraedron4;
734 return IT_Pentaedron6;
736 return IT_Hexaedron8;
738 return IT_Heptaedron10;
740 return IT_Octaedron12;
753template <
typename LimaMaliReader>
754class LimaMalippReader
767 const String& file_name,
Real length_multiplier);
775template <
typename LimaMaliReader>
778 const String& filename,
Real length_multiplier)
790 reader =
new LimaMaliReader(filename.
localstr(), 1);
792 catch (
const Lima::erreur& ex) {
793 ARCANE_FATAL(
"Impossible de lire le fichier MLI Lima <{0}> :", filename, ex.what());
796 ARCANE_FATAL(
"Impossible de lire le fichier MLI Lima <{0}>", filename);
798 dimension = reader->dimension();
804 if (dimension == Lima::D3) {
805 info() <<
"Maillage 3D";
806 mesh->setDimension(3);
809 else if (dimension == Lima::D2) {
810 info() <<
"Maillage 2D";
811 mesh->setDimension(2);
818 log() <<
"Dimension du maillage non reconnue par lima";
821 bool ret = lm->readMeshPart(timer_mng, reader.
get(),
mesh, filename, length_multiplier);
830template <
typename ReaderWrapper>
833 const String& filename,
Real length_multiplier)
835 return _readMeshPart(timer_mng, reader,
mesh, filename, length_multiplier);
845template <
typename ReaderWrapper>
848 const String& file_name,
Real length_multiplier)
860 this->
pwarning() <<
"Chargement Lima du fichier USING MALIPP avec partitionnement '" << file_name <<
'"';
861 if (basic_step < 100000)
862 this->
pwarning() <<
"Small basic_step value=" << basic_step;
864 const char* version = Lima::lima_version();
865 info() <<
"Utilisation de la version " << version <<
" de Lima";
869 this->
log() <<
"Début lecture fichier " << file_name;
871 ReaderWrapper wrapper;
872 wrapper.setReader(reader);
874 if (reader && reader->dimension() != wrapper.limaDimension())
875 ARCANE_FATAL(
"Le fichier n'est pas un maillage {0}", wrapper.strDimension());
877 bool is_3d = (
mesh->dimension() == 3);
879 Int64 mesh_nb_node = 0;
880 Int64 mesh_nb_cell = 0;
881 Int64 mesh_nb_face = 0;
885 Lima::Composition lima_cells = wrapper.cells();
886 Lima::Composition lima_nodes = wrapper.nodes();
887 Lima::Composition lima_faces = wrapper.faces();
889 mesh_nb_node = (
Int64)lima_nodes.nb_elements;
890 mesh_nb_cell = (
Int64)lima_cells.nb_elements;
891 mesh_nb_face = (
Int64)lima_faces.nb_elements;
893 nb_items[0] = mesh_nb_node;
894 nb_items[1] = mesh_nb_cell;
895 nb_items[2] = mesh_nb_face;
898 info() <<
"Unité de longueur du fichier: " << reader->unite_longueur();
899 if (length_multiplier == 0.0)
900 length_multiplier = 1.0;
902 length_multiplier *= reader->unite_longueur();
903 pm->broadcast(
RealArrayView(1, &length_multiplier), master_rank);
908 mesh_nb_node = nb_items[0];
909 mesh_nb_cell = nb_items[1];
910 mesh_nb_face = nb_items[2];
911 pm->broadcast(
RealArrayView(1, &length_multiplier), master_rank);
917 info() <<
"-- Informations sur le maillage (Lima):";
918 info() <<
"Nombre de noeuds " << mesh_nb_node;
919 info() <<
"Nombre d'arêtes " << nb_edge;
920 info() <<
"Nombre de faces " << mesh_nb_face;
921 info() <<
"Nombre de mailles " << mesh_nb_cell;
922 if (mesh_nb_node == 0) {
923 ARCANE_FATAL(
"Pas de noeuds dans le fichier de maillage.");
928 Int64 uid_to_add = 0;
931 info() <<
"WARNING: UniqueId begin at 1";
934 Integer average_nb_cell = CheckedConvert::toInteger(mesh_nb_cell / nb_rank);
943 cells_infos.
reserve(average_nb_cell * 2);
945 Integer cell_step = average_nb_cell;
947 ARCANE_FATAL(
"Number of cells is less than number of sub domains");
950 size_type* buffer = wrapper.allocateCellsBuffer(cell_step + nb_rank);
951 Int64 total_nb_cell = mesh_nb_cell;
955 for (
Integer i = 0; total_count < total_nb_cell; ++i) {
957 ARCANE_FATAL(
"Too many count reading cells i={0} nrank=", i, nb_rank);
958 Int64 wanted_count = cell_step;
960 if ((i + 1) == nb_rank)
961 wanted_count = mesh_nb_cell;
962 Integer count = CheckedConvert::toInteger(wrapper.readCells(i * cell_step, wanted_count, buffer));
964 Integer p = (i * 20) / nb_rank;
965 if (p > last_print) {
967 info() <<
"Reading cells rank=" << i <<
" n=" << wanted_count <<
" count=" << count
968 <<
" (" << (p * 5) <<
"%)";
970 current_nb_cell = count;
971 total_count += count;
974 for (
Integer p = 0; p < count; ++p) {
975 Integer cell_local_id = CheckedConvert::toInteger(*ptr++);
976 const Lima::size_type nodeCount = *ptr++;
977 Integer n = CheckedConvert::toInteger(nodeCount);
978 Integer ct = ReaderWrapper::cellToType(n);
979 if (ct == IT_NullType)
984 cells_infos.
add(uid_to_add + cell_local_id - 1);
986 for (Lima::size_type z = 0; z < nodeCount; ++z) {
987 Int64 node_local_id = *ptr++;
988 cells_infos.
add(uid_to_add + node_local_id - 1);
991 if (i != master_rank) {
993 nb_cells_infos[0] = current_nb_cell;
994 nb_cells_infos[1] = cells_infos.
size();
996 pm->send(cells_infos, i);
999 own_nb_cell = current_nb_cell;
1000 own_cells_infos = cells_infos;
1008 own_nb_cell = nb_cells_infos[0];
1009 own_cells_infos.
resize(nb_cells_infos[1]);
1010 pm->
recv(own_cells_infos, master_rank);
1014 info() <<
" READ COORDINATES 1";
1020 for (
Integer i = 0; i < own_nb_cell; ++i) {
1027 for (
Integer z = 0; z < current_nb_node; ++z) {
1028 Int64 node_uid = own_cells_infos[cell_index + z];
1029 nodes_coords.
add(node_uid,
Real3());
1031 cell_index += current_nb_node;
1035 info() <<
" READ COORDINATES 2";
1039 size_type step_size = (lima_nb_node > basic_step) ? basic_step : mesh_nb_node;
1041 size_type* idBuffer = reader->allouer_tampon_ids(step_size);
1042 double* coordsBuffer = reader->allouer_tampon_coords(step_size);
1043 Integer dim_step = reader->dimension();
1045 for (
Integer i = 0; i < mesh_nb_node;) {
1046 Integer count = CheckedConvert::toInteger(reader->lire_noeuds(i, step_size, idBuffer, coordsBuffer));
1047 current_coords.
clear();
1048 for (
Integer n = 0; n < count; ++n, ++nodeCount) {
1053 coord.
x = coordsBuffer[n];
1056 coord.
x = coordsBuffer[2 * n];
1057 coord.
y = coordsBuffer[(2 * n) + 1];
1060 coord.
x = coordsBuffer[3 * n];
1061 coord.
y = coordsBuffer[(3 * n) + 1];
1062 coord.
z = coordsBuffer[(3 * n) + 2];
1065 if (length_multiplier != 1.0)
1066 current_coords.
add(coord * length_multiplier);
1068 current_coords.
add(coord);
1071 sizes_info[0] = count;
1074 pm->broadcast(current_coords, master_rank);
1075 this->_setCoords(current_coords, nodes_coords, i + uid_to_add);
1079 delete[] coordsBuffer;
1083 for (
Int64 i = 0; i < mesh_nb_node;) {
1086 Integer count = sizes_info[0];
1087 current_coords.
resize(count);
1089 pm->broadcast(current_coords, master_rank);
1090 this->_setCoords(current_coords, nodes_coords, i + uid_to_add);
1095 info() <<
" READ CELLS";
1106 for (
Integer i = 0; i < own_nb_cell; ++i) {
1109 Int64 cell_uid = own_cells_infos[cell_index];
1113 local_coords.
resize(current_nb_node);
1114 for (
Integer z = 0; z < current_nb_node; ++z)
1115 local_coords[z] = nodes_coords.
lookupValue(own_cells_infos[cell_index + z]);
1116 if (type_id == IT_Hexaedron8) {
1117 Real volume = LimaVolume::Hexaedron8Volume(local_coords.
data());
1119 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1120 std::swap(own_cells_infos[cell_index + 3], own_cells_infos[cell_index + 2]);
1121 std::swap(own_cells_infos[cell_index + 4], own_cells_infos[cell_index + 5]);
1122 std::swap(own_cells_infos[cell_index + 7], own_cells_infos[cell_index + 6]);
1123 info() <<
"Volume negatif Hexaedron8 uid=" << cell_uid <<
" v=" << volume;
1127 else if (type_id == IT_Pyramid5) {
1128 Real volume = LimaVolume::Pyramid5Volume(local_coords.
data());
1130 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1131 std::swap(own_cells_infos[cell_index + 2], own_cells_infos[cell_index + 3]);
1132 info() <<
"Volume negatif Pyramid5 uid=" << cell_uid <<
" v=" << volume;
1136 else if (type_id == IT_Quad4) {
1137 Real surface = LimaVolume::Quad4Surface(local_coords.
data());
1138 if (surface < 0.0) {
1139 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1140 std::swap(own_cells_infos[cell_index + 2], own_cells_infos[cell_index + 3]);
1141 info() <<
"Surface negative Quad4 uid=" << cell_uid <<
" v=" << surface;
1145 else if (type_id == IT_Triangle3) {
1146 Real surface = LimaVolume::Triangle3Surface(local_coords.
data());
1147 if (surface < 0.0) {
1148 std::swap(own_cells_infos[cell_index + 0], own_cells_infos[cell_index + 1]);
1149 info() <<
"Surface negative Triangle3 uid=" << cell_uid <<
" v=" << surface;
1154 cell_index += current_nb_node;
1156 info() <<
"NB reoriented cell = " << nb_reoriented;
1159 logdate() <<
"Start mesh allocation";
1160 mesh->allocateCells(own_nb_cell, own_cells_infos,
false);
1161 logdate() <<
"End mesh allocation";
1165 for (
Integer i = 0, is = cells.
size(); i < is; ++i)
1166 cells[i]->setOwner(sid, sid);
1168 mesh->endAllocate();
1173 mesh->setOwnersFromCells();
1175 this->_createGroups(
mesh,
IK_Cell, wrapper.cellGroupReader(), 0);
1176 this->_createGroups(
mesh,
IK_Node, wrapper.nodeGroupReader(), 0);
1188 face_nodes_index.
reserve(100);
1193 size_type step_size = (mesh_nb_face > (
Int64)face_basic_step) ? face_basic_step : mesh_nb_face;
1196 Int64 current_nb_face = 0;
1197 Integer nb_lima_face_in_sub_domain = 0;
1198 info() <<
"Total_nb_face2=" << total_nb_face;
1202 for (
size_type i = 0; (i * step_size) < total_nb_face; ++i) {
1205 count = CheckedConvert::toInteger(wrapper.readFaces(i * step_size, step_size, buffer.
data()));
1207 pm->broadcast(buffer, master_rank);
1211 pm->broadcast(buffer, master_rank);
1214 info() <<
" Read Face2 N=" << i <<
" count=" << count <<
" step_size=" << step_size;
1215 orig_nodes_id.
clear();
1216 faces_first_node_unique_id.
clear();
1217 faces_nb_node.
resize(count);
1218 faces_nodes_unique_id.
clear();
1220 for (
Integer p = 0; p < count; ++p) {
1223 nodeCount = CheckedConvert::toInteger(*ptr++);
1228 faces_nb_node[p] = n;
1230 face_nodes_index.
resize(n);
1231 for (
Integer z = 0; z < nodeCount; ++z) {
1232 Integer node_local_id = CheckedConvert::toInteger(*ptr++);
1234 orig_nodes_id[z] = node_local_id - 1;
1238 for (
Integer z = 0; z < n; ++z)
1239 faces_nodes_unique_id.
add(orig_nodes_id[face_nodes_index[z]]);
1240 faces_first_node_unique_id.
add(orig_nodes_id[face_nodes_index[0]]);
1244 mesh->nodeFamily()->itemsUniqueIdToLocalId(faces_first_node_local_id, faces_first_node_unique_id,
false);
1246 Integer faces_nodes_unique_id_index = 0;
1247 for (
Integer i_face = 0; i_face < count; ++i_face) {
1248 Integer n = faces_nb_node[i_face];
1249 Int64ConstArrayView face_nodes_id(n, &faces_nodes_unique_id[faces_nodes_unique_id_index]);
1250 Int32 first_node_id = faces_first_node_local_id[i_face];
1252 if (first_node_id != NULL_ITEM_ID) {
1253 Node current_node(mesh_nodes[first_node_id]);
1254 Face face = mesh_utils::getFaceFromNodesUnique(current_node, face_nodes_id);
1258 faces_local_id.
add(current_nb_face + i_face, face.
localId());
1259 ++nb_lima_face_in_sub_domain;
1262 faces_nodes_unique_id_index += n;
1264 current_nb_face += count;
1266 info() <<
"NB LIMA FACE IN SUB-DOMAIN =" << nb_lima_face_in_sub_domain;
1269 this->_createGroups(
mesh,
IK_Face, wrapper.faceGroupReader(), &faces_local_id);
1275 const Node& node = *i;
1279 nodes_coord_var.synchronize();
1282 logdate() <<
"End file reading";
1289template <
typename LimaMaliReader>
1292 Int64 current_unique_id)
1294 for (
Integer i = 0, is = coords.
size(); i < is; ++i) {
1295 Int64 uid = current_unique_id + i;
1298 d->value() = coords[i];
1305template <
typename LimaMaliReader>
1311 Integer master_rank = pm->masterIORank();
1312 Integer is_master_io = pm->isMasterIO();
1322 Integer nb_group = groups_name.size();
1324 sizes_infos[0] = nb_group;
1326 for (
Integer i = 0; i < nb_group; ++i) {
1328 String group_name = groups_name[i];
1329 pm->broadcastString(group_name, master_rank);
1332 lima_group_reader->read(group_name, unique_ids);
1333 Integer nb_item_in_group = unique_ids.size();
1334 sizes_infos[0] = nb_item_in_group;
1336 pm->broadcast(unique_ids, master_rank);
1338 _createGroupFromHashTable(
mesh, group_name, item_kind, unique_ids, *converter);
1340 _createGroupFromUniqueIds(
mesh, group_name, item_kind, unique_ids);
1346 Integer nb_group = sizes_infos[0];
1347 for (
Integer i = 0; i < nb_group; ++i) {
1349 pm->broadcastString(group_name, master_rank);
1352 Integer nb_item_in_group = sizes_infos[0];
1353 unique_ids.resize(nb_item_in_group);
1354 pm->broadcast(unique_ids, master_rank);
1356 _createGroupFromHashTable(
mesh, group_name, item_kind, unique_ids, *converter);
1358 _createGroupFromUniqueIds(
mesh, group_name, item_kind, unique_ids);
1366template <
typename LimaMaliReader>
1371 Integer nb_item_in_group = unique_ids.size();
1374 family->itemsUniqueIdToLocalId(local_ids, unique_ids,
false);
1376 for (
Integer i = 0; i < nb_item_in_group; ++i) {
1377 if (local_ids[i] != NULL_ITEM_ID)
1378 group_ids.add(local_ids[i]);
1380 info() <<
"Group Name <" << name <<
"> (" << nb_item_in_group <<
" elements)";
1387template <
typename LimaMaliReader>
1393 Integer nb_item_in_group = unique_ids.size();
1397 for (
Integer i = 0; i < nb_item_in_group; ++i) {
1400 group_ids.add(data->value());
1402 info() <<
"Group Name <" << name <<
"> (" << nb_item_in_group <<
" elements)";
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Various mathematical functions.
Utility functions for the mesh.
bool reorderNodesOfFace2(Int64ConstArrayView nodes_unique_id, Int32ArrayView new_index)
Reorders the nodes of a face.
This file contains the various service factories and macros for registering services.
Integer size() const
Number of elements in the vector.
void resize(Int64 s)
Changes the number of elements in the array to s.
void clear()
Removes the elements from the array.
void add(ConstReferenceType val)
Adds element val to the end of the array.
const T * data() const
Access to the root of the array without any protection.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
constexpr Integer size() const noexcept
Number of elements in the array.
Hash table for associative arrays.
Data * lookup(KeyTypeConstRef id)
Searches for the value corresponding to key id.
ValueType & lookupValue(KeyTypeConstRef id)
Searches for the value corresponding to key id.
bool add(KeyTypeConstRef id, const ValueType &value)
Adds the value value corresponding to key id.
Interface of an entity family.
eReturnType
Types of return codes for a read or write operation.
@ RTIrrelevant
Not relevant to the operation. This means that the file format does not match this reader or that the...
@ RTError
Error during the operation.
@ RTOk
Operation successfully performed.
Interface of the parallelism manager for a subdomain.
virtual ITraceMng * traceMng() const =0
Trace manager.
virtual Int32 commRank() const =0
Rank of this instance in the communicator.
virtual void recv(ArrayView< char > values, Int32 rank)=0
virtual bool isMasterIO() const =0
true if the instance is a master I/O manager.
virtual Int32 commSize() const =0
Number of instances in the communicator.
virtual Integer masterIORank() const =0
Rank of the instance managing I/O (for which isMasterIO() is true).
Interface of a timer manager.
Info on a mesh entity type.
Integer nbLocalNode() const
Number of nodes of the entity.
Mesh entity type manager.
ItemTypeInfo * typeFromId(Integer id) const
Type corresponding to the number id.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
constexpr bool null() const
true if the entity is null (i.e. not connected to the mesh)
Construction of a 3D mesh.
Mesh file reader via the LIMA library for '.mli' or 'mli2' files.
Mesh file reader via the LIMA library.
TraceMessage logdate() const
Flow for a log message preceded by the date.
TraceMessage log() const
Flow for a log message.
TraceMessage info() const
Flow for an information message.
bool _readMeshPart(ITimerMng *timer_mng, LimaMaliReader *reader, IPrimaryMesh *mesh, const String &filename, Real length_multiplier)
Mesh reading. Only the master process has a non-null instance of reader. Others must not use it.
Mesh file reader via the LIMA library.
static void createGroup(IItemFamily *family, const String &name, Int32ArrayView local_ids)
Creates a group of entities.
Exception when an operation is not supported.
T * get() const
Returns the object referenced by the instance.
Class managing a 3-dimensional real vector.
Encapsulation of an automatically destructing pointer.
Unicode character string.
bool null() const
Returns true if the string is null.
const char * localstr() const
Returns the conversion of the instance into UTF-8 encoding.
bool empty() const
True if the string is empty (null or "").
@ TimerReal
Timer using real time.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage logdate() const
Flow for a log message preceded by the date.
TraceMessage log() const
Flow for a log message.
TraceMessage info() const
Flow for an information message.
TraceMessage pwarning() const
1D data vector with value semantics (STL style).
Exception when a mesh entity is not of a known type.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
__host__ __device__ double log(double v)
Natural logarithm of v.
__host__ __device__ Real matDet(Real3 u, Real3 v, Real3 w)
Determinant of the matrix u,v,w.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Int64 > Int64Array
Dynamic one-dimensional array of 64-bit integers.
ArrayView< Int64 > Int64ArrayView
C equivalent of a 1D array of 64-bit integers.
ConstArrayView< Real3 > Real3ConstArrayView
C equivalent of a 1D array of Real3.
UniqueArray< Int64 > Int64UniqueArray
Dynamic 1D array of 64-bit integers.
ConstArrayView< String > StringConstArrayView
C equivalent of a 1D array of strings.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
UniqueArray< Real3 > Real3UniqueArray
Dynamic 1D array of rank 3 vectors.
ArrayView< Integer > IntegerArrayView
C equivalent of a 1D array of integers.
ConstArrayView< ItemInternal * > ItemInternalList
Type of the internal list of entities.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
eItemKind
Mesh entity type.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
@ IK_Face
Face mesh entity.
double Real
Type representing a real number.
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.
UniqueArray< Integer > IntegerUniqueArray
Dynamic 1D array of integers.
ConstArrayView< Integer > IntegerConstArrayView
C equivalent of a 1D array of integers.
ArrayView< Real > RealArrayView
C equivalent of a 1D array of reals.
std::int32_t Int32
Signed integer type of 32 bits.
Real y
second component of the triplet
Real z
third component of the triplet
Real x
first component of the triplet