Commit 78dffd13 authored by graham's avatar graham
Browse files

Merge branch 'master' into sixDofPatch

parents 86de68de fa511d33
......@@ -15,8 +15,7 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lengine \
......
......@@ -26,8 +26,13 @@ Application
coalChemistryFoam
Description
Transient solver for compressible, turbulent flow with coal and
limestone parcel injections, and combustion.
Transient solver for:
- compressible,
- turbulent flow,
with
- coal and limestone parcel injections,
- energy source, and
- combustion.
\*---------------------------------------------------------------------------*/
......@@ -38,7 +43,7 @@ Description
#include "CoalCloud.H"
#include "psiChemistryModel.H"
#include "chemistrySolver.H"
#include "timeActivatedExplicitCellSource.H"
#include "timeActivatedExplicitSource.H"
#include "radiationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -127,10 +127,11 @@
fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p)
);
Info<< "\nConstructing explicit enthalpy cell source" << endl;
timeActivatedExplicitCellSource enthalpySource
Info<< "\nConstructing explicit enthalpy source" << endl;
scalarTimeActivatedExplicitSourceList enthalpySource
(
"enthalpySource",
"energy",
mesh,
h.dimensions()*phi.dimensions()/mesh.V().dimensions()
dimEnergy/dimTime/dimVolume,
"h"
);
......@@ -7,6 +7,7 @@
==
rho.dimensionedInternalField()*g
+ parcels.SU()
+ momentumSource.Su()
);
pZones.addResistance(UEqn);
......
......@@ -28,7 +28,7 @@ tmp<fv::convectionScheme<scalar> > mvConvection
==
parcels.Srho(i)
+ kappa*chemistry.RR(i)().dimensionedInternalField()
+ pointMassSources.Su(i),
+ massSource.Su(i),
mesh.solver("Yi")
);
......
Info<< "\nConstructing reacting cloud" << endl;
icoPoly8ThermoReactingCloud parcels
icoPoly8ThermoReactingMultiphaseCloud parcels
(
"reactingCloud1",
rho,
......
Info<< "Creating mass source\n" << endl;
scalarTimeActivatedExplicitSourceList massSource
(
"mass",
mesh,
dimMass/dimTime/dimVolume,
composition.species()
);
Info<< "Creating momentum source\n" << endl;
vectorTimeActivatedExplicitSourceList momentumSource
(
"momentum",
mesh,
dimMass*dimVelocity/dimTime/dimVolume,
"U"
);
Info<< "Creating energy source\n" << endl;
scalarTimeActivatedExplicitSourceList energySource
(
"energy",
mesh,
dimEnergy/dimTime/dimVolume,
"h"
);
Info<< "\nConstructing multi-component mass flow rate point sources" << endl;
timeActivatedExplicitMulticomponentPointSource pointMassSources
(
"pointMassSources",
mesh,
Y,
dimMass/dimVolume/dimTime
);
......@@ -39,6 +39,7 @@
pWork()
+ parcels.Sh()
+ radiation->Sh(thermo)
+ energySource.Su()
);
thermo.correct();
......
......@@ -32,7 +32,7 @@
- fvm::laplacian(rho*rAU, p)
==
parcels.Srho()
+ pointMassSources.Su()
+ massSource.SuTot()
);
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
......
......@@ -27,10 +27,11 @@ Application
Description
Transient PISO solver for compressible, laminar or turbulent flow with
reacting Lagrangian parcels for porous media, including explicit sources
reacting multiphase Lagrangian parcels for porous media, including explicit
sources for mass, momentum and energy
The solver includes:
- reacting parcel cloud
- reacting multiphase parcel cloud
- porous media
- point mass sources
- polynomial based, incompressible thermodynamics (f(T))
......@@ -43,12 +44,12 @@ Description
#include "fvCFD.H"
#include "hReactionThermo.H"
#include "turbulenceModel.H"
#include "BasicReactingCloud.H"
#include "BasicReactingMultiphaseCloud.H"
#include "rhoChemistryModel.H"
#include "chemistrySolver.H"
#include "radiationModel.H"
#include "porousZones.H"
#include "timeActivatedExplicitMulticomponentPointSource.H"
#include "timeActivatedExplicitSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -63,7 +64,7 @@ int main(int argc, char *argv[])
#include "createFields.H"
#include "createRadiationModel.H"
#include "createClouds.H"
#include "createMulticomponentPointSources.H"
#include "createExplicitSources.H"
#include "createPorousZones.H"
#include "initContinuityErrs.H"
#include "readTimeControls.H"
......
......@@ -37,7 +37,7 @@ Description
+ fvc::div(phi)
==
parcels.Srho()
+ pointMassSources.Su()
+ massSource.SuTot()
);
rhoEqn.relax();
......
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# this will have to do until we have a makefile rule
if type Coco > /dev/null 2>&1
then
Coco \
-frames $WM_THIRD_PARTY_DIR/coco-r \
calcEntry/calcEntry.atg
else
echo "Coco not installed"
fi
wmake
dictionaryTest.C
calcEntry/calcEntry.C
calcEntry/calcEntryParser.cpp
calcEntry/calcEntryScanner.cpp
EXE = $(FOAM_USER_APPBIN)/dictionaryTest
/*-------------------------------------------------------------------------
compile with:
Coco \
-frames $WM_THIRD_PARTY_DIR/coco-r \
calcEntry.atg
-------------------------------------------------------------------------*/
#include "dictionary.H"
#include "scalar.H"
#include "error.H"
#include "wchar.H"
COMPILER calcEntry
$prefix=calcEntry
$namespace=Foam::functionEntries::calcEntryInternal
$eof=true // grammar handles eof itself
// Simple four function calculator for OpenFOAM dictionaries
//! with debug
static const int debug = 0;
//! The parent dictionary
mutable dictionary* dict_;
//! Track that parent dictionary was set
bool hasDict_;
//! The calculation result
scalar val;
//! token -> scalar
scalar getScalar() const
{
return coco_string_toDouble(t->val);
}
//! token -> string
std::string getString() const
{
char* str = coco_string_create_char(t->val);
std::string s(str);
coco_string_delete(str);
return s;
}
//! attach a dictionary
void dict(const dictionary& dict)
{
dict_ = const_cast<dictionary*>(&dict);
hasDict_ = true;
}
//! lookup dictionary entry
scalar getDictLookup() const
{
scalar dictValue = 0;
if (!hasDict_)
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "No dictionary attached!"
<< exit(FatalError);
return 0;
}
char* chars = coco_string_create_char
(
t->val,
1,
(coco_string_length(t->val) - 1)
);
word keyword(chars);
coco_string_delete(chars);
if (debug)
{
Info<<"lookup: " << keyword << nl;
}
entry* entryPtr = dict_->lookupEntryPtr(keyword, true, false);
if (entryPtr && !entryPtr->isDict())
{
if (entryPtr->stream().size() != 1)
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "keyword " << keyword << " has "
<< entryPtr->stream().size() << " values in dictionary "
<< exit(FatalError);
}
entryPtr->stream() >> dictValue;
}
else
{
FatalErrorIn
(
"calcEntry::getDictEntry() const"
) << "keyword " << keyword << " is undefined in dictionary "
<< exit(FatalError);
}
return dictValue;
}
scalar Result() const
{
return val;
}
/*---------------------------------------------------------------------------*/
CHARACTERS
letter = 'A'..'Z' + 'a'..'z'.
qualifier = '_' + ':'.
dollar = '$'.
digit = "0123456789".
sign = '+' + '-'.
cr = '\r'.
lf = '\n'.
tab = '\t'.
stringCh = ANY - '"' - '\\' - cr - lf.
printable = '\u0020' .. '\u007e'.
// * * * * * * * * * * * * * * * * TOKENS * * * * * * * * * * * * * * * * * //
TOKENS
// identifier
ident =
letter { letter | digit | qualifier }.
// string
string =
'"' { stringCh | '\\' printable } '"'.
// dictionary lookup identifier
// starts with '$' and otherwise limited to a normal indentifier
variable =
dollar letter { letter | digit | qualifier }.
// floating point and integer numbers
number =
[sign] ('.' digit { digit } ) | ( digit { digit } [ '.' { digit } ])
[ ('E' | 'e') [sign] digit { digit } ].
// * * * * * * * * * * * PRAGMAS / COMMENTS / IGNORE * * * * * * * * * * * //
COMMENTS FROM "/*" TO "*/" NESTED
COMMENTS FROM "//" TO lf
IGNORE cr + lf + tab
// * * * * * * * * * * * * * * * PRODUCTIONS * * * * * * * * * * * * * * * //
PRODUCTIONS
calcEntry (. val = 0;
if (debug){Info<<"start val pos:"<< t->pos << nl;}
.)
=
'{' Expr<val> '}' (.
if (debug){
Info<<"end {} at pos:"<< t->pos
<<" val:"<< t->val
<<" len:"<< coco_string_length(t->val)
<<" la pos:"<< la->pos << nl;
}
// reposition to immediately after the closing '}'
scanner->buffer->SetPos
(
t->pos + coco_string_length(t->val)
);
.)
| ( Expr<val> EOF )
.
/*---------------------------------------------------------------------------*/
Expr<scalar& val> (. scalar val2 = 0;
if (debug) {Info<<"Expr:"<< val<< " pos:"<< t->pos << nl;}
.)
=
Term<val>
{
"+" Term<val2> (. if (debug) {Info<<"+Term:"<<val2 << " pos:"<< t->pos << nl;}
val += val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
.)
| "-" Term<val2> (. if (debug) {Info<<"-Term:"<<val2<< " pos:"<< t->pos << nl;}
val -= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
.)
}
.
/*---------------------------------------------------------------------------*/
Term<scalar& val> (. scalar val2 = 0;
if (debug) {Info<<"Term:"<< val<< " pos:"<< t->pos << nl;}
.)
=
Factor<val>
{
"*" Factor<val2> (. if (debug) {Info<<"*Factor:"<<val2<< " pos:"<< t->pos << nl;}
val *= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
.)
| "/" Factor<val2> (. if (debug) {Info<<"/Factor:"<<val2<< " pos:"<< t->pos << nl;}
val /= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
.)
}
.
/*---------------------------------------------------------------------------*/
Factor<scalar& val>
=
variable (. val = getDictLookup();
if (debug) {Info<<"lookup:"<<val<< " pos:"<< t->pos << nl;}
.)
| number (. val = getScalar();
if (debug) {Info<<"got num:"<<val<< " pos:"<< t->pos << nl;}
.)
| '-' '(' Expr<val> ')' (. val = -val;
if (debug) {Info<<"inv:"<<val<< " pos:"<< t->pos << nl;}
.)
| '(' Expr<val> ')' (. if (debug){Info<<"got Expr:"<<val<< " pos:"<< t->pos << nl;}
.)
.
/*---------------------------------------------------------------------------*/
END calcEntry.
// ************************************************************************* //
#include <wchar.h>
#include "calcEntryParser.h"
namespace Foam {
namespace functionEntries {
namespace calcEntryInternal {
// ----------------------------------------------------------------------------
// Parser Implementation
// ----------------------------------------------------------------------------
void Parser::SynErr(int n) {
if (errDist >= minErrDist) errors->SynErr(la->line, la->col, n);
errDist = 0;
}
void Parser::SemErr(const wchar_t* msg) {
if (errDist >= minErrDist) errors->Error(t->line, t->col, msg);
errDist = 0;
}
void Parser::Get() {
for (;;) {
t = la;
la = scanner->Scan();
if (la->kind <= maxT) {
++errDist;
break;
}
if (dummyToken != t) {
dummyToken->kind = t->kind;
dummyToken->pos = t->pos;
dummyToken->col = t->col;
dummyToken->line = t->line;
dummyToken->next = NULL;
coco_string_delete(dummyToken->val);
dummyToken->val = coco_string_create(t->val);
t = dummyToken;
}
la = t;
}
}
void Parser::Expect(int n) {
if (la->kind == n) {
Get();
}
else {
SynErr(n);
}
}
void Parser::ExpectWeak(int n, int follow) {
if (la->kind == n) {
Get();
}
else {
SynErr(n);
while (!StartOf(follow)) {
Get();
}
}
}
bool Parser::WeakSeparator(int n, int syFol, int repFol) {
if (la->kind == n) {
Get();
return true;
}
else if (StartOf(repFol)) {
return false;
}
else {
SynErr(n);
while (!(StartOf(syFol) || StartOf(repFol) || StartOf(0))) {
Get();
}
return StartOf(syFol);
}
}
void Parser::calcEntry() {
val = 0;
if (debug){Info<<"start val pos:"<< t->pos << nl;}
if (la->kind == 5) {
Get();
Expr(val);
Expect(6);
if (debug){
Info<<"end {} at pos:"<< t->pos
<<" val:"<< t->val
<<" len:"<< coco_string_length(t->val)
<<" la pos:"<< la->pos << nl;
}
// reposition to immediately after the closing '}'
scanner->buffer->SetPos
(
t->pos + coco_string_length(t->val)
);
} else if (StartOf(1)) {
Expr(val);
Expect(0);
} else SynErr(14);
}
void Parser::Expr(scalar& val) {
scalar val2 = 0;
if (debug) {Info<<"Expr:"<< val<< " pos:"<< t->pos << nl;}
Term(val);
while (la->kind == 7 || la->kind == 8) {
if (la->kind == 7) {
Get();
Term(val2);
if (debug) {Info<<"+Term:"<<val2 << " pos:"<< t->pos << nl;}
val += val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
} else {
Get();
Term(val2);
if (debug) {Info<<"-Term:"<<val2<< " pos:"<< t->pos << nl;}
val -= val2;
if (debug) {Info<<"="<< val<< " pos:"<< t->pos << nl;}
}
}