40 "Given location of data must be either Cell or Node, not ZeroD"
55 "Importing coefficients defined on geometry is not implemented" << std::endl <<
56 " when geometry is made from multiple meshes"
63 "CoeffReader does not support files with extension " << ext << std::endl <<
64 " Supported extensions are .vtk and .msh"
77 return ext==
"msh" or ext==
"vtk";
84 "Reader has no scalar array with name " << label <<
" in file " <<
m_fileName
94 "Reader has no vector array with name " << label <<
" in file " <<
m_fileName
104 "Reader has no tensor array with name " << label <<
" in file " <<
m_fileName
115 "Provided dimension must be either -1 or 0 1 2"
119 while (i<end and not found)
136 vtkDataSetReader *reader = vtkDataSetReader::New ();
138 reader->SetReadAllScalars(1);
139 reader->SetReadAllVectors(1);
140 reader->SetReadAllNormals(1);
141 reader->SetReadAllTensors(1);
142 reader->SetReadAllFields(1);
144 reader->GetOutput()->Register(reader);
145 m_vtkData = vtkDataSet::SafeDownCast(reader->GetOutput());
150 switch(
m_vtkData->GetCellData()->GetArray(i)->GetNumberOfComponents())
163 for (
CepsInt i = 0; i <
m_vtkData->GetPointData()->GetNumberOfArrays(); i++)
164 switch(
m_vtkData->GetPointData()->GetArray(i)->GetNumberOfComponents())
193 CepsInt nStringTags,nRealTags,nComp;
195 nStringTags =
ceps::readInt(
m_file,e+
"cannot read number of string tags after " + keywords[ii]);
196 for(
CepsInt i=0;i<nStringTags+1;i++)
197 std::getline(
m_file,line);
198 CepsString label = line.substr(line.find_first_of(
'\"')+1,line.find_last_of(
'\"')-1);
202 for (
CepsInt i = 0U; i < nRealTags; i++)
210 (*nameArrays[ii])[0].push_back(label);
213 (*nameArrays[ii])[1].push_back(label);
216 (*nameArrays[ii])[2].push_back(label);
220 }
while (iLine != -1);
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_ABORT(message)
Stops the execution with a message. If testing is enabled, only throws a runtime_error.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
std::basic_string< CepsChar > CepsString
C++ format string.
std::array< _Type, _N > CepsArray
C++ arrays.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
int32_t CepsInt
Need 32 bit integer.
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 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.
CepsLocationFlag m_loc
Used to choose between point or cell data.
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...
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.
CepsUInt skipLines(CepsUInt nbLines)
Skip given number of lines.
CepsString m_fileName
file to open
std::ifstream m_file
stream
Encapsulates all the geometrical data.
CepsBool hasMeshOfDim(CepsUInt dim) const
true if geometry has data of requested dimension
CepsBool contains(const CepsVector< _Type, _Alloc > &vec, const _Type &item)
Tells if vectors contains a given item.
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.
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
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...