Commit 70f453b4 authored by henry's avatar henry
Browse files
parents 7787fd6c dedabab1
......@@ -4,9 +4,13 @@
# editor and misc backup files - anywhere
*~
.*~
*.orig
*.bak
*.bak[0-9][0-9]
*.orig
*.orig[0-9][0-9]
\#*\#
# file-browser settings - anywhere
.directory
# CVS recovered versions - anywhere
......@@ -18,7 +22,7 @@
*.so
*.jar
# ignore derived files
# derived files
lex.yy.c
# Corefiles
......@@ -30,7 +34,7 @@ core
# lnInclude (symlink) folders - anywhere
lnInclude
# build folder(s) - anywhere
# build folders - anywhere
linux*Gcc*/
linux*Icc*/
linuxming*/
......@@ -38,9 +42,6 @@ SiCortex*Gcc*/
solaris*Gcc*/
SunOS*Gcc*/
# all of the wmake wmkdep and dirToString binaries
wmake/bin
# doxygen generated documentation
doc/[Dd]oxygen/html
doc/[Dd]oxygen/latex
......
......@@ -58,6 +58,8 @@
their keywords. When searching, an exact match has priority over a regular
expression match. Multiple regular expressions are matched in reverse
order.
+ The *new* =#includeIfPresent= directive is similar to the =#include=
directive, but does not generate an error if the file does not exist.
+ The default =#inputMode= is now '=merge=', which corresponds to the most
general usage. The =#inputMode warn= corresponds to the previous default
behaviour.
......
......@@ -78,6 +78,7 @@ boundaryField
// NB: the inputMode has a global scope
#inputMode merge
#include "testDict2"
#includeIfPresent "SomeUnknownFile"
foo
{
......
mvBakTest.C
EXE = $(FOAM_USER_APPBIN)/mvBakTest
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "argList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::validArgs.insert("file .. fileN");
argList::validOptions.erase("case");
argList::validOptions.insert("ext", "bak");
argList args(argc, argv, false, true);
if (args.additionalArgs().empty())
{
args.printUsage();
}
label ok = 0;
forAll(args.additionalArgs(), argI)
{
const string& srcFile = args.additionalArgs()[argI];
if (args.optionFound("ext"))
{
if (mvBak(srcFile, args.option("ext")))
{
ok++;
}
}
else
{
if (mvBak(srcFile))
{
ok++;
}
}
}
Info<< "mvBak called for " << args.additionalArgs().size()
<< " files (moved " << ok << ")\n" << endl;
return 0;
}
// ************************************************************************* //
......@@ -26,7 +26,14 @@ Application
redistributeMeshPar
Description
Parallel redecomposition of mesh.
Parallel redecomposition of mesh. Start with maximum number of processors.
Balances mesh and writes new mesh to new timedirectory.
Can also work like decomposePar:
mkdir processor0
cp -r constant processor0
mpirun -np ddd redistributeMeshPar -parallel
\*---------------------------------------------------------------------------*/
......
......@@ -47,7 +47,7 @@ void UnMapped(const IOobjectList& objects)
++fieldIter
)
{
mv(fieldIter()->objectPath(), fieldIter()->objectPath() + ".unmapped");
mvBak(fieldIter()->objectPath(), "unmapped");
}
}
......
......@@ -474,20 +474,20 @@ Foam::fileName::Type Foam::type(const fileName& name)
// Does the name exist in the filing system?
bool Foam::exists(const fileName& name)
bool Foam::exists(const fileName& name, const bool checkGzip)
{
return mode(name) || isFile(name);
return mode(name) || isFile(name, checkGzip);
}
// Does the directory exist
// Does the directory exist?
bool Foam::isDir(const fileName& name)
{
return S_ISDIR(mode(name));
}
// Does the file exist
// Does the file exist?
bool Foam::isFile(const fileName& name, const bool checkGzip)
{
return S_ISREG(mode(name)) || (checkGzip && S_ISREG(mode(name + ".gz")));
......@@ -757,31 +757,70 @@ bool Foam::ln(const fileName& src, const fileName& dst)
// Rename srcFile dstFile
bool Foam::mv(const fileName& srcFile, const fileName& dstFile)
bool Foam::mv(const fileName& src, const fileName& dst)
{
if (POSIX::debug)
{
Info<< "Move : " << srcFile << " to " << dstFile << endl;
Info<< "Move : " << src << " to " << dst << endl;
}
if
(
dstFile.type() == fileName::DIRECTORY
&& srcFile.type() != fileName::DIRECTORY
dst.type() == fileName::DIRECTORY
&& src.type() != fileName::DIRECTORY
)
{
const fileName dstName(dstFile/srcFile.name());
const fileName dstName(dst/src.name());
return rename(srcFile.c_str(), dstName.c_str()) == 0;
return rename(src.c_str(), dstName.c_str()) == 0;
}
else
{
return rename(srcFile.c_str(), dstFile.c_str()) == 0;
return rename(src.c_str(), dst.c_str()) == 0;
}
}
// Remove a file returning true if successful otherwise false
//- Rename to a corresponding backup file
// If the backup file already exists, attempt with "01" .. "99" index
bool Foam::mvBak(const fileName& src, const std::string& ext)
{
if (POSIX::debug)
{
Info<< "mvBak : " << src << " to extension " << ext << endl;
}
if (exists(src, false))
{
const int maxIndex = 99;
char index[3];
for (int n = 0; n <= maxIndex; n++)
{
fileName dstName(src + "." + ext);
if (n)
{
sprintf(index, "%02d", n);
dstName += index;
}
// avoid overwriting existing files, except for the last
// possible index where we have no choice
if (!exists(dstName, false) || n == maxIndex)
{
return rename(src.c_str(), dstName.c_str()) == 0;
}
}
}
// fall-through: nothing to do
return false;
}
// Remove a file, returning true if successful otherwise false
bool Foam::rm(const fileName& file)
{
if (POSIX::debug)
......
......@@ -132,6 +132,7 @@ $(dictionaryEntry)/dictionaryEntryIO.C
functionEntries = $(dictionary)/functionEntries
$(functionEntries)/functionEntry/functionEntry.C
$(functionEntries)/includeEntry/includeEntry.C
$(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C
$(functionEntries)/inputModeEntry/inputModeEntry.C
$(functionEntries)/removeEntry/removeEntry.C
......
......@@ -62,7 +62,7 @@ namespace functionEntries
}
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
Foam::fileName Foam::functionEntries::includeEntry::includeFileName
(
......@@ -112,6 +112,7 @@ bool Foam::functionEntries::includeEntry::execute
}
}
bool Foam::functionEntries::includeEntry::execute
(
const dictionary& parentDict,
......
......@@ -67,15 +67,19 @@ class includeEntry
{
// Private Member Functions
//- Read the include fileName from Istream, expand and return
static fileName includeFileName(Istream&);
//- Disallow default bitwise copy construct
includeEntry(const includeEntry&);
//- Disallow default bitwise assignment
void operator=(const includeEntry&);
protected:
// Protected Member Functions
//- Read the include fileName from Istream, expand and return
static fileName includeFileName(Istream&);
public:
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "includeIfPresentEntry.H"
#include "dictionary.H"
#include "IFstream.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::word Foam::functionEntries::includeIfPresentEntry::typeName
(
Foam::functionEntries::includeIfPresentEntry::typeName_()
);
// Don't lookup the debug switch here as the debug switch dictionary
// might include includeIfPresentEntry
int Foam::functionEntries::includeIfPresentEntry::debug(0);
namespace Foam
{
namespace functionEntries
{
addToMemberFunctionSelectionTable
(
functionEntry,
includeIfPresentEntry,
execute,
dictionaryIstream
);
addToMemberFunctionSelectionTable
(
functionEntry,
includeIfPresentEntry,
execute,
primitiveEntryIstream
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::includeIfPresentEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
IFstream ifs(includeFileName(is));
if (ifs)
{
parentDict.read(ifs);
}
return true;
}
bool Foam::functionEntries::includeIfPresentEntry::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
IFstream ifs(includeFileName(is));
if (ifs)
{
entry.read(parentDict, ifs);
}
return true;
}
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2006-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -23,132 +23,75 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::compressible::
backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
Foam::functionEntries::includeIfPresentEntry
Description
Compatibility for the new namespace qualifier
Foam::compressible::turbulentMixingLengthDissipationRateInletFvPatchScalarField
Specify a file to include if it exists. Expects a single string to follow.
The @c \#includeIfPresent directive is similar to the @c \#include
directive, but does not generate an error if the file does not exist.
See Also
Foam::functionEntries::includeEntry
SourceFiles
backwardsCompatibilityTurbulentMixingLengthDissipationRateInlet.C
includeIfPresentEntry.C
\*---------------------------------------------------------------------------*/
#ifndef backwardsCompatibilityTurbulentMixingLengthDissipationRateInlet_H
#define backwardsCompatibilityTurbulentMixingLengthDissipationRateInlet_H
#ifndef includeIfPresentEntry_H
#define includeIfPresentEntry_H
#include "fixedValueFvPatchFields.H"
#include "includeEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace compressible
namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField Declaration
Class includeIfPresentEntry Declaration
\*---------------------------------------------------------------------------*/
class backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
class includeIfPresentEntry
:
public fixedValueFvPatchScalarField
public includeEntry
{
// Private data
// Private Member Functions
//- turbulent length scale
scalar mixingLength_;
//- Disallow default bitwise copy construct
includeIfPresentEntry(const includeIfPresentEntry&);
//- Disallow default bitwise assignment
void operator=(const includeIfPresentEntry&);
public:
//- Runtime type information
TypeName("turbulentMixingLengthDissipationRateInlet");
ClassName("includeIfPresent");
// Constructors
//- Construct from patch and internal field
backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
// Member Functions
//- Construct from patch, internal field and dictionary
backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Execute the functionEntry in a sub-dict context
static bool execute(dictionary& parentDict, Istream&);
//- Construct by mapping given
// backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
// onto a new patch
backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
//- Execute the functionEntry in a primitiveEntry context
static bool execute
(
const backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
const dictionary& parentDict,
primitiveEntry&,
Istream&
);
//- Construct as copy
backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
(
const backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
(
*this
)
);
}
//- Construct as copy setting internal field reference
backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
(
const backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new backwardsCompatibilityTurbulentMixingLengthDissipationRateInletFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //