mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Adding updates to Ensight converter (Mark Olesen)
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -35,6 +35,9 @@ Usage
|
||||
\param -ascii \n
|
||||
Write Ensight data in ASCII format instead of "C Binary"
|
||||
|
||||
\parm -name \<subdir\>\n
|
||||
define sub-directory name to use for Ensight data (default: "Ensight")
|
||||
|
||||
\param -noZero \n
|
||||
Exclude the often incomplete initial conditions.
|
||||
|
||||
@ -46,6 +49,9 @@ Usage
|
||||
Suppress writing the geometry. Can be useful for converting partial
|
||||
results for a static geometry.
|
||||
|
||||
\param -width \<n\>\n
|
||||
width of Ensight data subdir
|
||||
|
||||
Note
|
||||
- no parallel data.
|
||||
- writes to \a Ensight directory to avoid collisions with foamToEnsight.
|
||||
@ -96,6 +102,19 @@ int main(int argc, char *argv[])
|
||||
"suppress writing the geometry. "
|
||||
"Can be useful for converting partial results for a static geometry"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"name",
|
||||
"subdir",
|
||||
"define sub-directory name to use for Ensight data "
|
||||
"(default: \"Ensight\")"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"width",
|
||||
"n",
|
||||
"width of Ensight data subdir"
|
||||
);
|
||||
|
||||
// the volume field types that we handle
|
||||
wordHashSet volFieldTypes;
|
||||
@ -133,7 +152,21 @@ int main(int argc, char *argv[])
|
||||
// always write the geometry, unless the -noMesh option is specified
|
||||
bool optNoMesh = args.optionFound("noMesh");
|
||||
|
||||
fileName ensightDir = args.rootPath()/args.globalCaseName()/"Ensight";
|
||||
// adjust output width
|
||||
if (args.optionFound("width"))
|
||||
{
|
||||
ensightFile::subDirWidth(args.optionRead<label>("width"));
|
||||
}
|
||||
|
||||
// define sub-directory name to use for Ensight data
|
||||
fileName ensightDir = "Ensight";
|
||||
args.optionReadIfPresent("name", ensightDir);
|
||||
|
||||
if (!ensightDir.isAbsolute())
|
||||
{
|
||||
ensightDir = args.rootPath()/args.globalCaseName()/ensightDir;
|
||||
}
|
||||
|
||||
fileName dataDir = ensightDir/"data";
|
||||
fileName caseFileName = "Ensight.case";
|
||||
fileName dataMask = fileName("data")/ensightFile::mask();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightFile.H"
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -31,6 +32,53 @@ bool Foam::ensightFile::allowUndef_ = false;
|
||||
|
||||
Foam::scalar Foam::ensightFile::undefValue_ = Foam::floatScalarVGREAT;
|
||||
|
||||
// default is width 8
|
||||
Foam::string Foam::ensightFile::mask_ = "********";
|
||||
|
||||
Foam::string Foam::ensightFile::dirFmt_ = "%08d";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::string Foam::ensightFile::mask()
|
||||
{
|
||||
return mask_;
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::ensightFile::subDir(const label n)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
sprintf(buf, dirFmt_.c_str(), n);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightFile::subDirWidth(const label n)
|
||||
{
|
||||
// enforce max limit to avoid buffer overflow in subDir()
|
||||
if (n < 1 || n > 31)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// appropriate printf format
|
||||
std::ostringstream oss;
|
||||
oss << "%0" << n << "d";
|
||||
dirFmt_ = oss.str();
|
||||
|
||||
// set mask accordingly
|
||||
mask_.resize(n, '*');
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::ensightFile::subDirWidth()
|
||||
{
|
||||
return mask_.size();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ensightFile::ensightFile
|
||||
@ -247,22 +295,4 @@ Foam::Ostream& Foam::ensightFile::writeBinaryHeader()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::string Foam::ensightFile::mask()
|
||||
{
|
||||
char buf[16] = "********";
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::ensightFile::subDir(const label n)
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
sprintf(buf, "%08d", n);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -57,6 +57,12 @@ class ensightFile
|
||||
//- value to represent undef in results
|
||||
static scalar undefValue_;
|
||||
|
||||
//- The '*' mask appropriate for subDir
|
||||
static string mask_;
|
||||
|
||||
//- The printf format for zero-padded subdirectory numbers
|
||||
static string dirFmt_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -88,12 +94,19 @@ public:
|
||||
//- Return setting for whether 'undef' values are allowed in results
|
||||
static bool allowUndef();
|
||||
|
||||
//- '*' mask appropriate for subDir
|
||||
//- The '*' mask appropriate for subDir
|
||||
static string mask();
|
||||
|
||||
//- consistent zero-padded numbers for subdirectories
|
||||
//- Consistent zero-padded numbers for subdirectories
|
||||
static string subDir(const label);
|
||||
|
||||
//- Set width of subDir and mask. Default width is 8 digits.
|
||||
// Max width is 31 digits.
|
||||
static void subDirWidth(const label);
|
||||
|
||||
//- Return current width of subDir and mask.
|
||||
static label subDirWidth();
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user