mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -31,7 +31,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "psiThermo.H"
|
||||
#include "rhoThermo.H"
|
||||
#include "RASModel.H"
|
||||
#include "radiationModel.H"
|
||||
#include "simpleControl.H"
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
Info<< "Reading thermophysical properties\n" << endl;
|
||||
|
||||
autoPtr<psiThermo> pThermo
|
||||
autoPtr<rhoThermo> pThermo
|
||||
(
|
||||
psiThermo::New(mesh)
|
||||
rhoThermo::New(mesh)
|
||||
);
|
||||
psiThermo& thermo = pThermo();
|
||||
rhoThermo& thermo = pThermo();
|
||||
thermo.validate(args.executable(), "h", "e");
|
||||
|
||||
volScalarField rho
|
||||
|
||||
34
applications/solvers/heatTransfer/thermoFoam/EEqn.H
Normal file
34
applications/solvers/heatTransfer/thermoFoam/EEqn.H
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
volScalarField& he = thermo.he();
|
||||
|
||||
fvScalarMatrix EEqn
|
||||
(
|
||||
fvm::ddt(rho, he) + fvm::div(phi, he)
|
||||
+ fvc::ddt(rho, K) + fvc::div(phi, K)
|
||||
+ (
|
||||
he.name() == "e"
|
||||
? fvc::div
|
||||
(
|
||||
fvc::absolute(phi/fvc::interpolate(rho), U),
|
||||
p,
|
||||
"div(phiv,p)"
|
||||
)
|
||||
: -dpdt
|
||||
)
|
||||
- fvm::laplacian(alphaEff, he)
|
||||
==
|
||||
radiation->Sh(thermo)
|
||||
+ fvOptions(rho, he)
|
||||
);
|
||||
|
||||
EEqn.relax();
|
||||
|
||||
fvOptions.constrain(EEqn);
|
||||
|
||||
EEqn.solve();
|
||||
|
||||
fvOptions.correct(he);
|
||||
|
||||
thermo.correct();
|
||||
radiation->correct();
|
||||
}
|
||||
3
applications/solvers/heatTransfer/thermoFoam/Make/files
Normal file
3
applications/solvers/heatTransfer/thermoFoam/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
thermoFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/thermoFoam
|
||||
24
applications/solvers/heatTransfer/thermoFoam/Make/options
Normal file
24
applications/solvers/heatTransfer/thermoFoam/Make/options
Normal file
@ -0,0 +1,24 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/fvOptions/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels \
|
||||
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lsampling \
|
||||
-lmeshTools \
|
||||
-lfvOptions \
|
||||
-lfluidThermophysicalModels \
|
||||
-lradiationModels \
|
||||
-lspecie \
|
||||
-lcompressibleTurbulenceModel \
|
||||
-lcompressibleRASModels \
|
||||
-lcompressibleLESModels
|
||||
54
applications/solvers/heatTransfer/thermoFoam/createFields.H
Normal file
54
applications/solvers/heatTransfer/thermoFoam/createFields.H
Normal file
@ -0,0 +1,54 @@
|
||||
Info<< "Reading thermophysical properties\n" << endl;
|
||||
|
||||
autoPtr<rhoThermo> pThermo(rhoThermo::New(mesh));
|
||||
rhoThermo& thermo = pThermo();
|
||||
thermo.validate(args.executable(), "h", "e");
|
||||
|
||||
volScalarField rho
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rho",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
thermo.rho()
|
||||
);
|
||||
|
||||
volScalarField& p = thermo.p();
|
||||
|
||||
Info<< "Reading field U\n" << endl;
|
||||
volVectorField U
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
#include "compressibleCreatePhi.H"
|
||||
|
||||
#include "setAlphaEff.H"
|
||||
|
||||
Info<< "Creating field dpdt\n" << endl;
|
||||
volScalarField dpdt
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"dpdt",
|
||||
runTime.timeName(),
|
||||
mesh
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("dpdt", p.dimensions()/dimTime, 0)
|
||||
);
|
||||
|
||||
Info<< "Creating field kinetic energy K\n" << endl;
|
||||
volScalarField K("K", 0.5*magSqr(U));
|
||||
93
applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H
Normal file
93
applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H
Normal file
@ -0,0 +1,93 @@
|
||||
Info<< "Creating turbulence model\n" << endl;
|
||||
tmp<volScalarField> talphaEff;
|
||||
|
||||
IOobject turbulenceHeader
|
||||
(
|
||||
"turbulenceProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
IOobject RASHeader
|
||||
(
|
||||
"RASProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
IOobject LESHeader
|
||||
(
|
||||
"LESProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
if (turbulenceHeader.headerOk())
|
||||
{
|
||||
autoPtr<compressible::turbulenceModel> turbulence
|
||||
(
|
||||
compressible::turbulenceModel::New
|
||||
(
|
||||
rho,
|
||||
U,
|
||||
phi,
|
||||
thermo
|
||||
)
|
||||
);
|
||||
|
||||
talphaEff = turbulence->alphaEff();
|
||||
}
|
||||
else if (RASHeader.headerOk())
|
||||
{
|
||||
autoPtr<compressible::RASModel> turbulence
|
||||
(
|
||||
compressible::RASModel::New
|
||||
(
|
||||
rho,
|
||||
U,
|
||||
phi,
|
||||
thermo
|
||||
)
|
||||
);
|
||||
|
||||
talphaEff = turbulence->alphaEff();
|
||||
}
|
||||
else if (LESHeader.headerOk())
|
||||
{
|
||||
autoPtr<compressible::LESModel> turbulence
|
||||
(
|
||||
compressible::LESModel::New
|
||||
(
|
||||
rho,
|
||||
U,
|
||||
phi,
|
||||
thermo
|
||||
)
|
||||
);
|
||||
|
||||
talphaEff = turbulence->alphaEff();
|
||||
}
|
||||
else
|
||||
{
|
||||
talphaEff = tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"alphaEff",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimMass/dimLength/dimTime, 0.0)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const volScalarField& alphaEff = talphaEff();
|
||||
107
applications/solvers/heatTransfer/thermoFoam/thermoFoam.C
Normal file
107
applications/solvers/heatTransfer/thermoFoam/thermoFoam.C
Normal file
@ -0,0 +1,107 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 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/>.
|
||||
|
||||
Application
|
||||
thermoFoam
|
||||
|
||||
Description
|
||||
Evolves the thermodynamics on a forzen flow field
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "rhoThermo.H"
|
||||
#include "turbulenceModel.H"
|
||||
#include "RASModel.H"
|
||||
#include "LESModel.H"
|
||||
#include "radiationModel.H"
|
||||
#include "fvIOoptionList.H"
|
||||
#include "simpleControl.H"
|
||||
#include "pimpleControl.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "createFields.H"
|
||||
#include "createFvOptions.H"
|
||||
#include "createRadiationModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "\nEvolving thermodynamics\n" << endl;
|
||||
|
||||
if (mesh.solutionDict().found("SIMPLE"))
|
||||
{
|
||||
simpleControl simple(mesh);
|
||||
|
||||
while (simple.loop())
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
while (simple.correctNonOrthogonal())
|
||||
{
|
||||
#include "EEqn.H"
|
||||
}
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
|
||||
runTime.write();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pimpleControl pimple(mesh);
|
||||
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
while (pimple.correctNonOrthogonal())
|
||||
{
|
||||
#include "EEqn.H"
|
||||
}
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
|
||||
runTime.write();
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -42,11 +42,20 @@ int main(int argc, char *argv[])
|
||||
argList::validArgs.append("CHEMKINThermodynamicsFile");
|
||||
argList::validArgs.append("FOAMChemistryFile");
|
||||
argList::validArgs.append("FOAMThermodynamicsFile");
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"newFormat",
|
||||
"read Chemkin thermo file in new format"
|
||||
);
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
bool newFormat = args.optionFound("newFormat");
|
||||
|
||||
speciesTable species;
|
||||
|
||||
chemkinReader cr(args[1], species, args[2]);
|
||||
chemkinReader cr(args[1], species, args[2], newFormat);
|
||||
|
||||
OFstream reactionsFile(args[3]);
|
||||
reactionsFile
|
||||
|
||||
@ -219,7 +219,7 @@ case ThirdParty:
|
||||
case Gcc++0x:
|
||||
case Gcc46:
|
||||
case Gcc46++0x:
|
||||
set gcc_version=gcc-4.6.2
|
||||
set gcc_version=gcc-4.6.1
|
||||
set gmp_version=gmp-5.0.4
|
||||
set mpfr_version=mpfr-3.1.0
|
||||
set mpc_version=mpc-0.9
|
||||
@ -238,17 +238,6 @@ case ThirdParty:
|
||||
set mpfr_version=mpfr-2.4.2
|
||||
set mpc_version=mpc-0.8.1
|
||||
breaksw
|
||||
case Gcc44:
|
||||
case Gcc44++0x:
|
||||
set gcc_version=gcc-4.4.3
|
||||
set gmp_version=gmp-5.0.1
|
||||
set mpfr_version=mpfr-2.4.2
|
||||
breaksw
|
||||
case Gcc43:
|
||||
set gcc_version=gcc-4.3.3
|
||||
set gmp_version=gmp-4.2.4
|
||||
set mpfr_version=mpfr-2.4.1
|
||||
breaksw
|
||||
case Clang:
|
||||
# using clang - not gcc
|
||||
setenv WM_CC 'clang'
|
||||
|
||||
@ -240,12 +240,6 @@ fi
|
||||
case "${foamCompiler}" in
|
||||
OpenFOAM | ThirdParty)
|
||||
case "$WM_COMPILER" in
|
||||
Gcc463)
|
||||
gcc_version=gcc-4.6.3
|
||||
gmp_version=gmp-5.0.2
|
||||
mpfr_version=mpfr-3.0.1
|
||||
mpc_version=mpc-0.9
|
||||
;;
|
||||
Gcc | Gcc++0x | Gcc46 | Gcc46++0x)
|
||||
gcc_version=gcc-4.6.1
|
||||
gmp_version=gmp-5.0.4
|
||||
@ -264,16 +258,6 @@ OpenFOAM | ThirdParty)
|
||||
mpfr_version=mpfr-2.4.2
|
||||
mpc_version=mpc-0.8.1
|
||||
;;
|
||||
Gcc44 | Gcc44++0x)
|
||||
gcc_version=gcc-4.4.3
|
||||
gmp_version=gmp-5.0.1
|
||||
mpfr_version=mpfr-2.4.2
|
||||
;;
|
||||
Gcc43)
|
||||
gcc_version=gcc-4.3.3
|
||||
gmp_version=gmp-4.2.4
|
||||
mpfr_version=mpfr-2.4.1
|
||||
;;
|
||||
Clang)
|
||||
# using clang - not gcc
|
||||
export WM_CC='clang'
|
||||
|
||||
@ -52,6 +52,13 @@ Foam::fileName Foam::externalCoupledMixedFvPatchField<Type>::baseDir() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::externalCoupledMixedFvPatchField<Type>::lockFile() const
|
||||
{
|
||||
return fileName(baseDir()/(lockName + ".lock"));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::externalCoupledMixedFvPatchField<Type>::createLockFile() const
|
||||
{
|
||||
@ -65,7 +72,7 @@ void Foam::externalCoupledMixedFvPatchField<Type>::createLockFile() const
|
||||
Info<< type() << ": creating lock file" << endl;
|
||||
}
|
||||
|
||||
OFstream os(baseDir()/(lockName + ".lock"));
|
||||
OFstream os(lockFile());
|
||||
os << "waiting";
|
||||
os.flush();
|
||||
}
|
||||
@ -84,7 +91,7 @@ void Foam::externalCoupledMixedFvPatchField<Type>::removeLockFile() const
|
||||
Info<< type() << ": removing lock file" << endl;
|
||||
}
|
||||
|
||||
rm(baseDir()/(lockName + ".lock"));
|
||||
rm(lockFile());
|
||||
}
|
||||
|
||||
|
||||
@ -153,15 +160,13 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeAndWait
|
||||
os.flush();
|
||||
}
|
||||
|
||||
const fileName lockFile(baseDir()/(lockName + ".lock"));
|
||||
|
||||
// remove lock file, signalling external source to execute
|
||||
removeLockFile();
|
||||
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << ": beginning wait for lock file " << lockFile
|
||||
Info<< type() << ": beginning wait for lock file " << lockFile()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -189,13 +194,13 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeAndWait
|
||||
<< " s" << abort(FatalError);
|
||||
}
|
||||
|
||||
IFstream is(lockFile);
|
||||
IFstream is(lockFile());
|
||||
|
||||
if (is.good())
|
||||
{
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << ": found lock file " << lockFile << endl;
|
||||
Info<< type() << ": found lock file " << lockFile() << endl;
|
||||
}
|
||||
|
||||
found = true;
|
||||
@ -438,8 +443,7 @@ void Foam::externalCoupledMixedFvPatchField<Type>::write(Ostream& os) const
|
||||
os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("waitInterval") << waitInterval_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
os.writeKeyword("timeOut") << timeOut_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
os.writeKeyword("timeOut") << timeOut_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("calcFrequency") << calcFrequency_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
os.writeKeyword("log") << log_ << token::END_STATEMENT << nl;
|
||||
|
||||
@ -47,7 +47,7 @@ Description
|
||||
|
||||
$FOAM_CASE/comms/patchName/data.out
|
||||
|
||||
The lock file is then removed, instructing the exterbal source to take
|
||||
The lock file is then removed, instructing the external source to take
|
||||
control of the program execution. When ready, the external program
|
||||
should create the return values, e.g. to file
|
||||
|
||||
@ -62,9 +62,9 @@ Description
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
commsDir | communications folder | yes |
|
||||
fileName | data transfer file name | yes |
|
||||
fileName | transfer file name | yes |
|
||||
waitInterval | interval [s] between file checks | no | 1
|
||||
timeOut | time after which error invoked | no | 100*waitInterval
|
||||
timeOut | time after which error invoked [s] |no |100*waitInterval
|
||||
calcFrequency | calculation frequency | no | 1
|
||||
log | log program control | no | no
|
||||
\endtable
|
||||
@ -137,6 +137,9 @@ protected:
|
||||
//- Return the file path to the base communications folder
|
||||
fileName baseDir() const;
|
||||
|
||||
//- Return the file path to the lock file
|
||||
fileName lockFile() const;
|
||||
|
||||
//- Create lock file
|
||||
void createLockFile() const;
|
||||
|
||||
|
||||
@ -372,8 +372,14 @@ inline Foam::scalar Foam::KinematicCloud<CloudType>::penetration
|
||||
}
|
||||
|
||||
// lists of parcels mass and distance from initial injection point
|
||||
List<scalar> mass(nParcel, 0.0);
|
||||
List<scalar> dist(nParcel, 0.0);
|
||||
List<List<scalar> > procMass(Pstream::nProcs());
|
||||
List<List<scalar> > procDist(Pstream::nProcs());
|
||||
|
||||
List<scalar>& mass = procMass[Pstream::myProcNo()];
|
||||
List<scalar>& dist = procDist[Pstream::myProcNo()];
|
||||
|
||||
mass.setSize(nParcel);
|
||||
dist.setSize(nParcel);
|
||||
|
||||
label i = 0;
|
||||
scalar mSum = 0.0;
|
||||
@ -392,75 +398,86 @@ inline Foam::scalar Foam::KinematicCloud<CloudType>::penetration
|
||||
|
||||
// calculate total mass across all processors
|
||||
reduce(mSum, sumOp<scalar>());
|
||||
Pstream::gatherList(procMass);
|
||||
Pstream::gatherList(procDist);
|
||||
|
||||
// flatten the mass list
|
||||
List<scalar> allMass(nParcelSum, 0.0);
|
||||
SubList<scalar>
|
||||
(
|
||||
allMass,
|
||||
globalParcels.localSize(Pstream::myProcNo()),
|
||||
globalParcels.offset(Pstream::myProcNo())
|
||||
).assign(mass);
|
||||
|
||||
// flatten the distance list
|
||||
SortableList<scalar> allDist(nParcelSum, 0.0);
|
||||
SubList<scalar>
|
||||
(
|
||||
allDist,
|
||||
globalParcels.localSize(Pstream::myProcNo()),
|
||||
globalParcels.offset(Pstream::myProcNo())
|
||||
).assign(dist);
|
||||
|
||||
// sort allDist distances into ascending order
|
||||
// note: allMass masses are left unsorted
|
||||
allDist.sort();
|
||||
|
||||
if (nParcelSum > 1)
|
||||
if (Pstream::master())
|
||||
{
|
||||
const scalar mLimit = fraction*mSum;
|
||||
const labelList& indices = allDist.indices();
|
||||
|
||||
if (mLimit > (mSum - allMass[indices.last()]))
|
||||
// flatten the mass lists
|
||||
List<scalar> allMass(nParcelSum, 0.0);
|
||||
SortableList<scalar> allDist(nParcelSum, 0.0);
|
||||
for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||
{
|
||||
distance = allDist.last();
|
||||
SubList<scalar>
|
||||
(
|
||||
allMass,
|
||||
globalParcels.localSize(procI),
|
||||
globalParcels.offset(procI)
|
||||
).assign(procMass[procI]);
|
||||
|
||||
// flatten the distance list
|
||||
SubList<scalar>
|
||||
(
|
||||
allDist,
|
||||
globalParcels.localSize(procI),
|
||||
globalParcels.offset(procI)
|
||||
).assign(procDist[procI]);
|
||||
}
|
||||
else
|
||||
|
||||
// sort allDist distances into ascending order
|
||||
// note: allMass masses are left unsorted
|
||||
allDist.sort();
|
||||
|
||||
if (nParcelSum > 1)
|
||||
{
|
||||
// assuming that 'fraction' is generally closer to 1 than 0, loop
|
||||
// through in reverse distance order
|
||||
const scalar mThreshold = (1.0 - fraction)*mSum;
|
||||
scalar mCurrent = 0.0;
|
||||
label i0 = 0;
|
||||
const scalar mLimit = fraction*mSum;
|
||||
const labelList& indices = allDist.indices();
|
||||
|
||||
forAllReverse(indices, i)
|
||||
{
|
||||
label indI = indices[i];
|
||||
|
||||
mCurrent += allMass[indI];
|
||||
|
||||
if (mCurrent > mThreshold)
|
||||
{
|
||||
i0 = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i0 == indices.size() - 1)
|
||||
if (mLimit > (mSum - allMass[indices.last()]))
|
||||
{
|
||||
distance = allDist.last();
|
||||
}
|
||||
else
|
||||
{
|
||||
// linearly interpolate to determine distance
|
||||
scalar alpha = (mCurrent - mThreshold)/allMass[indices[i0]];
|
||||
distance = allDist[i0] + alpha*(allDist[i0+1] - allDist[i0]);
|
||||
// assuming that 'fraction' is generally closer to 1 than 0,
|
||||
// loop through in reverse distance order
|
||||
const scalar mThreshold = (1.0 - fraction)*mSum;
|
||||
scalar mCurrent = 0.0;
|
||||
label i0 = 0;
|
||||
|
||||
forAllReverse(indices, i)
|
||||
{
|
||||
label indI = indices[i];
|
||||
|
||||
mCurrent += allMass[indI];
|
||||
|
||||
if (mCurrent > mThreshold)
|
||||
{
|
||||
i0 = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i0 == indices.size() - 1)
|
||||
{
|
||||
distance = allDist.last();
|
||||
}
|
||||
else
|
||||
{
|
||||
// linearly interpolate to determine distance
|
||||
scalar alpha = (mCurrent - mThreshold)/allMass[indices[i0]];
|
||||
distance =
|
||||
allDist[i0] + alpha*(allDist[i0+1] - allDist[i0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = allDist.first();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = allDist.first();
|
||||
}
|
||||
|
||||
Pstream::scatter(distance);
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
@ -171,12 +171,7 @@ Foam::tmp<Foam::vectorField> Foam::axesRotation::transform
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<vectorField> Foam::axesRotation:: "
|
||||
"transform(const vectorField& st) const"
|
||||
);
|
||||
return tmp<vectorField>(NULL);
|
||||
return (R_ & st);
|
||||
}
|
||||
|
||||
|
||||
@ -185,12 +180,7 @@ Foam::tmp<Foam::vectorField> Foam::axesRotation::invTransform
|
||||
const vectorField& st
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"tmp<vectorField> Foam::axesRotation::"
|
||||
"invTransform(const vectorField& st) const"
|
||||
);
|
||||
return tmp<vectorField>(NULL);
|
||||
return (Rtr_ & st);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -146,6 +146,7 @@ Foam::scalarTransport::scalarTransport
|
||||
active_(true),
|
||||
phiName_("phi"),
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
DT_(0.0),
|
||||
userDT_(false),
|
||||
resetOnStartUp_(false),
|
||||
@ -192,6 +193,7 @@ void Foam::scalarTransport::read(const dictionary& dict)
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
UName_ = dict.lookupOrDefault<word>("UName", "U");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
|
||||
|
||||
userDT_ = false;
|
||||
if (dict.readIfPresent("DT", DT_))
|
||||
@ -237,24 +239,59 @@ void Foam::scalarTransport::execute()
|
||||
relaxCoeff = mesh_.equationRelaxationFactor(schemeVar);
|
||||
}
|
||||
|
||||
// solve
|
||||
for (label i = 0; i <= nCorr_; i++)
|
||||
if (phi.dimensions() == dimMass/dimTime)
|
||||
{
|
||||
fvScalarMatrix TEqn
|
||||
(
|
||||
fvm::ddt(T_)
|
||||
+ fvm::div(phi, T_, divScheme)
|
||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
||||
==
|
||||
fvOptions_(T_)
|
||||
);
|
||||
const volScalarField& rho =
|
||||
mesh_.lookupObject<volScalarField>(rhoName_);
|
||||
|
||||
TEqn.relax(relaxCoeff);
|
||||
// solve
|
||||
for (label i = 0; i <= nCorr_; i++)
|
||||
{
|
||||
fvScalarMatrix TEqn
|
||||
(
|
||||
fvm::ddt(rho, T_)
|
||||
+ fvm::div(phi, T_, divScheme)
|
||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
||||
==
|
||||
fvOptions_(rho, T_)
|
||||
);
|
||||
|
||||
fvOptions_.constrain(TEqn);
|
||||
TEqn.relax(relaxCoeff);
|
||||
|
||||
TEqn.solve(mesh_.solverDict(UName_));
|
||||
fvOptions_.constrain(TEqn);
|
||||
|
||||
TEqn.solve(mesh_.solverDict(schemeVar));
|
||||
}
|
||||
}
|
||||
else if (phi.dimensions() == dimVolume/dimTime)
|
||||
{
|
||||
// solve
|
||||
for (label i = 0; i <= nCorr_; i++)
|
||||
{
|
||||
fvScalarMatrix TEqn
|
||||
(
|
||||
fvm::ddt(T_)
|
||||
+ fvm::div(phi, T_, divScheme)
|
||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
||||
==
|
||||
fvOptions_(T_)
|
||||
);
|
||||
|
||||
TEqn.relax(relaxCoeff);
|
||||
|
||||
fvOptions_.constrain(TEqn);
|
||||
|
||||
TEqn.solve(mesh_.solverDict(schemeVar));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("void Foam::scalarTransport::execute()")
|
||||
<< "Incompatible dimensions for phi: " << phi.dimensions() << nl
|
||||
<< "Dimensions should be " << dimMass/dimTime << " or "
|
||||
<< dimVolume/dimTime << endl;
|
||||
}
|
||||
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -90,6 +90,9 @@ class scalarTransport
|
||||
//- Name of velocity field (optional)
|
||||
word UName_;
|
||||
|
||||
//- Name of density field (optional)
|
||||
word rhoName_;
|
||||
|
||||
//- Diffusion coefficient (optional)
|
||||
scalar DT_;
|
||||
|
||||
|
||||
@ -439,20 +439,25 @@ bool finishReaction = false;
|
||||
|
||||
<readThermoSpecieName>{thermoSpecieName} {
|
||||
string specieString(foamSpecieString(YYText()));
|
||||
// Old format
|
||||
size_t spacePos = specieString.find(' ');
|
||||
if (spacePos != string::npos)
|
||||
if (newFormat_)
|
||||
{
|
||||
currentSpecieName = specieString(0, spacePos);
|
||||
specieString.replaceAll(" ", "_");
|
||||
size_t strEnd = specieString.find_last_not_of('_');
|
||||
currentSpecieName = specieString.substr(0, strEnd + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSpecieName = specieString;
|
||||
size_t spacePos = specieString.find(' ');
|
||||
if (spacePos != string::npos)
|
||||
{
|
||||
currentSpecieName = specieString(0, spacePos);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSpecieName = specieString;
|
||||
}
|
||||
}
|
||||
// New format
|
||||
// specieString.replaceAll(" ", "_");
|
||||
// size_t strEnd = specieString.find_last_not_of('_');
|
||||
// currentSpecieName = specieString.substr(0, strEnd + 1);
|
||||
|
||||
BEGIN(readThermoDate);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -862,13 +862,15 @@ Foam::chemkinReader::chemkinReader
|
||||
(
|
||||
const fileName& CHEMKINFileName,
|
||||
speciesTable& species,
|
||||
const fileName& thermoFileName
|
||||
const fileName& thermoFileName,
|
||||
const bool newFormat
|
||||
)
|
||||
:
|
||||
lineNo_(1),
|
||||
specieNames_(10),
|
||||
speciesTable_(species),
|
||||
reactions_(speciesTable_, speciesThermo_)
|
||||
reactions_(speciesTable_, speciesThermo_),
|
||||
newFormat_(newFormat)
|
||||
{
|
||||
read(CHEMKINFileName, thermoFileName);
|
||||
}
|
||||
@ -883,8 +885,14 @@ Foam::chemkinReader::chemkinReader
|
||||
lineNo_(1),
|
||||
specieNames_(10),
|
||||
speciesTable_(species),
|
||||
reactions_(speciesTable_, speciesThermo_)
|
||||
reactions_(speciesTable_, speciesThermo_),
|
||||
newFormat_(thermoDict.lookupOrDefault("newFormat", false))
|
||||
{
|
||||
if (newFormat_)
|
||||
{
|
||||
Info<< "Reading CHEMKIN thermo data in new file format" << endl;
|
||||
}
|
||||
|
||||
fileName chemkinFile(fileName(thermoDict.lookup("CHEMKINFile")).expand());
|
||||
|
||||
fileName thermoFile = fileName::null;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,6 +39,7 @@ SourceFiles
|
||||
#include "chemistryReader.H"
|
||||
#include "fileName.H"
|
||||
#include "typeInfo.H"
|
||||
#include "Switch.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "ReactionList.H"
|
||||
#include "DynamicList.H"
|
||||
@ -207,6 +208,9 @@ private:
|
||||
//- List of the reactions
|
||||
ReactionList<gasHThermoPhysics> reactions_;
|
||||
|
||||
//- Flag to indicate that file is in new format
|
||||
Switch newFormat_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -319,7 +323,8 @@ public:
|
||||
(
|
||||
const fileName& chemkinFile,
|
||||
speciesTable& species,
|
||||
const fileName& thermoFileName = fileName::null
|
||||
const fileName& thermoFileName = fileName::null,
|
||||
const bool newFormat = false
|
||||
);
|
||||
|
||||
//- Construct by getting the CHEMKIN III file name from dictionary
|
||||
|
||||
@ -33,8 +33,14 @@ porosity1
|
||||
|
||||
coordinateSystem
|
||||
{
|
||||
e1 (0.70710678 0.70710678 0);
|
||||
e3 (0 0 1);
|
||||
type cartesian;
|
||||
origin (0 0 0);
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (0.70710678 0.70710678 0);
|
||||
e3 (0 0 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,10 +54,17 @@ geometry
|
||||
scale (1.0 1.0 2.1);
|
||||
transform
|
||||
{
|
||||
type cartesian;
|
||||
origin (2 2 0);
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1);
|
||||
coordinateSystem
|
||||
{
|
||||
type cartesian;
|
||||
origin (2 2 0);
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
herring
|
||||
@ -66,10 +73,17 @@ geometry
|
||||
scale (1.0 1.0 2.1);
|
||||
transform
|
||||
{
|
||||
type cartesian;
|
||||
origin (3.5 3 0);
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1);
|
||||
coordinateSystem
|
||||
{
|
||||
type cartesian;
|
||||
origin (3.5 3 0);
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ FoamFile
|
||||
|
||||
thermoType
|
||||
{
|
||||
type hePsiThermo;
|
||||
type heRhoThermo;
|
||||
mixture pureMixture;
|
||||
transport const;
|
||||
thermo hConst;
|
||||
|
||||
@ -42,16 +42,16 @@ solvers
|
||||
|
||||
SIMPLE
|
||||
{
|
||||
momentumPredictor yes;
|
||||
momentumPredictor no;
|
||||
nNonOrthogonalCorrectors 0;
|
||||
pRefCell 0;
|
||||
pRefValue 0;
|
||||
|
||||
residualControl
|
||||
{
|
||||
p_rgh 1e-2;
|
||||
U 1e-3;
|
||||
h 1e-3;
|
||||
p_rgh 1e-4;
|
||||
U 1e-4;
|
||||
h 1e-4;
|
||||
|
||||
// possibly check turbulence fields
|
||||
"(k|epsilon|omega)" 1e-3;
|
||||
|
||||
@ -17,7 +17,7 @@ FoamFile
|
||||
|
||||
thermoType
|
||||
{
|
||||
type hePsiThermo;
|
||||
type heRhoThermo;
|
||||
mixture pureMixture;
|
||||
transport const;
|
||||
thermo hConst;
|
||||
|
||||
@ -17,7 +17,7 @@ FoamFile
|
||||
|
||||
thermoType
|
||||
{
|
||||
type hePsiThermo;
|
||||
type heRhoThermo;
|
||||
mixture pureMixture;
|
||||
transport const;
|
||||
thermo hConst;
|
||||
|
||||
@ -17,7 +17,7 @@ FoamFile
|
||||
|
||||
thermoType
|
||||
{
|
||||
type hePsiThermo;
|
||||
type heRhoThermo;
|
||||
mixture pureMixture;
|
||||
transport const;
|
||||
thermo hConst;
|
||||
|
||||
@ -15,11 +15,9 @@ FoamFile
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// thermoType hePsiThermo<pureMixture<const<hConst<perfectGas<specie>>,sensibleEnthalpy>>>;
|
||||
|
||||
thermoType
|
||||
{
|
||||
type hePsiThermo;
|
||||
type heRhoThermo;
|
||||
mixture pureMixture;
|
||||
transport const;
|
||||
thermo hConst;
|
||||
|
||||
@ -51,8 +51,14 @@ porosityBlockage
|
||||
|
||||
coordinateSystem
|
||||
{
|
||||
e1 (0 1 0);
|
||||
e2 (0 0 1);
|
||||
type cartesian;
|
||||
origin (0 0 0);
|
||||
coordinateRotation
|
||||
{
|
||||
type axesRotation;
|
||||
e1 (0 1 0);
|
||||
e2 (0 0 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ chemistryType
|
||||
chemistryThermo psi;
|
||||
}
|
||||
|
||||
chemistry off;
|
||||
chemistry on;
|
||||
|
||||
initialChemicalTimeStep 1e-07;
|
||||
|
||||
|
||||
@ -15,9 +15,9 @@ FoamFile
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
combustionModel PaSR<psiChemistryCombustion>;
|
||||
combustionModel PaSR<psiChemistryCombustion>;
|
||||
|
||||
active false;
|
||||
active yes;
|
||||
|
||||
PaSRCoeffs
|
||||
{
|
||||
|
||||
@ -28,7 +28,9 @@ thermoType
|
||||
|
||||
CHEMKINFile "$FOAM_CASE/chemkin/chem.inp";
|
||||
|
||||
CHEMKINThermoFile "~OpenFOAM/thermoData/therm.dat";
|
||||
CHEMKINThermoFile "$FOAM_CASE/chemkin/therm.dat";
|
||||
|
||||
newFormat yes;
|
||||
|
||||
inertSpecie N2;
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format binary;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object controlDict;
|
||||
|
||||
Reference in New Issue
Block a user