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

Commit 68977d9e 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 | 1906
| string | /openfoam/patch | "190401"
| string | /openfoam/endian | "LSB"
| int | /openfoam/label | 32
| int | /openfoam/scalar | 64
......@@ -61,15 +62,6 @@ of the `/openfoam/regions` attribute. No particular sort order is
specified for the region names.
These additional attributes provide assistance when reading the data files.
These entries are advisable.
| type | name | example
|---------|-----------------------------|--------
| string | /openfoam/baseline/plus | 1612
| string | /openfoam/platform | "linux64Gcc"
### General Variables
Coordinated data for all mesh, fields and cloud information.
......@@ -95,8 +87,8 @@ values are available directly from the meta-data.
| double | /time/value | time-value
| double | /time/deltaT | current time-step value
| double | /time/deltaT0 | previous time-step value
| double[]| /time/faces | time-value of mesh topology (per region)
| double[]| /time/points | time-value of mesh points (per region)
| double | /time/faces | time-value of mesh topology (per region)
| double | /time/points | time-value of mesh points (per region)
The order of the `/time/faces` and `/time/points` attributes must
correspond exactly to the ordering used by the `/openfoam/regions` attribute.
......@@ -175,7 +167,7 @@ also true.
| int | \<regionName\>/polyMesh/nInternalFaces | per processor
#### Localized Variables
#### Local Variables
| type | name | comment
|---------|---------------------------------------|-------------
......@@ -190,14 +182,14 @@ also true.
### Fields
#### Localized Variables
#### Local Variables
| type | name | comment
|---------|--------------------------------------|-------------
| double | \<regionName\>/field/p | internalField - primitive field content
| byte | \<regionName\>/field/p/boundaryField | as per OPENFOAM binary file content
| double | \<regionName\>/field/U | primitive field content
| byte | \<regionName\>/field/U/boundaryField | internalField - primitive field content
| double | \<regionName\>/field/p | internalField - primitive field content
| byte | \<regionName\>/field/p/boundaryField | as per OPENFOAM binary file content
| | ...
......@@ -205,10 +197,10 @@ also true.
| type | name | example
|---------|-------------------------------------|-------------
| string | \<regionName\>/field/p/class | "volScalarField"
| string[]| \<regionName\>/field/p/patch-types | { "zeroGradient", "zeroGradient", "empty" }
| string | \<regionName\>/field/U/class | "volVectorField"
| string[]| \<regionName\>/field/U/patch-types | {"fixedValue", "fixedValue", "empty"}
| string | \<regionName\>/field/p/class | "volScalarField"
| string[]| \<regionName\>/field/p/patch-types | { "zeroGradient", "zeroGradient", "empty" }
| | ...
......@@ -217,9 +209,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
......@@ -233,18 +223,8 @@ from its list of names and types.
| type | name | comment
|---------|--------------------------------|-------------
| byte | \<regionName\>/cloud/\<cloudName\> | cloud binary content
| int | \<regionName\>/cloud/\<cloudName\>/nParcels | per processor
| int | \<regionName\>/cloud/\<cloudName\>/sizes | parcels sizes for variable-sized content
| double | \<regionName\>/cloud/\<cloudName\>/position | cloud x,y,z positions
The cloud attribute `min-size` corresponds to the fixed parcel length
known _a priori_ (eg, via the respective parcel `sizeofFields` value.
The cloud attribute `max-size` corresponds to the
maximum parcel length at a given time-step. If the `max-size` is not
equal to the `min-size`, the cloud type has variable-sized content and
the `sizes` variable is necessary for decoding the parcel content
manually.
#### Cloud Attributes
......@@ -252,28 +232,6 @@ manually.
|---------|--------------------------------|-------------
| string | \<regionName\>/cloud/\<cloudName\>/class | "Cloud\<basicKinematicCollidingParcel\>"
| int | \<regionName\>/cloud/\<cloudName\>/nParcels | total count (sum of corresponding variable)
| int | \<regionName\>/cloud/\<cloudName\>/min-size | 238 (bytes)
| int | \<regionName\>/cloud/\<cloudName\>/max-size | 380 (bytes)
| string[]| \<regionName\>/cloud/\<cloudName\>/names | {"position", "cellI", "faceI", "stepFraction", "tetFaceI", "tetPtI", "origProc", "origId", "active", "typeId", "nParticle", "d", "dTarget", "U", "rho", "age", "tTurb", "UTurb", "f", "angularMomentum", "torque", "*"}
| string[]| \<regionName\>/cloud/\<cloudName\>/types | {"vector", "label", "label", "scalar", "label", "label", "label", "label", "label", "label", "scalar", "scalar", "scalar", "vector", "scalar", "scalar", "scalar", "vector", "vector", "vector", "vector", "*"}
| int[] | \<regionName\>/cloud/\<cloudName\>/offset | {1, 25, 29, 33, 41, 45, 49, 53, 59, 63, 67, 75, 83, 91, 115, 123, 131, 139, 165, 189, 213, 238}
| 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,