14#include "arcane/utils/String.h"
15#include "arcane/utils/Enumerator.h"
16#include "arcane/utils/Iterator.h"
17#include "arcane/utils/List.h"
18#include "arcane/utils/PlatformUtils.h"
19#include "arcane/utils/Iostream.h"
20#include "arcane/utils/OStringStream.h"
21#include "arcane/utils/ArcanePrecomp.h"
23#include "arcane/core/Item.h"
25#include "arcane/core/IVariable.h"
26#include "arcane/core/ISubDomain.h"
27#include "arcane/core/IMesh.h"
28#include "arcane/core/IMeshSubMeshTransition.h"
29#include "arcane/core/StdNum.h"
30#include "arcane/core/ItemGroup.h"
31#include "arcane/core/IParallelMng.h"
32#include "arcane/core/Directory.h"
33#include "arcane/core/PostProcessorWriterBase.h"
34#include "arcane/core/Service.h"
35#include "arcane/core/SimpleProperty.h"
36#include "arcane/core/FactoryService.h"
37#include "arcane/core/VariableCollection.h"
39#include "arcane/std/DumpW.h"
55 Integer code_hex[8] = { 0, 3, 2, 1, 4, 7, 6, 5 };
56 Integer code_prism[6] = { 2, 1, 0, 5, 4, 3 };
57 Integer code_pyr[5] = { 4, 1, 2, 3, 0 };
58 Integer code_tet[4] = { 0, 1, 3, 2 };
79 ARCANE_UNUSED(meta_data);
86 void writeVal(IVariable&, ConstArrayView<Real3>)
override;
87 void writeVal(IVariable&, ConstArrayView<Int64>)
override {}
88 void writeVal(IVariable&, ConstArrayView<Int32>)
override {}
89 void writeVal(IVariable&, ConstArrayView<Real2x2>)
override {}
90 void writeVal(IVariable&, ConstArrayView<Real3x3>)
override {}
91 void writeVal(IVariable&, ConstArrayView<String>)
override {}
93 void writeVal(IVariable&, ConstArray2View<Byte>)
override {}
94 void writeVal(IVariable&, ConstArray2View<Real>)
override {}
95 void writeVal(IVariable&, ConstArray2View<Int64>)
override {}
96 void writeVal(IVariable&, ConstArray2View<Int32>)
override {}
97 void writeVal(IVariable&, ConstArray2View<Real2>)
override {}
98 void writeVal(IVariable&, ConstArray2View<Real3>)
override {}
99 void writeVal(IVariable&, ConstArray2View<Real2x2>)
override {}
100 void writeVal(IVariable&, ConstArray2View<Real3x3>)
override {}
102 void writeVal(IVariable&, ConstMultiArray2View<Byte>)
override {}
103 void writeVal(IVariable&, ConstMultiArray2View<Real>)
override {}
104 void writeVal(IVariable&, ConstMultiArray2View<Int64>)
override {}
105 void writeVal(IVariable&, ConstMultiArray2View<Int32>)
override {}
106 void writeVal(IVariable&, ConstMultiArray2View<Real2>)
override {}
107 void writeVal(IVariable&, ConstMultiArray2View<Real3>)
override {}
108 void writeVal(IVariable&, ConstMultiArray2View<Real2x2>)
override {}
109 void writeVal(IVariable&, ConstMultiArray2View<Real3x3>)
override {}
116 static constexpr Integer m_max_digit = 5;
118 static constexpr Integer MAX_FLOAT_DIGIT = FloatInfo<Real>::maxDigit() + 1;
120 ISubDomain* m_sub_domain;
140, m_base_directory(filename)
142, m_save_variables(variables.clone())
150 const int type = cell.
type();
151 if (type == IT_Vertex || type == IT_Line2 || type == IT_Triangle3 || type == IT_Quad4 || type == IT_Hexaedron8 || type == IT_Pyramid5 || type == IT_Pentagon5 || type == IT_Tetraedron4)
155 <<
" is unknown in UCD format. Cell will be ignored.";
162 for (
Integer i = 0; i < nb_cell_var; ++i) {
167 for (
Integer i = 0; i < nb_node_var; ++i) {
173 debug() <<
"DumpWUCD::DumpWUCD - "
174 <<
m_mesh->nbCell() <<
" cells among which "
197 info() <<
"** HERE dump Real variable " << v.
name();
203 for (
Integer i = 0; i < size; i++)
208 for (
Integer i = 0; i < size; i++) {
214 info() <<
"Variable not managed by UCD writer: " << v.
name();
229 info() <<
"** HERE dump Real3 variable " << v.
name();
235 for (
Integer i = 0; i < size; i++) {
243 for (
Integer i = 0; i < size; i++) {
252 info() <<
"Variable not managed by UCD writer: " << v.
name();
272 info() <<
"** Entering method DumpWUCD::writeBegin";
285 info() <<
"** Entering method DumpWUCD::writeEnd";
291 ostr().width(m_max_digit);
295 std::ofstream ucd_file(buf.
localstr());
307 Integer comp_node_data_size = 0;
308 Integer comp_cell_data_size = 0;
311 ndata_size_stream().precision(MAX_FLOAT_DIGIT);
312 ndata_name_stream().precision(MAX_FLOAT_DIGIT);
313 cdata_size_stream().precision(MAX_FLOAT_DIGIT);
314 cdata_name_stream().precision(MAX_FLOAT_DIGIT);
316 ndata_size_stream().flags(std::ios::scientific);
317 ndata_name_stream().flags(std::ios::scientific);
318 cdata_size_stream().flags(std::ios::scientific);
319 cdata_name_stream().flags(std::ios::scientific);
330 debug() <<
" Variable " << name
331 <<
" kind = IK_Node, type = DT_Real";
333 comp_node_data_size++;
334 ndata_size_stream() <<
" 1";
335 ndata_name_stream() << name <<
", Unknown" <<
'\n';
338 debug() <<
" Variable " << name
339 <<
" kind = IK_Cell, type = DT_Real";
341 comp_cell_data_size++;
342 cdata_size_stream() <<
" 1";
343 cdata_name_stream() << name <<
", Unknown" <<
'\n';
348 debug() <<
" Variable " << name
349 <<
" kind = IK_Node, type = DT_Real3";
351 comp_node_data_size += 3;
352 ndata_size_stream() <<
" 3";
353 ndata_name_stream() << name <<
", Unknown" <<
'\n';
356 debug() <<
" Variable " << name
357 <<
" kind = IK_Cell, type = DT_Real3";
359 comp_cell_data_size += 3;
360 cdata_size_stream() <<
" 3";
361 cdata_name_stream() << name <<
", Unknown" <<
'\n';
369 ucd_file << nb_node <<
" "
370 << nb_managed_cell <<
" "
371 << comp_node_data_size <<
" "
372 << comp_cell_data_size <<
" 0" <<
'\n';
376 for (
Integer i = 0; i < nb_node; i++) {
377 const Real3 node_coord = node_coords[i];
378 ucd_file << i + 1 <<
" "
379 << node_coord.
x <<
" "
380 << node_coord.
y <<
" "
381 << node_coord.
z <<
'\n';
385 for (
Integer iz = 0; iz < nb_managed_cell; ++iz) {
388 ucd_file <<
id + 1 <<
" 1 ";
390 switch (cell.
type()) {
397 for (
Integer i = 0; i < nb_cell_node; i++)
402 for (
Integer i = 0; i < nb_cell_node; i++)
407 for (
Integer i = 0; i < nb_cell_node; i++)
410 case (IT_Hexaedron8):
412 for (
Integer i = 0; i < nb_cell_node; i++)
413 ucd_file <<
" " << cell.
node(code_hex[i]).
localId() + 1;
417 for (
Integer i = 0; i < nb_cell_node; i++)
418 ucd_file <<
" " << cell.
node(code_pyr[i]).
localId() + 1;
422 for (
Integer i = 0; i < nb_cell_node; i++)
423 ucd_file <<
" " << cell.
node(code_prism[i]).
localId() + 1;
425 case (IT_Tetraedron4):
427 for (
Integer i = 0; i < nb_cell_node; i++)
428 ucd_file <<
" " << cell.
node(code_tet[i]).
localId() + 1;
440 if (nb_comp_node_data) {
441 ucd_file << nb_comp_node_data
442 << ndata_size_stream.str()
444 << ndata_name_stream.str();
445 for (
Integer i = 0; i < nb_node; i++)
450 if (nb_comp_cell_data) {
451 ucd_file << nb_comp_cell_data
452 << cdata_size_stream.str()
454 << cdata_name_stream.str();
455 for (
Integer i = 0; i < nb_managed_cell; i++) {
463 code_ostr().fill(
'0');
464 code_ostr().width(m_max_digit);
465 code_ostr() <<
m_times.size() - 1;
468 std::ofstream code_file(buf.
localstr());
469 code_file << m_sub_domain->commonVariables().globalIteration() <<
'\n'
475 << comp_node_data_size <<
'\n'
476 << comp_cell_data_size <<
'\n';
477 for (
Integer i = 0; i < comp_node_data_size; i++)
478 code_file <<
"1" <<
'\n';
479 for (
Integer i = 0; i < comp_cell_data_size; i++)
480 code_file <<
"1" <<
'\n';
492class UCDPostProcessorService
493:
public PostProcessorWriterBase
498 : PostProcessorWriterBase(sbi)
517 m_writer =
new DumpWUCD(subDomain(), subDomain()->defaultMesh(),
#define ARCANE_REGISTER_SUB_DOMAIN_FACTORY(aclass, ainterface, aname)
Registers a factory service for the class aclass.
#define ARCANE_REGISTER_CASE_OPTIONS_NOAXL_FACTORY(aclass, ainterface, aname)
Registers a factory service for the class aclass.
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
Class managing a directory.
bool createDirectory() const override
Creates the directory.
VariableList m_save_variables
List of variables to export.
UniqueArray< Ref< OStringStream > > m_cell_streams
Variable values at cells.
UniqueArray< Ref< OStringStream > > m_node_streams
Variable values at nodes.
void writeVal(IVariable &, ConstArrayView< Byte >) override
Writing for variable v of array a.
RealUniqueArray m_times
List of time instances.
Directory m_base_directory
Storage directory name.
UniqueArray< Cell > m_managed_cells
List of managed cells.
void beginWrite() override
Creation of the UCD file (named UCD_<no_iteration>) and its header. This header contains:
void endWrite() override
Concatenation of the stream containing cell data to the main file.
void setMetaData(const String &meta_data) override
Sets metadata information.
wrapper transforming calls to the IDataWriter interface into IDumpW
Interface for writing variable data.
virtual Integer nbNode()=0
Number of mesh nodes.
virtual CellGroup allCells()=0
Group of all cells.
Interface for a writer for post-processing information.
Interface of the subdomain manager.
virtual eDataType dataType() const =0
Data type managed by the variable (Real, Integer, ...).
virtual eItemKind itemKind() const =0
Kind of mesh entities on which the variable is based.
virtual Integer dimension() const =0
Dimension of the variable.
virtual String name() const =0
Variable name.
Node node(Int32 i) const
i-th node of the entity
Int32 nbNode() const
Number of nodes of the entity.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
Int16 type() const
Entity type.
Output stream linked to a String.
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.
Class managing a 3-dimensional real vector.
Structure containing the information to create a service.
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 info() const
Flow for an information message.
Post-processing in UCD format.
void notifyBeginWrite() override
Notifies that an output is going to be performed with the current parameters.
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.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
UniqueArray< Real > RealUniqueArray
Dynamic 1D array of reals.
eItemKind
Mesh entity type.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
@ DT_Real3
Vector 3 data type.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Real y
second component of the triplet
Real z
third component of the triplet
Real x
first component of the triplet