Add the OpenFOAM source tree

This commit is contained in:
Henry
2014-12-10 22:40:10 +00:00
parent ee487c860d
commit 446e5777f0
13379 changed files with 3983377 additions and 0 deletions

View File

@ -0,0 +1,4 @@
abortCalculation/abortCalculation.C
abortCalculation/abortCalculationFunctionObject.C
LIB = $(FOAM_LIBBIN)/libjobControl

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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/>.
Typedef
Foam::IOabortCalculation
Description
Instance of the generic IOOutputFilter for abortCalculation.
\*---------------------------------------------------------------------------*/
#ifndef IOabortCalculation_H
#define IOabortCalculation_H
#include "abortCalculation.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<abortCalculation> IOabortCalculation;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,194 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ 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 "abortCalculation.H"
#include "dictionary.H"
#include "error.H"
#include "Time.H"
#include "OSspecific.H"
#include "PstreamReduceOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(abortCalculation, 0);
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::abortCalculation::actionType,
3
>::names[] =
{
"noWriteNow",
"writeNow",
"nextWrite"
};
}
const Foam::NamedEnum<Foam::abortCalculation::actionType, 3>
Foam::abortCalculation::actionTypeNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::abortCalculation::removeFile() const
{
bool hasAbort = isFile(abortFile_);
reduce(hasAbort, orOp<bool>());
if (hasAbort && Pstream::master())
{
// cleanup ABORT file (on master only)
rm(abortFile_);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::abortCalculation::abortCalculation
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
name_(name),
obr_(obr),
abortFile_("$FOAM_CASE/" + name),
action_(nextWrite)
{
abortFile_.expand();
read(dict);
// remove any old files from previous runs
removeFile();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::abortCalculation::~abortCalculation()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::abortCalculation::read(const dictionary& dict)
{
if (dict.found("action"))
{
action_ = actionTypeNames_.read(dict.lookup("action"));
}
else
{
action_ = nextWrite;
}
if (dict.readIfPresent("fileName", abortFile_))
{
abortFile_.expand();
}
}
void Foam::abortCalculation::execute()
{
bool hasAbort = isFile(abortFile_);
reduce(hasAbort, orOp<bool>());
if (hasAbort)
{
switch (action_)
{
case noWriteNow :
{
if (obr_.time().stopAt(Time::saNoWriteNow))
{
Info<< "USER REQUESTED ABORT (timeIndex="
<< obr_.time().timeIndex()
<< "): stop without writing data"
<< endl;
}
break;
}
case writeNow :
{
if (obr_.time().stopAt(Time::saWriteNow))
{
Info<< "USER REQUESTED ABORT (timeIndex="
<< obr_.time().timeIndex()
<< "): stop+write data"
<< endl;
}
break;
}
case nextWrite :
{
if (obr_.time().stopAt(Time::saNextWrite))
{
Info<< "USER REQUESTED ABORT (timeIndex="
<< obr_.time().timeIndex()
<< "): stop after next data write"
<< endl;
}
break;
}
}
}
}
void Foam::abortCalculation::end()
{
removeFile();
}
void Foam::abortCalculation::timeSet()
{
// Do nothing - only valid on execute
}
void Foam::abortCalculation::write()
{
// Do nothing - only valid on execute
}
// ************************************************************************* //

View File

@ -0,0 +1,173 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ 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::abortCalculation
Group
grpJobControlFunctionObjects
Description
Watches for presence of the named file in the $FOAM_CASE directory
and aborts the calculation if it is present.
Currently the following action types are supported:
- noWriteNow
- writeNow
- nextWrite
SourceFiles
abortCalculation.C
IOabortCalculation.H
\*---------------------------------------------------------------------------*/
#ifndef abortCalculation_H
#define abortCalculation_H
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class polyMesh;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class abortCalculation Declaration
\*---------------------------------------------------------------------------*/
class abortCalculation
{
public:
// Public data
//- Enumeration defining the type of action
enum actionType
{
noWriteNow, /*!< stop immediately without writing data */
writeNow, /*!< write data and stop immediately */
nextWrite /*!< stop the next time data are written */
};
private:
// Private data
//- Name of the abort file unless otherwise specified
word name_;
const objectRegistry& obr_;
//- The fully-qualified name of the abort file
fileName abortFile_;
//- Action type names
static const NamedEnum<actionType, 3> actionTypeNames_;
//- The type of action
actionType action_;
// Private Member Functions
//- Remove abort file.
void removeFile() const;
//- Disallow default bitwise copy construct
abortCalculation(const abortCalculation&);
//- Disallow default bitwise assignment
void operator=(const abortCalculation&);
public:
//- Runtime type information
TypeName("abort");
// Constructors
//- Construct for given objectRegistry and dictionary.
abortCalculation
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFilesUnused = false
);
//- Destructor
virtual ~abortCalculation();
// Member Functions
//- Return name of the abort file
virtual const word& name() const
{
return name_;
}
//- Read the dictionary settings
virtual void read(const dictionary&);
//- Execute, check existence of abort file and take action
virtual void execute();
//- Execute at the final time-loop, used for cleanup
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
//- Execute, check existence of abort file and take action
virtual void write();
//- Update for changes of mesh - does nothing
virtual void updateMesh(const mapPolyMesh&)
{}
//- Update for changes of mesh - does nothing
virtual void movePoints(const polyMesh&)
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,42 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 "abortCalculationFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(abortCalculationFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
abortCalculationFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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/>.
Typedef
Foam::abortCalculationFunctionObject
Description
FunctionObject wrapper around abortCalculation to allow it to be created via
the functions entry within controlDict.
SourceFiles
abortCalculationFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef abortCalculationFunctionObject_H
#define abortCalculationFunctionObject_H
#include "abortCalculation.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<abortCalculation>
abortCalculationFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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/>.
\defgroup grpJobControlFunctionObjects Job control function objects
@{
\ingroup grpFunctionObjects
This group contains job control-based function objects
@}
\*---------------------------------------------------------------------------*/