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"
27#include "arcane/core/IDataWriter.h"
28#include "arcane/core/Item.h"
30#include "arcane/core/IVariable.h"
31#include "arcane/core/ISubDomain.h"
32#include "arcane/core/IMesh.h"
33#include "arcane/core/IMeshSubMeshTransition.h"
34#include "arcane/core/StdNum.h"
35#include "arcane/core/ItemGroup.h"
36#include "arcane/core/IParallelMng.h"
37#include "arcane/core/Directory.h"
38#include "arcane/core/MeshVariable.h"
39#include "arcane/core/PostProcessorWriterBase.h"
40#include "arcane/core/Service.h"
41#include "arcane/core/SimpleProperty.h"
42#include "arcane/core/IItemFamily.h"
43#include "arcane/core/VariableCollection.h"
44#include "arcane/core/SharedVariable.h"
46#include "arcane/core/FactoryService.h"
49#include "arcane/std/Ensight7PostProcessor_axl.h"
50#include "arcane/std/DumpW.h"
54#include <unordered_map>
101 static const int int_width = 10;
102 static const int g_line_length = 80;
122 EnsightPart(
const EnsightPart& part)
127 , m_reindex(part.m_reindex)
134 inline int type()
const {
return m_type; }
139 inline bool hasReindex()
const {
return !m_reindex.empty(); }
140 inline void setReindex(
Integer* reindex)
144 m_reindex[i] = reindex[i];
178 _init(use_degenerated_hexa);
184 n += m_parts[i].items().size();
187 const EnsightPart& typeInfo(
Integer i)
const {
return m_parts[i]; }
188 EnsightPart& typeInfo(
Integer i) {
return m_parts[i]; }
189 ItemGroup group()
const {
return m_group; }
191 Int32 generalItemTypeId(
const Item& item)
const
196 EnsightPart* getTypeInfo(
int type)
198 auto ensight_part_element = m_parts_map.find(type);
199 if (ensight_part_element != m_parts_map.end())
200 return ensight_part_element->second;
210 bool m_is_polygonal_type_registration_done =
false;
211 bool m_is_polyhedral_type_registration_done =
false;
215 std::unordered_map<TypeId, EnsightPart*> m_parts_map;
221 for (
auto& ensight_part : m_parts) {
222 m_parts_map[ensight_part.type()] = &ensight_part;
226 void _init(
bool use_degenerated_hexa)
235 m_parts.add(
EnsightPart(IT_Triangle3, 3,
"tria3"));
237 m_parts.add(
EnsightPart(IT_Pentagon5, 5,
"nsided"));
238 m_parts.add(
EnsightPart(IT_Hexagon6, 6,
"nsided"));
239 m_parts.add(
EnsightPart(IT_Heptagon7, 7,
"nsided"));
240 m_parts.add(
EnsightPart(IT_Octogon8, 8,
"nsided"));
251 if (!m_is_polygonal_type_registration_done) {
253 ItemWithNodes item = iitem->toItemWithNodes();
254 if (item.nbNode() == item.itemBase().nbEdge()) {
256 m_parts.
add(EnsightPart(type_id++, item.nbNode(),
"nsided"));
259 m_is_polygonal_type_registration_done =
true;
262 m_parts.add(EnsightPart(IT_Tetraedron4, 4,
"tetra4"));
263 m_parts.add(EnsightPart(IT_Pyramid5, 5,
"pyramid5"));
264 m_parts.add(EnsightPart(IT_Pentaedron6, 6,
"penta6"));
265 m_parts.add(EnsightPart(IT_Hexaedron8, 8,
"hexa8"));
266 if (use_degenerated_hexa) {
267 m_parts.add(EnsightPart(IT_HemiHexa7, 8,
"hexa8"));
269 Integer reindex[8] = { 1, 6, 5, 0, 2, 3, 4, 0 };
270 m_parts[m_parts.size() - 1].setReindex(reindex);
272 m_parts.add(EnsightPart(IT_HemiHexa6, 8,
"hexa8"));
274 Integer reindex[8] = { 0, 1, 3, 5, 0, 2, 3, 4 };
275 m_parts[m_parts.size() - 1].setReindex(reindex);
277 m_parts.add(EnsightPart(IT_HemiHexa5, 8,
"hexa8"));
279 Integer reindex[8] = { 0, 1, 3, 4, 0, 2, 3, 4 };
280 m_parts[m_parts.size() - 1].setReindex(reindex);
282 m_parts.add(EnsightPart(IT_AntiWedgeLeft6, 8,
"hexa8"));
284 Integer reindex[8] = { 2, 0, 1, 2, 5, 3, 4, 4 };
285 m_parts[m_parts.size() - 1].setReindex(reindex);
287 m_parts.add(EnsightPart(IT_AntiWedgeRight6, 8,
"hexa8"));
289 Integer reindex[8] = { 2, 0, 1, 1, 5, 3, 4, 5 };
290 m_parts[m_parts.size() - 1].setReindex(reindex);
292 m_parts.add(EnsightPart(IT_DiTetra5, 8,
"hexa8"));
294 Integer reindex[8] = { 4, 4, 2, 3, 0, 1, 1, 3 };
295 m_parts[m_parts.size() - 1].setReindex(reindex);
299 m_parts.add(EnsightPart(IT_HemiHexa7, 7,
"nfaced"));
300 m_parts.add(EnsightPart(IT_HemiHexa6, 6,
"nfaced"));
301 m_parts.add(EnsightPart(IT_HemiHexa5, 5,
"nfaced"));
302 m_parts.add(EnsightPart(IT_AntiWedgeLeft6, 6,
"nfaced"));
303 m_parts.add(EnsightPart(IT_AntiWedgeRight6, 6,
"nfaced"));
304 m_parts.add(EnsightPart(IT_DiTetra5, 5,
"nfaced"));
306 m_parts.add(EnsightPart(IT_Heptaedron10, 10,
"nfaced"));
307 m_parts.add(EnsightPart(IT_Octaedron12, 12,
"nfaced"));
308 m_parts.add(EnsightPart(IT_Enneedron14, 14,
"nfaced"));
309 m_parts.add(EnsightPart(IT_Decaedron16, 16,
"nfaced"));
312 ItemTypeInfo* type_info = item_type_mng->
typeFromId(i_type);
313 if (type_info->nbLocalNode() != type_info->nbLocalEdge()) {
314 m_parts.add(EnsightPart(i_type, type_info->nbLocalNode(),
"nfaced"));
319 if (!m_is_polyhedral_type_registration_done) {
321 ItemWithNodes item = iitem->toItemWithNodes();
322 if (item.nbNode() == 1)
324 else if (item.nbNode() == 2)
326 else if (item.nbNode() != item.itemBase().nbEdge()) {
328 m_parts.add(EnsightPart(type_id++, item.nbNode(),
"nfaced"));
331 m_is_polyhedral_type_registration_done =
true;
344 void writeFileString(std::ostream& o,
const String& str);
345 void writeFileInt(std::ostream& o,
int value);
346 void writeFileDouble(std::ostream& o,
double value);
347 Integer writeDoubleSize()
const;
371 explicit WriteBase(DumpWEnsight7& dw)
378 WriteBase(
const WriteBase& wb)
382 virtual ~WriteBase() {}
386 virtual WriteBase* clone() = 0;
387 virtual void begin() { init(); }
388 virtual void end() {}
393 m_ofile.precision(5);
394 m_ofile.flags(std::ios::scientific);
396 virtual void putValue(std::ostream& ofile)
398 ofile << m_ofile.str();
400 std::ostream& stream() {
return m_ofile; }
405 std::ostringstream m_ofile;
412 template <
typename FromType>
422 WriteDouble(
const WriteDouble& wd)
427 WriteBase* clone()
override {
return new WriteDouble(*
this); }
435 inline void write(
Integer index)
438 int reindex = (*m_idx)[index];
449 for (
Item e : items) {
458 template <
typename FromType>
459 class WriteArrayDouble
470 WriteArrayDouble(
const WriteArrayDouble& wd)
473 , m_idim2(wd.m_idim2)
476 WriteBase* clone()
override {
return new WriteArrayDouble(*
this); }
488 int reindex = (*m_idx)[index];
499 for (
Item e : items) {
521 WriteReal3(
const WriteReal3& wd)
526 WriteBase* clone()
override {
return new WriteReal3(*
this); }
534 void begin()
override
538 xostr.flags(std::ios::scientific);
540 yostr.flags(std::ios::scientific);
542 zostr.flags(std::ios::scientific);
548 int reindex = (*m_idx)[index];
564 for (
Item i : items) {
571 m_ofile << xostr.str();
572 m_ofile << yostr.str();
573 m_ofile << zostr.str();
578 std::ostringstream xostr;
579 std::ostringstream yostr;
580 std::ostringstream zostr;
593 class WriteArrayReal3
604 WriteArrayReal3(
const WriteArrayReal3& wd)
607 , m_idim2(wd.m_idim2)
610 WriteBase* clone()
override {
return new WriteArrayReal3(*
this); }
619 void begin()
override
623 xostr.flags(std::ios::scientific);
625 yostr.flags(std::ios::scientific);
627 zostr.flags(std::ios::scientific);
630 inline void write(
Integer index)
633 int reindex = (*m_idx)[index];
647 for (
Item i : items) {
654 m_ofile << xostr.str();
655 m_ofile << yostr.str();
656 m_ofile << zostr.str();
661 std::ostringstream xostr;
662 std::ostringstream yostr;
663 std::ostringstream zostr;
677 bool is_binary,
bool is_parallel,
Integer fileset_size,
678 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids);
685 void writeVal(IVariable&, ConstArrayView<Real2>)
override {}
686 void writeVal(IVariable&, ConstArrayView<Real3>)
override;
690 void writeVal(IVariable&, ConstArrayView<Real2x2>)
override {}
691 void writeVal(IVariable&, ConstArrayView<Real3x3>)
override {}
692 void writeVal(IVariable&, ConstArrayView<String>)
override {}
694 void writeVal(IVariable&, ConstArray2View<Byte>)
override {}
696 void writeVal(IVariable&, ConstArray2View<Real2>)
override {}
697 void writeVal(IVariable&, ConstArray2View<Real3>)
override;
701 void writeVal(IVariable&, ConstArray2View<Real2x2>)
override {}
702 void writeVal(IVariable&, ConstArray2View<Real3x3>)
override {}
704 void writeVal(IVariable&, ConstMultiArray2View<Byte>)
override {}
706 void writeVal(IVariable&, ConstMultiArray2View<Real2>)
override {}
707 void writeVal(IVariable&, ConstMultiArray2View<Real3> a)
override;
711 void writeVal(IVariable&, ConstMultiArray2View<Real2x2>)
override {}
712 void writeVal(IVariable&, ConstMultiArray2View<Real3x3>)
override {}
719 bool isMasterProcessor()
const {
return m_is_master; }
720 bool isOneFilePerTime()
const {
return m_fileset_size == 0; }
727 typedef UniqueArray<GroupPartInfo*> GroupPartInfoList;
736 std::ostringstream m_case_file_variables;
740 GroupPartInfoList m_parts;
746 bool m_use_degenerated_hexa;
747 bool m_force_first_geometry;
767 void _createCaseFile();
770 void _writeWildcardFilename(std::ostream& ofile,
const String& filename,
char joker =
'*');
771 int _fileOuttype()
const;
772 void _writeFileHeader(std::ostream& o,
bool write_c_binary);
773 bool _isNewBlocFile()
const;
776 void _saveGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
778 void _saveVariableOnGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
783 template <
typename T>
786 template <
typename T>
789 template <
typename T>
801 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
802 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
805 is_parallel_output, fileset_size, use_degenerated_hexa,
806 force_first_geometry, save_uids);
810createEnsight7(IMesh* m,
const String& f,
811 ConstArrayView<Real> times,
812 VariableCollection variables,
814 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
815 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
817 return new DumpWEnsight7(m, f, times, variables, groups, is_binary,
818 is_parallel_output, fileset_size, use_degenerated_hexa,
819 force_first_geometry, save_uids);
828 bool is_binary,
bool is_parallel_output,
Integer fileset_size,
829 bool use_degenerated_hexa,
bool force_first_geometry,
bool save_uids)
832, m_parallel_mng(
mesh->parallelMng())
833, m_base_directory(filename)
835, m_save_variables(variables.clone())
836, m_save_groups(groups.enumerator())
837, m_is_binary(is_binary)
840, m_is_parallel_output(is_parallel_output)
841, m_use_degenerated_hexa(use_degenerated_hexa)
842, m_force_first_geometry(force_first_geometry)
843, m_save_uids(save_uids)
844, m_total_nb_element(0)
846, m_fileset_size(fileset_size)
865 std::for_each(std::begin(m_parts), std::end(m_parts), Deleter());
922 Integer type_to_seek = type_info.type();
925 if (e.
type() == type_to_seek)
930 << nb_of_type <<
" items of type " << type_info.name();
934 if (mi.
type() == type_to_seek) {
944 const Item& item = *i2;
945 auto item_type = current_grp.generalItemTypeId(item);
946 EnsightPart* ensight_part = current_grp.getTypeInfo(item_type);
950 ensight_part->items().add(item_wn);
962 auto item_type = item->type();
963 EnsightPart* ensight_part = current_grp.getTypeInfo(item_type);
967 ensight_part->items().add(item_wn);
997_saveGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
1002 writeFileString(ofile,
"part");
1003 writeFileInt(ofile, ensight_grp.partId());
1004 if (isParallelOutput()) {
1007 std::ostringstream ostr;
1009 writeFileString(ofile, ostr.str().c_str());
1012 writeFileString(ofile, igrp.
name());
1019 const EnsightPart& type_info = ensight_grp.typeInfo(i);
1022 if (nb_sub_part == 0)
1025 String type_name = type_info.name();
1026 writeFileString(ofile, type_name);
1028 writeFileInt(ofile, nb_sub_part);
1034 writeFileInt(ofile,mi.
uniqueId()+1);
1038 if (type_name ==
"nfaced") {
1049 for (
Integer z = 0; z < nb_sub_part; ++z)
1050 writeFileInt(ofile, nb_face);
1054 for (
Item mi : items) {
1055 writeFileInt(ofile, mi.toCell().nbFace());
1062 for (
Item mi : items) {
1065 for (
Integer z = 0; z < nb_face; ++z)
1070 for (
Item mi : items) {
1073 writeFileInt(ofile, face.nbNode());
1080 for (
Item item : items) {
1081 Cell cell(item.toCell());
1085 for (
Integer z = 0; z < nb_face; ++z) {
1088 array_id.
resize(nb_node);
1089 for (
Integer y = 0; y < nb_node; ++y) {
1097 writeFileArray(ofile, array_id);
1102 for (
Item item : items) {
1105 for (
Integer z = 0; z < nb_face; ++z) {
1106 const Face local_face = cell.
face(z);
1108 array_id.
resize(nb_node);
1109 for (
Integer y = 0; y < nb_node; ++y) {
1110 array_id[y] = nodes_index[local_face.
node(y).
localId()];
1112 writeFileArray(ofile, array_id);
1117 else if (type_name ==
"nsided") {
1122 for (
Item mi : items) {
1125 writeFileInt(ofile, nb_node);
1128 for (
Item mi : items) {
1131 array_id.
resize(nb_node);
1132 for (
Integer z = 0; z < nb_node; ++z) {
1135 writeFileArray(ofile, array_id);
1141 Integer nb_node = type_info.nbNode();
1142 array_id.
resize(nb_node);
1147 if (type_info.hasReindex()) {
1149 for (
Item mi : items) {
1151 for (
Integer j = 0; j < nb_node; ++j) {
1152 array_id[j] = nodes_index[e.
node(reindex[j]).
localId()];
1154 writeFileArray(ofile, array_id);
1158 for (
Item mi : items) {
1160 for (
Integer j = 0; j < nb_node; ++j) {
1163 writeFileArray(ofile, array_id);
1196_saveVariableOnGroup(std::ostream& ofile,
const GroupPartInfo& ensight_grp,
1201 writeFileString(ofile,
"part");
1202 writeFileInt(ofile, ensight_grp.partId());
1210 const EnsightPart& type_info = ensight_grp.typeInfo(i);
1213 if (nb_sub_part == 0)
1215 String type_name = type_info.name();
1216 if (type_name != last_type_name) {
1220 func->putValue(ofile);
1222 last_type_name = type_name;
1223 writeFileString(ofile, type_name);
1224 func = from_func.clone();
1235 func->putValue(ofile);
1243writeFileInt(std::ostream& o,
int value)
1246 o.write((
const char*)&value,
sizeof(
int));
1249 o.width(DumpWEnsight7::int_width);
1263 return DumpWEnsight7::int_width + 1;
1270writeFileDouble(std::ostream& o,
double value)
1273 float fvalue = (float)(value);
1274 o.write((
const char*)&fvalue,
sizeof(
float));
1279 o.flags(std::ios::scientific);
1289writeDoubleSize()
const
1302 o.write((
const char*)value.data(),
sizeof(
Integer) * value.size());
1305 for (
Integer i = 0, s = value.size(); i < s; ++i) {
1306 o.width(DumpWEnsight7::int_width);
1317writeFileString(std::ostream& o,
const String& str)
1320 char buf[g_line_length];
1321 for (
int i = 0; i < g_line_length; ++i)
1324 buf[g_line_length - 1] =
'\0';
1325 o.write(buf, g_line_length);
1336_writeFileHeader(std::ostream& o,
bool write_c_binary)
1339 if (_isNewBlocFile() &&
m_is_binary && write_c_binary)
1340 writeFileString(o,
"C Binary");
1341 if (m_fileset_size != 0) {
1342 std::ostringstream ostr;
1343 ostr <<
"BEGIN TIME STEP "
1345 writeFileString(o, ostr.str().c_str());
1359class DumpWEnsight7OutFile
1365 , m_filename(filename)
1366 , m_is_master(dw.isMasterProcessor())
1367 , m_is_parallel_output(dw.isParallelOutput())
1372 m_filestream =
new std::ofstream(filename.
localstr(), (std::ios_base::openmode)outtype);
1373 m_stream = &m_strstream;
1374 if (!(*m_filestream))
1375 m_dw.warning() <<
"Unable to open file " << filename;
1379 m_stream = &m_strstream;
1381 ARCANE_CHECK_PTR(m_stream);
1383 ~DumpWEnsight7OutFile()
1385 delete m_filestream;
1394 ARCANE_CHECK_PTR(m_filestream);
1395 ARCANE_CHECK_PTR(m_strstream);
1397 (*m_filestream) << m_strstream.str();
1399 if (m_is_parallel_output) {
1401 ARCANE_CHECK_PTR(m_filestream);
1409 for (
Integer i = 1; i < nb_proc; ++i) {
1410 m_dw.debug(
Trace::High) <<
"Waiting for length of processor " << i;
1411 parallel_mng->
recv(len_array, i);
1413 m_dw.debug(
Trace::High) <<
"Length of processor " << i <<
" : " << len;
1416 m_dw.debug(
Trace::High) <<
"Waiting for receving geom of processor " << i;
1417 parallel_mng->
recv(str_array, i);
1418 m_dw.debug(
Trace::High) <<
"Receving geom of processor " << i;
1419 m_filestream->write((
const char*)str_array.
data(), str_array.
size());
1424 ARCANE_CHECK_PTR(m_strstream);
1431 std::string str = m_strstream.str();
1440 m_dw.debug(
Trace::High) <<
"Not a master. " << m_filename <<
" size = " << len;
1444 m_dw.debug(
Trace::High) <<
"Sending length for processor 0";
1445 parallel_mng->send(len_array, 0);
1450 m_dw.debug(
Trace::High) <<
"Sending data for processor 0";
1451 parallel_mng->send(bytes, 0);
1457 if (!m_dw.isOneFilePerTime())
1458 m_dw.writeFileString(*m_filestream,
"END TIME STEP");
1463 std::ostream& operator()() {
return *m_stream; }
1470 bool m_is_parallel_output;
1471 std::ostream* m_stream;
1472 std::ostringstream m_strstream;
1473 std::ofstream* m_filestream;
1488 bool is_parallel = parallel_mng->
isParallel();
1519 if (!list_group.contains(var_group))
1520 list_group.add(var_group);
1526 _computeGroupParts(list_group, partid);
1531 for (
auto i : m_parts) {
1532 total_nb_element += i->totalNbElement();
1538 debug() <<
"Add nodes " <<
mesh->nbNode();
1542 if (!(
m_times.size() > 1 && m_force_first_geometry)) {
1548 _writeFileHeader(dw_ofile(),
true);
1551 writeFileString(dw_ofile(),
"Output ensight test");
1552 writeFileString(dw_ofile(),
"File description");
1553 writeFileString(dw_ofile(),
"node id assign");
1554 writeFileString(dw_ofile(),
"element id assign");
1564 all_nodes_index.
fill(0);
1568 if (
mesh->parentMesh()) {
1570 coords_backup.
resize(
mesh->nodeFamily()->maxLocalId());
1572 coords_backup[i_item.localId()] = nodes_coords[i_item];
1574 coords_array = coords_backup.
view();
1584 writeFileString(wf.stream(),
"coordinates");
1585 writeFileInt(wf.stream(), all_nodes.
size());
1592 const Item& item = *i_item;
1593 all_nodes_index[item.
localId()] = ensight_index;
1602 const Item& item = *i_item;
1603 writeFileInt(wf.stream(),item.
uniqueId()+1);
1609 const Item& item = *i_item;
1616 _saveGroup(dw_ofile(), *part, all_nodes_index, wf);
1618 dw_ofile.syncFile();
1632 cell_uids[icell] = (
Real)(icell->uniqueId().asInt64());
1638 write(cell_uid_var, cell_uid_var->
data());
1645 node_uids[inode] = inode->uniqueId().asInt32();
1646 node_uids2[inode.index()] = (
Real)inode->uniqueId().asInt64();
1663 warning() <<
"Unable to write to file: <" << buf <<
"> error: " <<
m_case_file.rdstate();
1670 if (m_fileset_size != 0)
1672 if (m_force_first_geometry)
1673 _writeWildcardFilename(
m_case_file,
"ensight.geo",
'0');
1675 _writeWildcardFilename(
m_case_file,
"ensight.geo",
'*');
1699 if (m_fileset_size != 0) {
1702 if (m_fileset_size != 0) {
1704 for (
Integer i = 0; i < nb_timeset; ++i) {
1706 m_case_file <<
"number of steps: " << m_fileset_size <<
'\n';
1709 m_case_file <<
"filename index: " << nb_timeset <<
"\n";
1710 m_case_file <<
"number of steps: " <<
m_times.size() - (nb_timeset * m_fileset_size) <<
'\n';
1774 if (m_fileset_size == 0) {
1790 ostr() << current_time;
1791 fn_builder += ostr.str();
1803 filename = fn_builder;
1815 return group_kind == item_kind;
1834 bool has_prot =
false;
1835 if (m_fileset_size != 0) {
1838 prot_index = (nb_time - 1) / m_fileset_size;
1850 ostr() << prot_index;
1865_writeWildcardFilename(std::ostream& ofile,
const String& filename,
char joker)
1867 if (m_fileset_size == 0) {
1868 ofile <<
' ' << filename <<
'/' << filename;
1879 if (nb_time <= m_fileset_size)
1883 ofile <<
"/" << filename;
1891_isNewBlocFile()
const
1897 if (m_fileset_size == 0)
1900 Integer modulo = (nb_time - 1) % m_fileset_size;
1913 return ((isBinary()) ? std::ios::binary : 0) | ((_isNewBlocFile()) ? std::ios::trunc : std::ios::app);
1922template <
typename T>
1926 debug() <<
"Saving variable1 " << v.
name() <<
" ptr=" << ptr.
data() <<
" ps=" << ptr.
size();
1934 debug() <<
"Saving variable " << v.
name() <<
" in " << filename;
1938 _writeFileHeader(dw_ofile(),
false);
1941 writeFileString(dw_ofile(), v.
name());
1948 var_type_str =
"scalar per element: ";
1951 var_type_str =
"scalar per node: ";
1957 m_case_file_variables << var_type_str;
1958 m_case_file_variables <<
" 1 ";
1959 if (m_fileset_size != 0)
1960 m_case_file_variables <<
" 1 ";
1961 m_case_file_variables << v.
name();
1962 _writeWildcardFilename(m_case_file_variables, v.
name());
1963 m_case_file_variables <<
'\n';
1978 bool need_save =
false;
1980 need_save = v.
itemGroup() == part->group();
1982 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
1984 _saveVariableOnGroup(dw_ofile(), *part, wf);
1996 writeFileString(dw_ofile(),
"part");
1997 writeFileInt(dw_ofile(), part->partId());
1998 writeFileString(dw_ofile(),
"coordinates");
1999 wf.putValue(dw_ofile());
2006 dw_ofile.syncFile();
2018template <
typename T>
2025 for (
Integer idim2 = 0; idim2 < ptr.dim2Size(); ++idim2) {
2030 debug() <<
"Saving variable " << v.
name() <<
" component " << idim2 <<
" in " << filename;
2034 _writeFileHeader(dw_ofile(),
false);
2037 writeFileString(dw_ofile(), vname);
2044 var_type_str =
"scalar per element: ";
2047 var_type_str =
"scalar per node: ";
2053 m_case_file_variables << var_type_str;
2054 m_case_file_variables <<
" 1 ";
2055 if (m_fileset_size != 0)
2056 m_case_file_variables <<
" 1 ";
2057 m_case_file_variables << vname;
2058 _writeWildcardFilename(m_case_file_variables, vname);
2059 m_case_file_variables <<
'\n';
2074 bool need_save =
false;
2076 need_save = v.
itemGroup() == part->group();
2078 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2080 _saveVariableOnGroup(dw_ofile(), *part, wf);
2088 for (
Integer i = 0; i < ptr.dim1Size(); ++i)
2092 writeFileString(dw_ofile(),
"part");
2093 writeFileInt(dw_ofile(), part->partId());
2094 writeFileString(dw_ofile(),
"coordinates");
2095 wf.putValue(dw_ofile());
2102 dw_ofile.syncFile();
2115template <
typename T>
2124 warning() <<
"Impossible to write array variable "
2125 << v.
name() <<
" of non-constant size; variable saving skipped";
2143 debug() <<
"Saving variable " << v.
name() <<
" in " << filename;
2147 _writeFileHeader(dw_ofile(),
false);
2149 writeFileString(dw_ofile(), v.
name());
2155 m_case_file_variables <<
"vector per element: ";
2158 m_case_file_variables <<
"vector per node: ";
2164 m_case_file_variables <<
" 1 ";
2165 if (m_fileset_size != 0)
2166 m_case_file_variables <<
" 1 ";
2167 m_case_file_variables << v.
name();
2169 _writeWildcardFilename(m_case_file_variables, v.
name());
2170 m_case_file_variables <<
'\n';
2185 bool need_save =
false;
2187 need_save = v.
itemGroup() == part->group();
2189 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2191 _saveVariableOnGroup(dw_ofile(), *part, wf);
2203 writeFileString(dw_ofile(),
"part");
2204 writeFileInt(dw_ofile(), part->partId());
2205 writeFileString(dw_ofile(),
"coordinates");
2206 wf.putValue(dw_ofile());
2213 dw_ofile.syncFile();
2228 for (
Integer idim2 = 0; idim2 < ptr.dim2Size(); ++idim2) {
2233 debug() <<
"Saving variable " << v.
name() <<
" component " << idim2 <<
" in " << filename;
2237 _writeFileHeader(dw_ofile(),
false);
2239 writeFileString(dw_ofile(), vname);
2245 m_case_file_variables <<
"vector per element: ";
2248 m_case_file_variables <<
"vector per node: ";
2254 m_case_file_variables <<
" 1 ";
2255 if (m_fileset_size != 0)
2256 m_case_file_variables <<
" 1 ";
2257 m_case_file_variables << vname;
2259 _writeWildcardFilename(m_case_file_variables, vname);
2260 m_case_file_variables <<
'\n';
2275 bool need_save =
false;
2277 need_save = v.
itemGroup() == part->group();
2279 need_save = _isSameKindOfGroup(part->group(), v.
itemKind());
2281 _saveVariableOnGroup(dw_ofile(), *part, wf);
2289 for (
Integer i = 0; i < ptr.dim1Size(); ++i)
2293 writeFileString(dw_ofile(),
"part");
2294 writeFileInt(dw_ofile(), part->partId());
2295 writeFileString(dw_ofile(),
"coordinates");
2296 wf.putValue(dw_ofile());
2303 dw_ofile.syncFile();
2324 warning() <<
"Impossible to write array variable " << v.
name()
2325 <<
" of non-constant size; variable saving skipped";
2334class Ensight7PostProcessorService
2335:
public PostProcessorWriterBase
2340 : PostProcessorWriterBase(sbi)
2341 , m_mesh(sbi.
mesh())
2363 bool is_binary =
true;
2365 bool is_parallel = subDomain()->parallelMng()->isParallel();
2366 bool use_degenerated_hexa =
true;
2367 bool force_first_geometry =
false;
2368 bool save_uids =
false;
2371 fileset_size, use_degenerated_hexa,
2372 force_first_geometry, save_uids);
2391class Ensight7PostProcessorServiceV2
2402 , m_mesh(sbi.
mesh())
2420 IMesh* m_mesh =
nullptr;
2421 DumpW* m_writer =
nullptr;
2432 bool is_binary =
true;
2434 bool is_parallel = m_mesh->parallelMng()->isParallel();
2435 is_binary =
options()->binaryFile();
2436 fileset_size =
options()->filesetSize();
2437 bool use_degenerated_hexa =
options()->useDegeneratedHexa();
2438 bool force_first_geometry =
options()->forceFirstGeometry();
2439 bool save_uids =
options()->saveUids();
2442 use_degenerated_hexa, force_first_geometry, save_uids);
2456 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.