...
 
Commits (5)
#!/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 $*
#------------------------------------------------------------------------------
......@@ -15,13 +15,13 @@ ThirdParty
Until this is fully integrated into OpenFOAM, the user should compile
ADIOS using the ThirdParty `makeADIOS` script with the preferred ADIOS version.
Subsequently, set `ADIOS_ARCH_PATH` accordingly. Eg,
Subsequently, set `ADIOS1_ARCH_PATH` accordingly. Eg,
adios_version=ADIOS-1.11.0
export ADIOS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios_version
export ADIOS1_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios_version
And optionally add it to the PATH
PATH=$ADIOS_ARCH_PATH/bin:$PATH
PATH=$ADIOS1_ARCH_PATH/bin:$PATH
---
* Cold restart
* Not all Lagrangian types are yet supported
......@@ -12,13 +12,13 @@
---
2016-12-20
2019-04-10
---
* Storage directory: "adiosData/"
* Each "ofbp" (OpenFOAM binary packed) adios file is restricted to a
* Each "bp" (OpenFOAM binary packed) adios file is restricted to a
***single*** time-step/iteration.
This makes for simple and efficient handling.
......@@ -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 "DynamicCharList.H"
#include "IBufStream.H"
#include "OBufStream.H"
#include "OCountStream.H"
#include "OCompactStringStream.H"
#include "OCompactBufStream.H"
#include "OCompactCountStream.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 handling mpi init/finalize in serial
static unsigned refCount_;
// Private data
//- Group name within ADIOS files
word name_;
// Private Member Functions
//- Global initializations.
// Eg, Manual MPI_Init for serial runs (ADIOS always requires mpi).
static void global_init();
//- Cleanup global initializations.
// Eg, Manual MPI_Finalize for serial runs.
static void global_finalize();
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 DynamicCharList 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 OCompactStringStream OutputStringStreamer;
typedef OCompactBufStream OutputBufStreamer;
typedef OCompactCountStream OutputCounter;
// typedef OStringStream OStringStreamer;
// typedef OBufStream OutputBufStreamer;
// 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 DynamicCharList& 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
(
static_cast<const volScalarField&>(obj)
);
}
else if (fieldType == volVectorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const volVectorField&>(obj)
);
}
else if (fieldType == volSphericalTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const volSphericalTensorField&>(obj)
);
}
else if (fieldType == volSymmTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const volSymmTensorField&>(obj)
);
}
else if (fieldType == volTensorField::typeName)
{
varid = testOnly ? 1 : writeGeometricField
(
static_cast<const volTensorField&>(obj)
);
}
// Internal volume fields
else if (fieldType == volScalarField::Internal::typeName)
{
varid = testOnly ? 1 : writeInternalField
(
static_cast<const volScalarField::Internal&>(obj)
);
}
else if (fieldType == volVectorField::Internal::typeName)
{
varid = testOnly ? 1 : writeInternalField
(
static_cast<const volVectorField::Internal&>(obj)
);
}
else if (fieldType == volSphericalTensorField::Internal::typeName)
{
varid = testOnly ? 1 : writeInternalField
(
static_cast<const volSphericalTensorField::Internal&>(obj)
);
}
else if (fieldType == volSymmTensorField::Internal::typeName)
{
varid = testOnly ? 1 : writeInternalField
(
static_cast<const volSymmTensorField::Internal&>(obj)
);
}
else if (fieldType == volTensorField::Internal::typeName)
{
varid = testOnly ? 1 : writeInternalField
(
static_cast<const volTensorField::Internal&>(obj)
);
}
return varid;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
int64_t Foam::adiosCoreWrite::defineGenericVariable
(
const std::string& name,
enum ADIOS_DATATYPES type,
const std::string& local,
const std::string& global,
const std::string& offsets
)
{
int64_t varid = adios_define_var
(
groupID_,
name.c_str(), // name
nullptr, // path (deprecated)
type, // data-type
local.c_str(), // local dimensions
global.c_str(), // global dimensions
offsets.c_str() // local offsets
);
vars_.insert(name, varid);
return varid;
}
void Foam::adiosCoreWrite::writeGenericVariable
(
const int64_t varid,
const void* value
)
{
if (fileID_)
{
adios_write_byid(fileID_, varid, value);
}
else
{
WarningInFunction
<< "Attempting to write adios variable "
<< "without an open adios file"
<< endl;
}
}
void Foam::adiosCoreWrite::writeGenericVariable
(
const std::string& name,
const void* value
)
{
// could also check that variable has been defined
// vars_.found(name);
if (fileID_)
{
adios_write(fileID_, name.c_str(), value);
}
else
{
WarningInFunction
<< "Attempting to write adios variable "
<< name << " without an open adios file"
<< endl;
}
}
int64_t Foam::adiosCoreWrite::putLabelVariable
(
const std::string& name,
const label value
)
{
int64_t varid = adios_define_var
(
groupID_,
name.c_str(), // name
nullptr, // path (deprecated)
adiosTraits<label>::adiosType, // data-type
"1", // local dimensions
Foam::name(Pstream::nProcs()).c_str(), // global 1D array of this info
Foam::name(Pstream::myProcNo()).c_str() // offsets of this process into array
);
vars_.insert(name, varid);
if (fileID_)
{
adios_write_byid(fileID_, varid, &value);
}
else
{
WarningInFunction
<< "Attempting to write adios variable \""
<< name << "\" without an open adios file"
<< endl;
}
return varid;
}
int64_t Foam::adiosCoreWrite::defineStreamVariable
(
const std::string& name,
size_t count
)
{
// Use unsigned byte for raw storage
int64_t varid = adios_define_var
(
groupID_,
name.c_str(), // name
nullptr, // path (deprecated)
adios_unsigned_byte, // data-type
Foam::name(count).c_str(), // local dimensions
nullptr, // global dimensions
nullptr // local offsets
);
vars_.insert(name, varid);
return varid;
}
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -23,106 +23,19 @@ License
\*---------------------------------------------------------------------------*/
#include "adiosCore.H"
#include "adios.h"
#include "adios_types.h"
#include "fileNameList.H"
#include "IStringStream.H"
#include "token.H"
#include "scalar.H"
#include "adiosFoam.H"
#include "OSspecific.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::Enum<Foam::adiosCore::readType> Foam::adiosCore::readMethodNames
{
{ readType::READ_BP, "BP"},
{ readType::READ_BP_AGGREGATE, "BP_AGGREGATE" },
};
const Foam::word
Foam::adiosCore::dataDirectory("adiosData");
const Foam::word
Foam::adiosCore::fileExt("ofbp");
const Foam::string
Foam::adiosCore::foamAttribute = "/openfoam";
const Foam::string
Foam::adiosCore::timeAttribute = "/time";
unsigned Foam::adiosCore::refCount_ = 0;
Foam::DynamicCharList Foam::adiosCore::transfer_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::adiosCore::global_init()
{
if (refCount_ == 0) // first one in
{
if (!Pstream::parRun())
{
// NULL args are OK for openmpi, mpich-2
MPI_Init(nullptr, nullptr);
}
// Runtime assertions (verify assumed sizes) - or emit a fatal error
adiosTraits<label>::ok();
adiosTraits<scalar>::ok();
}
++refCount_;
}
void Foam::adiosCore::global_finalize()
{
if (refCount_ == 1) // last one out
{
// Cleanup our own MPI_Init()
if (!Pstream::parRun())
{
MPI_Finalize();
}
transfer_.clearStorage();
}
--refCount_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::adiosCore::adiosCore
(
const word& name
)
:
name_(name)
{
global_init();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::adiosCore::~adiosCore()
{
global_finalize();
}
const Foam::word Foam::adiosFoam::defaultDirectory("adiosData");
const Foam::string Foam::adiosFoam::foamAttribute("/openfoam");
const Foam::string Foam::adiosFoam::timeAttribute("/time");
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
Foam::instantList Foam::adiosCore::findTimes
Foam::instantList Foam::adiosFoam::findTimes
(
const fileName& directory,
const word& constantName
......@@ -137,12 +50,12 @@ Foam::instantList Foam::adiosCore::findTimes
// Check for "constant" - not yet useful
bool haveConstant = false;
for (const auto& dirEntry : dirEntries)
for (const fileName& dirEntry : dirEntries)
{
if (dirEntry.ext() == fileExt && dirEntry.lessExt() == constantName)
if (dirEntry.hasExt("bp") && dirEntry.lessExt() == constantName)
{
Times[nTimes].value() = 0;
Times[nTimes].name() = dataDirectory/dirEntry;
Times[nTimes].name() = word(dirEntry);
++nTimes;
haveConstant = true;
break;
......@@ -150,17 +63,17 @@ Foam::instantList Foam::adiosCore::findTimes
}
// Read and parse all the entries in the directory
for (const auto& dirEntry : dirEntries)
for (const fileName& dirEntry : dirEntries)
{
if (dirEntry.ext() == fileExt)
if (dirEntry.hasExt("bp"))
{
IStringStream timeStream(dirEntry.lessExt());
token timeToken(timeStream);
scalar val;
const word dirValue(dirEntry.lessExt());
if (timeToken.isNumber() && timeStream.eof())
if (readScalar(dirValue, val))
{
Times[nTimes].value() = timeToken.number();
Times[nTimes].name() = dataDirectory/dirEntry;
Times[nTimes].value() = val;
Times[nTimes].name() = word(dirEntry);
++nTimes;
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -21,93 +21,112 @@ License
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::OCompactStream
Namespace
Foam::adiosFoam
Description
A generic output stream using an output with reduced spacing.
Core routines and definitions for OpenFOAM ADIOS files.
SourceFiles
OCompactStream.C
adiosFoam.C
\*---------------------------------------------------------------------------*/
#ifndef OCompactStream_H
#define OCompactStream_H
#ifndef adiosFoam_H
#define adiosFoam_H
#include "OSstream.H"
#include "fileName.H"
#include <iostream>
#include "instantList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace adiosFoam
{
/*---------------------------------------------------------------------------*\
Class OCompactStream Declaration
Namespace adiosFoam Declaration
\*---------------------------------------------------------------------------*/
class OCompactStream
:
public OSstream
{
// Private Member Functions
//- Disallow default bitwise copy construct
OCompactStream(const OCompactStream&) = delete;
//- The default directory name for ADIOS files ("adiosData")
extern const word defaultDirectory;
//- Disallow default bitwise assignment
void operator=(const OCompactStream&) = delete;
//- OpenFOAM global attributes within ADIOS file ("/openfoam")
extern const string foamAttribute;
public:
//- OpenFOAM time attributes within ADIOS file ("/time")
extern const string timeAttribute;
// Constructors
//- Set stream status
OCompactStream
(
ostream& os,
const string& name,
streamFormat format=ASCII,
versionNumber version=currentVersion,
compressionType compression=UNCOMPRESSED
);
//- Search a given directory for ADIOS time files
instantList findTimes
(
const fileName& directory,
const word& constantName = "constant"
);
// Member functions
//- Path name for a region
inline const word& regionPath
(
const word& regionName
)
{
return regionName;
}
// Write functions
//- Add indentation characters
virtual void indent();
//- Extract region name from a variable name (somewhat fragile)
inline word regionOf
(
const fileName& varName
)
{
const auto i = varName.find('/');
//- Write the keyword followed by an appropriate indentation
virtual Ostream& writeKeyword(const keyType&);
return varName.substr(0, i);
}
//- Write begin block group with the given name
virtual Ostream& beginBlock(const word&);
//- Write begin block group without a name
virtual Ostream& beginBlock();
//- Path name for fields
inline fileName fieldPath
(
const word& regionName,
const fileName& var = fileName::null
)
{
return regionPath(regionName) / "field" / var;
}
//- Write end block group
virtual Ostream& endBlock();
//- Path name for meshes
inline fileName meshPath
(
const word& regionName,
const fileName& var = fileName::null
)
{
return regionPath(regionName) / "polyMesh" / var;
}
// Stream state functions
//- Add newline and flush stream
virtual void endl();
//- Path name for clouds
inline fileName cloudPath
(
const word& regionName,
const word& cloudName = word::null
)
{
return regionPath(regionName) / "cloud" / cloudName;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace adiosFoam
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
This diff is collapsed.
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "adiosReader.H"
#include "emptyFvPatchField.H"
#include "pointFields.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::adiosReader::readFieldObject
(
regIOobject& obj,
const fieldInfo& src
) const
{
const word& fieldType = obj.type();
const word& srcType = src.type();
if (fieldType != srcType)
{
// probably fatal:
Info<<"WARNING mismatch on field " << src
<< " (expected: " << fieldType
<< " but had " << srcType << ")\n";
return -1;
}
Info<<"Read " << obj.name() << " (type " << fieldType << ") from file\n";
// Point fields
if (fieldType == pointScalarField::typeName)
{
return readGeometricField
(
static_cast<pointScalarField&>(obj),
src
);
}
else if (fieldType == pointVectorField::typeName)
{
return readGeometricField
(
static_cast<pointVectorField&>(obj),
src
);
}
else if (fieldType == pointSphericalTensorField::typeName)
{
return readGeometricField
(
static_cast<pointSphericalTensorField&>(obj),
src
);
}
else if (fieldType == pointSymmTensorField::typeName)
{
return readGeometricField
(
static_cast<pointSymmTensorField&>(obj),
src
);
}
else if (fieldType == pointTensorField::typeName)
{
return readGeometricField
(
static_cast<pointTensorField&>(obj),
src
);
}
// Surface fields
else if (fieldType == surfaceScalarField::typeName)
{
return readGeometricField
(
static_cast<surfaceScalarField&>(obj),
src
);
}
else if (fieldType == surfaceVectorField::typeName)
{
return readGeometricField
(
static_cast<surfaceVectorField&>(obj),
src
);
}
else if (fieldType == surfaceSphericalTensorField::typeName)
{
return readGeometricField
(
static_cast<surfaceSphericalTensorField&>(obj),
src
);
}
else if (fieldType == surfaceSymmTensorField::typeName)
{
return readGeometricField
(
static_cast<surfaceSymmTensorField&>(obj),
src
);
}
else if (fieldType == surfaceTensorField::typeName)
{
return readGeometricField
(
static_cast<surfaceTensorField&>(obj),
src
);
}
// Volume fields
else if (fieldType == volScalarField::typeName)
{
return readGeometricField
(
static_cast<volScalarField&>(obj),
src
);
}
else if (fieldType == volVectorField::typeName)
{
return readGeometricField
(
static_cast<volVectorField&>(obj),
src
);
}
else if (fieldType == volSphericalTensorField::typeName)
{
return readGeometricField
(
static_cast<volSphericalTensorField&>(obj),
src
);
}
else if (fieldType == volSymmTensorField::typeName)
{
return readGeometricField
(
static_cast<volSymmTensorField&>(obj),
src
);
}
else if (fieldType == volTensorField::typeName)
{
return readGeometricField
(
static_cast<volTensorField&>(obj),
src
);
}
// Internal volume fields
else if (fieldType == volScalarField::Internal::typeName)
{
return readField
(
static_cast<volScalarField::Internal&>(obj),
src
);
}
else if (fieldType == volVectorField::Internal::typeName)
{
return readField
(
static_cast<volVectorField::Internal&>(obj),
src
);
}
else if (fieldType == volSphericalTensorField::Internal::typeName)
{
return readField
(
static_cast<volSphericalTensorField::Internal&>(obj),
src