Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
sergio
2011-06-22 15:07:59 +01:00
8 changed files with 258 additions and 129 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,15 +33,72 @@ Description
#include "cellSet.H" #include "cellSet.H"
#include "faceSet.H" #include "faceSet.H"
#include "pointSet.H" #include "pointSet.H"
#include "globalMeshData.H"
#include "timeSelector.H"
using namespace Foam; using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void printMesh(const Time& runTime, const polyMesh& mesh)
{
Info<< "Time:" << runTime.timeName()
<< " cells:" << mesh.globalData().nTotalCells()
<< " faces:" << mesh.globalData().nTotalFaces()
<< " points:" << mesh.globalData().nTotalPoints()
<< " patches:" << mesh.boundaryMesh().size()
<< " bb:" << mesh.bounds() << nl;
}
polyMesh::readUpdateState meshReadUpdate(polyMesh& mesh)
{
polyMesh::readUpdateState stat = mesh.readUpdate();
switch(stat)
{
case polyMesh::UNCHANGED:
{
Info<< " mesh not changed." << endl;
break;
}
case polyMesh::POINTS_MOVED:
{
Info<< " points moved; topology unchanged." << endl;
break;
}
case polyMesh::TOPO_CHANGE:
{
Info<< " topology changed; patches unchanged." << nl
<< " ";
printMesh(mesh.time(), mesh);
break;
}
case polyMesh::TOPO_PATCH_CHANGE:
{
Info<< " topology changed and patches changed." << nl
<< " ";
printMesh(mesh.time(), mesh);
break;
}
default:
{
FatalErrorIn("meshReadUpdate(polyMesh&)")
<< "Illegal mesh update state "
<< stat << abort(FatalError);
break;
}
}
return stat;
}
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions(true, false);
argList::addOption argList::addOption
( (
"dict", "dict",
@ -57,6 +114,9 @@ int main(int argc, char *argv[])
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
instantList timeDirs = timeSelector::selectIfPresent(runTime, args);
# include "createNamedPolyMesh.H" # include "createNamedPolyMesh.H"
const bool noSync = args.optionFound("noSync"); const bool noSync = args.optionFound("noSync");
@ -99,128 +159,142 @@ int main(int argc, char *argv[])
// Read set construct info from dictionary // Read set construct info from dictionary
PtrList<dictionary> patchSources(topoSetDict.lookup("actions")); PtrList<dictionary> actions(topoSetDict.lookup("actions"));
forAll(patchSources, i) forAll(timeDirs, timeI)
{ {
const dictionary& dict = patchSources[i]; runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
const word setName(dict.lookup("name")); // Optionally re-read mesh
const word actionName(dict.lookup("action")); meshReadUpdate(mesh);
const word setType(dict.lookup("type"));
// Execute all actions
topoSetSource::setAction action = topoSetSource::toAction(actionName); forAll(actions, i)
autoPtr<topoSet> currentSet;
if
(
(action == topoSetSource::NEW)
|| (action == topoSetSource::CLEAR)
)
{ {
currentSet = topoSet::New(setType, mesh, setName, 10000); const dictionary& dict = actions[i];
Info<< "Created set " << setName << endl;
} const word setName(dict.lookup("name"));
else if (action == topoSetSource::REMOVE) const word actionName(dict.lookup("action"));
{ const word setType(dict.lookup("type"));
//?
}
else topoSetSource::setAction action = topoSetSource::toAction
{
currentSet = topoSet::New
( (
setType, actionName
mesh,
setName,
IOobject::MUST_READ
); );
Info<< "Read set " << setName << " with size "
<< currentSet().size() << endl;
}
autoPtr<topoSet> currentSet;
if
// Handle special actions (clear, invert) locally, rest through sources. (
switch (action) (action == topoSetSource::NEW)
{ || (action == topoSetSource::CLEAR)
case topoSetSource::NEW: )
case topoSetSource::ADD:
case topoSetSource::DELETE:
{ {
Info<< " Applying source " << word(dict.lookup("source")) currentSet = topoSet::New(setType, mesh, setName, 10000);
<< endl; Info<< "Created set " << setName << endl;
autoPtr<topoSetSource> source = topoSetSource::New
(
dict.lookup("source"),
mesh,
dict.subDict("sourceInfo")
);
source().applyToSet(action, currentSet());
// Synchronize for coupled patches.
if (!noSync) currentSet().sync(mesh);
currentSet().write();
} }
break; else if (action == topoSetSource::REMOVE)
case topoSetSource::SUBSET:
{ {
Info<< " Applying source " << word(dict.lookup("source")) //?
<< endl; }
autoPtr<topoSetSource> source = topoSetSource::New else
{
currentSet = topoSet::New
( (
dict.lookup("source"), setType,
mesh, mesh,
dict.subDict("sourceInfo") setName,
IOobject::MUST_READ
); );
Info<< "Read set " << setName << " with size "
<< currentSet().size() << endl;
}
// Backup current set.
autoPtr<topoSet> oldSet
( // Handle special actions (clear, invert) locally, rest through
topoSet::New // sources.
switch (action)
{
case topoSetSource::NEW:
case topoSetSource::ADD:
case topoSetSource::DELETE:
{
Info<< " Applying source " << word(dict.lookup("source"))
<< endl;
autoPtr<topoSetSource> source = topoSetSource::New
( (
setType, dict.lookup("source"),
mesh, mesh,
currentSet().name() + "_old2", dict.subDict("sourceInfo")
currentSet() );
)
);
currentSet().clear(); source().applyToSet(action, currentSet());
source().applyToSet(topoSetSource::NEW, currentSet()); // Synchronize for coupled patches.
if (!noSync) currentSet().sync(mesh);
currentSet().write();
}
break;
// Combine new value of currentSet with old one. case topoSetSource::SUBSET:
currentSet().subset(oldSet()); {
// Synchronize for coupled patches. Info<< " Applying source " << word(dict.lookup("source"))
if (!noSync) currentSet().sync(mesh); << endl;
currentSet().write(); autoPtr<topoSetSource> source = topoSetSource::New
(
dict.lookup("source"),
mesh,
dict.subDict("sourceInfo")
);
// Backup current set.
autoPtr<topoSet> oldSet
(
topoSet::New
(
setType,
mesh,
currentSet().name() + "_old2",
currentSet()
)
);
currentSet().clear();
source().applyToSet(topoSetSource::NEW, currentSet());
// Combine new value of currentSet with old one.
currentSet().subset(oldSet());
// Synchronize for coupled patches.
if (!noSync) currentSet().sync(mesh);
currentSet().write();
}
break;
case topoSetSource::CLEAR:
Info<< " Clearing set" << endl;
currentSet().clear();
currentSet().write();
break;
case topoSetSource::INVERT:
Info<< " Inverting set" << endl;
currentSet().invert(currentSet().maxSize(mesh));
currentSet().write();
break;
default:
WarningIn(args.executable())
<< "Unhandled action " << action << endl;
break;
} }
break;
case topoSetSource::CLEAR: if (currentSet.valid())
Info<< " Clearing set" << endl; {
currentSet().clear(); Info<< " Set " << currentSet().name()
currentSet().write(); << " now size " << currentSet().size()
break; << endl;
}
case topoSetSource::INVERT:
Info<< " Inverting set" << endl;
currentSet().invert(currentSet().maxSize(mesh));
currentSet().write();
break;
default:
WarningIn(args.executable())
<< "Unhandled action " << action << endl;
break;
}
if (currentSet.valid())
{
Info<< " Set " << currentSet().name()
<< " now size " << currentSet().size()
<< endl;
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,7 +51,7 @@ bool Foam::timeSelector::selected(const instant& value) const
} }
Foam::List<bool> Foam::timeSelector::selected(const List<instant>& Times) const Foam::List<bool> Foam::timeSelector::selected(const instantList& Times) const
{ {
List<bool> lst(Times.size(), false); List<bool> lst(Times.size(), false);
@ -97,19 +97,14 @@ Foam::List<bool> Foam::timeSelector::selected(const List<instant>& Times) const
} }
Foam::List<Foam::instant> Foam::timeSelector::select Foam::List<Foam::instant> Foam::timeSelector::select(const instantList& Times)
( const
const List<instant>& Times
) const
{ {
return subset(selected(Times), Times); return subset(selected(Times), Times);
} }
void Foam::timeSelector::inplaceSelect void Foam::timeSelector::inplaceSelect(instantList& Times) const
(
List<instant>& Times
) const
{ {
inplaceSubset(selected(Times), Times); inplaceSubset(selected(Times), Times);
} }
@ -159,7 +154,7 @@ void Foam::timeSelector::addOptions
Foam::List<Foam::instant> Foam::timeSelector::select Foam::List<Foam::instant> Foam::timeSelector::select
( (
const List<instant>& timeDirs, const instantList& timeDirs,
const argList& args const argList& args
) )
{ {
@ -270,4 +265,29 @@ Foam::List<Foam::instant> Foam::timeSelector::select0
} }
Foam::List<Foam::instant> Foam::timeSelector::selectIfPresent
(
Time& runTime,
const argList& args
)
{
if
(
args.optionFound("latestTime")
|| args.optionFound("time")
|| args.optionFound("constant")
|| args.optionFound("noZero")
|| args.optionFound("zeroTime")
)
{
return select0(runTime, args);
}
else
{
// No timeSelector option specified. Do not change runTime.
return instantList(1, instant(runTime.value(), runTime.timeName()));
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -72,7 +72,7 @@ SourceFiles
#define timeSelector_H #define timeSelector_H
#include "scalarRanges.H" #include "scalarRanges.H"
#include "instant.H" #include "instantList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -109,13 +109,13 @@ public:
//- Return the set of selected instants in the given list that are //- Return the set of selected instants in the given list that are
// within the ranges // within the ranges
List<bool> selected(const List<instant>&) const; List<bool> selected(const instantList&) const;
//- Select a list of Time values that are within the ranges //- Select a list of Time values that are within the ranges
List<instant> select(const List<instant>&) const; instantList select(const instantList&) const;
//- Select a list of Time values that are within the ranges //- Select a list of Time values that are within the ranges
void inplaceSelect(List<instant>&) const; void inplaceSelect(instantList&) const;
//- Add the options handled by timeSelector to argList::validOptions //- Add the options handled by timeSelector to argList::validOptions
// //
@ -135,15 +135,24 @@ public:
); );
//- Return the set of times selected based on the argList options //- Return the set of times selected based on the argList options
static List<instant> select static instantList select
( (
const List<instant>&, const instantList&,
const argList& args const argList& args
); );
//- Return the set of times selected based on the argList options //- Return the set of times selected based on the argList options
// also set the runTime to the first instance // also set the runTime to the first instance
static List<instant> select0 static instantList select0
(
Time& runTime,
const argList& args
);
//- If any time option provided return the set of times (as select0)
// otherwise return just the current time.
// Also set the runTime to the first instance
static instantList selectIfPresent
( (
Time& runTime, Time& runTime,
const argList& args const argList& args

View File

@ -85,6 +85,14 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
stringOps::inplaceExpand(libs_, dict); stringOps::inplaceExpand(libs_, dict);
} }
// optional
const entry* localPtr = dict.lookupEntryPtr("localCode", false, false);
if (localPtr)
{
localCode_ = stringOps::trim(localPtr->stream());
stringOps::inplaceExpand(localCode_, dict);
}
// calculate SHA1 digest from include, options, localCode, code // calculate SHA1 digest from include, options, localCode, code
OSHA1stream os; OSHA1stream os;
os << include_ << options_ << libs_ << localCode_ << code_; os << include_ << options_ << libs_ << localCode_ << code_;
@ -103,14 +111,18 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
{ {
addLineDirective(include_, includePtr->startLineNumber(), dict.name()); addLineDirective(include_, includePtr->startLineNumber(), dict.name());
} }
if (optionsPtr)
{ // Do not add line directive to options_ (Make/options) since at it is a
addLineDirective(options_, optionsPtr->startLineNumber(), dict.name()); // single line at this point. Can be fixed.
}
if (libsPtr) if (libsPtr)
{ {
addLineDirective(libs_, libsPtr->startLineNumber(), dict.name()); addLineDirective(libs_, libsPtr->startLineNumber(), dict.name());
} }
if (localPtr)
{
addLineDirective(localCode_, localPtr->startLineNumber(), dict.name());
}
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,6 +46,12 @@ namespace Foam
gasThermoPhysics gasThermoPhysics
); );
makeChemistryModel makeChemistryModel
(
ODEChemistryModel,
psiChemistryModel,
constGasThermoPhysics
);
makeChemistryModel
( (
ODEChemistryModel, ODEChemistryModel,
psiChemistryModel, psiChemistryModel,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,6 +46,12 @@ namespace Foam
gasThermoPhysics gasThermoPhysics
); );
makeChemistryModel makeChemistryModel
(
ODEChemistryModel,
rhoChemistryModel,
constGasThermoPhysics
);
makeChemistryModel
( (
ODEChemistryModel, ODEChemistryModel,
rhoChemistryModel, rhoChemistryModel,

View File

@ -34,8 +34,10 @@ License
namespace Foam namespace Foam
{ {
makeChemistrySolverTypes(psiChemistryModel, gasThermoPhysics); makeChemistrySolverTypes(psiChemistryModel, gasThermoPhysics);
makeChemistrySolverTypes(psiChemistryModel, constGasThermoPhysics);
makeChemistrySolverTypes(psiChemistryModel, icoPoly8ThermoPhysics); makeChemistrySolverTypes(psiChemistryModel, icoPoly8ThermoPhysics);
makeChemistrySolverTypes(rhoChemistryModel, gasThermoPhysics); makeChemistrySolverTypes(rhoChemistryModel, gasThermoPhysics);
makeChemistrySolverTypes(rhoChemistryModel, constGasThermoPhysics);
makeChemistrySolverTypes(rhoChemistryModel, icoPoly8ThermoPhysics); makeChemistrySolverTypes(rhoChemistryModel, icoPoly8ThermoPhysics);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -889,12 +889,12 @@ Foam::chemkinReader::chemkinReader(const dictionary& thermoDict)
fileName relPath = thermoDict.name().path(); fileName relPath = thermoDict.name().path();
if (relPath.size()) if (relPath.size())
{ {
if (chemkinFile.size() && chemkinFile[0] != '/') if (!chemkinFile.isAbsolute())
{ {
chemkinFile = relPath/chemkinFile; chemkinFile = relPath/chemkinFile;
} }
if (thermoFile.size() && thermoFile[0] != '/') if (!thermoFile.isAbsolute())
{ {
thermoFile = relPath/thermoFile; thermoFile = relPath/thermoFile;
} }