Commit af803b85 authored by mark's avatar mark

ENH: report endian/label-size/scalar-size, skip processor patches

parent 4b214257
......@@ -67,7 +67,7 @@ Foam::adiosCore::foamAttribute = "/openfoam";
const Foam::string
Foam::adiosCore::timeAttribute = "/time";
int Foam::adiosCore::refCount_ = 0;
unsigned Foam::adiosCore::refCount_ = 0;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -84,7 +84,7 @@ private:
// Static data
//- Reference counting for handling mpi init/finalize in serial
static int refCount_;
static unsigned refCount_;
// Private data
......
......@@ -242,15 +242,15 @@ void Foam::adiosCoreWrite::defineBaseAttributes()
(
"label-size",
adiosCore::foamAttribute,
adiosTraits<label>::nBits
int(8 * sizeof(label))
);
// OpenFOAM scalar type (single-precision?)
defineAttribute
// OpenFOAM scalar size (32=single, 64=double)
defineIntAttribute
(
"precision",
"scalar-size",
adiosCore::foamAttribute,
adiosTraits<scalar>::precisionName
int(8 * sizeof(scalar))
);
// other general information
......
......@@ -32,8 +32,8 @@ License
#include "IOstream.H"
#include "IOstreams.H"
#include "Ostream.H"
#warning "TODO - truncrate patch-names to non-processor patches"
#include "processorFvPatch.H"
#include "processorPointPatch.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * * //
......@@ -43,27 +43,45 @@ int64_t Foam::adiosCoreWrite::writeField
const FieldType& field
)
{
const int64_t varid = writeInternalField(field);
const fileName varName = adiosCore::fieldPath
(
field.db().name(), // = region name
field.name() // = field name
);
if (Pstream::master())
{
// Attributes are global - only passed via the master
const typename FieldType::Boundary& bfield = field.boundaryField();
const typename FieldType::BoundaryMesh& bmesh = field.mesh().boundary();
// independent of how we store fields,
// Independent of how we store fields,
// a quick lookup of field patch types may prove useful
stringList pTypes(bfield.size());
label nPatches = 0;
forAll(bfield, patchI)
{
// Only count 'real' (non-processor patches)
if
(
isA<processorFvPatch>(bmesh[patchI])
|| isA<processorPointPatch>(bmesh[patchI])
)
{
break;
}
pTypes[patchI] = bfield[patchI].type();
++nPatches;
}
pTypes.setSize(nPatches);
defineListAttribute("patch-types", varName, pTypes);
}
return writeInternalField(field);
return varid;
}
......@@ -79,15 +97,30 @@ int64_t Foam::adiosCoreWrite::writeInternalField
field.name() // = field name
);
// could also write field.dimensions() as an attribute (as required)
defineAttribute("class", varName, field.type());
if (Pstream::master())
{
// Attributes are global - only passed via the master
// Could also write field.dimensions() as an attribute (as required)
defineAttribute("class", varName, field.type());
const dimensionSet& dims = field.dimensions();
scalarList units(dimensionSet::nDimensions);
forAll(units, i)
{
units[i] = dims[i];
}
defineListAttribute("dimensions", varName, units);
}
OutputCounter counter(adiosCore::strFormat);
counter << field;
int64_t varid = defineStreamVariable(varName, counter.size());
// use iobuffer_ to avoid too many reallocations - needs some rework?
// Use iobuffer_ to avoid too many reallocations - needs some rework?
iobuffer_.reserve(adios_expected_var_size(varid));
OutputBufStreamer os(iobuffer_, adiosCore::strFormat);
......
......@@ -34,17 +34,29 @@ void Foam::adiosCoreWrite::definePatchAttributes(const polyMesh& mesh)
const polyPatchList& patches = mesh.boundaryMesh();
stringList pNames(patches.size());
stringList pTypes(patches.size());
label nPatches = 0;
forAll(patches, patchI)
{
const polyPatch& p = patches[patchI];
// Only count 'real' (non-processor patches)
if (isA<processorPolyPatch>(p))
{
break;
}
pNames[patchI] = p.name();
pTypes[patchI] = p.type();
++nPatches;
}
pNames.setSize(nPatches);
pTypes.setSize(nPatches);
const fileName varPath = adiosCore::regionPath(mesh.name());
defineIntAttribute("nPatches", varPath, patches.size());
defineIntAttribute("nPatches", varPath, nPatches);
defineListAttribute("patch-names", varPath, pNames);
defineListAttribute("patch-types", varPath, pTypes);
}
......
......@@ -48,13 +48,11 @@ Foam::adiosTraits<Foam::label>::adiosType = adios_long;
const size_t
Foam::adiosTraits<Foam::label>::adiosSize = 8;
#else
# error "WM_LABEL_SIZE not defined in adiosTypes"
#error "WM_LABEL_SIZE not defined in adiosTypes"
#endif
const int
Foam::adiosTraits<Foam::label>::nBits = WM_LABEL_SIZE;
#if defined(WM_SP)
......@@ -64,9 +62,6 @@ Foam::adiosTraits<Foam::scalar>::adiosType = adios_real;
const size_t
Foam::adiosTraits<Foam::scalar>::adiosSize = 4;
const char* const
Foam::adiosTraits<Foam::scalar>::precisionName = "single";
#elif defined(WM_DP)
const enum ADIOS_DATATYPES
......@@ -75,11 +70,8 @@ Foam::adiosTraits<Foam::scalar>::adiosType = adios_double;
const size_t
Foam::adiosTraits<Foam::scalar>::adiosSize = 8;
const char* const
Foam::adiosTraits<Foam::scalar>::precisionName = "double";
#else
# error "WM_SP/WM_DP not defined in adiosTypes"
# error "(WM_SP | WM_DP) not defined in adiosTypes"
#endif
......
......@@ -47,7 +47,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- template specialization for adiosTraits<label>
//- Template specialization for adiosTraits<label>
template<>
class adiosTraits<label>
{
......@@ -64,9 +64,6 @@ public:
//- Size of ADIOS type
static const size_t adiosSize;
//- Number of bits
static const int nBits;
//- Verify ADIOS type-size
static bool ok();
......@@ -95,7 +92,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- template specialization for adiosTraits<scalar>
//- Template specialization for adiosTraits<scalar>
template<>
class adiosTraits<scalar>
{
......@@ -112,9 +109,6 @@ public:
//- Size of ADIOS type
static const size_t adiosSize;
//- Name of the precision (single|double)
static const char* const precisionName;
//- Verify ADIOS type-size
static bool ok();
......
......@@ -212,8 +212,9 @@ bool Foam::adiosWrite::read(const dictionary& dict)
// Print info to terminal
Info<< type() << " " << adiosCore::name() << ":" << endl
<< " Compiled with " << adiosTraits<scalar>::adiosSize
<< " bytes precision." << nl
<< " Compiled with label=int" << int(8 * sizeof(label))
<< " scalar=float" << int(8 * sizeof(scalar)) << "."
<< nl
<< " Writing every " << writeInterval_ << " iterations:" << endl;
......
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