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.nbNode() != item.itemBase().nbEdge()) {
329 m_parts.add(EnsightPart(type_id++, item.nbNode(),
"nfaced"));
332 m_is_polyhedral_type_registration_done =
true;
345 void writeFileString(std::ostream& o,
const String& str);
346 void writeFileInt(std::ostream& o,
int value);
347 void writeFileDouble(std::ostream& o,
double value);
348 Integer writeDoubleSize()
const;
372 explicit WriteBase(DumpWEnsight7& dw)
379 WriteBase(
const WriteBase& wb)
383 virtual ~WriteBase() {}
387 virtual WriteBase* clone() = 0;
388 virtual void begin() { init(); }
389 virtual void end() {}
394 m_ofile.precision(5);
395 m_ofile.flags(std::ios::scientific);
397 virtual void putValue(std::ostream& ofile)
399 ofile << m_ofile.str();
401 std::ostream& stream() {
return m_ofile; }
406 std::ostringstream m_ofile;
413 template <
typename FromType>
423 WriteDouble(
const WriteDouble& wd)
428 WriteBase* clone()
override {
return new WriteDouble(*
this); }
436 inline void write(
Integer index)
439 int reindex = (*m_idx)[index];
450 for (
Item e : items) {
459 template <
typename FromType>
460 class WriteArrayDouble
471 WriteArrayDouble(
const WriteArrayDouble& wd)
474 , m_idim2(wd.m_idim2)
477 WriteBase* clone()
override {
return new WriteArrayDouble(*
this); }
489 int reindex = (*m_idx)[index];
500 for (
Item e : items) {
522 WriteReal3(
const WriteReal3& wd)
527 WriteBase* clone()
override {
return new WriteReal3(*
this); }
535 void begin()
override
539 xostr.flags(std::ios::scientific);
541 yostr.flags(std::ios::scientific);
543 zostr.flags(std::ios::scientific);
549 int reindex = (*m_idx)[index];
565 for (
Item i : items) {
572 m_ofile << xostr.str();
573 m_ofile << yostr.str();
574 m_ofile << zostr.str();
579 std::ostringstream xostr;
580 std::ostringstream yostr;
581 std::ostringstream zostr;
594 class WriteArrayReal3
605 WriteArrayReal3(
const WriteArrayReal3& wd)
608 , m_idim2(wd.m_idim2)
611 WriteBase* clone()
override {
return new WriteArrayReal3(*
this); }
620 void begin()
override
624 xostr.flags(std::ios::scientific);
626 yostr.flags(std::ios::scientific);
628 zostr.flags(std::ios::scientific);
631 inline void write(
Integer index)
634 int reindex = (*m_idx)[index];
648 for (
Item i : items) {
655 m_ofile << xostr.str();
656 m_ofile << yostr.str();
657 m_ofile << zostr.str();
662 std::ostringstream xostr;
663 std::ostringstream yostr;
664 std::ostringstream zostr;
678 bool is_binary,
bool is_parallel,
Integer fileset_size,
679 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids);
686 void writeVal(IVariable&, ConstArrayView<Real2>)
override {}
687 void writeVal(IVariable&, ConstArrayView<Real3>)
override;
691 void writeVal(IVariable&, ConstArrayView<Real2x2>)
override {}
692 void writeVal(IVariable&, ConstArrayView<Real3x3>)
override {}
693 void writeVal(IVariable&, ConstArrayView<String>)
override {}
695 void writeVal(IVariable&, ConstArray2View<Byte>)
override {}
697 void writeVal(IVariable&, ConstArray2View<Real2>)
override {}
698 void writeVal(IVariable&, ConstArray2View<Real3>)
override;
702 void writeVal(IVariable&, ConstArray2View<Real2x2>)
override {}
703 void writeVal(IVariable&, ConstArray2View<Real3x3>)
override {}
705 void writeVal(IVariable&, ConstMultiArray2View<Byte>)
override {}
707 void writeVal(IVariable&, ConstMultiArray2View<Real2>)
override {}
708 void writeVal(IVariable&, ConstMultiArray2View<Real3> a)
override;
712 void writeVal(IVariable&, ConstMultiArray2View<Real2x2>)
override {}
713 void writeVal(IVariable&, ConstMultiArray2View<Real3x3>)
override {}
720 bool isMasterProcessor()
const {
return m_is_master; }
721 bool isOneFilePerTime()
const {
return m_fileset_size == 0; }
728 typedef UniqueArray<GroupPartInfo*> GroupPartInfoList;
737 std::ostringstream m_case_file_variables;
741 GroupPartInfoList m_parts;
747 bool m_use_degenerated_hexa;
748 bool m_force_first_geometry;
768 void _createCaseFile();
771 void _writeWildcardFilename(std::ostream& ofile,
const String& filename,
char joker =
'*');
772 int _fileOuttype()
const;
773 void _writeFileHeader(std::ostream& o,
bool write_c_binary);
774 bool _isNewBlocFile()
const;
777 void _saveGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
779 void _saveVariableOnGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
784 template <
typename T>
787 template <
typename T>
790 template <
typename T>
802 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
803 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
806 is_parallel_output, fileset_size, use_degenerated_hexa,
807 force_first_geometry, save_uids);
811createEnsight7(IMesh* m,
const String& f,
812 ConstArrayView<Real> times,
813 VariableCollection variables,
815 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
816 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
818 return new DumpWEnsight7(m, f, times, variables, groups, is_binary,
819 is_parallel_output, fileset_size, use_degenerated_hexa,
820 force_first_geometry, save_uids);
829 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
830 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
833, m_parallel_mng(
mesh->parallelMng())
834, m_base_directory(filename)
836, m_save_variables(variables.clone())
837, m_save_groups(groups.enumerator())
838, m_is_binary(is_binary)
841, m_is_parallel_output(is_parallel_output)
842, m_use_degenerated_hexa(use_degenerated_hexa)
843, m_force_first_geometry(force_first_geometry)
844, m_save_uids(save_uids)
845, m_total_nb_element(0)
847, m_fileset_size(fileset_size)
866 std::for_each(std::begin(m_parts), std::end(m_parts), Deleter());
923 Integer type_to_seek = type_info.type();
926 if (e.
type() == type_to_seek)
931 << nb_of_type <<
" items of type " << type_info.name();
935 if (mi.
type() == type_to_seek) {
945 const Item& item = *i2;
946 auto item_type = current_grp.generalItemTypeId(item);
947 EnsightPart* ensight_part = current_grp.getTypeInfo(item_type);
951 ensight_part->items().add(item_wn);
963 auto item_type = item->type();
964 EnsightPart* ensight_part = current_grp.getTypeInfo(item_type);
968 ensight_part->items().add(item_wn);
998_saveGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
1003 writeFileString(ofile,
"part");
1004 writeFileInt(ofile, ensight_grp.partId());
1005 if (isParallelOutput()) {
1008 std::ostringstream ostr;
1010 writeFileString(ofile, ostr.str().c_str());
1013 writeFileString(ofile, igrp.
name());
1020 const EnsightPart& type_info = ensight_grp.typeInfo(i);
1023 if (nb_sub_part == 0)
1026 String type_name = type_info.name();
1027 writeFileString(ofile, type_name);
1029 writeFileInt(ofile, nb_sub_part);
1035 writeFileInt(ofile,mi.
uniqueId()+1);
1039 if (type_name ==
"nfaced") {
1050 for (
Integer z = 0; z < nb_sub_part; ++z)
1051 writeFileInt(ofile, nb_face);
1055 for (
Item mi : items) {
1056 writeFileInt(ofile, mi.toCell().nbFace());
1063 for (
Item mi : items) {
1066 for (
Integer z = 0; z < nb_face; ++z)
1071 for (
Item mi : items) {
1074 writeFileInt(ofile, face.nbNode());
1081 for (
Item item : items) {
1082 Cell cell(item.toCell());
1086 for (
Integer z = 0; z < nb_face; ++z) {
1089 array_id.
resize(nb_node);
1090 for (
Integer y = 0; y < nb_node; ++y) {
1098 writeFileArray(ofile, array_id);
1103 for (
Item item : items) {
1106 for (
Integer z = 0; z < nb_face; ++z) {
1107 const Face local_face = cell.
face(z);
1109 array_id.
resize(nb_node);
1110 for (
Integer y = 0; y < nb_node; ++y) {
1111 array_id[y] = nodes_index[local_face.
node(y).
localId()];
1113 writeFileArray(ofile, array_id);
1118 else if (type_name ==
"nsided") {
1123 for (
Item mi : items) {
1126 writeFileInt(ofile, nb_node);
1129 for (
Item mi : items) {
1132 array_id.
resize(nb_node);
1133 for (
Integer z = 0; z < nb_node; ++z) {
1136 writeFileArray(ofile, array_id);
1142 Integer nb_node = type_info.nbNode();
1143 array_id.
resize(nb_node);
1148 if (type_info.hasReindex()) {
1150 for (
Item mi : items) {
1152 for (
Integer j = 0; j < nb_node; ++j) {
1153 array_id[j] = nodes_index[e.
node(reindex[j]).
localId()];
1155 writeFileArray(ofile, array_id);
1159 for (
Item mi : items) {
1161 for (
Integer j = 0; j < nb_node; ++j) {
1164 writeFileArray(ofile, array_id);
1197_saveVariableOnGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
1202 writeFileString(ofile,
"part");
1203 writeFileInt(ofile, ensight_grp.partId());
1211 const EnsightPart& type_info = ensight_grp.typeInfo(i);
1214 if (nb_sub_part == 0)
1216 String type_name = type_info.name();
1217 if (type_name != last_type_name) {
1221 func->putValue(ofile);
1223 last_type_name = type_name;
1224 writeFileString(ofile, type_name);
1225 func = from_func.clone();
1236 func->putValue(ofile);
1244writeFileInt(std::ostream& o,
int value)
1247 o.write((
const char*)&value,
sizeof(
int));
1250 o.width(DumpWEnsight7::int_width);
1264 return DumpWEnsight7::int_width + 1;
1271writeFileDouble(std::ostream& o,
double value)
1274 float fvalue = (float)(value);
1275 o.write((
const char*)&fvalue,
sizeof(
float));
1280 o.flags(std::ios::scientific);
1290writeDoubleSize()
const
1303 o.write((
const char*)value.data(),
sizeof(
Integer) * value.size());
1306 for (
Integer i = 0, s = value.size(); i < s; ++i) {
1307 o.width(DumpWEnsight7::int_width);
1318writeFileString(std::ostream& o,
const String& str)
1321 char buf[g_line_length];
1322 for (
int i = 0; i < g_line_length; ++i)
1325 buf[g_line_length - 1] =
'\0';
1326 o.write(buf, g_line_length);
1337_writeFileHeader(std::ostream& o,
bool write_c_binary)
1340 if (_isNewBlocFile() &&
m_is_binary && write_c_binary)
1341 writeFileString(o,
"C Binary");
1342 if (m_fileset_size != 0) {
1343 std::ostringstream ostr;
1344 ostr <<
"BEGIN TIME STEP "
1346 writeFileString(o, ostr.str().c_str());
1360class DumpWEnsight7OutFile
1366 , m_filename(filename)
1367 , m_is_master(dw.isMasterProcessor())
1368 , m_is_parallel_output(dw.isParallelOutput())
1373 m_filestream =
new std::ofstream(filename.
localstr(), (std::ios_base::openmode)outtype);
1374 m_stream = &m_strstream;
1375 if (!(*m_filestream))
1376 m_dw.warning() <<
"Unable to open file " << filename;
1380 m_stream = &m_strstream;
1382 ARCANE_CHECK_PTR(m_stream);
1384 ~DumpWEnsight7OutFile()
1386 delete m_filestream;
1395 ARCANE_CHECK_PTR(m_filestream);
1396 ARCANE_CHECK_PTR(m_strstream);
1398 (*m_filestream) << m_strstream.str();
1400 if (m_is_parallel_output) {
1402 ARCANE_CHECK_PTR(m_filestream);
1410 for (
Integer i = 1; i < nb_proc; ++i) {
1411 m_dw.debug(
Trace::High) <<
"Waiting for length of processor " << i;
1412 parallel_mng->
recv(len_array, i);
1414 m_dw.debug(
Trace::High) <<
"Length of processor " << i <<
" : " << len;
1417 m_dw.debug(
Trace::High) <<
"Waiting for receving geom of processor " << i;
1418 parallel_mng->
recv(str_array, i);
1419 m_dw.debug(
Trace::High) <<
"Receving geom of processor " << i;
1420 m_filestream->write((
const char*)str_array.
data(), str_array.
size());
1425 ARCANE_CHECK_PTR(m_strstream);
1432 std::string str = m_strstream.str();
1441 m_dw.debug(
Trace::High) <<
"Not a master. " << m_filename <<
" size = " << len;
1445 m_dw.debug(
Trace::High) <<
"Sending length for processor 0";
1446 parallel_mng->send(len_array, 0);
1451 m_dw.debug(
Trace::High) <<
"Sending data for processor 0";
1452 parallel_mng->send(bytes, 0);
1458 if (!m_dw.isOneFilePerTime())
1459 m_dw.writeFileString(*m_filestream,
"END TIME STEP");
1464 std::ostream& operator()() {
return *m_stream; }
1471 bool m_is_parallel_output;
1472 std::ostream* m_stream;
1473 std::ostringstream m_strstream;
1474 std::ofstream* m_filestream;
1489 bool is_parallel = parallel_mng->
isParallel();
1520 if (!list_group.contains(var_group))
1521 list_group.add(var_group);
1527 _computeGroupParts(list_group, partid);
1532 for (
auto i : m_parts) {
1533 total_nb_element += i->totalNbElement();
1539 debug() <<
"Add nodes " <<
mesh->nbNode();
1543 if (!(
m_times.size() > 1 && m_force_first_geometry)) {
1549 _writeFileHeader(dw_ofile(),
true);
1552 writeFileString(dw_ofile(),
"Output ensight test");
1553 writeFileString(dw_ofile(),
"File description");
1554 writeFileString(dw_ofile(),
"node id assign");
1555 writeFileString(dw_ofile(),
"element id assign");
1565 all_nodes_index.
fill(0);
1569 if (
mesh->parentMesh()) {
1571 coords_backup.
resize(
mesh->nodeFamily()->maxLocalId());
1573 coords_backup[i_item.localId()] = nodes_coords[i_item];
1575 coords_array = coords_backup.
view();
1585 writeFileString(wf.stream(),
"coordinates");
1586 writeFileInt(wf.stream(), all_nodes.
size());
1593 const Item& item = *i_item;
1594 all_nodes_index[item.
localId()] = ensight_index;
1603 const Item& item = *i_item;
1604 writeFileInt(wf.stream(),item.
uniqueId()+1);
1610 const Item& item = *i_item;
1617 _saveGroup(dw_ofile(), *part, all_nodes_index, wf);
1619 dw_ofile.syncFile();
1633 cell_uids[icell] = (
Real)(icell->uniqueId().asInt64());
1639 write(cell_uid_var, cell_uid_var->
data());
1646 node_uids[inode] = inode->uniqueId().asInt32();
1647 node_uids2[inode.index()] = (
Real)inode->uniqueId().asInt64();
1664 warning() <<
"Unable to write to file: <" << buf <<
"> error: " <<
m_case_file.rdstate();
1671 if (m_fileset_size != 0)
1673 if (m_force_first_geometry)
1674 _writeWildcardFilename(
m_case_file,
"ensight.geo",
'0');
1676 _writeWildcardFilename(
m_case_file,
"ensight.geo",
'*');
1700 if (m_fileset_size != 0) {
1703 if (m_fileset_size != 0) {
1705 for (
Integer i = 0; i < nb_timeset; ++i) {
1707 m_case_file <<
"number of steps: " << m_fileset_size <<
'\n';
1710 m_case_file <<
"filename index: " << nb_timeset <<
"\n";
1711 m_case_file <<
"number of steps: " <<
m_times.size() - (nb_timeset * m_fileset_size) <<
'\n';
1775 if (m_fileset_size == 0) {
1791 ostr() << current_time;
1792 fn_builder += ostr.str();
1804 filename = fn_builder;
1816 return group_kind == item_kind;
1835 bool has_prot =
false;
1836 if (m_fileset_size != 0) {
1839 prot_index = (nb_time - 1) / m_fileset_size;
1851 ostr() << prot_index;
1866_writeWildcardFilename(std::ostream& ofile,
const String& filename,
char joker)
1868 if (m_fileset_size == 0) {
1869 ofile <<
' ' << filename <<
'/' << filename;
1880 if (nb_time <= m_fileset_size)
1884 ofile <<
"/" << filename;
1892_isNewBlocFile()
const
1898 if (m_fileset_size == 0)
1901 Integer modulo = (nb_time - 1) % m_fileset_size;
1914 return ((isBinary()) ? std::ios::binary : 0) | ((_isNewBlocFile()) ? std::ios::trunc : std::ios::app);
1923template <
typename T>
1927 debug() <<
"Saving variable1 " << v.
name() <<
" ptr=" << ptr.
data() <<
" ps=" << ptr.
size();
1935 debug() <<
"Saving variable " << v.
name() <<
" in " << filename;
1939 _writeFileHeader(dw_ofile(),
false);
1942 writeFileString(dw_ofile(), v.
name());
1949 var_type_str =
"scalar per element: ";
1952 var_type_str =
"scalar per node: ";
1958 m_case_file_variables << var_type_str;
1959 m_case_file_variables <<
" 1 ";
1960 if (m_fileset_size != 0)
1961 m_case_file_variables <<
" 1 ";
1962 m_case_file_variables << v.
name();
1963 _writeWildcardFilename(m_case_file_variables, v.
name());
1964 m_case_file_variables <<
'\n';
1979 bool need_save =
false;
1981 need_save = v.
itemGroup() == part->group();
1983 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
1985 _saveVariableOnGroup(dw_ofile(), *part, wf);
1997 writeFileString(dw_ofile(),
"part");
1998 writeFileInt(dw_ofile(), part->partId());
1999 writeFileString(dw_ofile(),
"coordinates");
2000 wf.putValue(dw_ofile());
2007 dw_ofile.syncFile();
2019template <
typename T>
2026 for (
Integer idim2 = 0; idim2 < ptr.dim2Size(); ++idim2) {
2031 debug() <<
"Saving variable " << v.
name() <<
" component " << idim2 <<
" in " << filename;
2035 _writeFileHeader(dw_ofile(),
false);
2038 writeFileString(dw_ofile(), vname);
2045 var_type_str =
"scalar per element: ";
2048 var_type_str =
"scalar per node: ";
2054 m_case_file_variables << var_type_str;
2055 m_case_file_variables <<
" 1 ";
2056 if (m_fileset_size != 0)
2057 m_case_file_variables <<
" 1 ";
2058 m_case_file_variables << vname;
2059 _writeWildcardFilename(m_case_file_variables, vname);
2060 m_case_file_variables <<
'\n';
2075 bool need_save =
false;
2077 need_save = v.
itemGroup() == part->group();
2079 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2081 _saveVariableOnGroup(dw_ofile(), *part, wf);
2089 for (
Integer i = 0; i < ptr.dim1Size(); ++i)
2093 writeFileString(dw_ofile(),
"part");
2094 writeFileInt(dw_ofile(), part->partId());
2095 writeFileString(dw_ofile(),
"coordinates");
2096 wf.putValue(dw_ofile());
2103 dw_ofile.syncFile();
2116template <
typename T>
2125 warning() <<
"Impossible to write array variable "
2126 << v.
name() <<
" of non-constant size; variable saving skipped";
2144 debug() <<
"Saving variable " << v.
name() <<
" in " << filename;
2148 _writeFileHeader(dw_ofile(),
false);
2150 writeFileString(dw_ofile(), v.
name());
2156 m_case_file_variables <<
"vector per element: ";
2159 m_case_file_variables <<
"vector per node: ";
2165 m_case_file_variables <<
" 1 ";
2166 if (m_fileset_size != 0)
2167 m_case_file_variables <<
" 1 ";
2168 m_case_file_variables << v.
name();
2170 _writeWildcardFilename(m_case_file_variables, v.
name());
2171 m_case_file_variables <<
'\n';
2186 bool need_save =
false;
2188 need_save = v.
itemGroup() == part->group();
2190 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2192 _saveVariableOnGroup(dw_ofile(), *part, wf);
2204 writeFileString(dw_ofile(),
"part");
2205 writeFileInt(dw_ofile(), part->partId());
2206 writeFileString(dw_ofile(),
"coordinates");
2207 wf.putValue(dw_ofile());
2214 dw_ofile.syncFile();
2229 for (
Integer idim2 = 0; idim2 < ptr.dim2Size(); ++idim2) {
2234 debug() <<
"Saving variable " << v.
name() <<
" component " << idim2 <<
" in " << filename;
2238 _writeFileHeader(dw_ofile(),
false);
2240 writeFileString(dw_ofile(), vname);
2246 m_case_file_variables <<
"vector per element: ";
2249 m_case_file_variables <<
"vector per node: ";
2255 m_case_file_variables <<
" 1 ";
2256 if (m_fileset_size != 0)
2257 m_case_file_variables <<
" 1 ";
2258 m_case_file_variables << vname;
2260 _writeWildcardFilename(m_case_file_variables, vname);
2261 m_case_file_variables <<
'\n';
2276 bool need_save =
false;
2278 need_save = v.
itemGroup() == part->group();
2280 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2282 _saveVariableOnGroup(dw_ofile(), *part, wf);
2290 for (
Integer i = 0; i < ptr.dim1Size(); ++i)
2294 writeFileString(dw_ofile(),
"part");
2295 writeFileInt(dw_ofile(), part->partId());
2296 writeFileString(dw_ofile(),
"coordinates");
2297 wf.putValue(dw_ofile());
2304 dw_ofile.syncFile();
2325 warning() <<
"Impossible to write array variable " << v.
name()
2326 <<
" of non-constant size; variable saving skipped";
2335class Ensight7PostProcessorService
2336:
public PostProcessorWriterBase
2341 : PostProcessorWriterBase(sbi)
2342 , m_mesh(sbi.
mesh())
2364 bool is_binary =
true;
2366 bool is_parallel = subDomain()->parallelMng()->isParallel();
2367 bool use_degenerated_hexa =
true;
2368 bool force_first_geometry =
false;
2369 bool save_uids =
false;
2372 fileset_size, use_degenerated_hexa,
2373 force_first_geometry, save_uids);
2392class Ensight7PostProcessorServiceV2
2403 , m_mesh(sbi.
mesh())
2421 IMesh* m_mesh =
nullptr;
2422 DumpW* m_writer =
nullptr;
2433 bool is_binary =
true;
2435 bool is_parallel = m_mesh->parallelMng()->isParallel();
2436 is_binary =
options()->binaryFile();
2437 fileset_size =
options()->filesetSize();
2438 bool use_degenerated_hexa =
options()->useDegeneratedHexa();
2439 bool force_first_geometry =
options()->forceFirstGeometry();
2440 bool save_uids =
options()->saveUids();
2443 use_degenerated_hexa, force_first_geometry, save_uids);
2457 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.