31 #ifndef _COEFF_READER_HPP_
32 #define _COEFF_READER_HPP_
36 #include <vtkCellData.h>
37 #include <vtkDataArray.h>
38 #include <vtkDataSet.h>
39 #include <vtkDataSetReader.h>
40 #include <vtkPointData.h>
41 #include <vtkSmartPointer.h>
100 template<
typename _Result>
105 template<
typename _Result>
110 template<
typename _Result>
131 template<
typename _Result>
145 template<
typename _Result>
151 vtkDataArray *array =
nullptr;
156 array =
m_vtkData->GetCellData()->GetArray(label.c_str());
161 array =
m_vtkData->GetPointData()->GetArray(label.c_str());
165 CepsReal* d = ceps::newArray<CepsReal>(9);
167 for (vtkIdType i = 0; i < nbData; ++i)
169 array->GetTuple(i,d);
193 template<
typename _Result>
199 CepsInt nRealTags,nIntTags,nComp,nToRead;
204 std::stringstream keyword;
205 keyword <<
"\"" << label <<
"\"";
209 for (
CepsInt i = 0U; i < nRealTags; i++)
215 for (
CepsInt i = 3U; i < nIntTags; i++)
219 CepsReal* d = ceps::newArray<CepsReal>(9);
221 for (
CepsInt n = 0U; n < nToRead; n++)
224 for (
CepsInt i = 0; i < nComp; i++)
237 dest.
add(ceps::convertReal<_Result>(d),gId,gId,node->
getOwner());
CepsLocationFlag
DataLocation: an enum that will be used by various elements of the code (pde, readers,...
@ Cell
Data is defined at cell centers.
@ Point
Data is defined on each point.
#define CEPS_SAYS(message)
Writes a message in the debug log and in the terminal (stdio).
std::basic_string< CepsChar > CepsString
C++ format string.
std::array< _Type, _N > CepsArray
C++ arrays.
CepsIndex CepsGlobalIndex
Many uses. Has to be signed for PETSc.
float CepsReal
Need single precision floating point.
int32_t CepsInt
Need 32 bit integer.
Reader used to import point or cell data from files.
CepsArray< CepsVector< CepsString >, 3 > m_nodeArrayNames
Names of data arrays defined on nodes (array index: scalar, vector, tensor)
void read(const CepsString &label, DistributedInfos< _Result > &dest)
Read the array and stores the data into instance. The label is needed for vtk format.
~CoeffReader() override
Destructor.
vtkSmartPointer< vtkDataSet > m_vtkData
Array in the vtk format.
void readMsh(const CepsString &label, DistributedInfos< _Result > &dest)
Read the array with given label in file, stores the data into instance.
void getData(const CepsString &label, DistributedInfos< CepsMathScalar > &dest)
Extract a distributed data structure of scalars with given label.
void buildArrayNamesList()
Stores the names of the arrays for easier access afterwards.
void readVtk(const CepsString &label, DistributedInfos< _Result > &dest)
Read the array with given label in file, stores the data into instance.
CepsLocationFlag m_loc
Used to choose between point or cell data.
Geometry * m_geom
Link to geometry.
CepsArray< CepsVector< CepsString >, 3 > m_cellArrayNames
Names of data arrays defined on cells (array index: scalar, vector, tensor)
CoeffReader(const CepsString &fileName, const CepsLocationFlag &loc, Geometry *geom)
Constructor from file name, and location flag, linked to geometry.
CepsBool isValidExtension(CepsString ext)
Tells if extension is compatible with reader.
CepsBool hasArray(const CepsString &label, CepsInt dim=-1) const
Tells if file has data array, dim = 0 for scalars, 1 for vector, 2 for tensor.
A class that manages data that is distributed between processors, not only real values (as in Distrib...
void add(const _Type &x, const _Hash &hashValue, const CepsGlobalIndex &globalId, const CepsUInt &pId)
Add entry with global ID to the container, hash must be provided, pId selects owned or halo.
Base class that regroups common reader functionalities.
CepsInt lineIndex(const CepsString &word)
Index of first line starting with word, search starting from the current stream position.
void reset()
Set file stream to the beginning of the file.
CepsString m_fileName
file to open
std::ifstream m_file
stream
Abstract class for geometrical cell. On top of index and attributes managament, the cell has informat...
Base class for nodes used in meshes.
Encapsulates all the geometrical data.
GeomNode * getNode(CepsNodeGlobalIndex globalID, CepsBool ownedOnly=false)
Returns a pointer to the node with given global ID. Nullptr if node is not owned or halo.
const CepsVector< CepsNodeGlobalIndex > & getNodePartitionMap()
The node index map from before to after partitioning.
GeomCell * getCell(CepsCellGlobalIndex globalID)
Returns a pointer to the cell with given global ID. Nullptr if cell is not owned.
const CepsVector< CepsCellGlobalIndex > & getCellPartitionMap()
The node index map from before to after partitioning.
const CepsProcId & getOwner() const
Get owner (processus id) of this entity.
CepsUInt getRank()
Returns current processor rank.
CepsString toString(_Tp value)
Convert a given value to a string (input has to be compatible with std::to_string)
void destroyTabular(_Type &)
Destroy[delete] any type.
CepsBool isValidPtr(_Type *ptr)
Tells if pointer is not null.
CepsInt readInt(std::istream &file, const CepsString &errorMessage="")
Reads an integral number from an istream, aborts if conversion fails advances the stream by 1 word.
CepsString getExtension(const CepsString &str)
Returns the extension of a file, if any.
CepsReal readReal(std::istream &file, const CepsString &errorMessage="")
Reads a floating point number from an istream, aborts if conversion fails advances the stream by 1 wo...