14#include "arcane/utils/StringBuilder.h"
15#include "arcane/utils/Enumerator.h"
16#include "arcane/utils/Iterator.h"
17#include "arcane/utils/List.h"
18#include "arcane/utils/ScopedPtr.h"
19#include "arcane/utils/PlatformUtils.h"
20#include "arcane/utils/Iostream.h"
21#include "arcane/utils/Deleter.h"
22#include "arcane/utils/ITraceMng.h"
23#include "arcane/utils/OStringStream.h"
24#include "arcane/utils/NotImplementedException.h"
25#include "arcane/utils/CStringUtils.h"
26#include "arcane/utils/Convert.h"
28#include "arcane/core/IDataWriter.h"
29#include "arcane/core/Item.h"
31#include "arcane/core/IVariable.h"
32#include "arcane/core/ISubDomain.h"
33#include "arcane/core/IMesh.h"
34#include "arcane/core/IMeshSubMeshTransition.h"
35#include "arcane/core/StdNum.h"
36#include "arcane/core/ItemGroup.h"
37#include "arcane/core/IParallelMng.h"
38#include "arcane/core/Directory.h"
39#include "arcane/core/MeshVariable.h"
40#include "arcane/core/PostProcessorWriterBase.h"
41#include "arcane/core/Service.h"
42#include "arcane/core/SimpleProperty.h"
43#include "arcane/core/IItemFamily.h"
44#include "arcane/core/VariableCollection.h"
45#include "arcane/core/SharedVariable.h"
47#include "arcane/core/FactoryService.h"
50#include "arcane/std/Ensight7PostProcessor_axl.h"
51#include "arcane/std/DumpW.h"
55#include <unordered_map>
102 static const int int_width = 10;
103 static const int g_line_length = 80;
123 EnsightPart(
const EnsightPart& part)
128 , m_reindex(part.m_reindex)
135 inline int type()
const {
return m_type; }
140 inline bool hasReindex()
const {
return !m_reindex.empty(); }
141 inline void setReindex(
Integer* reindex)
145 m_reindex[i] = reindex[i];
179 _init(use_degenerated_hexa);
185 n += m_parts[i].items().size();
188 const EnsightPart& typeInfo(
Integer i)
const {
return m_parts[i]; }
189 EnsightPart& typeInfo(
Integer i) {
return m_parts[i]; }
190 ItemGroup group()
const {
return m_group; }
192 Int32 generalItemTypeId(
const Item& item)
const
197 EnsightPart* getTypeInfo(
int type)
199 auto ensight_part_element = m_parts_map.find(type);
200 if (ensight_part_element != m_parts_map.end())
201 return ensight_part_element->second;
211 bool m_is_polygonal_type_registration_done =
false;
212 bool m_is_polyhedral_type_registration_done =
false;
216 std::unordered_map<TypeId, EnsightPart*> m_parts_map;
222 for (
auto& ensight_part : m_parts) {
223 m_parts_map[ensight_part.type()] = &ensight_part;
227 void _init(
bool use_degenerated_hexa)
236 m_parts.add(
EnsightPart(IT_Triangle3, 3,
"tria3"));
238 m_parts.add(
EnsightPart(IT_Pentagon5, 5,
"nsided"));
239 m_parts.add(
EnsightPart(IT_Hexagon6, 6,
"nsided"));
240 m_parts.add(
EnsightPart(IT_Heptagon7, 7,
"nsided"));
241 m_parts.add(
EnsightPart(IT_Octogon8, 8,
"nsided"));
252 if (!m_is_polygonal_type_registration_done) {
254 ItemWithNodes item = iitem->toItemWithNodes();
255 if (item.nbNode() == item.itemBase().nbEdge()) {
257 m_parts.
add(EnsightPart(type_id++, item.nbNode(),
"nsided"));
260 m_is_polygonal_type_registration_done =
true;
263 m_parts.add(EnsightPart(IT_Tetraedron4, 4,
"tetra4"));
264 m_parts.add(EnsightPart(IT_Pyramid5, 5,
"pyramid5"));
265 m_parts.add(EnsightPart(IT_Pentaedron6, 6,
"penta6"));
266 m_parts.add(EnsightPart(IT_Hexaedron8, 8,
"hexa8"));
267 if (use_degenerated_hexa) {
268 m_parts.add(EnsightPart(IT_HemiHexa7, 8,
"hexa8"));
270 Integer reindex[8] = { 1, 6, 5, 0, 2, 3, 4, 0 };
271 m_parts[m_parts.size() - 1].setReindex(reindex);
273 m_parts.add(EnsightPart(IT_HemiHexa6, 8,
"hexa8"));
275 Integer reindex[8] = { 0, 1, 3, 5, 0, 2, 3, 4 };
276 m_parts[m_parts.size() - 1].setReindex(reindex);
278 m_parts.add(EnsightPart(IT_HemiHexa5, 8,
"hexa8"));
280 Integer reindex[8] = { 0, 1, 3, 4, 0, 2, 3, 4 };
281 m_parts[m_parts.size() - 1].setReindex(reindex);
283 m_parts.add(EnsightPart(IT_AntiWedgeLeft6, 8,
"hexa8"));
285 Integer reindex[8] = { 2, 0, 1, 2, 5, 3, 4, 4 };
286 m_parts[m_parts.size() - 1].setReindex(reindex);
288 m_parts.add(EnsightPart(IT_AntiWedgeRight6, 8,
"hexa8"));
290 Integer reindex[8] = { 2, 0, 1, 1, 5, 3, 4, 5 };
291 m_parts[m_parts.size() - 1].setReindex(reindex);
293 m_parts.add(EnsightPart(IT_DiTetra5, 8,
"hexa8"));
295 Integer reindex[8] = { 4, 4, 2, 3, 0, 1, 1, 3 };
296 m_parts[m_parts.size() - 1].setReindex(reindex);
300 m_parts.add(EnsightPart(IT_HemiHexa7, 7,
"nfaced"));
301 m_parts.add(EnsightPart(IT_HemiHexa6, 6,
"nfaced"));
302 m_parts.add(EnsightPart(IT_HemiHexa5, 5,
"nfaced"));
303 m_parts.add(EnsightPart(IT_AntiWedgeLeft6, 6,
"nfaced"));
304 m_parts.add(EnsightPart(IT_AntiWedgeRight6, 6,
"nfaced"));
305 m_parts.add(EnsightPart(IT_DiTetra5, 5,
"nfaced"));
307 m_parts.add(EnsightPart(IT_Heptaedron10, 10,
"nfaced"));
308 m_parts.add(EnsightPart(IT_Octaedron12, 12,
"nfaced"));
309 m_parts.add(EnsightPart(IT_Enneedron14, 14,
"nfaced"));
310 m_parts.add(EnsightPart(IT_Decaedron16, 16,
"nfaced"));
313 ItemTypeInfo* type_info = item_type_mng->
typeFromId(i_type);
314 if (type_info->nbLocalNode() != type_info->nbLocalEdge()) {
315 m_parts.add(EnsightPart(i_type, type_info->nbLocalNode(),
"nfaced"));
320 if (!m_is_polyhedral_type_registration_done) {
322 ItemWithNodes item = iitem->toItemWithNodes();
323 if (item.nbNode() == 1)
325 else if (item.nbNode() == 2)
327 else if (item.typeInfo()->isPolyhedron()) {
329 m_parts.add(EnsightPart(type_id++, item.nbNode(),
"nfaced"));
331 else if (item.nbNode() != item.itemBase().nbEdge()) {
333 m_parts.add(EnsightPart(type_id++, item.nbNode(),
"nfaced"));
336 m_is_polyhedral_type_registration_done =
true;
349 void writeFileString(std::ostream& o,
const String& str);
350 void writeFileInt(std::ostream& o,
int value);
351 void writeFileDouble(std::ostream& o,
double value);
352 Integer writeDoubleSize()
const;
376 explicit WriteBase(DumpWEnsight7& dw)
383 WriteBase(
const WriteBase& wb)
387 virtual ~WriteBase() {}
391 virtual WriteBase* clone() = 0;
392 virtual void begin() { init(); }
393 virtual void end() {}
398 m_ofile.precision(5);
399 m_ofile.flags(std::ios::scientific);
401 virtual void putValue(std::ostream& ofile)
403 ofile << m_ofile.str();
405 std::ostream& stream() {
return m_ofile; }
410 std::ostringstream m_ofile;
417 template <
typename FromType>
427 WriteDouble(
const WriteDouble& wd)
432 WriteBase* clone()
override {
return new WriteDouble(*
this); }
440 inline void write(
Integer index)
443 int reindex = (*m_idx)[index];
454 for (
Item e : items) {
463 template <
typename FromType>
464 class WriteArrayDouble
475 WriteArrayDouble(
const WriteArrayDouble& wd)
478 , m_idim2(wd.m_idim2)
481 WriteBase* clone()
override {
return new WriteArrayDouble(*
this); }
493 int reindex = (*m_idx)[index];
504 for (
Item e : items) {
526 WriteReal3(
const WriteReal3& wd)
531 WriteBase* clone()
override {
return new WriteReal3(*
this); }
539 void begin()
override
543 xostr.flags(std::ios::scientific);
545 yostr.flags(std::ios::scientific);
547 zostr.flags(std::ios::scientific);
553 int reindex = (*m_idx)[index];
569 for (
Item i : items) {
576 m_ofile << xostr.str();
577 m_ofile << yostr.str();
578 m_ofile << zostr.str();
583 std::ostringstream xostr;
584 std::ostringstream yostr;
585 std::ostringstream zostr;
598 class WriteArrayReal3
609 WriteArrayReal3(
const WriteArrayReal3& wd)
612 , m_idim2(wd.m_idim2)
615 WriteBase* clone()
override {
return new WriteArrayReal3(*
this); }
624 void begin()
override
628 xostr.flags(std::ios::scientific);
630 yostr.flags(std::ios::scientific);
632 zostr.flags(std::ios::scientific);
635 inline void write(
Integer index)
638 int reindex = (*m_idx)[index];
652 for (
Item i : items) {
659 m_ofile << xostr.str();
660 m_ofile << yostr.str();
661 m_ofile << zostr.str();
666 std::ostringstream xostr;
667 std::ostringstream yostr;
668 std::ostringstream zostr;
682 bool is_binary,
bool is_parallel,
Integer fileset_size,
683 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids);
690 void writeVal(IVariable&, ConstArrayView<Real2>)
override {}
691 void writeVal(IVariable&, ConstArrayView<Real3>)
override;
695 void writeVal(IVariable&, ConstArrayView<Real2x2>)
override {}
696 void writeVal(IVariable&, ConstArrayView<Real3x3>)
override {}
697 void writeVal(IVariable&, ConstArrayView<String>)
override {}
699 void writeVal(IVariable&, ConstArray2View<Byte>)
override {}
701 void writeVal(IVariable&, ConstArray2View<Real2>)
override {}
702 void writeVal(IVariable&, ConstArray2View<Real3>)
override;
706 void writeVal(IVariable&, ConstArray2View<Real2x2>)
override {}
707 void writeVal(IVariable&, ConstArray2View<Real3x3>)
override {}
709 void writeVal(IVariable&, ConstMultiArray2View<Byte>)
override {}
711 void writeVal(IVariable&, ConstMultiArray2View<Real2>)
override {}
712 void writeVal(IVariable&, ConstMultiArray2View<Real3> a)
override;
716 void writeVal(IVariable&, ConstMultiArray2View<Real2x2>)
override {}
717 void writeVal(IVariable&, ConstMultiArray2View<Real3x3>)
override {}
724 bool isMasterProcessor()
const {
return m_is_master; }
725 bool isOneFilePerTime()
const {
return m_fileset_size == 0; }
732 typedef UniqueArray<GroupPartInfo*> GroupPartInfoList;
741 std::ostringstream m_case_file_variables;
745 GroupPartInfoList m_parts;
751 bool m_use_degenerated_hexa;
752 bool m_force_first_geometry;
772 void _createCaseFile();
775 void _writeWildcardFilename(std::ostream& ofile,
const String& filename,
char joker =
'*');
776 int _fileOuttype()
const;
777 void _writeFileHeader(std::ostream& o,
bool write_c_binary);
778 bool _isNewBlocFile()
const;
781 void _saveGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
783 void _saveVariableOnGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
788 template <
typename T>
791 template <
typename T>
794 template <
typename T>
806 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
807 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
810 is_parallel_output, fileset_size, use_degenerated_hexa,
811 force_first_geometry, save_uids);
815createEnsight7(IMesh* m,
const String& f,
816 ConstArrayView<Real> times,
817 VariableCollection variables,
819 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
820 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
822 return new DumpWEnsight7(m, f, times, variables, groups, is_binary,
823 is_parallel_output, fileset_size, use_degenerated_hexa,
824 force_first_geometry, save_uids);
833 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
834 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
837, m_parallel_mng(
mesh->parallelMng())
838, m_base_directory(filename)
840, m_save_variables(variables.clone())
841, m_save_groups(groups.enumerator())
842, m_is_binary(is_binary)
845, m_is_parallel_output(is_parallel_output)
846, m_use_degenerated_hexa(use_degenerated_hexa)
847, m_force_first_geometry(force_first_geometry)
848, m_save_uids(save_uids)
849, m_total_nb_element(0)
851, m_fileset_size(fileset_size)
870 std::for_each(std::begin(m_parts), std::end(m_parts), Deleter());
927 Integer type_to_seek = type_info.type();
930 if (e.
type() == type_to_seek)
935 << nb_of_type <<
" items of type " << type_info.name();
939 if (mi.
type() == type_to_seek) {
949 const Item& item = *i2;
950 auto item_type = current_grp.generalItemTypeId(item);
951 EnsightPart* ensight_part = current_grp.getTypeInfo(item_type);
955 ensight_part->items().add(item_wn);
967 auto item_type = item->type();
968 EnsightPart* ensight_part = current_grp.getTypeInfo(item_type);
972 ensight_part->items().add(item_wn);
1002_saveGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
1007 writeFileString(ofile,
"part");
1008 writeFileInt(ofile, ensight_grp.partId());
1009 if (isParallelOutput()) {
1012 std::ostringstream ostr;
1014 writeFileString(ofile, ostr.str().c_str());
1017 writeFileString(ofile, igrp.
name());
1024 const EnsightPart& type_info = ensight_grp.typeInfo(i);
1027 if (nb_sub_part == 0)
1030 String type_name = type_info.name();
1031 writeFileString(ofile, type_name);
1033 writeFileInt(ofile, nb_sub_part);
1039 writeFileInt(ofile,mi.
uniqueId()+1);
1043 if (type_name ==
"nfaced") {
1054 for (
Integer z = 0; z < nb_sub_part; ++z)
1055 writeFileInt(ofile, nb_face);
1059 for (
Item mi : items) {
1060 writeFileInt(ofile, mi.toCell().nbFace());
1067 for (
Item mi : items) {
1070 for (
Integer z = 0; z < nb_face; ++z)
1075 for (
Item mi : items) {
1078 writeFileInt(ofile, face.nbNode());
1085 for (
Item item : items) {
1086 Cell cell(item.toCell());
1090 for (
Integer z = 0; z < nb_face; ++z) {
1093 array_id.
resize(nb_node);
1094 for (
Integer y = 0; y < nb_node; ++y) {
1102 writeFileArray(ofile, array_id);
1107 for (
Item item : items) {
1110 for (
Integer z = 0; z < nb_face; ++z) {
1111 const Face local_face = cell.
face(z);
1113 array_id.
resize(nb_node);
1114 for (
Integer y = 0; y < nb_node; ++y) {
1115 array_id[y] = nodes_index[local_face.
node(y).
localId()];
1117 writeFileArray(ofile, array_id);
1122 else if (type_name ==
"nsided") {
1127 for (
Item mi : items) {
1130 writeFileInt(ofile, nb_node);
1133 for (
Item mi : items) {
1136 array_id.
resize(nb_node);
1137 for (
Integer z = 0; z < nb_node; ++z) {
1140 writeFileArray(ofile, array_id);
1146 Integer nb_node = type_info.nbNode();
1147 array_id.
resize(nb_node);
1152 if (type_info.hasReindex()) {
1154 for (
Item mi : items) {
1156 for (
Integer j = 0; j < nb_node; ++j) {
1157 array_id[j] = nodes_index[e.
node(reindex[j]).
localId()];
1159 writeFileArray(ofile, array_id);
1163 for (
Item mi : items) {
1165 for (
Integer j = 0; j < nb_node; ++j) {
1168 writeFileArray(ofile, array_id);
1201_saveVariableOnGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
1206 writeFileString(ofile,
"part");
1207 writeFileInt(ofile, ensight_grp.partId());
1215 const EnsightPart& type_info = ensight_grp.typeInfo(i);
1218 if (nb_sub_part == 0)
1220 String type_name = type_info.name();
1221 if (type_name != last_type_name) {
1225 func->putValue(ofile);
1227 last_type_name = type_name;
1228 writeFileString(ofile, type_name);
1229 func = from_func.clone();
1240 func->putValue(ofile);
1248writeFileInt(std::ostream& o,
int value)
1251 o.write((
const char*)&value,
sizeof(
int));
1254 o.width(DumpWEnsight7::int_width);
1268 return DumpWEnsight7::int_width + 1;
1275writeFileDouble(std::ostream& o,
double value)
1278 float fvalue = (float)(value);
1279 o.write((
const char*)&fvalue,
sizeof(
float));
1284 o.flags(std::ios::scientific);
1294writeDoubleSize()
const
1307 o.write((
const char*)value.data(),
sizeof(
Integer) * value.size());
1310 for (
Integer i = 0, s = value.size(); i < s; ++i) {
1311 o.width(DumpWEnsight7::int_width);
1322writeFileString(std::ostream& o,
const String& str)
1325 char buf[g_line_length];
1326 for (
int i = 0; i < g_line_length; ++i)
1329 buf[g_line_length - 1] =
'\0';
1330 o.write(buf, g_line_length);
1341_writeFileHeader(std::ostream& o,
bool write_c_binary)
1344 if (_isNewBlocFile() &&
m_is_binary && write_c_binary)
1345 writeFileString(o,
"C Binary");
1346 if (m_fileset_size != 0) {
1347 std::ostringstream ostr;
1348 ostr <<
"BEGIN TIME STEP "
1350 writeFileString(o, ostr.str().c_str());
1364class DumpWEnsight7OutFile
1370 , m_filename(filename)
1371 , m_is_master(dw.isMasterProcessor())
1372 , m_is_parallel_output(dw.isParallelOutput())
1377 m_filestream =
new std::ofstream(filename.
localstr(), (std::ios_base::openmode)outtype);
1378 m_stream = &m_strstream;
1379 if (!(*m_filestream))
1380 m_dw.warning() <<
"Unable to open file " << filename;
1384 m_stream = &m_strstream;
1386 ARCANE_CHECK_PTR(m_stream);
1388 ~DumpWEnsight7OutFile()
1390 delete m_filestream;
1399 ARCANE_CHECK_PTR(m_filestream);
1400 ARCANE_CHECK_PTR(m_strstream);
1402 (*m_filestream) << m_strstream.str();
1404 if (m_is_parallel_output) {
1406 ARCANE_CHECK_PTR(m_filestream);
1414 for (
Integer i = 1; i < nb_proc; ++i) {
1415 m_dw.debug(
Trace::High) <<
"Waiting for length of processor " << i;
1416 parallel_mng->
recv(len_array, i);
1418 m_dw.debug(
Trace::High) <<
"Length of processor " << i <<
" : " << len;
1421 m_dw.debug(
Trace::High) <<
"Waiting for receving geom of processor " << i;
1422 parallel_mng->
recv(str_array, i);
1423 m_dw.debug(
Trace::High) <<
"Receving geom of processor " << i;
1424 m_filestream->write((
const char*)str_array.
data(), str_array.
size());
1429 ARCANE_CHECK_PTR(m_strstream);
1436 std::string str = m_strstream.str();
1445 m_dw.debug(
Trace::High) <<
"Not a master. " << m_filename <<
" size = " << len;
1449 m_dw.debug(
Trace::High) <<
"Sending length for processor 0";
1450 parallel_mng->send(len_array, 0);
1455 m_dw.debug(
Trace::High) <<
"Sending data for processor 0";
1456 parallel_mng->send(bytes, 0);
1462 if (!m_dw.isOneFilePerTime())
1463 m_dw.writeFileString(*m_filestream,
"END TIME STEP");
1468 std::ostream& operator()() {
return *m_stream; }
1475 bool m_is_parallel_output;
1476 std::ostream* m_stream;
1477 std::ostringstream m_strstream;
1478 std::ofstream* m_filestream;
1493 bool is_parallel = parallel_mng->
isParallel();
1524 if (!list_group.contains(var_group))
1525 list_group.add(var_group);
1531 _computeGroupParts(list_group, partid);
1536 for (
auto i : m_parts) {
1537 total_nb_element += i->totalNbElement();
1543 debug() <<
"Add nodes " <<
mesh->nbNode();
1547 if (!(
m_times.size() > 1 && m_force_first_geometry)) {
1553 _writeFileHeader(dw_ofile(),
true);
1556 writeFileString(dw_ofile(),
"Output ensight test");
1557 writeFileString(dw_ofile(),
"File description");
1558 writeFileString(dw_ofile(),
"node id assign");
1559 writeFileString(dw_ofile(),
"element id assign");
1569 all_nodes_index.
fill(0);
1573 if (
mesh->parentMesh()) {
1575 coords_backup.
resize(
mesh->nodeFamily()->maxLocalId());
1577 coords_backup[i_item.localId()] = nodes_coords[i_item];
1579 coords_array = coords_backup.
view();
1589 writeFileString(wf.stream(),
"coordinates");
1590 writeFileInt(wf.stream(), all_nodes.
size());
1597 const Item& item = *i_item;
1598 all_nodes_index[item.
localId()] = ensight_index;
1607 const Item& item = *i_item;
1608 writeFileInt(wf.stream(),item.
uniqueId()+1);
1614 const Item& item = *i_item;
1621 _saveGroup(dw_ofile(), *part, all_nodes_index, wf);
1623 dw_ofile.syncFile();
1637 cell_uids[icell] = (
Real)(icell->uniqueId().asInt64());
1643 write(cell_uid_var, cell_uid_var->
data());
1650 node_uids[inode] = inode->uniqueId().asInt32();
1651 node_uids2[inode.index()] = (
Real)inode->uniqueId().asInt64();
1668 warning() <<
"Unable to write to file: <" << buf <<
"> error: " <<
m_case_file.rdstate();
1675 if (m_fileset_size != 0)
1677 if (m_force_first_geometry)
1678 _writeWildcardFilename(
m_case_file,
"ensight.geo",
'0');
1680 _writeWildcardFilename(
m_case_file,
"ensight.geo",
'*');
1704 if (m_fileset_size != 0) {
1707 if (m_fileset_size != 0) {
1709 for (
Integer i = 0; i < nb_timeset; ++i) {
1711 m_case_file <<
"number of steps: " << m_fileset_size <<
'\n';
1714 m_case_file <<
"filename index: " << nb_timeset <<
"\n";
1715 m_case_file <<
"number of steps: " <<
m_times.size() - (nb_timeset * m_fileset_size) <<
'\n';
1779 if (m_fileset_size == 0) {
1795 ostr() << current_time;
1796 fn_builder += ostr.str();
1808 filename = fn_builder;
1820 return group_kind == item_kind;
1839 bool has_prot =
false;
1840 if (m_fileset_size != 0) {
1843 prot_index = (nb_time - 1) / m_fileset_size;
1855 ostr() << prot_index;
1870_writeWildcardFilename(std::ostream& ofile,
const String& filename,
char joker)
1872 if (m_fileset_size == 0) {
1873 ofile <<
' ' << filename <<
'/' << filename;
1884 if (nb_time <= m_fileset_size)
1888 ofile <<
"/" << filename;
1896_isNewBlocFile()
const
1902 if (m_fileset_size == 0)
1905 Integer modulo = (nb_time - 1) % m_fileset_size;
1918 return ((isBinary()) ? std::ios::binary : 0) | ((_isNewBlocFile()) ? std::ios::trunc : std::ios::app);
1927template <
typename T>
1931 debug() <<
"Saving variable1 " << v.
name() <<
" ptr=" << ptr.
data() <<
" ps=" << ptr.
size();
1939 debug() <<
"Saving variable " << v.
name() <<
" in " << filename;
1943 _writeFileHeader(dw_ofile(),
false);
1946 writeFileString(dw_ofile(), v.
name());
1953 var_type_str =
"scalar per element: ";
1956 var_type_str =
"scalar per node: ";
1962 m_case_file_variables << var_type_str;
1963 m_case_file_variables <<
" 1 ";
1964 if (m_fileset_size != 0)
1965 m_case_file_variables <<
" 1 ";
1966 m_case_file_variables << v.
name();
1967 _writeWildcardFilename(m_case_file_variables, v.
name());
1968 m_case_file_variables <<
'\n';
1983 bool need_save =
false;
1985 need_save = v.
itemGroup() == part->group();
1987 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
1989 _saveVariableOnGroup(dw_ofile(), *part, wf);
2001 writeFileString(dw_ofile(),
"part");
2002 writeFileInt(dw_ofile(), part->partId());
2003 writeFileString(dw_ofile(),
"coordinates");
2004 wf.putValue(dw_ofile());
2011 dw_ofile.syncFile();
2023template <
typename T>
2030 for (
Integer idim2 = 0; idim2 < ptr.dim2Size(); ++idim2) {
2035 debug() <<
"Saving variable " << v.
name() <<
" component " << idim2 <<
" in " << filename;
2039 _writeFileHeader(dw_ofile(),
false);
2042 writeFileString(dw_ofile(), vname);
2049 var_type_str =
"scalar per element: ";
2052 var_type_str =
"scalar per node: ";
2058 m_case_file_variables << var_type_str;
2059 m_case_file_variables <<
" 1 ";
2060 if (m_fileset_size != 0)
2061 m_case_file_variables <<
" 1 ";
2062 m_case_file_variables << vname;
2063 _writeWildcardFilename(m_case_file_variables, vname);
2064 m_case_file_variables <<
'\n';
2079 bool need_save =
false;
2081 need_save = v.
itemGroup() == part->group();
2083 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2085 _saveVariableOnGroup(dw_ofile(), *part, wf);
2093 for (
Integer i = 0; i < ptr.dim1Size(); ++i)
2097 writeFileString(dw_ofile(),
"part");
2098 writeFileInt(dw_ofile(), part->partId());
2099 writeFileString(dw_ofile(),
"coordinates");
2100 wf.putValue(dw_ofile());
2107 dw_ofile.syncFile();
2120template <
typename T>
2129 warning() <<
"Impossible to write array variable "
2130 << v.
name() <<
" of non-constant size; variable saving skipped";
2148 debug() <<
"Saving variable " << v.
name() <<
" in " << filename;
2152 _writeFileHeader(dw_ofile(),
false);
2154 writeFileString(dw_ofile(), v.
name());
2160 m_case_file_variables <<
"vector per element: ";
2163 m_case_file_variables <<
"vector per node: ";
2169 m_case_file_variables <<
" 1 ";
2170 if (m_fileset_size != 0)
2171 m_case_file_variables <<
" 1 ";
2172 m_case_file_variables << v.
name();
2174 _writeWildcardFilename(m_case_file_variables, v.
name());
2175 m_case_file_variables <<
'\n';
2190 bool need_save =
false;
2192 need_save = v.
itemGroup() == part->group();
2194 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2196 _saveVariableOnGroup(dw_ofile(), *part, wf);
2208 writeFileString(dw_ofile(),
"part");
2209 writeFileInt(dw_ofile(), part->partId());
2210 writeFileString(dw_ofile(),
"coordinates");
2211 wf.putValue(dw_ofile());
2218 dw_ofile.syncFile();
2233 for (
Integer idim2 = 0; idim2 < ptr.dim2Size(); ++idim2) {
2238 debug() <<
"Saving variable " << v.
name() <<
" component " << idim2 <<
" in " << filename;
2242 _writeFileHeader(dw_ofile(),
false);
2244 writeFileString(dw_ofile(), vname);
2250 m_case_file_variables <<
"vector per element: ";
2253 m_case_file_variables <<
"vector per node: ";
2259 m_case_file_variables <<
" 1 ";
2260 if (m_fileset_size != 0)
2261 m_case_file_variables <<
" 1 ";
2262 m_case_file_variables << vname;
2264 _writeWildcardFilename(m_case_file_variables, vname);
2265 m_case_file_variables <<
'\n';
2280 bool need_save =
false;
2282 need_save = v.
itemGroup() == part->group();
2284 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2286 _saveVariableOnGroup(dw_ofile(), *part, wf);
2294 for (
Integer i = 0; i < ptr.dim1Size(); ++i)
2298 writeFileString(dw_ofile(),
"part");
2299 writeFileInt(dw_ofile(), part->partId());
2300 writeFileString(dw_ofile(),
"coordinates");
2301 wf.putValue(dw_ofile());
2308 dw_ofile.syncFile();
2329 warning() <<
"Impossible to write array variable " << v.
name()
2330 <<
" of non-constant size; variable saving skipped";
2339class Ensight7PostProcessorService
2340:
public PostProcessorWriterBase
2345 : PostProcessorWriterBase(sbi)
2346 , m_mesh(sbi.
mesh())
2368 bool is_binary =
true;
2370 bool is_parallel = subDomain()->parallelMng()->isParallel();
2371 bool use_degenerated_hexa =
true;
2372 bool force_first_geometry =
false;
2373 bool save_uids =
false;
2376 fileset_size, use_degenerated_hexa,
2377 force_first_geometry, save_uids);
2396class Ensight7PostProcessorServiceV2
2407 , m_mesh(sbi.
mesh())
2425 IMesh* m_mesh =
nullptr;
2426 DumpW* m_writer =
nullptr;
2437 bool is_binary =
true;
2439 bool is_parallel = m_mesh->parallelMng()->isParallel();
2440 is_binary =
options()->binaryFile();
2441 fileset_size =
options()->filesetSize();
2442 bool use_degenerated_hexa =
options()->useDegeneratedHexa();
2443 bool force_first_geometry =
options()->forceFirstGeometry();
2444 bool save_uids =
options()->saveUids();
2447 use_degenerated_hexa, force_first_geometry, save_uids);
2461 Ensight7PostProcessor);
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
This file contains the various service factories and macros for registering services.
#define ARCANE_REGISTER_SUB_DOMAIN_FACTORY(aclass, ainterface, aname)
Registers a factory service for the class aclass.
Integer size() const
Number of elements in the vector.
CaseOptionsEnsight7PostProcessor * options() const
Options du jeu de données du service.
ArcaneEnsight7PostProcessorObject(const Arcane::ServiceBuildInfo &sbi)
Constructeur.
Base class for 1D data vectors.
void fill(ConstReferenceType value)
Fills the array with the value value.
void resize(Int64 s)
Changes the number of elements in the array to s.
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.
ArrayView< T > view() const
Mutable view of this array.
FaceConnectedListViewType faces() const
List of faces of the cell.
Face face(Int32 i) const
i-th face of the cell
Int32 nbFace() const
Number of faces of the cell.
Integer count() const
Number of elements in the collection.
View for a constant 2D array.
Constant view of an array of type T.
constexpr const_pointer data() const noexcept
Pointer to the allocated memory.
constexpr Integer size() const noexcept
Number of elements in the array.
ConstIterT< ConstArrayView< T > > const_iter
Type of a constant iterator over the entire array.
Constant iterator interval.
Constant view on a MultiArray2.
Class managing a directory.
bool createDirectory() const override
Creates the directory.
Abstraction of an output file for ensight.
Functor for writing a variable of type Real.
Functor to write a variable of type Real3.
Functor for writing a variable.
Functor for writing a variable of type Real.
Functor to write a variable of type Real2.
Writes in Ensight7 format.
void _writeRealValT(IVariable &v, ConstArrayView< T > a)
Template for writing variable as a real variable.
std::ofstream m_case_file
File describing the case.
bool m_is_binary
List of parts.
void writeVal(IVariable &, ConstArrayView< Byte >) override
Writing for variable v of array a.
void beginWrite() override
Notifies the start of writing.
Directory m_part_directory
Storage directory for the current iteration.
void _buildFileName(const String &varname, String &filename)
Constructs the filename for a variable or mesh name.
bool m_is_parallel_output
bool _isValidVariable(IVariable &) const
Checks the validity of the variable to be saved.
ItemGroupList m_save_groups
List of groups to export.
void _buildPartDirectory()
Constructs the directory where the variables will be saved.
IParallelMng * m_parallel_mng
Parallelism manager.
void endWrite() override
Notifies the end of writing.
RealUniqueArray m_times
description of saved variables
void setMetaData(const String &) override
Sets metadata information.
VariableList m_save_variables
List of variables to export.
static const Integer m_max_prots_digit
Maximum number of digits to indicate the protection number.
Directory m_base_directory
Storage directory name.
bool m_is_master
true if the processor manages the output
Integer m_total_nb_element
Total number of mesh elements across all groups to be saved.
Integer m_total_nb_group
Number of groups to save (== number of parts).
wrapper transforming calls to the IDataWriter interface into IDumpW
void write(IVariable *var, IData *data)
Writes the data data of the variable var.
Post-processing in Ensight7 format.
void notifyBeginWrite() override
Notifies that an output is going to be performed with the current parameters.
void close() override
Closes the writer. After closing, it can no longer be used.
void notifyEndWrite() override
Notifies that an output has just been performed.
IDataWriter * dataWriter() override
Returns the writer associated with this post-processor.
void setMesh(IMesh *mesh) override
Positions the mesh.
Post-processing in Ensight7 format.
IDataWriter * dataWriter() override
Returns the writer associated with this post-processor.
void close() override
Closes the writer. After closing, it can no longer be used.
void notifyEndWrite() override
Notifies that an output has just been performed.
void notifyBeginWrite() override
Notifies that an output is going to be performed with the current parameters.
Information about the floating-point type.
Base class of a hash table between group items and their positions in the table.
Interface for writing variable data.
virtual String name() const =0
Family name.
virtual ItemTypeMng * itemTypeMng() const =0
Associated entity type manager.
Interface of the parallelism manager for a subdomain.
virtual Int32 commRank() const =0
Rank of this instance in the communicator.
virtual void recv(ArrayView< char > values, Int32 rank)=0
virtual Int32 commSize() const =0
Number of instances in the communicator.
virtual bool isParallel() const =0
Returns true if the execution is parallel.
Interface for a writer for post-processing information.
Interface of the subdomain manager.
virtual IMesh * defaultMesh()=0
Default mesh.
virtual void setUsed(bool v)=0
Sets the usage state of the variable.
@ PTemporary
Indicates that the variable is temporary.
@ PPrivate
Indicates that the variable is private.
virtual eItemKind itemKind() const =0
Kind of mesh entities on which the variable is based.
virtual bool isPartial() const =0
Indicates if the variable is partial.
virtual IData * data()=0
Data associated with the variable.
virtual bool isUsed() const =0
Usage state of the variable.
virtual ItemGroup itemGroup() const =0
Associated mesh group.
virtual void notifyBeginWrite()=0
Notifies of the start of writing data().
virtual String name() const =0
Variable name.
const String & name() const
Group name.
bool isOwn() const
Returns whether the group contains only elements belonging to the subdomain.
SharedPtrT< GroupIndexTable > localIdToIndex() const
Table of local ids to a position for all entities in the group.
Integer size() const
Number of elements in the group.
IItemFamily * itemFamily() const
Entity family to which this group belongs (0 for the null group).
eItemKind itemKind() const
Group kind. This is the kind of its elements.
bool null() const
true means the group is the null group
IMesh * mesh() const
Mesh to which this group belongs (0 for the null group).
ItemGroup own() const
Group equivalent to this one but containing only the local elements of the subdomain.
Local information about a cell face.
Integer node(Integer i) const
Local index in the cell of the i-th node of the face.
Integer nbNode() const
Number of nodes of the face.
Info on a mesh entity type.
LocalFace localFace(Integer id) const
Local connectivity of the i-th face of the cell.
Integer nbLocalEdge() const
Number of edges of the entity.
Integer nbLocalNode() const
Number of nodes of the entity.
Integer nbLocalFace() const
Number of faces of the entity.
Mesh entity type manager.
bool hasGeneralCells(IMesh *mesh) const
Indicates if the mesh mesh contains generic cells (outside of built-in or additional types).
static Integer nbBasicItemType()
number of available types
ItemTypeInfo * typeFromId(Integer id) const
Type corresponding to the number id.
static Integer nbBuiltInItemType()
number of built-in types (excluding additional types)
Mesh element based on nodes (Edge,Face,Cell).
Node node(Int32 i) const
i-th node of the entity
Int32 nbNode() const
Number of nodes of the entity.
Base class for a mesh element.
const ItemTypeInfo * typeInfo() const
Information about the entity type.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
ItemWithNodes toItemWithNodes() const
Converts the entity to the ItemWithNodes kind.
Cell toCell() const
Converts the entity to the Cell kind.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
Int16 type() const
Entity type.
void clone(const Collection< T > &base)
Clone the collection base.
ListEnumeratorT< ItemGroup > Enumerator
Exception when a function is not implemented.
Output stream linked to a String.
ItemGroupCollection groups() override
List of groups to save.
VariableCollection variables() override
List of variables to save.
ConstArrayView< Real > times() override
List of saved times.
const String & baseDirectoryName() override
Name of the output directory for files.
T * get() const
Returns the object referenced by the instance.
Encapsulation of an automatically destructing pointer.
IMesh * mesh() const
Access to the associated IMesh.
Structure containing the information to create a service.
Unicode character string constructor.
String toString() const
Returns the constructed character string.
Unicode character string.
const char * localstr() const
Returns the conversion of the instance into UTF-8 encoding.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
TraceMessage warning() const
Flow for a warning message.
1D data vector with value semantics (STL style).
Parameters necessary for building a variable.
IVariable * variable() const
Associated variable.
ItemGroupT< Node > NodeGroup
Group of nodes.
MeshVariableScalarRefT< Cell, Real > VariableCellReal
Real type quantity at cell center.
MeshVariableScalarRefT< Node, Integer > VariableNodeInteger
Quantity at the node of integer type.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
char * copyn(char *to, const char *from, Integer n)
Copies the first n characters of from into to.
Real toReal(Real r)
Converts r to a Real.
double toDouble(Real r)
Converts a Real to double.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Integer arcaneCheckArraySize(unsigned long long size)
Checks that size can be converted into an 'Integer' to serve as the size of an array....
Collection< ItemGroup > ItemGroupCollection
Collection of mesh item groups.
Int32 Integer
Type representing an integer.
List< ItemGroup > ItemGroupList
Array of mesh item groups.
SharedMeshVariableScalarRefT< Node, Real3 > SharedVariableNodeReal3
Quantity at the node of coordinate type.
UniqueArray< Real > RealUniqueArray
Dynamic 1D array of reals.
eItemKind
Mesh entity type.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
@ IK_Unknown
Unknown or uninitialized mesh entity.
@ IK_Face
Face mesh entity.
@ IK_Edge
Edge mesh entity.
double Real
Type representing a real number.
UniqueArray< Integer > IntegerUniqueArray
Dynamic 1D array of integers.
ConstArrayView< Integer > IntegerConstArrayView
C equivalent of a 1D array of integers.
std::int32_t Int32
Signed integer type of 32 bits.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Correspondence between Ensight element type and Arcane.
int m_type
Arcane type of the element.
UniqueArray< Item > m_items
Entities of elements of this type.
Integer m_nb_node
Number of nodes.
String m_name
Ensight name of this element.
Information to share a group into elements of the same subtype.
ItemGroup m_group
Associated group.
Integer m_part_id
Part number.
std::unique_ptr< VariableItemInt32 > m_general_item_types
Variable to store the types of general items (untyped).
Integer nbType() const
Number of subtypes.