Commit 0df6e8b0 authored by Mark Olesen's avatar Mark Olesen

ENH: reduce number of methods for writing attributes

parent 629d1733
......@@ -101,7 +101,7 @@ private:
// Private Member Functions
//- Read the adiosWriter data
void read(const dictionary&);
void read(const dictionary& dict);
//- Disallow default bitwise copy construct
adiosCoreWrite(const adiosCoreWrite&) = delete;
......@@ -146,19 +146,19 @@ protected:
void putBaseAttributes();
//- Define and write attributes for OpenFOAM time information
void putTimeAttributes(const TimeState&);
void putTimeAttributes(const TimeState& t);
//- Define and write mesh patch attributes (name, type, etc)
void putPatchAttributes(const polyMesh&);
void putPatchAttributes(const polyMesh& mesh);
//- Define/write mesh points
void writeMeshPoints(const polyMesh&);
void writeMeshPoints(const polyMesh& mesh);
//- Define/write mesh face information
void writeMeshFaces(const polyMesh&);
void writeMeshFaces(const polyMesh& mesh);
//- Define/write mesh proc-addressing
void writeMeshAddressing(const polyMesh&);
void writeMeshAddressing(const polyMesh& mesh);
//- Define/write list of mesh zones
template<class ZoneMeshType>
......@@ -169,7 +169,7 @@ protected:
);
//- Define/write mesh points and face information
void writeMesh(const polyMesh&);
void writeMesh(const polyMesh& mesh);
//- Define/write adios variable for field object,
......@@ -188,7 +188,7 @@ protected:
template<class Type, template<class> class PatchField, class GeoMesh>
int64_t writeGeometricField
(
const GeometricField<Type, PatchField, GeoMesh>&
const GeometricField<Type, PatchField, GeoMesh>& field
);
//- Define/write adios data for internal field, return adios Id.
......@@ -204,7 +204,7 @@ protected:
(
const fileName& varName,
const word& local,
const DimensionedField<Type, GeoMesh>&
const DimensionedField<Type, GeoMesh>& field
);
//- Define/write adios data for field, return adios Id.
......@@ -212,7 +212,7 @@ protected:
int64_t writeField
(
const fileName& varName,
const DimensionedField<Type, GeoMesh>&
const DimensionedField<Type, GeoMesh>& field
);
......@@ -223,95 +223,71 @@ protected:
//- Define and write a string attribute
void putAttribute
(
const char* attrName,
const char* varName,
const string& value
);
//- Define and write a string attribute
void putAttribute
(
const char* attrName,
const string& varName,
const string& value
const std::string& attrName,
const std::string& varName,
const std::string& value
);
//- Define and write an int attribute
void putIntAttribute
(
const char* attrName,
const char* varName,
const std::string& attrName,
const std::string& varName,
const int value
);
//- Define and write an int attribute
void putIntAttribute
(
const char* attrName,
const string& varName,
const int value
);
//- Define and write a double attribute
void putScalarAttribute
(
const char* attrName,
const char* varName,
const double value
);
//- Define and write a double attribute
void putScalarAttribute
(
const char* attrName,
const string& varName,
const std::string& attrName,
const std::string& varName,
const double value
);
//- Define and write an array attribute of integer values
bool putListAttribute
(
const char* attrName,
const string& varName,
const std::string& attrName,
const std::string& varName,
const UList<int>& list
);
//- Define and write an array attribute of double values
bool putListAttribute
(
const char* attrName,
const string& varName,
const std::string& attrName,
const std::string& varName,
const UList<double>& list
);
//- Define and write an array attribute of strings
bool putListAttribute
(
const char* attrName,
const string& varName,
const std::string& attrName,
const std::string& varName,
const CStringList& list
);
//- Define and write an array attribute of strings
bool putListAttribute
(
const char* attrName,
const string& varName,
const wordList& list
const std::string& attrName,
const std::string& varName,
const UList<word>& list
);
//- Define and write an array attribute of strings
bool putListAttribute
(
const char* attrName,
const string& varName,
const stringList& list
const std::string& attrName,
const std::string& varName,
const UList<string>& list
);
//- Define and write an "dimensions" attribute (an array of doubles).
bool putDimensionsAttribute
(
const string& varName,
const std::string& varName,
const dimensionSet& dims
);
......@@ -321,44 +297,44 @@ protected:
//- Generic define a variable, return adios Id.
int64_t defineGenericVariable
(
const string& name,
const std::string& name,
enum ADIOS_DATATYPES type,
const string& localDimensions,
const string& globalDimensions,
const string& offsets
const std::string& localDimensions,
const std::string& globalDimensions,
const std::string& offsets
);
//- Generic write variable (by id)
void writeGenericVariable(const int64_t varid, const void* value);
//- Generic write a variable
void writeGenericVariable(const string& name, const void* value);
void writeGenericVariable(const std::string& name, const void* value);
//- Define and write an integer variable containing ONE element.
// To be stored as part of a global 1D array of this name.
// Return adios Id.
int64_t putLabelVariable(const string& name, const label value);
int64_t putLabelVariable(const std::string& name, const label value);
//- Define and write a variable from the list contents
template<class T>
inline int64_t putListVariable
(
const string& name,
const std::string& name,
const UList<T>& list
);
//- Define a byte-stream variable with count elements.
// Return adios Id.
int64_t defineStreamVariable(const string& name, size_t count);
int64_t defineStreamVariable(const std::string& name, size_t count);
//- Write an object as a byte-stream.
// Return adios Id.
template<class Type>
int64_t writeStreamVariable(const string& name, const Type& obj);
int64_t writeStreamVariable(const std::string& name, const Type& obj);
public:
......@@ -366,7 +342,7 @@ public:
// Constructors
//- Construct for specified group name, using dictionary parameters
adiosCoreWrite(const word& groupName, const dictionary&);
adiosCoreWrite(const word& groupName, const dictionary& dict);
//- Destructor
......
......@@ -39,16 +39,16 @@ License
void Foam::adiosCoreWrite::putAttribute
(
const char* attrName,
const char* varName,
const string& value
const std::string& attrName,
const std::string& varName,
const std::string& value
)
{
adios_define_attribute
(
groupID_,
attrName,
varName,
attrName.c_str(),
varName.c_str(),
adios_string,
value.c_str(),
nullptr
......@@ -56,21 +56,10 @@ void Foam::adiosCoreWrite::putAttribute
}
void Foam::adiosCoreWrite::putAttribute
(
const char* attrName,
const string& varName,
const string& value
)
{
putAttribute(attrName, varName.c_str(), value);
}
void Foam::adiosCoreWrite::putIntAttribute
(
const char* attrName,
const char* varName,
const std::string& attrName,
const std::string& varName,
const int value
)
{
......@@ -79,8 +68,8 @@ void Foam::adiosCoreWrite::putIntAttribute
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName,
attrName.c_str(),
varName.c_str(),
adios_integer,
1,
&intval
......@@ -88,21 +77,10 @@ void Foam::adiosCoreWrite::putIntAttribute
}
void Foam::adiosCoreWrite::putIntAttribute
(
const char* attrName,
const string& varName,
const int value
)
{
putIntAttribute(attrName, varName.c_str(), value);
}
void Foam::adiosCoreWrite::putScalarAttribute
(
const char* attrName,
const char* varName,
const std::string& attrName,
const std::string& varName,
const double value
)
{
......@@ -111,8 +89,8 @@ void Foam::adiosCoreWrite::putScalarAttribute
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName,
attrName.c_str(),
varName.c_str(),
adios_double,
1,
&fltval
......@@ -120,21 +98,10 @@ void Foam::adiosCoreWrite::putScalarAttribute
}
void Foam::adiosCoreWrite::putScalarAttribute
(
const char* attrName,
const string& varName,
const double value
)
{
putScalarAttribute(attrName, varName.c_str(), value);
}
bool Foam::adiosCoreWrite::putListAttribute
(
const char* attrName,
const string& varName,
const std::string& attrName,
const std::string& varName,
const UList<int>& list
)
{
......@@ -146,7 +113,7 @@ bool Foam::adiosCoreWrite::putListAttribute
adios_define_attribute_byvalue
(
groupID_,
attrName,
attrName.c_str(),
varName.c_str(),
adiosTraits<int>::adiosType,
list.size(),
......@@ -159,8 +126,8 @@ bool Foam::adiosCoreWrite::putListAttribute
bool Foam::adiosCoreWrite::putListAttribute
(
const char* attrName,
const string& varName,
const std::string& attrName,
const std::string& varName,
const UList<double>& list
)
{
......@@ -172,7 +139,7 @@ bool Foam::adiosCoreWrite::putListAttribute
adios_define_attribute_byvalue
(
groupID_,
attrName,
attrName.c_str(),
varName.c_str(),
adiosTraits<double>::adiosType,
list.size(),
......@@ -185,8 +152,8 @@ bool Foam::adiosCoreWrite::putListAttribute
bool Foam::adiosCoreWrite::putListAttribute
(
const char* attrName,
const string& varName,
const std::string& attrName,
const std::string& varName,
const CStringList& cstrings
)
{
......@@ -195,7 +162,7 @@ bool Foam::adiosCoreWrite::putListAttribute
adios_define_attribute_byvalue
(
groupID_,
attrName,
attrName.c_str(),
varName.c_str(),
adios_string_array,
cstrings.size(),
......@@ -211,9 +178,9 @@ bool Foam::adiosCoreWrite::putListAttribute
bool Foam::adiosCoreWrite::putListAttribute
(
const char* attrName,
const string& varName,
const wordList& list
const std::string& attrName,
const std::string& varName,
const UList<word>& list
)
{
CStringList cstrings;
......@@ -228,9 +195,9 @@ bool Foam::adiosCoreWrite::putListAttribute
bool Foam::adiosCoreWrite::putListAttribute
(
const char* attrName,
const string& varName,
const stringList& list
const std::string& attrName,
const std::string& varName,
const UList<string>& list
)
{
CStringList cstrings;
......@@ -245,7 +212,7 @@ bool Foam::adiosCoreWrite::putListAttribute
bool Foam::adiosCoreWrite::putDimensionsAttribute
(
const string& varName,
const std::string& varName,
const dimensionSet& dims
)
{
......
......@@ -35,7 +35,7 @@ License
template<class Type>
int64_t Foam::adiosCoreWrite::putListVariable
(
const string& name,
const std::string& name,
const UList<Type>& list
)
{
......@@ -63,7 +63,7 @@ int64_t Foam::adiosCoreWrite::putListVariable
if (fileID_)
{
if (floatingPoint<cmptType>())
if (std::is_floating_point<cmptType>())
{
// floating point data:
// adios_set_transform(varid, "zfp:accuracy=0.0001");
......@@ -91,7 +91,7 @@ int64_t Foam::adiosCoreWrite::putListVariable
template<class Type>
int64_t Foam::adiosCoreWrite::writeStreamVariable
(
const string& name,
const std::string& name,
const Type& obj
)
{
......
......@@ -29,11 +29,11 @@ License
int64_t Foam::adiosCoreWrite::defineGenericVariable
(
const string& name,
const std::string& name,
enum ADIOS_DATATYPES type,
const string& local,
const string& global,
const string& offsets
const std::string& local,
const std::string& global,
const std::string& offsets
)
{
int64_t varid = adios_define_var
......@@ -73,7 +73,7 @@ void Foam::adiosCoreWrite::writeGenericVariable
void Foam::adiosCoreWrite::writeGenericVariable
(
const string& name,
const std::string& name,
const void* value
)
{
......@@ -96,7 +96,7 @@ void Foam::adiosCoreWrite::writeGenericVariable
int64_t Foam::adiosCoreWrite::putLabelVariable
(
const string& name,
const std::string& name,
const label value
)
{
......@@ -130,7 +130,7 @@ int64_t Foam::adiosCoreWrite::putLabelVariable
int64_t Foam::adiosCoreWrite::defineStreamVariable
(
const string& name,
const std::string& name,
size_t count
)
{
......
......@@ -28,7 +28,6 @@ License
#include "IOstreams.H"
#include "Pstream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::adiosReader::VarInfo::readInfo
......@@ -61,7 +60,6 @@ bool Foam::adiosReader::VarInfo::readInfo
<< "Reading sizes for adios_string variables incomplete: "
<< name_ << endl;
// free ADIOS_VARINFO and any ADIOS_VARBLOCK(s)
adios_free_varinfo(vinfo);
......@@ -170,7 +168,6 @@ bool Foam::adiosReader::VarInfo::readInfo
<< endl;
}
// free ADIOS_VARINFO and any ADIOS_VARBLOCK(s)
adios_free_varinfo(vinfo);
}
......
......@@ -32,6 +32,8 @@ Description
#ifndef adiosTraits_H
#define adiosTraits_H
#include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -59,16 +61,6 @@ public:
};
//- Assume the data associated with type T are not floating-point values
template<class T>
inline bool floatingPoint() {return false;}
template<>
inline bool floatingPoint<float>() {return true;}
template<>
inline bool floatingPoint<double>() {return true;}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment