OpenFOAM: v1912 released! - For more information see https://www.openfoam.com/releases/openfoam-v1912

Commit fb725e37 authored by Mark Olesen's avatar Mark Olesen

WIP: migration to adios2

parent aa2c8a2c
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
cd ${0%/*} || exit 1 # Run from this directory
targetType=libso
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
......@@ -12,6 +12,4 @@ targetType=libso
src/hasAdios || exit 1
src/Allwmake $targetType $*
# [ -d applications ] && applications/Allwmake $targetType $*
#------------------------------------------------------------------------------
......@@ -12,7 +12,7 @@
---
2016-12-20
2019-04-10
---
......@@ -46,7 +46,8 @@ All entries are considered mandatory.
|---------|-----------------------------|--------
| _any_ | /constant/... | _reserved_
| _any_ | /system/... | _reserved_
| string | /openfoam/version | "plus-e40d8870f95a"
| int | /openfoam/api | 1812
| string | /openfoam/patch | "190401"
| string | /openfoam/endian | "LSB"
| int | /openfoam/label | 32
| int | /openfoam/scalar | 64
......@@ -217,9 +218,7 @@ also true.
These entries are only available when the region also has any active
cloud information. A missing value of `nClouds` is equivalent to `nClouds=0`.
For efficiency, the parcel contents are stored directly as a binary
*blob*. The meaning of the binary content can be reconstructed
from its list of names and types.
The cloud contents are written as their IOFields.
#### Region Cloud Attributes
......@@ -260,20 +259,4 @@ manually.
| int[] | \<regionName\>/cloud/\<cloudName\>/byte-size | {24, 4, 4, 8, 4, 4, 4, 4, 4, 4, 8, 8, 8, 24, 8, 8, 8, 24, 24, 24, 24, 0}
The following pseudocode illustrates a possible means of traversing
the parcel content:
get cloud attributes
if max-size != min-size
read "sizes" variable
read cloud binary stream
offset = 1 # leading '('
for each parcel
nbytes = sizes ? sizes[parcel] : min-size
encoded = stream[offset, offset + nbytes]
offset += nbytes
decode parcel content
---
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
. $WM_PROJECT_DIR/wmake/scripts/have_adios2
# -----------------------------------------------------------------------------
adiosFoam/Allwmake
functionObjects/Allwmake
if have_adios2
then
adiosFoam/Allwmake
functionObjects/Allwmake
else
hint_adios2
fi
# -----------------------------------------------------------------------------
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
. $WM_PROJECT_DIR/wmake/scripts/have_adios2
if ../hasAdios
# -----------------------------------------------------------------------------
if have_adios2
then
wmake libso
else
......
adiosTypes.C
adiosTime.C
adiosFoam.C
adiosCore.C
adiosCoreWrite.C
adiosCoreWriteAttr.C
adiosCoreWriteVar.C
adiosCoreWriteMesh.C
adiosCoreWriteField.C
core/adiosCore.C
adiosReader.C
adiosReaderCloudInfo.C
adiosReaderField.C
adiosReaderVarInfo.C
read/adiosReader.C
read/adiosReaderCloud.C
read/adiosReaderField.C
lagrangian/ParcelEncoding.C
lagrangian/ParcelEncodingFragment.C
write/adiosCoreWrite.C
write/adiosCoreWriteAttr.C
write/adiosCoreWriteVar.C
write/adiosCoreWriteMesh.C
write/adiosCoreWriteField.C
write/adiosCoreWriteCloud.C
streams/OCompactStream.C
time/adiosTime.C
LIB = $(FOAM_USER_LIBBIN)/libadiosFoam
/* sinclude $(GENERAL_RULES)/ADIOS */
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
sinclude $(RULES)/mplib$(WM_MPLIB)
/* Obtain compile/link flags via adios_config */
ADIOS_INC := $(shell $(ADIOS_ARCH_PATH)/bin/adios_config -c)
ADIOS_LIBS := $(shell $(ADIOS_ARCH_PATH)/bin/adios_config -l)
sinclude $(GENERAL_RULES)/ADIOS2
EXE_INC = \
-DFOAM_PLATFORM="$(WM_ARCH)$(WM_COMPILER)" \
$(PFLAGS) $(PINC) $(ADIOS_INC) \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
$(PFLAGS) $(PINC) $(ADIOS_FLAGS) \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
LIB_LIBS = \
$(PLIBS) $(ADIOS_LIBS) \
-llagrangian \
-lmeshTools -lfiniteVolume
-lmeshTools \
-lfiniteVolume \
-lfiniteArea \
-llagrangian
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Class
Foam::adiosCore
Description
Core routines for reading/writing ADIOS files for OpenFOAM.
SourceFiles
adiosCore.C
\*---------------------------------------------------------------------------*/
#ifndef adiosCore_H
#define adiosCore_H
#include "adiosTypes.H"
#include "word.H"
#include "instantList.H"
#include "IOstreams.H"
#include "Enum.H"
#include "CStringList.H"
#include "DynamicList.H"
#include "OCountStream.H"
#include "UListStream.H"
#include "OCountCompactStream.H"
#include "OStringCompactStream.H"
#include "UOListCompactStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class adiosCore;
/*---------------------------------------------------------------------------*\
Class adiosCore Declaration
\*---------------------------------------------------------------------------*/
class adiosCore
{
public:
//- Adios read methods. Values as per adios_read.h
enum readType
{
READ_BP = 0, //!< ADIOS_READ_METHOD_BP (=0)
READ_BP_AGGREGATE = 1 //!< ADIOS_READ_METHOD_BP_AGGREGATE (=1)
};
// Static data
static const Enum<readType> readMethodNames;
private:
// Static data
//- Reference counting for cleanup of common transfer buffer
static unsigned refCount_;
// Private data
//- Group name within ADIOS files
word name_;
protected:
// Protected data
//- Directory name for ADIOS files
static const word dataDirectory;
//- File extension for ADIOS files
static const word fileExt;
//- Buffer for reading/writing (streamed) content to/from ADIOS files
static DynamicList<char> transfer_;
public:
//- OpenFOAM global attributes within ADIOS file
static const string foamAttribute;
//- OpenFOAM time attributes within ADIOS file
static const string timeAttribute;
// static const IOstream::streamFormat strFormat = IOstream::ASCII;
static const IOstream::streamFormat strFormat = IOstream::BINARY;
typedef OStringCompactStream OutputStringStreamer;
typedef UOListCompactStream OutputListStreamer;
typedef OCountCompactStream OutputCounter;
// typedef OStringStream OStringStreamer;
// typedef UOListStream OutputListStreamer;
// typedef OCountStream OutputCounter;
// Constructors
//- Construct for given ADIOS group name
adiosCore(const word& groupName);
//- Destructor
virtual ~adiosCore();
// Member Functions
//- Return name of the ADIOS group
const word& name() const
{
return name_;
}
//- Search a given directory for ADIOS time files
static instantList findTimes
(
const fileName& directory = dataDirectory,
const word& constantName = "constant"
);
//- Path name for a region
inline static const word& regionPath
(
const word& regionName
)
{
return regionName;
}
//- Path name for fields
inline static fileName fieldPath
(
const word& regionName,
const fileName& var = fileName::null
)
{
return regionPath(regionName) / "field" / var;
}
//- Path name for meshes
inline static fileName meshPath
(
const word& regionName,
const fileName& var = fileName::null
)
{
return regionPath(regionName) / "polyMesh" / var;
}
//- Path name for clouds
inline static fileName cloudPath
(
const word& regionName,
const word& cloudName = word::null
)
{
return regionPath(regionName) / "cloud" / cloudName;
}
//- Buffer for reading/writing (streamed) content to/from ADIOS files.
// Also used when reading/writing dissimilar content.
inline static DynamicList<char>& transferBuffer()
{
return transfer_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 Norbert Podhorszki
-------------------------------------------------------------------------------
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::putAttribute
(
const std::string& attrName,
const std::string& varName,
const std::string& value
)
{
adios_define_attribute
(
groupID_,
attrName.c_str(),
varName.c_str(),
adios_string,
value.c_str(),
nullptr
);
}
void Foam::adiosCoreWrite::putIntAttribute
(
const std::string& attrName,
const std::string& varName,
const int value
)
{
int intval = value;
adios_define_attribute_byvalue
(
groupID_,
attrName.c_str(),
varName.c_str(),
adios_integer,
1,
&intval
);
}
void Foam::adiosCoreWrite::putScalarAttribute
(
const std::string& attrName,
const std::string& varName,
const double value
)
{
double fltval = value;
adios_define_attribute_byvalue
(
groupID_,
attrName.c_str(),
varName.c_str(),
adios_double,
1,
&fltval
);
}
bool Foam::adiosCoreWrite::putListAttribute
(
const std::string& attrName,
const std::string& varName,
const UList<int>& list
)
{
if (list.empty())
{
return false;
}
adios_define_attribute_byvalue
(
groupID_,
attrName.c_str(),
varName.c_str(),
adiosTraits<int>::adiosType,
list.size(),
list.cdata()
);
return true;
}
bool Foam::adiosCoreWrite::putListAttribute
(
const std::string& attrName,
const std::string& varName,
const UList<double>& list
)
{
if (list.empty())
{
return false;
}
adios_define_attribute_byvalue
(
groupID_,
attrName.c_str(),
varName.c_str(),
adiosTraits<double>::adiosType,
list.size(),
list.cdata()
);
return true;
}
bool Foam::adiosCoreWrite::putListAttribute
(
const std::string& attrName,
const std::string& varName,
const CStringList& cstrings
)
{
if (cstrings.size())
{
adios_define_attribute_byvalue
(
groupID_,
attrName.c_str(),
varName.c_str(),
adios_string_array,
cstrings.size(),
cstrings.strings()
);
return true;
}
return false;
}
bool Foam::adiosCoreWrite::putListAttribute
(
const std::string& attrName,
const std::string& varName,
const UList<word>& list
)
{
CStringList cstrings;
if (!list.empty())
{
cstrings.reset(list);
}
return putListAttribute(attrName, varName, cstrings);
}
bool Foam::adiosCoreWrite::putListAttribute
(
const std::string& attrName,
const std::string& varName,
const UList<string>& list
)
{
CStringList cstrings;
if (!list.empty())
{
cstrings.reset(list);
}
return putListAttribute(attrName, varName, cstrings);
}
bool Foam::adiosCoreWrite::putDimensionsAttribute
(
const std::string& varName,
const dimensionSet& dims
)
{
scalarList units(dimensionSet::nDimensions);
forAll(units, i)
{
units[i] = dims[i];
}
return putListAttribute("dimensions", varName, units);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "volFields.H"
#include "nullObject.H"
#include "IOstreams.H"
#include "pointFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
int64_t Foam::adiosCoreWrite::writeFieldObject
(
const regIOobject& obj,
const bool testOnly
)
{
int64_t varid = -1;
const word& fieldType = obj.type();
// Point fields
if (fieldType == pointScalarField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const pointScalarField&>(obj)
);
}
else if (fieldType == pointVectorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const pointVectorField&>(obj)
);
}
else if (fieldType == pointSphericalTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const pointSphericalTensorField&>(obj)
);
}
else if (fieldType == pointSymmTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const pointSymmTensorField&>(obj)
);
}
else if (fieldType == pointTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const pointTensorField&>(obj)
);
}
// Surface fields
else if (fieldType == surfaceScalarField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const surfaceScalarField&>(obj)
);
}
else if (fieldType == surfaceVectorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const surfaceVectorField&>(obj)
);
}
else if (fieldType == surfaceSphericalTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const surfaceSphericalTensorField&>(obj)
);
}
else if (fieldType == surfaceSymmTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const surfaceSymmTensorField&>(obj)
);
}
else if (fieldType == surfaceTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const surfaceTensorField&>(obj)
);
}
// Volume fields
else if (fieldType == volScalarField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(