Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::VtkMeshIOService Class Reference

Mesh file reader for legacy VTK format. More...

Inheritance diagram for Arcane::VtkMeshIOService:
Collaboration diagram for Arcane::VtkMeshIOService:

Classes

class  VtkMesh
class  VtkStructuredGrid

Public Types

enum  eMeshType { VTK_MT_Unknown , VTK_MT_StructuredGrid , VTK_MT_UnstructuredGrid }

Public Member Functions

 VtkMeshIOService (ITraceMng *tm)
void build ()
bool readMesh (IPrimaryMesh *mesh, const String &file_name, const String &dir_name, bool use_internal_partition)
 Allows starting the reading of a vtk file.
Public Member Functions inherited from Arcane::TraceAccessor
 TraceAccessor (ITraceMng *m)
 Constructs an accessor via the trace manager m.
 TraceAccessor (const TraceAccessor &rhs)
 Copy constructor.
TraceAccessoroperator= (const TraceAccessor &rhs)
 Copy assignment operator.
virtual ~TraceAccessor ()
 Frees resources.
ITraceMngtraceMng () const
 Trace manager.
TraceMessage info () const
 Flow for an information message.
TraceMessage pinfo () const
 Flow for a parallel information message.
TraceMessage info (char category) const
 Flow for an information message of a given category.
TraceMessage pinfo (char category) const
 Flow for a parallel information message of a given category.
TraceMessage info (bool v) const
 Flow for an information message.
TraceMessage warning () const
 Flow for a warning message.
TraceMessage pwarning () const
TraceMessage error () const
 Flow for an error message.
TraceMessage perror () const
TraceMessage log () const
 Flow for a log message.
TraceMessage plog () const
 Flow for a log message.
TraceMessage logdate () const
 Flow for a log message preceded by the date.
TraceMessage fatal () const
 Flow for a fatal error message.
TraceMessage pfatal () const
 Flow for a parallel fatal error message.
TraceMessageDbg debug (Trace::eDebugLevel=Trace::Medium) const
 Flow for a debug message.
Trace::eDebugLevel configDbgLevel () const
 Debug level of the configuration file.
TraceMessage info (Int32 verbose_level) const
 Flow for an information message of a given level.
TraceMessage linfo () const
 Flow for an information message with the local information level of this instance.
TraceMessage linfo (Int32 relative_level) const
 Flow for an information message with the local information level of this instance.
void fatalMessage (const StandaloneTraceMessage &o) const

Private Member Functions

bool _readStructuredGrid (IPrimaryMesh *mesh, VtkFile &, bool use_internal_partition)
 Allows reading a vtk file containing a STRUCTURED_GRID.
bool _readUnstructuredGrid (IPrimaryMesh *mesh, VtkFile &vtk_file, bool use_internal_partition)
 Allows reading a vtk file containing an UNSTRUCTURED_GRID.
void _readCellVariable (IMesh *mesh, VtkFile &vtk_file, const String &name_str, Integer nb_cell)
 Allows creating a cell variable from the information in the vtk file.
void _readItemGroup (IMesh *mesh, VtkFile &vtk_file, const String &name_str, Integer nb_item, eItemKind ik, ConstArrayView< Int32 > local_id)
 Allows creating an item group.
void _readNodeGroup (IMesh *mesh, VtkFile &vtk_file, const String &name, Integer nb_item)
 Allows creating a node group.
void _createFaceGroup (IMesh *mesh, const String &name, Int32ConstArrayView faces_lid)
 Allows creating a face group named "name" composed of faces having the IDs included in "faces_lid".
bool _readData (IMesh *mesh, VtkFile &vtk_file, bool use_internal_partition, eItemKind cell_kind, Int32ConstArrayView local_id, Integer nb_node)
 Allows reading supplementary data (POINT_DATA / CELL_DATA).
void _readNodesUnstructuredGrid (IMesh *mesh, VtkFile &vtk_file, Array< Real3 > &node_coords)
 Read nodes and their coordinates.
void _readCellsUnstructuredGrid (IMesh *mesh, VtkFile &vtk_file, Array< Int32 > &cells_nb_node, Array< ItemTypeId > &cells_type, Array< Int64 > &cells_connectivity)
 Read cells and their connectivity.
void _readFacesMesh (IMesh *mesh, const String &file_name, const String &dir_name, bool use_internal_partition)
 Allows reading the truc.vtkfaces.vtk file (if it exists).
bool _readMetadata (IMesh *mesh, VtkFile &vtk_file)
 Read metadata.

