Commit e49810e3 authored by mark's avatar mark

STYLE: move attributes to separate file

parent 3c10ac3e
......@@ -3,6 +3,7 @@ adiosTime.C
adiosCore.C
adiosCoreWrite.C
adiosCoreWriteAttr.C
adiosCoreWriteMesh.C
adiosCoreWriteField.C
......
......@@ -617,265 +617,31 @@ int64_t Foam::adiosCoreWrite::defineVectorVariable
}
void Foam::adiosCoreWrite::defineAttribute
(
const char* attrName,
const char* varName,
const string& value
)
{
adios_define_attribute
(
groupID_,
attrName,
varName,
adios_string,
value.c_str(),
nullptr
);
}
void Foam::adiosCoreWrite::defineAttribute
(
const char* attrName,
const string& varName,
const string& value
)
{
defineAttribute(attrName, varName.c_str(), value);
}
void Foam::adiosCoreWrite::defineIntAttribute
(
const char* attrName,
const char* varName,
const int value
)
{
int intval = value;
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName,
adios_integer,
1,
&intval
);
}
void Foam::adiosCoreWrite::defineIntAttribute
(
const char* attrName,
const string& varName,
const int value
)
{
defineIntAttribute(attrName, varName.c_str(), value);
}
void Foam::adiosCoreWrite::defineScalarAttribute
(
const char* attrName,
const char* varName,
const double value
)
{
double fltval = value;
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName,
adios_double,
1,
&fltval
);
}
void Foam::adiosCoreWrite::defineScalarAttribute
(
const char* attrName,
const string& varName,
const double value
)
{
defineScalarAttribute(attrName, varName.c_str(), value);
}
bool Foam::adiosCoreWrite::defineListAttribute
(
const char* attrName,
const string& varName,
const UList<int>& list
)
{
if (list.empty())
{
return false;
}
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName.c_str(),
adios_integer,
list.size(),
list.cdata()
);
return true;
}
bool Foam::adiosCoreWrite::defineListAttribute
(
const char* attrName,
const string& varName,
const UList<double>& list
)
{
if (list.empty())
{
return false;
}
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName.c_str(),
adios_double,
list.size(),
list.cdata()
);
return true;
}
bool Foam::adiosCoreWrite::defineListAttribute
(
const char* attrName,
const string& varName,
const wordList& list
)
{
CStringList cstrings;
if (!list.empty())
{
cstrings.reset(list);
}
if (cstrings.size())
{
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName.c_str(),
adios_string_array,
cstrings.size(),
cstrings.strings()
);
return true;
}
return false;
}
bool Foam::adiosCoreWrite::defineListAttribute
(
const char* attrName,
const string& varName,
const stringList& list
)
{
CStringList cstrings;
if (!list.empty())
{
cstrings.reset(list);
}
if (cstrings.size())
{
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName.c_str(),
adios_string_array,
cstrings.size(),
cstrings.strings()
);
return true;
}
return false;
}
bool Foam::adiosCoreWrite::defineDimensionsAttribute
(
const string& varName,
const dimensionSet& dims
)
{
scalarList units(dimensionSet::nDimensions);
forAll(units, i)
{
units[i] = dims[i];
}
return defineListAttribute("dimensions", varName, units);
}
void Foam::adiosCoreWrite::writeVariable
(
const char* name,
const string& name,
const void* value
)
{
const char* cname = name.c_str();
// could also check that variable has been defined
// vars_.found(name);
// vars_.found(cname);
if (fileID_)
{
adios_write(fileID_, name, value);
adios_write(fileID_, cname, value);
}
else
{
WarningInFunction
<< "Attempting to write adios variable \""
<< name << "\" without an open adios file"
<< "Attempting to write adios variable "
<< name << " without an open adios file"
<< endl;
}
}
void Foam::adiosCoreWrite::writeVariable
(
const string& name,
const void* value
)
{
writeVariable(name.c_str(), value);
}
void Foam::adiosCoreWrite::writeIntVariable
(
const char* name,
......
......@@ -231,6 +231,97 @@ protected:
// General adios handling
// Attributes
//- Define a string attribute
void defineAttribute
(
const char* attrName,
const char* varName,
const string& value
);
//- Define a string attribute
void defineAttribute
(
const char* attrName,
const string& varName,
const string& value
);
//- Define an int attribute
void defineIntAttribute
(
const char* attrName,
const char* varName,
const int value
);
//- Define an int attribute
void defineIntAttribute
(
const char* attrName,
const string& varName,
const int value
);
//- Define a double attribute
void defineScalarAttribute
(
const char* attrName,
const char* varName,
const double value
);
//- Define a double attribute
void defineScalarAttribute
(
const char* attrName,
const string& varName,
const double value
);
//- Define an array attribute of integer values
bool defineListAttribute
(
const char* attrName,
const string& varName,
const UList<int>& list
);
//- Define an array attribute of double values
bool defineListAttribute
(
const char* attrName,
const string& varName,
const UList<double>& list
);
//- Define an array attribute of strings
bool defineListAttribute
(
const char* attrName,
const string& varName,
const wordList& list
);
//- Define an array attribute of strings
bool defineListAttribute
(
const char* attrName,
const string& varName,
const stringList& list
);
//- Define an "dimensions" attribute (an array of doubles).
bool defineDimensionsAttribute
(
const string& varName,
const dimensionSet& dims
);
//- Generic define a variable, return adios Id.
int64_t defineVariable
(
......@@ -322,100 +413,13 @@ protected:
template<class Type>
int64_t defineFieldVariable(const string& name, size_t count);
//- Define a string attribute
void defineAttribute
(
const char* attrName,
const char* varName,
const string& value
);
//- Define a string attribute
void defineAttribute
(
const char* attrName,
const string& varName,
const string& value
);
//- Define an int attribute
void defineIntAttribute
(
const char* attrName,
const char* varName,
const int value
);
//- Define an int attribute
void defineIntAttribute
(
const char* attrName,
const string& varName,
const int value
);
//- Define a double attribute
void defineScalarAttribute
(
const char* attrName,
const char* varName,
const double value
);
//- Define a double attribute
void defineScalarAttribute
(
const char* attrName,
const string& varName,
const double value
);
//- Define an array attribute of integer values
bool defineListAttribute
(
const char* attrName,
const string& varName,
const UList<int>& list
);
//- Define an array attribute of double values
bool defineListAttribute
(
const char* attrName,
const string& varName,
const UList<double>& list
);
//- Define an array attribute of strings
bool defineListAttribute
(
const char* attrName,
const string& varName,
const wordList& list
);
//- Define an array attribute of strings
bool defineListAttribute
(
const char* attrName,
const string& varName,
const stringList& list
);
//- Define an "dimensions" attribute (an array of doubles).
bool defineDimensionsAttribute
(
const string& varName,
const dimensionSet& dims
);
//- Write a variable
void writeVariable
//- Define a list variable with size elements and nCmpt components.
// Return adios Id.
template<class T>
int64_t defineListVariable
(
const char* name,
const void* value
const string& name,
const UList<T>& list
);
//- Write a variable
......@@ -427,14 +431,11 @@ protected:
//- Write a variable from the list contents
template<class T>
inline void writeVariable
inline int64_t writeListVariable
(
const char* name,
const string& name,
const UList<T>& list
)
{
writeVariable(name, list.cdata());
}
);
//- Write a variable from the list contents
template<class T>
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 Norbert Podhorszki
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "adiosCoreWrite.H"
#include "adiosTime.H"
#include "foamVersion.H"
#include "endian.H"
#include "OSspecific.H"
// some internal pre-processor stringifications
#undef STRINGIFY
#undef TO_STRING
#define STRINGIFY(x) #x
#define TO_STRING(x) STRINGIFY(x)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::adiosCoreWrite::defineAttribute
(
const char* attrName,
const char* varName,
const string& value
)
{
adios_define_attribute
(
groupID_,
attrName,
varName,
adios_string,
value.c_str(),
nullptr
);
}
void Foam::adiosCoreWrite::defineAttribute
(
const char* attrName,
const string& varName,
const string& value
)
{
defineAttribute(attrName, varName.c_str(), value);
}
void Foam::adiosCoreWrite::defineIntAttribute
(
const char* attrName,
const char* varName,
const int value
)
{
int intval = value;
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName,
adios_integer,
1,
&intval
);
}
void Foam::adiosCoreWrite::defineIntAttribute
(
const char* attrName,
const string& varName,
const int value
)
{
defineIntAttribute(attrName, varName.c_str(), value);
}
void Foam::adiosCoreWrite::defineScalarAttribute
(
const char* attrName,
const char* varName,
const double value
)
{
double fltval = value;
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName,
adios_double,
1,
&fltval
);
}
void Foam::adiosCoreWrite::defineScalarAttribute
(
const char* attrName,
const string& varName,
const double value
)
{
defineScalarAttribute(attrName, varName.c_str(), value);
}
bool Foam::adiosCoreWrite::defineListAttribute
(
const char* attrName,
const string& varName,
const UList<int>& list
)
{
if (list.empty())
{
return false;
}
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName.c_str(),
adios_integer,
list.size(),
list.cdata()
);
return true;
}
bool Foam::adiosCoreWrite::defineListAttribute
(
const char* attrName,
const string& varName,
const UList<double>& list
)
{
if (list.empty())
{
return false;
}
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName.c_str(),
adios_double,
list.size(),
list.cdata()
);
return true;
}
bool Foam::adiosCoreWrite::defineListAttribute
(
const char* attrName,
const string& varName,
const wordList& list
)
{
CStringList cstrings;
if (!list.empty())
{
cstrings.reset(list);
}
if (cstrings.size())
{
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName.c_str(),
adios_string_array,
cstrings.size(),
cstrings.strings()
);
return true;
}
return false;
}
bool Foam::adiosCoreWrite::defineListAttribute
(
const char* attrName,
const string& varName,
const stringList& list
)
{
CStringList cstrings;
if (!list.empty())
{
cstrings.reset(list);
}
if (cstrings.size())
{
adios_define_attribute_byvalue
(
groupID_,
attrName,
varName.c_str(),
adios_string_array,
cstrings.size(),
cstrings.strings()
);
return true;
}
return false;
}
bool Foam::adiosCoreWrite::defineDimensionsAttribute
(
const string& varName,