Commit 108fffe3 authored by mark's avatar mark

CONFIG: update to work with OpenFOAM+/develop 2016-07-28

- CStringList and some other bits are now in the upstream code.

  Memory-buffered streams are not yet integrated.
  So just link them in here ourselves to reduce some complexity.
parent 366feaf0
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
makeType=${1:-libso}
targetType=libso
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
if [ -n "$ADIOS_DIR" ]
then
echo "using ADIOS_DIR=$ADIOS_DIR"
else
export ADIOS_DIR=$WM_THIRD_PARTY_DIR/platforms/linux64Gcc/adios-git
echo "setting ADIOS_DIR=$ADIOS_DIR"
fi
set -x
wmake $targetType streams
# an extra compile options for adios
incdir=$(cd streams && pwd -P)
export ADIOS_EXTRA_COMP="-I$incdir/lnInclude"
export ADIOS_EXTRA_LINK='-L$(FOAM_USER_LIBBIN) -ladiosStreams'
wmake $makeType IOadiosWrite #; cp IOh5Write/writeXDMF.py $FOAM_USER_APPBIN
wmake $targetType IOadiosWrite
# ----------------------------------------------------------------- end-of-file
......@@ -21,6 +21,5 @@ adiosWrite/ParcelEncodingFragment.C
/* these files should likely migrate into the OpenFOAM src */
/* adiosWrite/OCompactStream.C */
adiosWrite/CStringList.C
LIB = $(FOAM_USER_LIBBIN)/libIOadiosWrite
ADIOS_DIR = $(WM_THIRD_PARTY_DIR)/platforms/linux64Gcc/adios-git
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
sinclude $(RULES)/mplib$(WM_MPLIB)
......@@ -8,7 +6,7 @@ ADIOS_LIBS := ${shell ${ADIOS_DIR}/bin/adios_config -l}
EXE_INC = -DFOAM_PLATFORM="$(WM_ARCH)$(WM_COMPILER)" \
$(PFLAGS) $(PINC) \
$(ADIOS_INC) \
$(ADIOS_INC) $(ADIOS_EXTRA_COMP) \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
......@@ -27,6 +25,7 @@ EXE_INC = -DFOAM_PLATFORM="$(WM_ARCH)$(WM_COMPILER)" \
LIB_LIBS = $(PLIBS) \
$(ADIOS_LIBS) \
${ADIOS_EXTRA_LINK} \
-llagrangian -llagrangianIntermediate \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "CStringList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::CStringList::CStringList()
:
argc_(0),
len_(0),
argv_(0),
data_(0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::CStringList::~CStringList()
{
clear();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::CStringList::clear()
{
argc_ = 0;
len_ = 0;
if (data_)
{
delete[] data_;
data_ = 0;
}
if (argv_)
{
delete[] argv_;
argv_ = 0;
}
}
int Foam::CStringList::argc() const
{
return argc_;
}
int Foam::CStringList::size() const
{
return argc_;
}
size_t Foam::CStringList::length() const
{
return len_;
}
char** Foam::CStringList::argv() const
{
return argv_;
}
char* Foam::CStringList::data() const
{
return data_;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::CStringList
Description
An adapter for copying a list of C++ strings into a list of C-style
strings for passing to C code that expects argc/argv parameters.
In addition to providing a C-compatible list of C-strings,
the string lists are flattened into a single string of data that can be
also be passed en mass.
Example use:
\code
wordList myStrings; ...
CStringList cstrings(myStrings);
// pass as argc, argv:
someMain(cstrings.argc(), cstrings.argv());
// access copy of raw characters:
os.write(cstrings.data(), cstrings.length());
\endcode
\*---------------------------------------------------------------------------*/
#ifndef CStringList_H
#define CStringList_H
#include "fileNameList.H"
#include "stringList.H"
#include "wordList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class CStringList Declaration
\*---------------------------------------------------------------------------*/
class CStringList
{
// Private data
//- Number of strings
int argc_;
//- Overall length of the raw content
// Does not include the final nul-character
size_t len_;
//- List of strings, including trailing NULL pointer
char** argv_;
//- Flattened content with interspersed nul-characters
char* data_;
// Private Member Functions
//- Disallow default bitwise copy construct
CStringList(const CStringList&);
//- Disallow default bitwise assignment
void operator=(const CStringList&);
public:
// Constructors
//- Construct empty, adding content later (via reset).
CStringList();
//- Construct from a list of strings
// Copies the input characters.
template<class StringType>
CStringList(const UList<StringType>& input);
//- Destructor
~CStringList();
// Public Members
// Access
//- Return the number of C-strings
int argc() const;
//- Return the number of C-strings
// For consistency with normal STL methods
int size() const;
//- Overall length of the character content
//- Return the number of C-strings
size_t length() const;
//- Return the list of C-strings
// The position at argc is a NULL pointer
char** argv() const;
//- The flattened character content, with interspersed nul-chars
char* data() const;
// Edit
//- Clear contents and free memory
void clear();
//- Copy the input list of strings.
template<class StringType>
void reset(const UList<StringType>& input);
// Other
//- Create a string list from argc/argv parameters.
// A null pointer for argv is permissible when argc is zero.
template<class StringType>
static List<StringType> asList(int argc, const char * const argv[]);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "CStringListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class StringType>
Foam::CStringList::CStringList
(
const UList<StringType>& input
)
:
argc_(0),
len_(0),
argv_(0),
data_(0)
{
reset(input);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class StringType>
void Foam::CStringList::reset
(
const UList<StringType>& input
)
{
clear();
argc_ = input.size();
forAll(input, argI)
{
len_ += input[argI].size();
++len_; // nul terminator for C-strings
}
argv_ = new char*[argc_+1];
argv_[argc_] = NULL; // extra terminator
if (argc_ > 0)
{
// allocation includes final nul terminator,
// but overall count does not
data_ = new char[len_--];
char* ptr = data_;
forAll(input, argI)
{
argv_[argI] = ptr;
const std::string& str =
static_cast<const std::string&>(input[argI]);
for
(
std::string::const_iterator iter = str.begin();
iter != str.end();
++iter
)
{
*(ptr++) = *iter;
}
*(ptr++) = '\0';
}
}
}
template<class StringType>
Foam::List<StringType>
Foam::CStringList::asList(int argc, const char * const argv[])
{
List<StringType> lst(argc);
for (int i=0; i < argc; ++i)
{
lst[i] = argv[i];
}
return lst;
}
// ************************************************************************* //
......@@ -103,7 +103,7 @@ void Foam::ParcelEncoding::setTypes(Istream& is)
}
}
// could set types_
// could also set types_ directly
}
......
......@@ -208,6 +208,15 @@ size_t Foam::adiosCoreWrite::outputSize() const
void Foam::adiosCoreWrite::defineBaseAttributes()
{
#ifdef OPENFOAM_PLUS
defineIntAttribute
(
"baseline/plus",
adiosCore::foamAttribute,
OPENFOAM_PLUS
);
#endif
// OpenFOAM build information (also contains version)
defineAttribute
(
......@@ -748,7 +757,7 @@ bool Foam::adiosCoreWrite::defineListAttribute
cstrings.reset(list);
}
if (cstrings.argc())
if (cstrings.size())
{
adios_define_attribute_byvalue
(
......@@ -756,8 +765,8 @@ bool Foam::adiosCoreWrite::defineListAttribute
attrName,
varName.c_str(),
adios_string_array,
cstrings.argc(),
cstrings.argv()
cstrings.size(),
cstrings.strings()
);
return true;
......@@ -780,7 +789,7 @@ bool Foam::adiosCoreWrite::defineListAttribute
cstrings.reset(list);
}
if (cstrings.argc())
if (cstrings.size())
{
adios_define_attribute_byvalue
(
......@@ -788,8 +797,8 @@ bool Foam::adiosCoreWrite::defineListAttribute
attrName,
varName.c_str(),
adios_string_array,
cstrings.argc(),
cstrings.argv()
cstrings.size(),
cstrings.strings()
);
return true;
......
......@@ -127,7 +127,7 @@ public:
// Member functions
//- Return the current get position in the buffer
std::streampos pos()
std::streampos pos() const
{
return strPtr_->tellg();
}
......
OCompactStream.C
LIB = $(FOAM_USER_LIBBIN)/libadiosStreams
......@@ -398,7 +398,7 @@ public:
// Member functions
//- Return the current output position in the buffer
std::streampos size()
std::streampos size() const
{
return strPtr_->tellp();
}
......
......@@ -152,83 +152,6 @@ public:
};
/*---------------------------------------------------------------------------*\
Class ORawBufStream Declaration
\*---------------------------------------------------------------------------*/
//- An OSstream with an attached external buffer using a more compact output
// (fewer spaces) and raw binary output
class ORawBufStream
:
public OCompactBufStream
{
public:
// Constructors
//- Construct using specified buffer and number of bytes
ORawBufStream
(
char* buffer,
size_t nbytes,
streamFormat format=BINARY,
versionNumber version=currentVersion
)
:
OCompactBufStream(buffer, nbytes, format, version)
{
raw(true);
}
//- Construct using data area from buffer and number of bytes
template<class T>
ORawBufStream
(
UList<T>& buffer,
size_t nbytes,
streamFormat format=BINARY,
versionNumber version=currentVersion
)
:
OCompactBufStream(buffer, nbytes, format, version)
{
raw(true);
}
//- Construct using specified buffer and its inherent storage size
template<class T>
ORawBufStream
(
UList<T>& buffer,
streamFormat format=BINARY,
versionNumber version=currentVersion
)
:
OCompactBufStream(buffer, format, version)
{
raw(true);
}
//- Construct using specified buffer and its storage capacity
template<class T>
ORawBufStream
(
DynamicList<T>& buffer,
streamFormat format=BINARY,
versionNumber version=currentVersion
)
:
OCompactBufStream(buffer, format, version)
{
raw(true);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
......@@ -26,8 +26,7 @@ Class
Description
An output stream for calculating byte counts,
using a more compact output (fewer spaces).
Optionally supports raw binary output for data blocks.
using an output with reduced spacing.
\*---------------------------------------------------------------------------*/
......@@ -54,10 +53,10 @@ class OCompactCountStream
// Private Member Functions
//- Disallow default bitwise copy construct
OCompactCountStream(const OCompactCountStream&);
OCompactCountStream(const OCompactCountStream&) = delete;
//- Disallow default bitwise assignment
void operator=(const OCompactCountStream&);
void operator=(const OCompactCountStream&) = delete;
public:
......@@ -92,9 +91,9 @@ public:
// Access
//- Return the number of bytes counted
std::streamsize size()
std::streamsize size() const
{
return dynamic_cast<ocountstream&>(stdStream()).size();
return dynamic_cast<const ocountstream&>(stdStream()).size();
}
......@@ -109,36 +108,6 @@ public:
};
/*---------------------------------------------------------------------------*\
Class ORawCountStream Declaration
\*---------------------------------------------------------------------------*/
//- An output stream for calculating byte counts,
// using a more compact output (fewer spaces).
// Supports raw binary output for data blocks.
class ORawCountStream
:
public OCompactCountStream
{
public:
// Constructors
//- Construct and set stream status
ORawCountStream
(
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
OCompactCountStream(format, version)
{
raw(true); // raw also forces binary format
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
......@@ -37,65 +37,13 @@ Foam::OCompactStream::OCompactStream
compressionType compression
)
:
OSstream(os, name, format, version, compression),
raw_(false)
OSstream(os, name, format, version, compression)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::OCompactStream::raw() const
{
return raw_ && format() != ASCII;
}
void Foam::OCompactStream::raw(bool b)
{
raw_ = b;
if (raw_)
{
format(IOstream::BINARY);
}
}
Foam::Ostream& Foam::OCompactStream::write(const char c)
{
if (format() == ASCII || c != token::NL)
{