Additional Inherited Members

Protected Member Functions inherited from Arcane::TraceAccessor
void _setLocalVerboseLevel (Int32 v)
Int32 _localVerboseLevel () const

Detailed Description

Mesh file reader for legacy VTK format.

This is a preliminary version that only supports DATASETs of type STRUCTURED_GRID or UNSTRUCTURED_GRID. Furthermore, the reader and writer have only been partially tested.

The VTK file header must be:

vtk DataFile Version X.X

Where X.X is the VTK file version (support for VTK files <= 4.2).

It is possible to specify a set of variables in the file. In this case, their values are read simultaneously with the mesh and are used to initialize the variables. Currently, only cell values are supported.

Since VTK does not support the concept of a group, it is possible to specify a group as a variable (CELL_DATA). By convention, if the variable starts with the string 'GROUP_', then it is a group. The variable must be declared as follows: \begincode CELL_DATA n SCALARS GROUP_m int 1 LOOKUP_TABLE default with n being the number of cells, and m being the group name. A cell belongs to the group if the data value is different from 0.

Currently, point groups CANNOT be specified.

To specify face groups, a VTK file is required additional, identical to the original file but containing the description of the faces instead of the cells. By convention, if the currently read file is named 'toto.vtk', the file describing the faces will be 'toto.vtkfaces.vtk'. This file is optional.

Definition at line 102 of file VtkMeshIOService.cc.

Member Enumeration Documentation

◆ eMeshType

enum Arcane::VtkMeshIOService::eMeshType

Definition at line 117 of file VtkMeshIOService.cc.

Constructor & Destructor Documentation

◆ VtkMeshIOService()

Arcane::VtkMeshIOService::VtkMeshIOService ( ITraceMng * tm)
inlineexplicit

Definition at line 107 of file VtkMeshIOService.cc.

Member Function Documentation

◆ _createFaceGroup()

void Arcane::VtkMeshIOService::_createFaceGroup ( IMesh * mesh,
const String & name,
Int32ConstArrayView faces_lid )
private

Allows creating a face group named "name" composed of faces having the IDs included in "faces_lid".

Parameters
meshThe mesh to fill
nameThe name of the group to create
faces_lidThe IDs of the faces to include in the group

Definition at line 1718 of file VtkMeshIOService.cc.

References Arcane::TraceAccessor::info(), and Arcane::ConstArrayView< T >::size().

Referenced by _readStructuredGrid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readCellsUnstructuredGrid()

void Arcane::VtkMeshIOService::_readCellsUnstructuredGrid ( IMesh * mesh,
VtkFile & vtk_file,
Array< Int32 > & cells_nb_node,
Array< ItemTypeId > & cells_type,
Array< Int64 > & cells_connectivity )
private

Read cells and their connectivity.

Returns by filling cells_nb_node, cells_type, and cells_connectivity.

Parameters
meshThe mesh to fill
vtk_fileReference to a VtkFile object
cells_nb_nodeNumber of nodes per cell
cells_typeType of each cell
cells_connectivityConnectivity between cells

Definition at line 1034 of file VtkMeshIOService.cc.

References _readMetadata(), ARCANE_THROW, Arcane::VtkFile::checkString(), Arcane::VtkFile::getInt(), Arcane::VtkFile::getNextLine(), Arcane::TraceAccessor::info(), and Arcane::Array< T >::resize().

Referenced by _readFacesMesh(), and _readUnstructuredGrid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readCellVariable()

void Arcane::VtkMeshIOService::_readCellVariable ( IMesh * mesh,
VtkFile & vtk_file,
const String & var_name,
Integer nb_cell )
private

Allows creating a cell variable from the information in the vtk file.

Parameters
meshThe mesh to fill
vtk_fileReference to a VtkFile object
var_nameThe name of the variable to create
nb_cellThe number of cells

Definition at line 1738 of file VtkMeshIOService.cc.

References _readMetadata(), Arcane::VtkFile::getDouble(), and Arcane::TraceAccessor::info().

Referenced by _readData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readData()

bool Arcane::VtkMeshIOService::_readData ( IMesh * mesh,
VtkFile & vtk_file,
bool use_internal_partition,
eItemKind cell_kind,
Int32ConstArrayView local_id,
Integer nb_node )
private

Allows reading supplementary data (POINT_DATA / CELL_DATA).

Parameters
meshThe mesh to fill
file_nameThe vtk file name (with extension)
use_internal_partitionShould the internal partitioner be used or not
cell_kindType of mesh cells
local_idArray containing the local_id of the cells
nb_nodeNumber of nodes
Returns
false if everything went well, true otherwise

Definition at line 1442 of file VtkMeshIOService.cc.

References Arcane::IVariableMng::_internalApi(), _readCellVariable(), _readItemGroup(), _readNodeGroup(), Arcane::IVariableMngInternal::addAutoDestroyVariable(), Arcane::IParallelMng::broadcastMemoryBuffer(), Arcane::XmlNode::children(), Arcane::IParallelMng::commRank(), Arcane::IItemFamily::createGroup(), Arcane::TraceAccessor::debug(), Arcane::XmlNode::documentElement(), Arcane::TraceAccessor::error(), Arcane::TraceAccessor::fatal(), Arcane::VtkFile::getNextLine(), Arcane::IK_Cell, Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), Arcane::IXmlDocumentHolder::loadFromBuffer(), Arcane::ConstArrayView< T >::size(), Arcane::String::substring(), Arcane::TraceAccessor::traceMng(), and Arcane::String::utf8().

Referenced by _readFacesMesh(), _readStructuredGrid(), and _readUnstructuredGrid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readFacesMesh()

void Arcane::VtkMeshIOService::_readFacesMesh ( IMesh * mesh,
const String & file_name,
const String & dir_name,
bool use_internal_partition )
private

Allows reading the truc.vtkfaces.vtk file (if it exists).

Parameters
meshThe mesh to fill
file_nameThe vtk file name (with extension)
dir_nameThe file path
use_internal_partitionShould the internal partitioner be used or not

Definition at line 1338 of file VtkMeshIOService.cc.

References _readCellsUnstructuredGrid(), _readData(), _readNodesUnstructuredGrid(), Arcane::VtkFile::checkString(), Arcane::IParallelMng::commRank(), Arcane::TraceAccessor::error(), Arcane::IMeshUtilities::getFacesLocalIdFromConnectivity(), Arcane::VtkFile::getNextLine(), Arcane::IK_Face, Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), Arcane::String::localstr(), Arcane::Array< T >::resize(), and Arcane::AbstractArray< T >::size().

Referenced by readMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readItemGroup()

void Arcane::VtkMeshIOService::_readItemGroup ( IMesh * mesh,
VtkFile & vtk_file,
const String & name_str,
Integer nb_item,
eItemKind ik,
ConstArrayView< Int32 > local_id )
private

Allows creating an item group.

Parameters
meshThe mesh to fill
vtk_fileReference to a VtkFile object
nameThe name of the group to create
nb_itemNumber of items to read and include in the group
ikType of items read
local_idArray containing the local_ids of the cells

Definition at line 1767 of file VtkMeshIOService.cc.

References _readMetadata(), Arcane::Array< T >::add(), Arcane::IItemFamily::createGroup(), Arcane::VtkFile::getInt(), Arcane::TraceAccessor::info(), and Arcane::AbstractArray< T >::size().

Referenced by _readData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readMetadata()

bool Arcane::VtkMeshIOService::_readMetadata ( IMesh * mesh,
VtkFile & vtk_file )
private

Read metadata.

Parameters
meshThe mesh to fill
vtk_fileReference to a VtkFile object
Returns
false if everything went well, true otherwise

Definition at line 1122 of file VtkMeshIOService.cc.

References Arcane::VtkFile::getNextLine(), Arcane::VtkFile::isEmptyNextLine(), and Arcane::VtkFile::isEqualString().

Referenced by _readCellsUnstructuredGrid(), _readCellVariable(), _readItemGroup(), _readNodeGroup(), _readNodesUnstructuredGrid(), and _readStructuredGrid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readNodeGroup()

void Arcane::VtkMeshIOService::_readNodeGroup ( IMesh * mesh,
VtkFile & vtk_file,
const String & name,
Integer nb_item )
private

Allows creating a node group.

Parameters
meshThe mesh to fill
vtk_fileReference to a VtkFile object
nameThe name of the group to create
nb_itemNumber of items to read and include in the group

Definition at line 1798 of file VtkMeshIOService.cc.

References _readMetadata(), Arcane::Array< T >::add(), Arcane::IItemFamily::createGroup(), Arcane::VtkFile::getInt(), Arcane::IK_Node, Arcane::TraceAccessor::info(), and Arcane::AbstractArray< T >::size().

Referenced by _readData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readNodesUnstructuredGrid()

void Arcane::VtkMeshIOService::_readNodesUnstructuredGrid ( IMesh * mesh,
VtkFile & vtk_file,
Array< Real3 > & node_coords )
private

Read nodes and their coordinates.

Parameters
meshThe mesh to fill
vtk_fileReference to a VtkFile object
node_coordsThe array to fill with node coordinates

Definition at line 963 of file VtkMeshIOService.cc.

References _readMetadata(), ARCANE_THROW, Arcane::VtkFile::checkString(), Arcane::VtkFile::getDouble(), Arcane::VtkFile::getFloat(), Arcane::VtkFile::getInt(), Arcane::VtkFile::getNextLine(), Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), and Arcane::Array< T >::resize().

Referenced by _readFacesMesh(), and _readUnstructuredGrid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readStructuredGrid()

bool Arcane::VtkMeshIOService::_readStructuredGrid ( IPrimaryMesh * mesh,
VtkFile & vtk_file,
bool use_internal_partition )
private

Allows reading a vtk file containing a STRUCTURED_GRID.

Parameters
meshThe mesh to be filled
vtk_fileReference to a VtkFile object
use_internal_partitionShould the internal partitioner be used or not
Returns
false if everything went well, true otherwise

Definition at line 684 of file VtkMeshIOService.cc.

References _createFaceGroup(), _readData(), _readMetadata(), Arcane::Array< T >::add(), ARCANE_FATAL, ARCANE_THROW, Arcane::VtkFile::checkString(), ENUMERATE_FACE, ENUMERATE_NODE, Arcane::TraceAccessor::error(), Arcane::VtkFile::getDouble(), Arcane::VtkFile::getFloat(), Arcane::VtkFile::getInt(), Arcane::VtkFile::getNextLine(), Arcane::IK_Cell, Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), Arcane::Item::localId(), Arcane::ItemWithNodes::nodes(), and Arcane::Item::uniqueId().

Referenced by readMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readUnstructuredGrid()

bool Arcane::VtkMeshIOService::_readUnstructuredGrid ( IPrimaryMesh * mesh,
VtkFile & vtk_file,
bool use_internal_partition )
private

Allows reading a vtk file containing an UNSTRUCTURED_GRID.

Parameters
meshThe mesh to fill
vtk_fileReference to a VtkFile object
use_internal_partitionShould we use the internal partitioner or not
Returns
false if everything went well, true otherwise

Definition at line 1230 of file VtkMeshIOService.cc.

References _readCellsUnstructuredGrid(), _readData(), _readNodesUnstructuredGrid(), Arcane::UnstructuredMeshAllocateBuildInfo::addCell(), Arcane::UnstructuredMeshAllocateBuildInfo::allocateMesh(), ARCANE_FATAL, Arcane::TraceAccessor::debug(), Arcane::ItemTypeInfo::dimension(), ENUMERATE_NODE, Arcane::IK_Cell, Arcane::UnstructuredMeshAllocateBuildInfo::preAllocate(), Arcane::MessagePassing::ReduceMax, Arcane::Array< T >::resize(), Arcane::UnstructuredMeshAllocateBuildInfo::setMeshDimension(), Arcane::AbstractArray< T >::size(), Arcane::Array< T >::subView(), Arcane::ItemTypeMng::typeFromId(), and Arcane::Item::uniqueId().

Referenced by readMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build()

void Arcane::VtkMeshIOService::build ( )
inline

Definition at line 113 of file VtkMeshIOService.cc.

◆ readMesh()

bool Arcane::VtkMeshIOService::readMesh ( IPrimaryMesh * mesh,
const String & file_name,
const String & dir_name,
bool use_internal_partition )

Allows starting the reading of a vtk file.

Parameters
meshThe mesh to be filled
file_nameThe name of the vtk file (with extension)
dir_nameThe file path
use_internal_partitionShould the internal partitioner be used or not
Returns
false if everything went well, true otherwise

Definition at line 585 of file VtkMeshIOService.cc.

References _readFacesMesh(), _readStructuredGrid(), _readUnstructuredGrid(), Arcane::VtkFile::checkString(), Arcane::TraceAccessor::debug(), Arcane::TraceAccessor::error(), Arcane::VtkFile::getNextLine(), Arcane::TraceAccessor::info(), Arcane::VtkFile::isEqualString(), and Arcane::String::localstr().

Referenced by Arcane::VtkLegacyCaseMeshReader::Builder::allocateMeshItems(), and Arcane::VtkMeshReader::readMeshFromFile().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: