Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2012-10-12 16:19:20 +01:00
347 changed files with 5230 additions and 3785 deletions

View File

@ -7,7 +7,12 @@
+ betav*fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
hea.name() == "ea"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
phi/fvc::interpolate(rho),
p,
"div(phiv,p)"
)
: -betav*dpdt
)
- fvm::laplacian(Db, hea)

View File

@ -8,7 +8,12 @@ if (ign.ignited())
+ (betav*fvc::ddt(rho, K) + fvc::div(phi, K))*rho/thermo.rhou()
+ (
heau.name() == "eau"
? fvc::div(phi, volScalarField("Ep", p/rho))*rho/thermo.rhou()
? fvc::div
(
phi/fvc::interpolate(rho),
p,
"div(phiv,p)"
)*rho/thermo.rhou()
: -betav*dpdt*rho/thermo.rhou()
)
- fvm::laplacian(Db, heau)

View File

@ -116,7 +116,7 @@ void PDRkEpsilon::correct()
}
tmp<volTensorField> tgradU = fvc::grad(U_);
volScalarField G("RASModel::G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
volScalarField G("RASModel.G", mut_*(tgradU() && dev(twoSymm(tgradU()))));
tgradU.clear();
// Update espsilon and G at the wall

View File

@ -7,7 +7,12 @@
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
hea.name() == "ea"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt
)
- fvm::laplacian(turbulence->alphaEff(), hea)

View File

@ -8,7 +8,12 @@ if (ign.ignited())
+ (fvc::ddt(rho, K) + fvc::div(phi, K))*rho/thermo.rhou()
+ (
heau.name() == "eau"
? fvc::div(phi, volScalarField("Ep", p/rho))*rho/thermo.rhou()
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)*rho/thermo.rhou()
: -dpdt*rho/thermo.rhou()
)
- fvm::laplacian(turbulence->alphaEff(), heau)

View File

@ -66,5 +66,5 @@ K = 0.5*magSqr(U);
if (thermo.dpdt())
{
dpdt = fvc::ddt(p);
dpdt = fvc::ddt(p) - fvc::div(fvc::meshPhi(rho, U), p);
}

View File

@ -55,7 +55,12 @@ tmp<fv::convectionScheme<scalar> > mvConvection
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
he.name() == "e"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt
)
- fvm::laplacian(turbulence->alphaEff(), he)

View File

@ -7,7 +7,12 @@
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
he.name() == "e"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt
)
- fvm::laplacian(turbulence->alphaEff(), he)

View File

@ -2,8 +2,6 @@
cd ${0%/*} || exit 1 # run from this directory
set -x
wmake libso BCs
wmake
wmake rhoCentralDyMFoam
(wmake libso BCs && wmake && wmake rhoCentralDyMFoam)
# ----------------------------------------------------------------- end-of-file

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -195,10 +195,8 @@ void maxwellSlipUFvPatchVectorField::write(Ostream& os) const
<< thermalCreep_ << token::END_STATEMENT << nl;
os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl;
os.writeKeyword("refValue")
<< refValue() << token::END_STATEMENT << nl;
os.writeKeyword("valueFraction")
<< valueFraction() << token::END_STATEMENT << nl;
refValue().writeEntry("refValue", os);
valueFraction().writeEntry("valueFraction", os);
writeEntry("value", os);
}

View File

@ -7,7 +7,12 @@
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
he.name() == "e"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt
)
- fvm::laplacian(turbulence->alphaEff(), he)

View File

@ -2,7 +2,8 @@
solve
(
fvm::ddt(rho, e) + fvm::div(phi, e)
+ fvc::ddt(rho, K) + fvc::div(phi, volScalarField("Ekp", K + p/rho))
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ fvc::div(fvc::absolute(phi/fvc::interpolate(rho), U), p, "div(phiv,p)")
- fvm::laplacian(turbulence->alphaEff(), e)
);

View File

@ -1,11 +0,0 @@
{
solve
(
fvm::ddt(rho, e) + fvm::div(phi, e)
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ fvc::div(phi/fvc::interpolate(rho) + mesh.phi(), p, "div(phiv,p)")
- fvm::laplacian(turbulence->alphaEff(), e)
);
thermo.correct();
}

View File

@ -1,5 +1,6 @@
// Initialise solid field pointer lists
PtrList<solidThermo> thermos(solidRegions.size());
PtrList<radiation::radiationModel> radiations(solidRegions.size());
// Populate solid field pointer lists
forAll(solidRegions, i)
@ -13,4 +14,7 @@
i,
solidThermo::New(solidRegions[i])
);
Info<< " Adding to radiations\n" << endl;
radiations.set(i, radiation::radiationModel::New(thermos[i].T()));
}

View File

@ -1,5 +1,6 @@
fvMesh& mesh = solidRegions[i];
solidThermo& thermo = thermos[i];
const radiation::radiationModel& radiation = radiations[i];
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();

View File

@ -7,7 +7,12 @@
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
he.name() == "e"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt
)
- fvm::laplacian(turb.alphaEff(), he)

View File

@ -1,5 +1,6 @@
// Initialise solid field pointer lists
PtrList<solidThermo> thermos(solidRegions.size());
PtrList<radiation::radiationModel> radiations(solidRegions.size());
// Populate solid field pointer lists
forAll(solidRegions, i)
@ -9,4 +10,7 @@
Info<< " Adding to thermos\n" << endl;
thermos.set(i, solidThermo::New(solidRegions[i]));
Info<< " Adding to radiations\n" << endl;
radiations.set(i, radiation::radiationModel::New(thermos[i].T()));
}

View File

@ -1,5 +1,6 @@
fvMesh& mesh = solidRegions[i];
solidThermo& thermo = thermos[i];
const radiation::radiationModel& radiation = radiations[i];
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();

View File

@ -7,7 +7,12 @@
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
he.name() == "e"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt
)
- fvm::laplacian(turbulence->alphaEff(), he)

View File

@ -7,7 +7,12 @@
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
he.name() == "e"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt
)
- fvm::laplacian(turbulence->alphaEff(), he)

View File

@ -7,7 +7,12 @@
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ (
he.name() == "e"
? fvc::div(phi, volScalarField("Ep", p/rho))
? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt
)
- fvm::laplacian(turbulence->alphaEff(), he)

View File

@ -79,5 +79,5 @@ K = 0.5*magSqr(U);
if (thermo.dpdt())
{
dpdt = fvc::ddt(p);
dpdt = fvc::ddt(p) - fvc::div(fvc::meshPhi(rho, U), p);
}

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,6 +41,45 @@ int main(int argc, char *argv[])
Info<< ds*dt << " " << dt*ds << endl;
// dimensionSet
{
Pout<< "dimensionSet construct from is:"
<< dimensionSet(IStringStream("[Pa m^2 s^-2]")())
<< endl;
IStringStream is("[Pa m^2 s^-2]");
dimensionSet dset(dimless);
is >> dset;
Pout<< "dimensionSet read:" << dset << endl;
}
// dimensionedType
{
Pout<< "construct from is:"
<< dimensionedScalar(IStringStream("bla [Pa mm^2 s^-2] 3.0")())
<< endl;
Pout<< "construct from name,is:"
<< dimensionedScalar
(
"ABC",
IStringStream("[Pa mm^2 s^-2] 3.0")()
) << endl;
Pout<< "construct from name,dimensionSet,is:"
<< dimensionedScalar
(
"ABC",
dimLength,
IStringStream("bla [mm] 3.0")()
) << endl;
{
IStringStream is("bla [mm] 3.0");
dimensionedScalar ds;
is >> ds;
Pout<< "read:" << ds << endl;
}
}
Info<< "End\n" << endl;
return 0;

View File

@ -310,6 +310,10 @@ addLayersControls
// make straight angle.
featureAngle 60;
//- At non-patched sides allow mesh to slip if extrusion direction makes
// angle larger than slipFeatureAngle.
slipFeatureAngle 30;
//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;

View File

@ -7,6 +7,7 @@
#include "pointSet.H"
#include "IOmanip.H"
#include "emptyPolyPatch.H"
#include "processorPolyPatch.H"
Foam::label Foam::checkTopology
(
@ -289,10 +290,18 @@ Foam::label Foam::checkTopology
}
}
if (!Pstream::parRun())
{
Pout<< "\nChecking patch topology for multiply connected surfaces ..."
<< endl;
if (!Pstream::parRun())
{
Info<< "\nChecking patch topology for multiply connected"
<< " surfaces..." << endl;
}
else
{
Info<< "\nChecking basic patch addressing..." << endl;
}
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -301,90 +310,101 @@ Foam::label Foam::checkTopology
(
mesh,
"nonManifoldPoints",
mesh.nPoints()/100
mesh.nPoints()/1000
);
Pout.setf(ios_base::left);
Pout<< " "
Info<< " "
<< setw(20) << "Patch"
<< setw(9) << "Faces"
<< setw(9) << "Points"
<< setw(34) << "Surface topology";
<< setw(9) << "Points";
if (!Pstream::parRun())
{
Info<< setw(34) << "Surface topology";
}
if (allGeometry)
{
Pout<< " Bounding box";
Info<< " Bounding box";
}
Pout<< endl;
Info<< endl;
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
Pout<< " "
if (!isA<processorPolyPatch>(pp))
{
Info<< " "
<< setw(20) << pp.name()
<< setw(9) << pp.size()
<< setw(9) << pp.nPoints();
<< setw(9) << returnReduce(pp.size(), sumOp<label>())
<< setw(9) << returnReduce(pp.nPoints(), sumOp<label>());
primitivePatch::surfaceTopo pTyp = pp.surfaceType();
if (pp.empty())
{
Pout<< setw(34) << "ok (empty)";
}
else if (pTyp == primitivePatch::MANIFOLD)
{
if (pp.checkPointManifold(true, &points))
if (!Pstream::parRun())
{
Pout<< setw(34) << "multiply connected (shared point)";
}
else
{
Pout<< setw(34) << "ok (closed singly connected)";
}
primitivePatch::surfaceTopo pTyp = pp.surfaceType();
// Add points on non-manifold edges to make set complete
pp.checkTopology(false, &points);
}
else
{
pp.checkTopology(false, &points);
if (pTyp == primitivePatch::OPEN)
{
Pout<< setw(34) << "ok (non-closed singly connected)";
}
else
{
Pout<< setw(34) << "multiply connected (shared edge)";
}
}
if (allGeometry)
{
const pointField& pts = pp.points();
const labelList& mp = pp.meshPoints();
if (returnReduce(mp.size(), sumOp<label>()) > 0)
{
boundBox bb(point::max, point::min);
forAll (mp, i)
if (pp.empty())
{
bb.min() = min(bb.min(), pts[mp[i]]);
bb.max() = max(bb.max(), pts[mp[i]]);
Info<< setw(34) << "ok (empty)";
}
else if (pTyp == primitivePatch::MANIFOLD)
{
if (pp.checkPointManifold(true, &points))
{
Info<< setw(34)
<< "multiply connected (shared point)";
}
else
{
Info<< setw(34) << "ok (closed singly connected)";
}
// Add points on non-manifold edges to make set complete
pp.checkTopology(false, &points);
}
else
{
pp.checkTopology(false, &points);
if (pTyp == primitivePatch::OPEN)
{
Info<< setw(34)
<< "ok (non-closed singly connected)";
}
else
{
Info<< setw(34)
<< "multiply connected (shared edge)";
}
}
reduce(bb.min(), minOp<vector>());
reduce(bb.max(), maxOp<vector>());
Pout<< ' ' << bb;
}
if (allGeometry)
{
const pointField& pts = pp.points();
const labelList& mp = pp.meshPoints();
if (returnReduce(mp.size(), sumOp<label>()) > 0)
{
boundBox bb(point::max, point::min);
forAll (mp, i)
{
bb.min() = min(bb.min(), pts[mp[i]]);
bb.max() = max(bb.max(), pts[mp[i]]);
}
reduce(bb.min(), minOp<vector>());
reduce(bb.max(), maxOp<vector>());
Info<< ' ' << bb;
}
}
Info<< endl;
}
Pout<< endl;
}
if (points.size())
{
Pout<< " <<Writing " << points.size()
Info<< " <<Writing " << returnReduce(points.size(), sumOp<label>())
<< " conflicting points to set "
<< points.name() << endl;
@ -392,7 +412,7 @@ Foam::label Foam::checkTopology
points.write();
}
//Pout.setf(ios_base::right);
//Info.setf(ios_base::right);
}
// Force creation of all addressing if requested.

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -115,6 +115,7 @@ int main(int argc, char *argv[])
runTimeMaster
)
);
const word oldInstance = masterMesh.pointsInstance();
Info<< "Reading mesh to add for time = " << runTimeToAdd.timeName() << nl;
@ -139,7 +140,13 @@ int main(int argc, char *argv[])
masterMesh.addMesh(meshToAdd);
masterMesh.merge();
masterMesh.polyMesh::write();
if (overwrite)
{
masterMesh.setInstance(oldInstance);
}
masterMesh.write();
Info<< "\nEnd\n" << endl;

View File

@ -55,6 +55,8 @@ Description
this if you don't mind having disconnected domains in a single region.
This option requires all cells to be in one (and one only) cellZone.
- prefixRegion prefixes all normal patches with region name (interface
(patches already have region name prefix)
- Should work in parallel.
cellZones can differ on either side of processor boundaries in which case
@ -389,6 +391,40 @@ void reorderPatches
}
// Prepend prefix to selected patches.
void renamePatches
(
fvMesh& mesh,
const word& prefix,
const labelList& patchesToRename
)
{
polyBoundaryMesh& polyPatches =
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
forAll(patchesToRename, i)
{
label patchI = patchesToRename[i];
polyPatch& pp = polyPatches[patchI];
if (isA<coupledPolyPatch>(pp))
{
WarningIn
(
"renamePatches(fvMesh&, const word&, const labelList&"
) << "Encountered coupled patch " << pp.name()
<< ". Will only rename the patch itself,"
<< " not any referred patches."
<< " This might have to be done by hand."
<< endl;
}
pp.name() = prefix + '_' + pp.name();
}
// Recalculate any demand driven data (e.g. group to name lookup)
polyPatches.updateMesh();
}
template<class GeoField>
void subsetVolFields
(
@ -987,6 +1023,7 @@ void createAndWriteRegion
const fvMesh& mesh,
const labelList& cellRegion,
const wordList& regionNames,
const bool prefixRegion,
const labelList& faceToInterface,
const labelList& interfacePatches,
const label regionI,
@ -1017,6 +1054,7 @@ void createAndWriteRegion
addedPatches.insert(interfacePatches[interfaceI]+1);
}
Info<< "Mapping fields" << endl;
// Map existing fields
@ -1109,6 +1147,7 @@ void createAndWriteRegion
// Create reordering list to move patches-to-be-deleted to end
labelList oldToNew(newPatches.size(), -1);
DynamicList<label> sharedPatches(newPatches.size());
label newI = 0;
Info<< "Deleting empty patches" << endl;
@ -1122,7 +1161,12 @@ void createAndWriteRegion
{
if (returnReduce(pp.size(), sumOp<label>()) > 0)
{
oldToNew[patchI] = newI++;
oldToNew[patchI] = newI;
if (!addedPatches.found(patchI))
{
sharedPatches.append(newI);
}
newI++;
}
}
}
@ -1152,6 +1196,15 @@ void createAndWriteRegion
reorderPatches(newMesh(), oldToNew, nNewPatches);
// Rename shared patches with region name
if (prefixRegion)
{
Info<< "Prefixing patches with region name" << endl;
renamePatches(newMesh(), regionNames[regionI], sharedPatches);
}
Info<< "Writing new mesh" << endl;
newMesh().setInstance(newMeshInstance);
@ -1672,6 +1725,11 @@ int main(int argc, char *argv[])
"useFaceZones",
"use faceZones to patch inter-region faces instead of single patch"
);
argList::addBoolOption
(
"prefixRegion",
"prefix region name to all patches, not just coupling patches"
);
#include "setRootCase.H"
#include "createTime.H"
@ -1696,6 +1754,8 @@ int main(int argc, char *argv[])
const bool detectOnly = args.optionFound("detectOnly");
const bool sloppyCellZones = args.optionFound("sloppyCellZones");
const bool useFaceZones = args.optionFound("useFaceZones");
const bool prefixRegion = args.optionFound("prefixRegion");
if
(
@ -2226,6 +2286,7 @@ int main(int argc, char *argv[])
mesh,
cellRegion,
regionNames,
prefixRegion,
faceToInterface,
interfacePatches,
regionI,
@ -2246,6 +2307,7 @@ int main(int argc, char *argv[])
mesh,
cellRegion,
regionNames,
prefixRegion,
faceToInterface,
interfacePatches,
regionI,
@ -2266,6 +2328,7 @@ int main(int argc, char *argv[])
mesh,
cellRegion,
regionNames,
prefixRegion,
faceToInterface,
interfacePatches,
regionI,

View File

@ -56,7 +56,6 @@ EXE_LIBS = \
-lsolidMixtureProperties \
-lsolidParticle \
-lsolidProperties \
-lsolid \
-lspecie \
-lsurfaceFilmModels \
-lsurfMesh \

View File

@ -13,6 +13,5 @@ EXE_LIBS = \
-lfiniteVolume \
-lgenericPatchFields \
-lspecie \
-lsolid \
-lfluidThermophysicalModels \
-lsolidThermo

View File

@ -136,7 +136,7 @@ int main(int argc, char *argv[])
}
// Create G field - used by RAS wall functions
volScalarField G("RASModel::G", nut*2*sqr(S));
volScalarField G("RASModel.G", nut*2*sqr(S));
//--- Read and modify turbulence fields

View File

@ -721,16 +721,34 @@ int main(int argc, char *argv[])
deleteBox(surf, bb, true, edgeStat);
}
const Switch manifoldEdges =
subsetDict.lookupOrDefault<Switch>("manifoldEdges", "no");
const Switch nonManifoldEdges =
subsetDict.lookupOrDefault<Switch>("nonManifoldEdges", "yes");
if (manifoldEdges)
if (!nonManifoldEdges)
{
Info<< "Removing all non-manifold edges" << endl;
Info<< "Removing all non-manifold edges"
<< " (edges with > 2 connected faces)" << endl;
forAll(edgeStat, edgeI)
{
if (surf.edgeFaces()[edgeI].size() != 2)
if (surf.edgeFaces()[edgeI].size() > 2)
{
edgeStat[edgeI] = surfaceFeatures::NONE;
}
}
}
const Switch openEdges =
subsetDict.lookupOrDefault<Switch>("openEdges", "yes");
if (!openEdges)
{
Info<< "Removing all open edges"
<< " (edges with 1 connected face)" << endl;
forAll(edgeStat, edgeI)
{
if (surf.edgeFaces()[edgeI].size() == 1)
{
edgeStat[edgeI] = surfaceFeatures::NONE;
}

View File

@ -59,15 +59,21 @@ surface2.nas
{
// Use a plane to select feature edges
// (normal)(basePoint)
// Keep only edges that intersect the plane will be included
plane (1 0 0)(0 0 0);
// Select feature edges using a box
// (minPt)(maxPt)
// Keep edges inside the box:
insideBox (0 0 0)(1 1 1);
// Keep edges outside the box:
outsideBox (0 0 0)(1 1 1);
// Remove any non-manifold (open or > 2 connected faces) edges
manifoldEdges no;
// Keep nonManifold edges (edges with >2 connected faces)
nonManifoldEdges yes;
// Keep open edges (edges with 1 connected face)
openEdges yes;
}
addFeatures

View File

@ -1,37 +0,0 @@
#!/usr/bin/perl -w
use strict;
use File::Find ();
# -----------------------------------------------------------------------------
#
# Script
# find-junkFiles
#
# Description
# Search for "junk" files left over from editor, core, CVS, etc.
#
# - print filename only
#
# -----------------------------------------------------------------------------
sub wanted {
return unless -f $_;
if (
m{^\.?.+~$} ## editor backup
or m{^\#.+\#$} ## editor autosave
or m{^\.\#.+$} ## cvs replace update (eg, ".#test.c.1.3")
or m{^core(\.\d+)?$} ## core dump
) {
print "$File::Find::name\n";
}
}
## Traverse desired filesystems
for my $dir (@ARGV) {
no warnings 'File::Find';
warn "(**) checking '$dir' ...\n";
File::Find::find( { wanted => \&wanted }, $dir );
}

View File

@ -1,46 +0,0 @@
#!/usr/bin/perl -w
use strict;
use File::Find ();
# -----------------------------------------------------------------------------
#
# Script
# find-longlines
#
# Description
# Search for *.[CH] files that exceed the 80-column width
#
# - print filename lineNumber and offending line (with truncation point)
#
# -----------------------------------------------------------------------------
my $maxlen = 80;
my $re_filespec = qr{^.+\.[CH]$};
my $count;
sub wanted {
unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
return;
}
local @ARGV = $_;
while (<>) {
chomp;
s{\s+$}{}; # trim
if ( $maxlen < length ) {
$count++;
substr( $_, $maxlen, 0 ) = "||->>"; # show truncation point
print "$File::Find::name $. $_\n";
}
}
close ARGV;
}
## Traverse desired filesystems
for my $dir (@ARGV) {
no warnings 'File::Find';
warn "(**) checking '$dir' ...\n";
File::Find::find( { wanted => \&wanted }, $dir );
}

View File

@ -1,73 +0,0 @@
#!/usr/bin/perl -w
use strict;
use File::Find ();
# -----------------------------------------------------------------------------
#
# Script
# find-placeholderDescription
#
# Description
# Search for *.[H] files with a Description that looks like it is
# a placeholder
# eg, Foam::className
#
# - print filename '#' and the description
#
# -----------------------------------------------------------------------------
my $minLength = 16;
my $re_filespec = qr{^.+\.[H]$};
# for the convenience of &wanted calls, including -eval statements:
## use vars qw( *name *dir *prune );
## *name = *File::Find::name;
## *dir = *File::Find::dir;
## *prune = *File::Find::prune;
sub wanted {
unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
return;
}
my ( $tag, $description );
local @ARGV = $_;
while (<>) {
my $name;
## examine the class/typedef name
if (/^(Class|Typedef)\s*$/) {
$_ = <>;
($tag) = split;
}
if (/^Description\s*$/) {
$_ = <>;
( $description = $_ ) =~ s{^\s+|\s+$}{}g;
# remove trailing punctuation as being noise
$description =~ s{\s*[.,:]+$}{};
last;
}
}
$description ||= '';
## we have 'Class/Typedef' tag
if ( defined $tag ) {
# description looks like a class name
if (
$description =~ m{^\w+(::\w+)+$}
) {
print "$File::Find::name # $description\n";
}
}
}
## Traverse desired filesystems
for my $dir (@ARGV) {
no warnings 'File::Find';
warn "(**) checking '$dir' ...\n";
File::Find::find( { wanted => \&wanted }, $dir );
}

View File

@ -1,48 +0,0 @@
#!/usr/bin/perl -w
use strict;
use File::Find ();
# -----------------------------------------------------------------------------
#
# Script
# find-retagged
#
# Description
# Search for *.[H] files with 'InClass', 'InNamespace' or 'Type'
# starting in the first column.
# In some places these could removed. In other places they should be
# replaced with a 'Typedef'
# - print filename and the tag (InClass|InNamespace|Type)
#
# -----------------------------------------------------------------------------
my $re_filespec = qr{^.+\.[H]$};
# for the convenience of &wanted calls, including -eval statements:
## use vars qw( *name *dir *prune );
## *name = *File::Find::name;
## *dir = *File::Find::dir;
## *prune = *File::Find::prune;
sub wanted {
unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
return;
}
local @ARGV = $_;
while (<>) {
if (/^(InClass|InNamespace|Type)\s*$/) {
print "$File::Find::name $1 line=$.\n";
}
}
close ARGV;
}
## Traverse desired filesystems
for my $dir (@ARGV) {
no warnings 'File::Find';
warn "(**) checking '$dir' ...\n";
File::Find::find( { wanted => \&wanted }, $dir );
}

View File

@ -1,124 +0,0 @@
#!/usr/bin/perl -w
use strict;
use File::Find ();
# -----------------------------------------------------------------------------
#
# Script
# find-suspiciousTags
#
# Description
# Search for *.[CH] files with 'Class' or 'Namespace' starting in the
# first column but without a class being defined anywhere in the file.
# These are probably incorrect or should be at least be
# changed to 'In Class' / 'In Namespace' for now.
# - print filename and 'InClass' or 'InNamespace'
#
# Find the namespaces used in the files and compare these to what is
# given on the 'Class' information
# - print filename and corrected Class
#
# Check for trailing garbage in the 'Class' information
# - print filename and 'ClassWithTrailingInformation'
#
# -----------------------------------------------------------------------------
my $re_filespec = qr{^.+\.[CH]$};
# for the convenience of &wanted calls, including -eval statements:
## use vars qw( *name *dir *prune );
## *name = *File::Find::name;
## *dir = *File::Find::dir;
## *prune = *File::Find::prune;
sub wanted {
unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
return;
}
# potential className
( my $fileClass = $_ ) =~ s{\.[A-Za-z]$}{};
my ( $namespace, $currentClass, %classes, %found ) = ('');
local @ARGV = $_;
while (<>) {
my $name;
## look for (class|namespace), deal with repeats
if ( ($name) = /^\s*class\s+(\w+)\s*/ ) {
$classes{$name}++;
}
elsif ( ($name) = /^\s*namespace\s+(\w+)\s*/ ) {
## reset if 'Foam' namespace appears again
$namespace = '' if $name eq "Foam";
$namespace .= $name . "::";
}
elsif (/^(Class|Namespace)\s*/) {
$found{$1}++;
## examine the class name
if (/^Class\s*$/) {
$_ = <>;
my @trailing;
( $currentClass, @trailing ) = split;
if (@trailing) {
$found{-trailing}++;
}
# the next line should be blank
$_ = <>;
$_ ||= '';
if (not /^\s*$/) {
$found{-spacing}++;
}
}
}
}
# always report if the Class has trailing information
if ( delete $found{-trailing} ) {
print "$File::Find::name ClassWithTrailingInformation\n";
}
# always report if the Class has spacing problem
if ( delete $found{-spacing} ) {
print "$File::Find::name ClassWithSpacingIssue\n";
}
if (%classes) {
## we have 'Class' tag
if ( defined $currentClass ) {
if ($namespace) {
my ($currentNamespace) = $currentClass =~ m{^(.+::)};
$currentNamespace ||= '';
if ( $namespace ne $currentNamespace ) {
$currentClass =~ s{^(.+::)}{};
$currentClass ||= $fileClass;
print "$File::Find::name $namespace$currentClass\n";
}
}
elsif ( not $currentClass ) {
## supply a class name
print "$File::Find::name $fileClass\n";
}
}
}
else {
## no classes, all tags are deemed suspicious
for ( sort keys %found ) {
print "$File::Find::name In$_\n";
}
}
}
## Traverse desired filesystems
for my $dir (@ARGV) {
no warnings 'File::Find';
warn "(**) checking '$dir' ...\n";
File::Find::find( { wanted => \&wanted }, $dir );
}

View File

@ -1,54 +0,0 @@
#!/usr/bin/perl -w
use strict;
use File::Find ();
# -----------------------------------------------------------------------------
#
# Script
# find-templateInComments
#
# Description
# Search for *.[CH] files with '<xxx>' tags within the first comment block
# These likely need to be quoted as '\<xxx\>' for Doxygen.
# - print filename and lineNumber
#
# -----------------------------------------------------------------------------
my $re_filespec = qr{^.+\.[CH]$};
# for the convenience of &wanted calls, including -eval statements:
## use vars qw( *name *dir *prune );
## *name = *File::Find::name;
## *dir = *File::Find::dir;
## *prune = *File::Find::prune;
sub wanted {
unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
return;
}
local @ARGV = $_;
while (<>) {
if (m{^\s*/\*} ... m{\*/})
{
if (m{\<\s*\w+\s*\>}) {
print "$File::Find::name line=$.\n";
}
if (m{\*/}) {
last;
}
}
}
close ARGV;
}
## Traverse desired filesystems
for my $dir (@ARGV) {
no warnings 'File::Find';
warn "(**) checking '$dir' ...\n";
File::Find::find( { wanted => \&wanted }, $dir );
}

View File

@ -1,77 +0,0 @@
#!/usr/bin/perl -w
use strict;
use File::Find ();
# -----------------------------------------------------------------------------
#
# Script
# find-tinyDescription
#
# Description
# Search for *.[H] files with 'Class' starting in the first column
# and a missing Description, or a tiny Description.
# A tiny Description is less than XX letters and does not resemble
# the class name. We'll look for descriptions matching the class name
# in a later pass.
#
# - print filename '#' and the description
#
# -----------------------------------------------------------------------------
my $minLength = 16;
my $re_filespec = qr{^.+\.[H]$};
# for the convenience of &wanted calls, including -eval statements:
## use vars qw( *name *dir *prune );
## *name = *File::Find::name;
## *dir = *File::Find::dir;
## *prune = *File::Find::prune;
sub wanted {
unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
return;
}
my ( $currentClass, $description );
local @ARGV = $_;
while (<>) {
my $name;
## examine the class name
if (/^Class\s*$/) {
$_ = <>;
($currentClass) = split;
}
if (/^Description\s*$/) {
$_ = <>;
( $description = $_ ) =~ s{^\s+|\s+$}{}g;
# remove trailing punctuation as being noise
$description =~ s{\s*[.,:]+$}{};
last;
}
}
$description ||= '';
## we have 'Class' tag
if ( defined $currentClass ) {
# description doesnt looks like a class name
if (
$description !~ m{^\w+(::\w+)+$}
and
(length $description < $minLength or $description =~ m{^\S+$})
) {
print "$File::Find::name # $description\n";
}
}
}
## Traverse desired filesystems
for my $dir (@ARGV) {
no warnings 'File::Find';
warn "(**) checking '$dir' ...\n";
File::Find::find( { wanted => \&wanted }, $dir );
}

View File

@ -1,110 +0,0 @@
#!/bin/sh
# -----------------------------------------------------------------------------
# ========= |
# \\ / 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/>.
#
# Script
# fix-Class
#
# Description
# Process the lists given on the command line.
# Column 1 = fileName, column 2 = Class or action
# See find-suspiciousTags for details.
#
# 1. fix ClassWithTrailingInformation by hand
# 2. InClass and InNamespace fixup
# 3. change
# |Class
# | anything
# ->
# |Class
# | className
#
# -----------------------------------------------------------------------------
# stop if trailing junk has been detected
for fileList
do
[ -f $fileList -a -r $fileList ] || {
echo "cannot read file list: $fileList"
exit 1
}
grep ClassWithTrailingInformation $fileList
if [ $? = 0 ]
then
echo "#"
echo "# fix ClassWithTrailingInformation by hand"
echo "#"
exit 99
fi
done
for fileList
do
# repair InClass, InNamespace
for tag in Class Namespace
do
backup=".repair-In$tag"
for file in $(sed -n -e "s/In$tag *$//p" $fileList)
do
echo "repair In$tag: $file"
perl -i$backup -pe "s/^$tag/In$tag/" $file
done
done
# repair the class names (with namespace)
backup=".repair-reclassify"
cat $fileList | while read fileName className
do
# use classes with '::' separator to avoid too
# many false positives
perl -i$backup -x $0 $fileName $className
done
done
exit 0
# ---------------------------------------------------------------- end-of-file
# embedded Perl program
#!/usr/bin/perl -w
use strict;
# args: fileName className
# - className must contain '::'
my $className = pop;
@ARGV == 1 and ($className ||= '') =~ /::/ or exit 1;
warn "repair: @ARGV $className\n";
while (<>)
{
if (/^Class\s*$/) {
print;
$_ = <>; # get and discard the next line
$_ = " $className\n";
}
print;
}
# ---------------------------------------------------------------- end-of-file

View File

@ -981,15 +981,29 @@ DimensionSets
Cd Cd [ 0 0 0 0 0 0 1 ] 1.0;
// Derived units
Pa Pa [ kg^1 m^-2 ] 1.0;
Hz Hz [ s^-1 ] 1.0;
N N [ kg m s^-2 ] 1.0;
Pa Pa [ N m^-2 ] 1.0;
J J [ N m ] 1.0;
W W [ J s^-1 ] 1.0;
// Scaled units
mm mm [ kg^1 m^-2 ] 1e-3;
// Some non-symbolic ones
area area [m^2] 1.0;
volume volume [m^3] 1.0;
density density [ kg m^-3 ] 1.0;
acceleration acceleration [ m s^-2 ] 1.0;
kinematicPressure kinematicPressure [ Pa density^-1 ] 1.0;
// Scaled units. Only allowed in dymensionedType (dimensionedScalar,
// dimensionedVector etc.) and UniformDimensionedField, not
// in DimensionedField or GeometricField
cm cm [ m ] 1e-2;
mm mm [ m ] 1e-3;
km km [ m ] 1e3;
// Set of units used for printing. Can be any basic or derived
// but not scaled (only supported for dimensionedScalar, etc)
writeUnits (kg m s K mol A Cd);
//writeUnits (kg m s K mol A Cd);
}
}

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -167,6 +167,26 @@ void getSymbolForRaw
}
void error::safePrintStack(std::ostream& os)
{
// Get raw stack symbols
void *array[100];
size_t size = backtrace(array, 100);
char **strings = backtrace_symbols(array, size);
// See if they contain function between () e.g. "(__libc_start_main+0xd0)"
// and see if cplus_demangle can make sense of part before +
for (size_t i = 0; i < size; i++)
{
string msg(strings[i]);
fileName programFile;
word address;
os << '#' << label(i) << '\t' << msg << std::endl;
}
}
void error::printStack(Ostream& os)
{
// Reads the starting addresses for the dynamically linked libraries

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,8 +29,7 @@ Description
SourceFiles
ISstreamI.H
ISread.C
ISreadToken.C
ISstream.C
\*---------------------------------------------------------------------------*/

View File

@ -85,8 +85,8 @@ void Foam::Time::readDict()
{
if
(
secondaryWriteControl_
== wcTimeStep && label(secondaryWriteInterval_) < 1
secondaryWriteControl_ == wcTimeStep
&& label(secondaryWriteInterval_) < 1
)
{
FatalIOErrorIn("Time::readDict()", controlDict_)

View File

@ -189,7 +189,7 @@ Foam::dictionary::dictionary
parent_(parentDict)
{
transfer(dict());
name() = parentDict.name() + "::" + name();
name() = parentDict.name() + '.' + name();
}
@ -622,7 +622,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
}
else
{
return dictionary(*this, dictionary(name() + "::" + keyword));
return dictionary(*this, dictionary(name() + '.' + keyword));
}
}
else
@ -690,7 +690,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
{
entryPtr->name() = name() + "::" + entryPtr->keyword();
entryPtr->name() = name() + '.' + entryPtr->keyword();
if (entryPtr->keyword().isPattern())
{
@ -718,7 +718,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
{
entryPtr->name() = name() + "::" + entryPtr->keyword();
entryPtr->name() = name() + '.' + entryPtr->keyword();
IDLList<entry>::append(entryPtr);
if (entryPtr->keyword().isPattern())
@ -925,7 +925,7 @@ bool Foam::dictionary::changeKeyword
// change name and HashTable, but leave DL-List untouched
iter()->keyword() = newKeyword;
iter()->name() = name() + "::" + newKeyword;
iter()->name() = name() + '.' + newKeyword;
hashedEntries_.erase(oldKeyword);
hashedEntries_.insert(newKeyword, iter());

View File

@ -117,7 +117,7 @@ public:
{
const word scopedName = name_.name();
string::size_type i = scopedName.rfind(':');
string::size_type i = scopedName.rfind('.');
if (i == scopedName.npos)
{

View File

@ -37,7 +37,7 @@ Foam::dictionary::dictionary
Istream& is
)
:
dictionaryName(parentDict.name() + "::" + name),
dictionaryName(parentDict.name() + '.' + name),
parent_(parentDict)
{
read(is);

View File

@ -27,6 +27,7 @@ License
#include "dictionary.H"
#include "IFstream.H"
#include "addToMemberFunctionSelectionTable.H"
#include "stringOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -68,10 +69,14 @@ namespace functionEntries
Foam::fileName Foam::functionEntries::includeEntry::includeFileName
(
Istream& is
Istream& is,
const dictionary& dict
)
{
fileName fName(is);
// Substitute dictionary entries
stringOps::inplaceExpand(fName, dict);
// Substitute remaining environment variables
fName.expand();
if (fName.empty() || fName.isAbsolute())
@ -94,7 +99,7 @@ bool Foam::functionEntries::includeEntry::execute
Istream& is
)
{
const fileName fName(includeFileName(is));
const fileName fName(includeFileName(is, parentDict));
IFstream ifs(fName);
if (ifs)
@ -129,7 +134,7 @@ bool Foam::functionEntries::includeEntry::execute
Istream& is
)
{
const fileName fName(includeFileName(is));
const fileName fName(includeFileName(is, parentDict));
IFstream ifs(fName);
if (ifs)

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,7 +77,7 @@ protected:
// Protected Member Functions
//- Read the include fileName from Istream, expand and return
static fileName includeFileName(Istream&);
static fileName includeFileName(Istream&, const dictionary&);
public:

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,7 +69,7 @@ bool Foam::functionEntries::includeIfPresentEntry::execute
Istream& is
)
{
const fileName fName(includeFileName(is));
const fileName fName(includeFileName(is, parentDict));
IFstream ifs(fName);
if (ifs)
@ -92,7 +92,7 @@ bool Foam::functionEntries::includeIfPresentEntry::execute
Istream& is
)
{
const fileName fName(includeFileName(is));
const fileName fName(includeFileName(is, parentDict));
IFstream ifs(fName);
if (ifs)

View File

@ -81,7 +81,7 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& is)
entry(key),
ITstream(is)
{
name() += "::" + keyword();
name() += '.' + keyword();
}

View File

@ -186,7 +186,7 @@ Foam::primitiveEntry::primitiveEntry
entry(key),
ITstream
(
is.name() + "::" + key,
is.name() + '.' + key,
tokenList(10),
is.format(),
is.version()
@ -201,7 +201,7 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is)
entry(key),
ITstream
(
is.name() + "::" + key,
is.name() + '.' + key,
tokenList(10),
is.format(),
is.version()

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -162,6 +162,10 @@ public:
operator dictionary() const;
//- Helper function to print a stack (if OpenFOAM IO not yet
// initialised)
static void safePrintStack(std::ostream&);
//- Helper function to print a stack
static void printStack(Ostream&);

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -82,7 +82,13 @@ Description
) \
{ \
construct##argNames##ConstructorTables(); \
argNames##ConstructorTablePtr_->insert(lookup, New); \
if (!argNames##ConstructorTablePtr_->insert(lookup, New)) \
{ \
std::cerr<< "Duplicate entry " << lookup \
<< " in runtime selection table " << #baseType \
<< std::endl; \
error::safePrintStack(std::cerr); \
} \
} \
\
~add##argNames##ConstructorToTable() \
@ -167,11 +173,20 @@ Description
) \
{ \
construct##argNames##ConstructorTables(); \
argNames##ConstructorTablePtr_->insert \
if \
( \
lookup, \
New##baseType \
); \
!argNames##ConstructorTablePtr_->insert \
( \
lookup, \
New##baseType \
) \
) \
{ \
std::cerr<< "Duplicate entry " << lookup \
<< " in runtime selection table " << #baseType \
<< std::endl; \
error::safePrintStack(std::cerr); \
} \
} \
\
~add##argNames##ConstructorToTable() \

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -105,83 +105,6 @@ void Foam::dimensionSet::reset(const dimensionSet& ds)
}
Foam::string Foam::dimensionSet::asText() const
{
OStringStream buf;
bool Dimensionless = true;
for (int Dimension=0; Dimension < dimensionSet::nDimensions-1; ++Dimension)
{
const scalar& expt = exponents_[Dimension];
if (expt < smallExponent && expt > -smallExponent)
{
continue;
}
if (Dimensionless)
{
Dimensionless = false;
}
else
{
buf << ' ';
}
// note: currently only handle SI
switch (Dimension)
{
case MASS:
buf << "kg";
break;
case LENGTH:
buf << "m";
break;
case TIME:
buf << "s";
break;
case TEMPERATURE:
buf << "K";
break;
case MOLES:
buf << "mol";
break;
case CURRENT:
buf << "A";
break;
case LUMINOUS_INTENSITY:
buf << "Cd";
break;
default:
buf << "??"; // this shouldn't be - flag as being weird
break;
}
if (expt != 1)
{
buf << '^' << expt;
}
}
if (Dimensionless)
{
return "none";
}
else
{
return buf.str();
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
Foam::scalar Foam::dimensionSet::operator[](const dimensionType type) const
@ -196,6 +119,18 @@ Foam::scalar& Foam::dimensionSet::operator[](const dimensionType type)
}
Foam::scalar Foam::dimensionSet::operator[](const label type) const
{
return exponents_[type];
}
Foam::scalar& Foam::dimensionSet::operator[](const label type)
{
return exponents_[type];
}
bool Foam::dimensionSet::operator==(const dimensionSet& ds) const
{
for (int Dimension=0; Dimension < nDimensions; ++Dimension)

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -40,10 +40,12 @@ SourceFiles
#ifndef dimensionSet_H
#define dimensionSet_H
#include "scalar.H"
#include "bool.H"
#include "dimensionedScalarFwd.H"
#include "className.H"
#include "scalarField.H"
#include "PtrList.H"
#include "HashTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,6 +55,7 @@ namespace Foam
// Forward declaration of friend functions and operators
class dimensionSet;
class dimensionSets;
// Friend functions
@ -140,6 +143,64 @@ public:
private:
// Private classes
class tokeniser
{
// Private data
Istream& is_;
List<token> tokens_;
label start_;
label size_;
// Private Member Functions
void push(const token&);
token pop();
void unpop(const token&);
public:
// Constructors
tokeniser(Istream&);
// Member Functions
Istream& stream()
{
return is_;
}
bool hasToken() const;
token nextToken();
void putBack(const token&);
void splitWord(const word&);
static bool valid(char c);
static label priority(const token& t);
};
dimensionedScalar parse
(
const label lastPrior,
tokeniser& tis,
const HashTable<dimensionedScalar>&
) const;
// private data
// dimensionSet stored as an array of dimension exponents
@ -189,14 +250,56 @@ public:
void reset(const dimensionSet&);
//- Return a text representation for added readability
string asText() const;
// I/O
//- Read using provided units. Used only in initial parsing
Istream& read
(
Istream& is,
scalar& multiplier,
const dictionary&
);
//- Read using provided units
Istream& read
(
Istream& is,
scalar& multiplier,
const HashTable<dimensionedScalar>&
);
//- Read using system units
Istream& read
(
Istream& is,
scalar& multiplier
);
//- Write using provided units
Ostream& write
(
Ostream& os,
scalar& multiplier,
const dimensionSets&
) const;
//- Write using system units
Ostream& write
(
Ostream& os,
scalar& multiplier
) const;
// Member operators
scalar operator[](const dimensionType) const;
scalar& operator[](const dimensionType);
scalar operator[](const label) const;
scalar& operator[](const label);
bool operator==(const dimensionSet&) const;
bool operator!=(const dimensionSet&) const;

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,7 @@ License
#include "dimensionSet.H"
#include "IOstreams.H"
#include "dimensionedScalar.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -34,46 +35,670 @@ Foam::dimensionSet::dimensionSet(Istream& is)
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::dimensionSet::tokeniser::tokeniser(Istream& is)
:
is_(is),
tokens_(100),
start_(0),
size_(0)
{}
Foam::Istream& Foam::operator>>(Istream& is, dimensionSet& dset)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::dimensionSet::tokeniser::push(const token& t)
{
// Read begining of dimensionSet
if (token(is) != token::BEGIN_SQR)
label end = (start_+size_)%tokens_.size();
tokens_[end] = t;
if (size_ == tokens_.size())
{
Info<< "expected a " << token::BEGIN_SQR << " in dimensionSet"
<< endl << "in stream " << is.info() << endl;
start_ = tokens_.fcIndex(start_);
}
else
{
size_++;
}
}
Foam::token Foam::dimensionSet::tokeniser::pop()
{
token t = tokens_[start_];
start_ = tokens_.fcIndex(start_);
--size_;
return t;
}
void Foam::dimensionSet::tokeniser::unpop(const token& t)
{
++size_;
start_ = tokens_.rcIndex(start_);
tokens_[start_] = t;
}
bool Foam::dimensionSet::tokeniser::hasToken() const
{
return size_ || is_.good();
}
bool Foam::dimensionSet::tokeniser::valid(char c)
{
return
(
!isspace(c)
&& c != '"' // string quote
&& c != '\'' // string quote
&& c != '/' // div
&& c != ';' // end statement
&& c != '{' // beg subdict
&& c != '}' // end subdict
&& c != '(' // beg expr
&& c != ')' // end expr
&& c != '[' // beg dim
&& c != ']' // end dim
&& c != '^' // power
&& c != '*' // mult
);
}
Foam::label Foam::dimensionSet::tokeniser::priority(const token& t)
{
if (!t.isPunctuation())
{
return 0;
}
else if
(
t.pToken() == token::MULTIPLY
|| t.pToken() == token::DIVIDE
)
{
return 2;
}
else if (t.pToken() == '^')
{
return 3;
}
else
{
return 0;
}
}
void Foam::dimensionSet::tokeniser::splitWord(const word& w)
{
size_t start = 0;
for (size_t i=0; i<w.size(); ++i)
{
if (!valid(w[i]))
{
if (i > start)
{
word subWord = w(start, i-start);
if (isdigit(subWord[0]) || subWord[0] == token::SUBTRACT)
{
push(token(readLabel(IStringStream(subWord)())));
}
else
{
push(token(subWord));
}
}
if (w[i] != token::SPACE)
{
if (isdigit(w[i]))
{
push(token(readLabel(IStringStream(w[i])())));
}
else
{
push(token::punctuationToken(w[i]));
}
}
start = i+1;
}
}
if (start < w.size())
{
word subWord = w(start, w.size()-start);
if (isdigit(subWord[0]) || subWord[0] == token::SUBTRACT)
{
push(token(readLabel(IStringStream(subWord)())));
}
else
{
push(token(subWord));
}
}
}
Foam::token Foam::dimensionSet::tokeniser::nextToken()
{
if (size_ == 0)
{
token t(is_);
if (t.isWord())
{
splitWord(t.wordToken());
return pop();
}
else
{
return t;
}
}
else
{
return pop();
}
}
void Foam::dimensionSet::tokeniser::putBack(const token& t)
{
if (size_ == 0)
{
push(t);
}
else
{
unpop(t);
}
}
Foam::dimensionedScalar Foam::dimensionSet::parse
(
const label lastPrior,
tokeniser& tis,
const HashTable<dimensionedScalar>& readSet
) const
{
dimensionedScalar ds("", dimless, 1.0);
// Get initial token
token nextToken(tis.nextToken());
// Store type of last token read. Used to detect two consecutive
// symbols and assume multiplication
bool haveReadSymbol = false;
while (true)
{
if (nextToken.isWord())
{
const word& unitName = nextToken.wordToken();
const dimensionedScalar& unitDim = readSet[unitName];
ds.dimensions() *= unitDim.dimensions();
ds.value() *= unitDim.value();
haveReadSymbol = true;
}
else if (nextToken.isNumber())
{
// no dimensions, just value
ds.value() *= nextToken.number();
haveReadSymbol = true;
}
else if (nextToken.isPunctuation())
{
label nextPrior = tokeniser::priority(nextToken);
if (nextToken.pToken() == token::BEGIN_SQR)
{
// No idea when this will happen
tis.putBack(nextToken);
return ds;
}
else if (nextToken.pToken() == token::END_SQR)
{
tis.putBack(nextToken);
return ds;
}
else if (nextToken.pToken() == token::BEGIN_LIST)
{
dimensionedScalar sub(parse(nextPrior, tis, readSet));
token t = tis.nextToken();
if (!t.isPunctuation() || t.pToken() != token::END_LIST)
{
FatalIOErrorIn
(
"dimensionSet::parse"
"(const label, tokeniser&"
", const HashTable<dimensionedScalar>&)",
tis.stream()
) << "Illegal token " << t << exit(FatalIOError);
}
ds.dimensions() *= sub.dimensions();
ds.value() *= sub.value();
haveReadSymbol = true;
}
else if (nextToken.pToken() == token::END_LIST)
{
tis.putBack(nextToken);
return ds;
}
else if (nextToken.pToken() == token::MULTIPLY)
{
if (nextPrior > lastPrior)
{
dimensionedScalar sub(parse(nextPrior, tis, readSet));
ds.dimensions() *= sub.dimensions();
ds.value() *= sub.value();
}
else
{
// Restore token
tis.putBack(nextToken);
return ds;
}
haveReadSymbol = false;
}
else if (nextToken.pToken() == token::DIVIDE)
{
if (nextPrior > lastPrior)
{
dimensionedScalar sub(parse(nextPrior, tis, readSet));
ds.dimensions() /= sub.dimensions();
ds.value() /= sub.value();
}
else
{
tis.putBack(nextToken);
return ds;
}
haveReadSymbol = false;
}
else if (nextToken.pToken() == '^')
{
if (nextPrior > lastPrior)
{
dimensionedScalar exp(parse(nextPrior, tis, readSet));
ds.dimensions().reset(pow(ds.dimensions(), exp.value()));
ds.value() = Foam::pow(ds.value(), exp.value());
}
else
{
tis.putBack(nextToken);
return ds;
}
haveReadSymbol = false;
}
else
{
FatalIOErrorIn
(
"dimensionSet::parse"
"(const label, tokeniser&"
", const HashTable<dimensionedScalar>&)",
tis.stream()
) << "Illegal token " << nextToken << exit(FatalIOError);
}
}
else
{
FatalIOErrorIn
(
"dimensionSet::parse"
"(const label, tokeniser&"
", const HashTable<dimensionedScalar>&)",
tis.stream()
) << "Illegal token " << nextToken << exit(FatalIOError);
}
if (!tis.hasToken())
{
break;
}
nextToken = tis.nextToken();
if (nextToken.error())
{
break;
}
if (haveReadSymbol && (nextToken.isWord() || nextToken.isNumber()))
{
// Two consecutive symbols. Assume multiplication
tis.putBack(nextToken);
nextToken = token(token::MULTIPLY);
}
}
// Read first five dimensions
for (int Dimension=0; Dimension<dimensionSet::CURRENT; Dimension++)
return ds;
}
Foam::Istream& Foam::dimensionSet::read
(
Istream& is,
scalar& multiplier,
const HashTable<dimensionedScalar>& readSet
)
{
multiplier = 1.0;
// Read begining of dimensionSet
token startToken(is);
if (startToken != token::BEGIN_SQR)
{
is >> dset.exponents_[Dimension];
FatalIOErrorIn
(
"dimensionSet::read"
"(Istream&, scalar&, const HashTable<dimensionedScalar>&)",
is
) << "expected a " << token::BEGIN_SQR << " in dimensionSet"
<< endl << "in stream " << is.info()
<< exit(FatalIOError);
}
// Read next token
token nextToken(is);
// If next token is another number
// read last two dimensions
// and then read another token for the end of the dimensionSet
if (nextToken.isNumber())
if (!nextToken.isNumber())
{
dset.exponents_[dimensionSet::CURRENT] = nextToken.number();
is >> dset.exponents_[dimensionSet::LUMINOUS_INTENSITY];
is >> nextToken;
is.putBack(nextToken);
tokeniser tis(is);
dimensionedScalar ds(parse(0, tis, readSet));
multiplier = ds.value();
for (int i=0; i < dimensionSet::nDimensions; ++i)
{
exponents_[i] = ds.dimensions()[i];
}
}
else
{
dset.exponents_[dimensionSet::CURRENT] = 0;
dset.exponents_[dimensionSet::LUMINOUS_INTENSITY] = 0;
// Read first five dimensions
exponents_[dimensionSet::MASS] = nextToken.number();
for (int Dimension=1; Dimension<dimensionSet::CURRENT; Dimension++)
{
is >> exponents_[Dimension];
}
// Read next token
token nextToken(is);
// If next token is another number
// read last two dimensions
// and then read another token for the end of the dimensionSet
if (nextToken.isNumber())
{
exponents_[dimensionSet::CURRENT] = nextToken.number();
is >> nextToken;
exponents_[dimensionSet::LUMINOUS_INTENSITY] = nextToken.number();
is >> nextToken;
}
else
{
exponents_[dimensionSet::CURRENT] = 0;
exponents_[dimensionSet::LUMINOUS_INTENSITY] = 0;
}
// Check end of dimensionSet
if (nextToken != token::END_SQR)
{
FatalIOErrorIn
(
"dimensionSet::read"
"(Istream&, scalar&, const HashTable<dimensionedScalar>&)",
is
) << "expected a " << token::END_SQR << " in dimensionSet "
<< endl << "in stream " << is.info()
<< exit(FatalIOError);
}
}
// Check state of Istream
is.check("Istream& operator>>(Istream&, dimensionSet&)");
return is;
}
Foam::Istream& Foam::dimensionSet::read
(
Istream& is,
scalar& multiplier
)
{
return read(is, multiplier, unitSet());
}
Foam::Istream& Foam::dimensionSet::read
(
Istream& is,
scalar& multiplier,
const dictionary& readSet
)
{
multiplier = 1.0;
// Read begining of dimensionSet
token startToken(is);
if (startToken != token::BEGIN_SQR)
{
FatalIOErrorIn
(
"dimensionSet::read"
"(Istream&, scalar&, const dictionary&)",
is
) << "expected a " << token::BEGIN_SQR << " in dimensionSet"
<< endl << "in stream " << is.info()
<< exit(FatalIOError);
}
// Check end of dimensionSet
if (nextToken != token::END_SQR)
// Read next token
token nextToken(is);
if (nextToken.isWord())
{
Info<< "expected a " << token::END_SQR << " in dimensionSet"
<< endl << "in stream " << is.info() << endl;
bool continueParsing = true;
do
{
word symbolPow = nextToken.wordToken();
if (symbolPow[symbolPow.size()-1] == token::END_SQR)
{
symbolPow = symbolPow(0, symbolPow.size()-1);
continueParsing = false;
}
// Parse unit
dimensionSet symbolSet(dimless);
size_t index = symbolPow.find('^');
if (index != string::npos)
{
word symbol = symbolPow(0, index);
word exp = symbolPow(index+1, symbolPow.size()-index+1);
scalar exponent = readScalar(IStringStream(exp)());
dimensionedScalar s;
s.read(readSet[symbol], readSet);
symbolSet.reset(pow(s.dimensions(), exponent));
multiplier *= Foam::pow(s.value(), exponent);
}
else
{
dimensionedScalar s;
s.read(readSet[symbolPow], readSet);
symbolSet.reset(s.dimensions());
multiplier *= s.value();
}
// Add dimensions without checking
for (int i=0; i < dimensionSet::nDimensions; ++i)
{
exponents_[i] += symbolSet[i];
}
if (continueParsing)
{
nextToken = token(is);
if (!nextToken.isWord() || nextToken == token::END_SQR)
{
continueParsing = false;
}
}
}
while (continueParsing);
}
else
{
// Read first five dimensions
exponents_[dimensionSet::MASS] = nextToken.number();
for (int Dimension=1; Dimension<dimensionSet::CURRENT; Dimension++)
{
is >> exponents_[Dimension];
}
// Read next token
token nextToken(is);
// If next token is another number
// read last two dimensions
// and then read another token for the end of the dimensionSet
if (nextToken.isNumber())
{
exponents_[dimensionSet::CURRENT] = nextToken.number();
is >> nextToken;
exponents_[dimensionSet::LUMINOUS_INTENSITY] = nextToken.number();
is >> nextToken;
}
else
{
exponents_[dimensionSet::CURRENT] = 0;
exponents_[dimensionSet::LUMINOUS_INTENSITY] = 0;
}
// Check end of dimensionSet
if (nextToken != token::END_SQR)
{
FatalIOErrorIn
(
"dimensionSet::read"
"(Istream&, scalar&, const dictionary&)",
is
) << "expected a " << token::END_SQR << " in dimensionSet "
<< endl << "in stream " << is.info()
<< exit(FatalIOError);
}
}
// Check state of Istream
is.check("Istream& operator>>(Istream&, dimensionSet&)");
return is;
}
Foam::Ostream& Foam::dimensionSet::write
(
Ostream& os,
scalar& multiplier,
const dimensionSets& writeUnits
) const
{
multiplier = 1.0;
os << token::BEGIN_SQR;
if (writeUnits.valid())
{
scalarField exponents(dimensionSet::nDimensions);
for (int d=0; d<dimensionSet::nDimensions; d++)
{
exponents[d] = exponents_[d];
}
writeUnits.coefficients(exponents);
bool hasPrinted = false;
forAll(exponents, i)
{
if (mag(exponents[i]) > smallExponent)
{
const dimensionedScalar& ds = writeUnits.units()[i];
if (hasPrinted)
{
os << token::SPACE;
}
hasPrinted = true;
os << ds.name();
if (mag(exponents[i]-1) > smallExponent)
{
os << '^' << exponents[i];
multiplier *= Foam::pow(ds.value(), exponents[i]);
}
else
{
multiplier *= ds.value();
}
}
}
}
else
{
for (int d=0; d<dimensionSet::nDimensions-1; d++)
{
os << exponents_[d] << token::SPACE;
}
os << exponents_[dimensionSet::nDimensions-1];
}
os << token::END_SQR;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const dimensionSet&)");
return os;
}
Foam::Ostream& Foam::dimensionSet::write
(
Ostream& os,
scalar& multiplier
) const
{
return write(os, multiplier, writeUnitSet());
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, dimensionSet& dset)
{
scalar multiplier;
dset.read(is, multiplier);
if (mag(multiplier-1.0) > dimensionSet::smallExponent)
{
FatalIOErrorIn("Foam::operator>>(Istream&, dimensionSet&)", is)
<< "Cannot use scaled units in dimensionSet"
<< exit(FatalIOError);
}
// Check state of Istream
@ -85,13 +710,8 @@ Foam::Istream& Foam::operator>>(Istream& is, dimensionSet& dset)
Foam::Ostream& Foam::operator<<(Ostream& os, const dimensionSet& dset)
{
os << token::BEGIN_SQR;
for (int Dimension=0; Dimension<dimensionSet::nDimensions-1; Dimension++)
{
os << dset.exponents_[Dimension] << token::SPACE;
}
os << dset.exponents_[dimensionSet::nDimensions-1] << token::END_SQR;
scalar multiplier;
dset.write(os, multiplier);
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const dimensionSet&)");

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,34 +24,210 @@ License
\*---------------------------------------------------------------------------*/
#include "dimensionSet.H"
#include "dimensionedScalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const Foam::dimensionSet Foam::dimless(0, 0, 0, 0, 0, 0, 0);
namespace Foam
{
const Foam::dimensionSet Foam::dimMass(1, 0, 0, 0, 0, 0, 0);
const Foam::dimensionSet Foam::dimLength(0, 1, 0, 0, 0, 0, 0);
const Foam::dimensionSet Foam::dimTime(0, 0, 1, 0, 0, 0, 0);
const Foam::dimensionSet Foam::dimTemperature(0, 0, 0, 1, 0, 0, 0);
const Foam::dimensionSet Foam::dimMoles(0, 0, 0, 0, 1, 0, 0);
const Foam::dimensionSet Foam::dimCurrent(0, 0, 0, 0, 0, 1, 0);
const Foam::dimensionSet Foam::dimLuminousIntensity(0, 0, 0, 0, 0, 0, 1);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const Foam::dimensionSet Foam::dimArea(sqr(dimLength));
const Foam::dimensionSet Foam::dimVolume(pow3(dimLength));
const Foam::dimensionSet Foam::dimVol(dimVolume);
dictionary* dimensionSystemsPtr_(NULL);
const Foam::dimensionSet Foam::dimVelocity(dimLength/dimTime);
const Foam::dimensionSet Foam::dimAcceleration(dimVelocity/dimTime);
dictionary& dimensionSystems()
{
return debug::switchSet
(
"DimensionSets",
dimensionSystemsPtr_
);
}
const Foam::dimensionSet Foam::dimDensity(dimMass/dimVolume);
const Foam::dimensionSet Foam::dimForce(dimMass*dimAcceleration);
const Foam::dimensionSet Foam::dimEnergy(dimForce*dimLength);
const Foam::dimensionSet Foam::dimPower(dimEnergy/dimTime);
const Foam::dimensionSet Foam::dimPressure(dimForce/dimArea);
const Foam::dimensionSet Foam::dimGasConstant(dimEnergy/dimMass/dimTemperature);
const Foam::dimensionSet Foam::dimSpecificHeatCapacity(dimGasConstant);
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
autoPtr<HashTable<dimensionedScalar> > unitSetPtr_;
autoPtr<dimensionSets> writeUnitSetPtr_;
const HashTable<dimensionedScalar>& unitSet()
{
if (!unitSetPtr_.valid())
{
const dictionary& dict = dimensionSystems();
if (!dict.found("unitSet"))
{
FatalIOErrorIn("unitSet()", dict)
<< "Cannot find unitSet in dictionary " << dict.name()
<< exit(FatalIOError);
}
const word unitSetCoeffs(word(dict.lookup("unitSet")) + "Coeffs");
if (!dict.found(unitSetCoeffs))
{
FatalIOErrorIn("unitSet()", dict)
<< "Cannot find " << unitSetCoeffs << " in dictionary "
<< dict.name() << exit(FatalIOError);
}
const dictionary& unitDict = dict.subDict(unitSetCoeffs);
unitSetPtr_.reset
(
new HashTable<dimensionedScalar>(unitDict.size())
);
forAllConstIter(dictionary, unitDict, iter)
{
if (iter().keyword() != "writeUnits")
{
dimensionedScalar dt;
dt.read(iter().stream(), unitDict);
bool ok = unitSetPtr_->insert(iter().keyword(), dt);
if (!ok)
{
FatalIOErrorIn("unitSet()", dict)
<< "Duplicate unit " << iter().keyword()
<< " in DimensionSets dictionary"
<< exit(FatalIOError);
}
}
}
wordList writeUnitNames
(
unitDict.lookupOrDefault<wordList>
(
"writeUnits",
wordList(0)
)
);
writeUnitSetPtr_.reset
(
new dimensionSets
(
unitSetPtr_(),
writeUnitNames
)
);
if (writeUnitNames.size() != 0 && writeUnitNames.size() != 7)
{
FatalIOErrorIn("unitSet()", dict)
<< "Cannot find entry \"writeUnits\" in " << unitDict.name()
<< " or it is not a wordList of size 7"
<< exit(FatalIOError);
}
}
return unitSetPtr_();
}
const dimensionSets& writeUnitSet()
{
if (!writeUnitSetPtr_.valid())
{
(void)unitSet();
}
return writeUnitSetPtr_();
}
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0);
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0);
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0);
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0);
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0);
const dimensionSet dimMoles(0, 0, 0, 0, 1, 0, 0);
const dimensionSet dimCurrent(0, 0, 0, 0, 0, 1, 0);
const dimensionSet dimLuminousIntensity(0, 0, 0, 0, 0, 0, 1);
const dimensionSet dimArea(sqr(dimLength));
const dimensionSet dimVolume(pow3(dimLength));
const dimensionSet dimVol(dimVolume);
const dimensionSet dimVelocity(dimLength/dimTime);
const dimensionSet dimAcceleration(dimVelocity/dimTime);
const dimensionSet dimDensity(dimMass/dimVolume);
const dimensionSet dimForce(dimMass*dimAcceleration);
const dimensionSet dimEnergy(dimForce*dimLength);
const dimensionSet dimPower(dimEnergy/dimTime);
const dimensionSet dimPressure(dimForce/dimArea);
const dimensionSet dimGasConstant(dimEnergy/dimMass/dimTemperature);
const dimensionSet dimSpecificHeatCapacity(dimGasConstant);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dimensionSets::dimensionSets
(
const HashTable<dimensionedScalar>& units,
const wordList& unitNames
)
:
units_(unitNames.size()),
conversion_(unitNames.size()),
conversionPivots_(unitNames.size()),
valid_(false)
{
forAll(unitNames, i)
{
units_.set
(
i,
new dimensionedScalar
(
units[unitNames[i]]
)
);
}
if (unitNames.size() == 7)
{
valid_ = true;
// Determine conversion from basic units to write units
for (label rowI = 0; rowI < conversion_.n(); rowI++)
{
scalar* row = conversion_[rowI];
for (label columnI = 0; columnI < conversion_.m(); columnI++)
{
const dimensionedScalar& dSet = units_[columnI];
row[columnI] = dSet.dimensions()[rowI];
}
}
conversionPivots_.setSize(conversion_.n());
LUDecompose(conversion_, conversionPivots_);
//- possibly some optimisation here to detect identity matri
//if
//(
// conversionPivots_ == identity(conversionPivots_.size())
// && conversion_ == I)
//)
//{
// identity_ = true;
//}
}
}
void Foam::dimensionSets::coefficients(scalarField& exponents) const
{
LUBacksubstitute(conversion_, conversionPivots_, exponents);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,6 +36,10 @@ SourceFiles
#ifndef dimensionSets_H
#define dimensionSets_H
#include "scalarMatrices.H"
#include "dimensionedScalarFwd.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -69,6 +73,65 @@ extern const dimensionSet dimGasConstant;
extern const dimensionSet dimSpecificHeatCapacity;
class dimensionSets
{
// Private data
//- Set of dimensions
PtrList<dimensionedScalar> units_;
//- LU decomposition of dimensions
scalarSquareMatrix conversion_;
//- See above
labelList conversionPivots_;
//- Is LU decomposition valid
bool valid_;
public:
// Constructors
//- Construct from all units and set of units to use for inversion
// (writing)
dimensionSets
(
const HashTable<dimensionedScalar>&,
const wordList& unitNames
);
// Member functions
//- Return the units
const PtrList<dimensionedScalar>& units() const
{
return units_;
}
//- Is there a valid inverse of the selected unit
bool valid() const
{
return valid_;
}
//- (if valid) obtain set of coefficients of unitNames
void coefficients(scalarField&) const;
};
//- Top level dictionary
dictionary& dimensionSystems();
//- Set of all dimensions
const HashTable<dimensionedScalar>& unitSet();
//- Set of units
const dimensionSets& writeUnitSet();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -97,10 +97,10 @@ dimensioned<Type>::dimensioned
Istream& is
)
:
name_(is),
dimensions_(is),
value_(pTraits<Type>(is))
{}
dimensions_(dimless)
{
read(is);
}
template <class Type>
@ -111,9 +111,13 @@ dimensioned<Type>::dimensioned
)
:
name_(name),
dimensions_(is),
value_(pTraits<Type>(is))
{}
dimensions_(dimless)
{
scalar multiplier;
dimensions_.read(is, multiplier);
is >> value_;
value_ *= multiplier;
}
template <class Type>
@ -141,24 +145,29 @@ dimensioned<Type>::dimensioned
}
// If the dimensions are provided compare with the argument
scalar multiplier = 1.0;
if (nextToken == token::BEGIN_SQR)
{
dimensionSet dims(is);
dimensionSet dims(dimless);
dims.read(is, multiplier);
if (dims != dimensions_)
{
FatalErrorIn
FatalIOErrorIn
(
"dimensioned<Type>::dimensioned"
"(const word&, const dimensionSet&, Istream&)"
"(const word&, const dimensionSet&, Istream&)",
is
) << "The dimensions " << dims
<< " provided do not match the required dimensions "
<< dimensions_
<< abort(FatalError);
<< abort(FatalIOError);
}
}
is >> value_;
value_ *= multiplier;
}
@ -247,6 +256,83 @@ bool dimensioned<Type>::readIfPresent(const dictionary& dict)
}
template <class Type>
Foam::Istream& dimensioned<Type>::read(Istream& is, const dictionary& readSet)
{
// Read name
is >> name_;
// Read dimensionSet + multiplier
scalar mult;
dimensions_.read(is, mult, readSet);
// Read value
is >> value_;
value_ *= mult;
// Check state of Istream
is.check
(
"Istream& dimensioned<Type>::read(Istream& is, const dictionary&)"
);
return is;
}
template <class Type>
Foam::Istream& dimensioned<Type>::read
(
Istream& is,
const HashTable<dimensionedScalar>& readSet
)
{
// Read name
is >> name_;
// Read dimensionSet + multiplier
scalar mult;
dimensions_.read(is, mult, readSet);
// Read value
is >> value_;
value_ *= mult;
// Check state of Istream
is.check
(
"Istream& dimensioned<Type>::read"
"(Istream& is, const HashTable<dimensionedScalar>&)"
);
return is;
}
template <class Type>
Foam::Istream& dimensioned<Type>::read(Istream& is)
{
// Read name
is >> name_;
// Read dimensionSet + multiplier
scalar mult;
dimensions_.read(is, mult);
// Read value
is >> value_;
value_ *= mult;
// Check state of Istream
is.check
(
"Istream& dimensioned<Type>::read(Istream& is)"
);
return is;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template <class Type>
@ -414,13 +500,15 @@ Istream& operator>>(Istream& is, dimensioned<Type>& dt)
}
// If the dimensions are provided reset the dimensions to those read
scalar multiplier = 1.0;
if (nextToken == token::BEGIN_SQR)
{
is >> dt.dimensions_;
dt.dimensions_.read(is, multiplier);
}
// Read the value
is >> dt.value_;
dt.value_ *= multiplier;
// Check state of Istream
is.check("Istream& operator>>(Istream&, dimensioned<Type>&)");
@ -432,10 +520,17 @@ Istream& operator>>(Istream& is, dimensioned<Type>& dt)
template <class Type>
Ostream& operator<<(Ostream& os, const dimensioned<Type>& dt)
{
// do a stream write op for a dimensions()et
os << dt.name() << token::SPACE
<< dt.dimensions() << token::SPACE
<< dt.value();
// Write the name
os << dt.name() << token::SPACE;
// Write the dimensions
scalar mult;
dt.dimensions().write(os, mult);
os << token::SPACE;
// Write the value
os << dt.value()/mult;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const dimensioned<Type>&)");

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -163,6 +163,17 @@ public:
bool readIfPresent(const dictionary&);
// I/O
//- Read using provided units. Only used during startup.
Istream& read(Istream& is, const dictionary&);
//- Read using provided units
Istream& read(Istream& is, const HashTable<dimensionedScalar>&);
//- Read using system units
Istream& read(Istream& is);
// Member operators
//- Return a component as a dimensioned<cmptType>

View File

@ -48,8 +48,10 @@ Foam::UniformDimensionedField<Type>::UniformDimensionedField
)
{
dictionary dict(readStream(typeName));
this->dimensions().reset(dict.lookup("dimensions"));
scalar multiplier;
this->dimensions().read(dict.lookup("dimensions"), multiplier);
dict.lookup("value") >> this->value();
this->value() *= multiplier;
}
}
@ -75,8 +77,10 @@ Foam::UniformDimensionedField<Type>::UniformDimensionedField
dimensioned<Type>(regIOobject::name(), dimless, pTraits<Type>::zero)
{
dictionary dict(readStream(typeName));
this->dimensions().reset(dict.lookup("dimensions"));
scalar multiplier;
this->dimensions().read(dict.lookup("dimensions"), multiplier);
dict.lookup("value") >> this->value();
this->value() *= multiplier;
}
@ -92,9 +96,11 @@ Foam::UniformDimensionedField<Type>::~UniformDimensionedField()
template<class Type>
bool Foam::UniformDimensionedField<Type>::writeData(Ostream& os) const
{
os.writeKeyword("dimensions") << this->dimensions() << token::END_STATEMENT
scalar multiplier;
os.writeKeyword("dimensions");
this->dimensions().write(os, multiplier) << token::END_STATEMENT
<< nl;
os.writeKeyword("value") << this->value() << token::END_STATEMENT
os.writeKeyword("value") << this->value()/multiplier << token::END_STATEMENT
<< nl << nl;
return (os.good());

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -121,6 +121,17 @@ public:
}
// Member functions
// Access
//- Return true if this patch field fixes a value
virtual bool fixesValue() const
{
return true;
}
// Member operators
// Disable assignment operators

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -278,6 +278,12 @@ public:
return internalField_;
}
//- Return true if this patch field fixes a value
virtual bool fixesValue() const
{
return false;
}
//- Return true if this patch field is coupled
virtual bool coupled() const
{

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -79,6 +79,9 @@ public:
//- Construct copy and increment reference count
inline tmp(const tmp<T>&);
//- Construct copy transferring content of temporary if required
inline tmp(const tmp<T>&, bool allowTransfer);
//- Destructor, delete object when reference count == 0
inline ~tmp();

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -68,6 +68,38 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t)
}
template<class T>
inline Foam::tmp<T>::tmp(const tmp<T>& t, bool allowTransfer)
:
isTmp_(t.isTmp_),
ptr_(t.ptr_),
ref_(t.ref_)
{
if (isTmp_)
{
if (allowTransfer)
{
const_cast<tmp<T>&>(t).ptr_ = 0;
}
else
{
if (ptr_)
{
ptr_->operator++();
}
else
{
FatalErrorIn
(
"Foam::tmp<T>::tmp(const tmp<T>&, bool allowTransfer)"
) << "attempted copy of a deallocated temporary"
<< abort(FatalError);
}
}
}
}
template<class T>
inline Foam::tmp<T>::~tmp()
{

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -322,7 +322,12 @@ Foam::string& Foam::stringOps::inplaceExpand
// lookup in the dictionary
const entry* ePtr = dict.lookupEntryPtr(varName, true, true);
const entry* ePtr = dict.lookupScopedEntryPtr
(
varName,
true,
false // wildcards disabled. See primitiveEntry
);
// if defined - copy its entries
if (ePtr)

View File

@ -210,7 +210,7 @@ void Foam::pressureGradientExplicitSource::setValue
(
IOobject
(
name_ + "::invA",
name_ + ".invA",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,

View File

@ -84,7 +84,6 @@ fvPatchFields = fields/fvPatchFields
$(fvPatchFields)/fvPatchField/fvPatchFields.C
basicFvPatchFields = $(fvPatchFields)/basic
$(basicFvPatchFields)/basicSymmetry/basicSymmetryFvPatchFields.C
$(basicFvPatchFields)/basicSymmetry/basicSymmetryFvPatchScalarField.C
$(basicFvPatchFields)/calculated/calculatedFvPatchFields.C
$(basicFvPatchFields)/coupled/coupledFvPatchFields.C

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,10 +58,6 @@ class basicSymmetryFvPatchField
public:
//- Runtime type information
TypeName(symmetryFvPatch::typeName_());
// Constructors
//- Construct from patch and internal field

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -269,98 +269,98 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
(
ITstream
(
objectPath() + "::ddtSchemes",
objectPath() + ".ddtSchemes",
tokenList()
)()
),
defaultDdtScheme_
(
ddtSchemes_.name() + "::default",
ddtSchemes_.name() + ".default",
tokenList()
),
d2dt2Schemes_
(
ITstream
(
objectPath() + "::d2dt2Schemes",
objectPath() + ".d2dt2Schemes",
tokenList()
)()
),
defaultD2dt2Scheme_
(
d2dt2Schemes_.name() + "::default",
d2dt2Schemes_.name() + ".default",
tokenList()
),
interpolationSchemes_
(
ITstream
(
objectPath() + "::interpolationSchemes",
objectPath() + ".interpolationSchemes",
tokenList()
)()
),
defaultInterpolationScheme_
(
interpolationSchemes_.name() + "::default",
interpolationSchemes_.name() + ".default",
tokenList()
),
divSchemes_
(
ITstream
(
objectPath() + "::divSchemes",
objectPath() + ".divSchemes",
tokenList()
)()
),
defaultDivScheme_
(
divSchemes_.name() + "::default",
divSchemes_.name() + ".default",
tokenList()
),
gradSchemes_
(
ITstream
(
objectPath() + "::gradSchemes",
objectPath() + ".gradSchemes",
tokenList()
)()
),
defaultGradScheme_
(
gradSchemes_.name() + "::default",
gradSchemes_.name() + ".default",
tokenList()
),
snGradSchemes_
(
ITstream
(
objectPath() + "::snGradSchemes",
objectPath() + ".snGradSchemes",
tokenList()
)()
),
defaultSnGradScheme_
(
snGradSchemes_.name() + "::default",
snGradSchemes_.name() + ".default",
tokenList()
),
laplacianSchemes_
(
ITstream
(
objectPath() + "::laplacianSchemes",
objectPath() + ".laplacianSchemes",
tokenList()
)()
),
defaultLaplacianScheme_
(
laplacianSchemes_.name() + "::default",
laplacianSchemes_.name() + ".default",
tokenList()
),
fluxRequired_
(
ITstream
(
objectPath() + "::fluxRequired",
objectPath() + ".fluxRequired",
tokenList()
)()
),

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -148,4 +148,39 @@ void Foam::fvc::makeAbsolute
}
Foam::tmp<Foam::surfaceScalarField> Foam::fvc::absolute
(
const tmp<surfaceScalarField>& tphi,
const volVectorField& U
)
{
if (tphi().mesh().moving())
{
return tphi + fvc::meshPhi(U);
}
else
{
return tmp<surfaceScalarField>(tphi, true);
}
}
Foam::tmp<Foam::surfaceScalarField> Foam::fvc::absolute
(
const tmp<surfaceScalarField>& tphi,
const volScalarField& rho,
const volVectorField& U
)
{
if (tphi().mesh().moving())
{
return tphi + fvc::meshPhi(rho, U);
}
else
{
return tmp<surfaceScalarField>(tphi, true);
}
}
// ************************************************************************* //

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -116,6 +116,22 @@ namespace fvc
const volScalarField& rho,
const volVectorField& U
);
//- Return the given relative flux in absolute form
tmp<surfaceScalarField> absolute
(
const tmp<surfaceScalarField>& tphi,
const volVectorField& U
);
//- Return the given relative flux in absolute form
tmp<surfaceScalarField> absolute
(
const tmp<surfaceScalarField>& tphi,
const volScalarField& rho,
const volVectorField& U
);
}

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,6 +54,7 @@ namespace Foam
scalar
)
/*
makeLimitedSurfaceInterpolationTypeScheme
(
MUSCL,
@ -71,6 +72,7 @@ namespace Foam
rhoMagSqr,
vector
)
*/
}
// ************************************************************************* //

View File

@ -346,7 +346,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
(
IOobject
(
this->name() + "::UTrans",
this->name() + ".UTrans",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
@ -362,7 +362,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
(
IOobject
(
this->name() + "::UCoeff",
this->name() + ".UCoeff",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
@ -426,7 +426,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
(
IOobject
(
this->name() + "::UTrans",
this->name() + ".UTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -442,7 +442,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
(
IOobject
(
name + "::UCoeff",
name + ".UCoeff",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,

View File

@ -564,7 +564,7 @@ Foam::KinematicCloud<CloudType>::theta() const
(
IOobject
(
this->name() + "::theta",
this->name() + ".theta",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -603,7 +603,7 @@ Foam::KinematicCloud<CloudType>::alpha() const
(
IOobject
(
this->name() + "::alpha",
this->name() + ".alpha",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -640,7 +640,7 @@ Foam::KinematicCloud<CloudType>::rhoEff() const
(
IOobject
(
this->name() + "::rhoEff",
this->name() + ".rhoEff",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,

View File

@ -107,7 +107,7 @@ inline Foam::tmp<Foam::fvScalarMatrix> Foam::ReactingCloud<CloudType>::SYi
(
IOobject
(
this->name() + "::rhoTrans",
this->name() + ".rhoTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -155,7 +155,7 @@ Foam::ReactingCloud<CloudType>::Srho(const label i) const
(
IOobject
(
this->name() + "::rhoTrans",
this->name() + ".rhoTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -192,7 +192,7 @@ Foam::ReactingCloud<CloudType>::Srho() const
(
IOobject
(
this->name() + "::rhoTrans",
this->name() + ".rhoTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -236,7 +236,7 @@ Foam::ReactingCloud<CloudType>::Srho(volScalarField& rho) const
(
IOobject
(
this->name() + "::rhoTrans",
this->name() + ".rhoTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,

View File

@ -64,7 +64,7 @@ void Foam::ThermoCloud<CloudType>::setModels()
(
IOobject
(
this->name() + "::radAreaP",
this->name() + ".radAreaP",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
@ -81,7 +81,7 @@ void Foam::ThermoCloud<CloudType>::setModels()
(
IOobject
(
this->name() + "::radT4",
this->name() + ".radT4",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
@ -98,7 +98,7 @@ void Foam::ThermoCloud<CloudType>::setModels()
(
IOobject
(
this->name() + "::radAreaPT4",
this->name() + ".radAreaPT4",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
@ -169,7 +169,7 @@ Foam::ThermoCloud<CloudType>::ThermoCloud
(
IOobject
(
this->name() + "::hsTrans",
this->name() + ".hsTrans",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
@ -185,7 +185,7 @@ Foam::ThermoCloud<CloudType>::ThermoCloud
(
IOobject
(
this->name() + "::hsCoeff",
this->name() + ".hsCoeff",
this->db().time().timeName(),
this->db(),
IOobject::READ_IF_PRESENT,
@ -239,7 +239,7 @@ Foam::ThermoCloud<CloudType>::ThermoCloud
(
IOobject
(
this->name() + "::hsTrans",
this->name() + ".hsTrans",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -255,7 +255,7 @@ Foam::ThermoCloud<CloudType>::ThermoCloud
(
IOobject
(
this->name() + "::hsCoeff",
this->name() + ".hsCoeff",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -274,7 +274,7 @@ Foam::ThermoCloud<CloudType>::ThermoCloud
(
IOobject
(
this->name() + "::radAreaP",
this->name() + ".radAreaP",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -291,7 +291,7 @@ Foam::ThermoCloud<CloudType>::ThermoCloud
(
IOobject
(
this->name() + "::radT4",
this->name() + ".radT4",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
@ -308,7 +308,7 @@ Foam::ThermoCloud<CloudType>::ThermoCloud
(
IOobject
(
this->name() + "::radAreaPT4",
this->name() + ".radAreaPT4",
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,

View File

@ -46,8 +46,8 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
{
if (writeFields_)
{
word massEscapeName(this->owner().name() + "::massEscape");
word massStickName(this->owner().name() + "::massStick");
word massEscapeName(this->owner().name() + ".massEscape");
word massStickName(this->owner().name() + ".massStick");
Info<< " Interaction fields will be written to " << massEscapeName
<< " and " << massStickName << endl;
@ -121,7 +121,7 @@ Foam::volScalarField& Foam::LocalInteraction<CloudType>::massEscape()
(
IOobject
(
this->owner().name() + "::massEscape",
this->owner().name() + ".massEscape",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
@ -150,7 +150,7 @@ Foam::volScalarField& Foam::LocalInteraction<CloudType>::massStick()
(
IOobject
(
this->owner().name() + "::massStick",
this->owner().name() + ".massStick",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,

View File

@ -710,7 +710,8 @@ void Foam::autoLayerDriver::setNumLayers
const indirectPrimitivePatch& pp,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
List<extrudeMode>& extrudeStatus,
label& nAddedCells
) const
{
const fvMesh& mesh = meshRefiner_.mesh();
@ -797,6 +798,24 @@ void Foam::autoLayerDriver::setNumLayers
}
}
// Calculate number of cells to create
nAddedCells = 0;
forAll(pp.localFaces(), faceI)
{
const face& f = pp.localFaces()[faceI];
// Get max of extrusion per point
label nCells = 0;
forAll(f, fp)
{
nCells = max(nCells, patchNLayers[f[fp]]);
}
nAddedCells += nCells;
}
reduce(nAddedCells, sumOp<label>());
//reduce(nConflicts, sumOp<label>());
//
//Info<< "Set displacement to zero for " << nConflicts
@ -2491,9 +2510,13 @@ void Foam::autoLayerDriver::addLayers
// extrudeStatus = EXTRUDE.
labelList patchNLayers(pp().nPoints(), 0);
// Ideal number of cells added
label nIdealAddedCells = 0;
// Whether to add edge for all pp.localPoints.
List<extrudeMode> extrudeStatus(pp().nPoints(), EXTRUDE);
{
// Get number of layer per point from number of layers per patch
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2506,7 +2529,8 @@ void Foam::autoLayerDriver::addLayers
patchDisp,
patchNLayers,
extrudeStatus
extrudeStatus,
nIdealAddedCells
);
// Precalculate mesh edge labels for patch edges
@ -2776,6 +2800,7 @@ void Foam::autoLayerDriver::addLayers
layerParams.nSmoothNormals(),
layerParams.nSmoothSurfaceNormals(),
layerParams.minMedianAxisAngleCos(),
layerParams.slipFeatureAngle(),
dispVec,
medialRatio,
@ -3101,10 +3126,24 @@ void Foam::autoLayerDriver::addLayers
label nExtruded = countExtrusion(pp, extrudeStatus);
label nTotFaces = returnReduce(pp().size(), sumOp<label>());
label nAddedCells = 0;
{
forAll(flaggedCells, cellI)
{
if (flaggedCells[cellI])
{
nAddedCells++;
}
}
reduce(nAddedCells, sumOp<label>());
}
Info<< "Extruding " << nExtruded
<< " out of " << nTotFaces
<< " faces (" << 100.0*nExtruded/nTotFaces << "%)."
<< " Removed extrusion at " << nTotChanged << " faces."
<< endl
<< "Added " << nAddedCells << " out of " << nIdealAddedCells
<< " cells (" << 100.0*nAddedCells/nIdealAddedCells << "%)."
<< endl;
if (nTotChanged == 0)

View File

@ -192,7 +192,8 @@ class autoLayerDriver
const indirectPrimitivePatch& pp,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
List<extrudeMode>& extrudeStatus,
label& nIdealAddedCells
) const;
//- Helper function to make a pointVectorField with correct
@ -469,6 +470,7 @@ class autoLayerDriver
const label nSmoothNormals,
const label nSmoothSurfaceNormals,
const scalar minMedianAxisAngleCos,
const scalar featureAngle,
pointVectorField& dispVec,
pointScalarField& medialRatio,

View File

@ -33,9 +33,10 @@ Description
#include "motionSmoother.H"
#include "pointData.H"
#include "PointEdgeWave.H"
#include "OFstream.H"
#include "OBJstream.H"
#include "meshTools.H"
#include "PatchTools.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -775,6 +776,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
const label nSmoothNormals,
const label nSmoothSurfaceNormals,
const scalar minMedianAxisAngleCos,
const scalar featureAngle,
pointVectorField& dispVec,
pointScalarField& medialRatio,
@ -904,7 +906,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
const edge& e = edges[edgeI];
// Approximate medial axis location on edge.
//const point medialAxisPt = e.centre(points);
vector eVec = e.vec(mesh.points());
vector eVec = e.vec(points);
scalar eMag = mag(eVec);
if (eMag > VSMALL)
{
@ -961,42 +963,111 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
labelHashSet adaptPatches(meshMover.adaptPatchIDs());
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
//const pointPatchVectorField& pvf =
// meshMover.displacement().boundaryField()[patchI];
const pointPatchVectorField& pvf =
meshMover.displacement().boundaryField()[patchI];
if
(
!pp.coupled()
&& !isA<emptyPolyPatch>(pp)
//&& pvf.constraintType() != word::null //exclude fixedValue
&& !adaptPatches.found(patchI)
)
{
Info<< "Inserting points on patch " << pp.name() << endl;
const labelList& meshPoints = pp.meshPoints();
forAll(meshPoints, i)
// Check the type of the patchField. The types are
// - fixedValue (0 or more layers) but the >0 layers have
// already been handled in the adaptPatches loop
// - constraint (but not coupled) types, e.g. symmetryPlane,
// slip.
if (pvf.fixesValue())
{
label pointI = meshPoints[i];
// Disable all movement on fixedValue patchFields
Info<< "Inserting all points on patch " << pp.name()
<< endl;
if (!pointMedialDist[pointI].valid(dummyTrackData))
forAll(meshPoints, i)
{
maxPoints.append(pointI);
maxInfo.append
(
pointData
label pointI = meshPoints[i];
if (!pointMedialDist[pointI].valid(dummyTrackData))
{
maxPoints.append(pointI);
maxInfo.append
(
points[pointI],
0.0,
pointI, // passive data
vector::zero // passive data
)
);
pointMedialDist[pointI] = maxInfo.last();
pointData
(
points[pointI],
0.0,
pointI, // passive data
vector::zero // passive data
)
);
pointMedialDist[pointI] = maxInfo.last();
}
}
}
else
{
// Based on geometry: analyse angle w.r.t. nearest moving
// point. In the pointWallDist we transported the
// normal as the passive vector. Note that this points
// out of the originating wall so inside of the domain
// on this patch.
Info<< "Inserting points on patch " << pp.name()
<< " if angle to nearest layer patch > "
<< featureAngle << " degrees." << endl;
scalar featureAngleCos = Foam::cos(degToRad(featureAngle));
pointField pointNormals
(
PatchTools::pointNormals
(
mesh,
pp,
identity(pp.size())+pp.start()
)
);
forAll(meshPoints, i)
{
label pointI = meshPoints[i];
if (!pointMedialDist[pointI].valid(dummyTrackData))
{
// Check if angle not too large.
scalar cosAngle =
(
-pointWallDist[pointI].v()
& pointNormals[i]
);
if (cosAngle > featureAngleCos)
{
// Extrusion direction practically perpendicular
// to the patch. Disable movement at the patch.
maxPoints.append(pointI);
maxInfo.append
(
pointData
(
points[pointI],
0.0,
pointI, // passive data
vector::zero // passive data
)
);
pointMedialDist[pointI] = maxInfo.last();
}
else
{
// Extrusion direction makes angle with patch
// so allow sliding - don't insert zero points
}
}
}
}
}
@ -1141,13 +1212,12 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
// reduce thickness where thickness/medial axis distance large
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autoPtr<OFstream> str;
label vertI = 0;
autoPtr<OBJstream> str;
if (debug)
{
str.reset
(
new OFstream
new OBJstream
(
mesh.time().path()
/ "thicknessRatioExcludePoints_"
@ -1159,13 +1229,12 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
<< str().name() << endl;
}
autoPtr<OFstream> medialVecStr;
label medialVertI = 0;
autoPtr<OBJstream> medialVecStr;
if (debug)
{
medialVecStr.reset
(
new OFstream
new OBJstream
(
mesh.time().path()
/ "thicknessRatioExcludeMedialVec_"
@ -1227,21 +1296,19 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
if (str.valid())
{
const point& pt = mesh.points()[pointI];
meshTools::writeOBJ(str(), pt);
vertI++;
meshTools::writeOBJ(str(), pt+patchDisp[patchPointI]);
vertI++;
str()<< "l " << vertI-1 << ' ' << vertI << nl;
str().write(linePointRef(pt, pt+patchDisp[patchPointI]));
}
if (medialVecStr.valid())
{
const point& pt = mesh.points()[pointI];
meshTools::writeOBJ(medialVecStr(), pt);
medialVertI++;
meshTools::writeOBJ(medialVecStr(), medialVec[pointI]);
medialVertI++;
medialVecStr()<< "l " << medialVertI-1
<< ' ' << medialVertI << nl;
medialVecStr().write
(
linePointRef
(
pt,
medialVec[pointI]
)
);
}
}
}

View File

@ -178,6 +178,24 @@ class autoSnapDriver
vector& edgeOffset // offset from pt to point on edge
) const;
//- For any reverse (so from feature back to mesh) attraction:
// add attraction if diagonal points on face attracted
void stringFeatureEdges
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch& pp,
const scalarField& snapDist,
const vectorField& rawPatchAttraction,
const List<pointConstraint>& rawPatchConstraints,
vectorField& patchAttraction,
List<pointConstraint>& patchConstraints
) const;
//- Return hit if on multiple points
pointIndexHit findMultiPatchPoint
(

View File

@ -848,17 +848,17 @@ void Foam::autoSnapDriver::featureAttractionUsingReconstruction
vector d = r.refPoint()-pt;
d -= (d&n)*n;
// Correct for attraction to non-dominant face
correctAttraction
(
surfacePoints,
surfaceCount,
r.refPoint(),
n, // normalised normal
pt,
d // perpendicular offset vector
);
//// Correct for attraction to non-dominant face
//correctAttraction
//(
// surfacePoints,
// surfaceCount,
// r.refPoint(),
// n, // normalised normal
// pt,
//
// d // perpendicular offset vector
//);
// Trim to snap distance
if (magSqr(d) > sqr(snapDist[pointI]))
@ -893,6 +893,15 @@ void Foam::autoSnapDriver::featureAttractionUsingReconstruction
patchConstraint.applyConstraint(surfaceNormals[0]);
patchConstraint.applyConstraint(surfaceNormals[1]);
patchConstraint.applyConstraint(surfaceNormals[2]);
//Pout<< "# Feature point " << pt << nl;
//meshTools::writeOBJ(Pout, pt);
//meshTools::writeOBJ(Pout, surfacePoints[0]);
//meshTools::writeOBJ(Pout, surfacePoints[1]);
//meshTools::writeOBJ(Pout, surfacePoints[2]);
//Pout<< "l 1 2" << nl
// << "l 1 3" << nl
// << "l 1 4" << nl;
}
}
@ -1001,6 +1010,195 @@ void Foam::autoSnapDriver::featureAttractionUsingReconstruction
}
void Foam::autoSnapDriver::stringFeatureEdges
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch& pp,
const scalarField& snapDist,
const vectorField& rawPatchAttraction,
const List<pointConstraint>& rawPatchConstraints,
vectorField& patchAttraction,
List<pointConstraint>& patchConstraints
) const
{
// Snap edges to feature edges
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Walk existing edges and snap remaining ones (that are marked as
// feature edges in rawPatchConstraints)
// What this does is fill in any faces where not all points
// on the face are being attracted:
/*
+
/ \
/ \
---+ +---
\ /
\ /
+
*/
// so the top and bottom will never get attracted since the nearest
// back from the feature edge will always be one of the left or right
// points since the face is diamond like. So here we walk the feature edges
// and add any non-attracted points.
while (true)
{
label nChanged = 0;
const labelListList& pointEdges = pp.pointEdges();
forAll(pointEdges, pointI)
{
if (patchConstraints[pointI].first() == 2)
{
const point& pt = pp.localPoints()[pointI];
const labelList& pEdges = pointEdges[pointI];
const vector& featVec = patchConstraints[pointI].second();
// Detect whether there are edges in both directions.
// (direction along the feature edge that is)
bool hasPos = false;
bool hasNeg = false;
forAll(pEdges, pEdgeI)
{
const edge& e = pp.edges()[pEdges[pEdgeI]];
label nbrPointI = e.otherVertex(pointI);
if (patchConstraints[nbrPointI].first() > 1)
{
const point& nbrPt = pp.localPoints()[nbrPointI];
const point featPt =
nbrPt + patchAttraction[nbrPointI];
const scalar cosAngle = (featVec & (featPt-pt));
if (cosAngle > 0)
{
hasPos = true;
}
else
{
hasNeg = true;
}
}
}
if (!hasPos || !hasNeg)
{
//Pout<< "**Detected feature string end at "
// << pp.localPoints()[pointI] << endl;
// No string. Assign best choice on either side
label bestPosPointI = -1;
scalar minPosDistSqr = GREAT;
label bestNegPointI = -1;
scalar minNegDistSqr = GREAT;
forAll(pEdges, pEdgeI)
{
const edge& e = pp.edges()[pEdges[pEdgeI]];
label nbrPointI = e.otherVertex(pointI);
if
(
patchConstraints[nbrPointI].first() <= 1
&& rawPatchConstraints[nbrPointI].first() > 1
)
{
const vector& nbrFeatVec =
rawPatchConstraints[pointI].second();
if (mag(featVec&nbrFeatVec) > featureCos)
{
// nbrPointI attracted to sameish feature
// Note: also check on position.
scalar d2 = magSqr
(
rawPatchAttraction[nbrPointI]
);
const point featPt =
pp.localPoints()[nbrPointI]
+ rawPatchAttraction[nbrPointI];
const scalar cosAngle =
(featVec & (featPt-pt));
if (cosAngle > 0)
{
if (!hasPos && d2 < minPosDistSqr)
{
minPosDistSqr = d2;
bestPosPointI = nbrPointI;
}
}
else
{
if (!hasNeg && d2 < minNegDistSqr)
{
minNegDistSqr = d2;
bestNegPointI = nbrPointI;
}
}
}
}
}
if (bestPosPointI != -1)
{
// Use reconstructed-feature attraction. Use only
// part of it since not sure...
//const point& bestPt =
// pp.localPoints()[bestPosPointI];
//Pout<< "**Overriding point " << bestPt
// << " on reconstructed feature edge at "
// << rawPatchAttraction[bestPosPointI]+bestPt
// << " to attracted-to-feature-edge." << endl;
patchAttraction[bestPosPointI] =
0.5*rawPatchAttraction[bestPosPointI];
patchConstraints[bestPosPointI] =
rawPatchConstraints[bestPosPointI];
nChanged++;
}
if (bestNegPointI != -1)
{
// Use reconstructed-feature attraction. Use only
// part of it since not sure...
//const point& bestPt =
// pp.localPoints()[bestNegPointI];
//Pout<< "**Overriding point " << bestPt
// << " on reconstructed feature edge at "
// << rawPatchAttraction[bestNegPointI]+bestPt
// << " to attracted-to-feature-edge." << endl;
patchAttraction[bestNegPointI] =
0.5*rawPatchAttraction[bestNegPointI];
patchConstraints[bestNegPointI] =
rawPatchConstraints[bestNegPointI];
nChanged++;
}
}
}
}
reduce(nChanged, sumOp<label>());
Info<< "Stringing feature edges : changed " << nChanged << " points"
<< endl;
if (nChanged == 0)
{
break;
}
}
}
Foam::pointIndexHit Foam::autoSnapDriver::findNearFeatureEdge
(
const indirectPrimitivePatch& pp,
@ -1125,7 +1323,7 @@ Foam::labelPair Foam::autoSnapDriver::findNearFeaturePoint
patchConstraints[oldPointI] = pointConstraint();
label edgeFeatI;
const pointIndexHit nearInfo = findNearFeatureEdge
findNearFeatureEdge
(
pp,
snapDist,
@ -1721,7 +1919,7 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
// the old point to attract to nearest edge
// instead.
label edgeFeatI;
const pointIndexHit nearInfo = findNearFeatureEdge
findNearFeatureEdge
(
pp,
snapDist,
@ -1752,7 +1950,7 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
// << endl;
label featI;
const pointIndexHit nearInfo = findNearFeatureEdge
findNearFeatureEdge
(
pp,
snapDist,
@ -2113,156 +2311,20 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
// Walk existing edges and snap remaining ones (that are marked as
// feature edges in allPatchConstraints)
while (true)
{
label nChanged = 0;
stringFeatureEdges
(
iter,
featureCos,
const labelListList& pointEdges = pp.pointEdges();
forAll(pointEdges, pointI)
{
if (patchConstraints[pointI].first() == 2)
{
const point& pt = pp.localPoints()[pointI];
const labelList& pEdges = pointEdges[pointI];
const vector& featVec = patchConstraints[pointI].second();
pp,
snapDist,
// Detect whether there are edges in both directions.
// (direction along the feature edge that is)
bool hasPos = false;
bool hasNeg = false;
forAll(pEdges, pEdgeI)
{
const edge& e = pp.edges()[pEdges[pEdgeI]];
label nbrPointI = e.otherVertex(pointI);
if (patchConstraints[nbrPointI].first() > 1)
{
const point& nbrPt = pp.localPoints()[nbrPointI];
const point featPt =
nbrPt + patchAttraction[nbrPointI];
const scalar cosAngle = (featVec & (featPt-pt));
if (cosAngle > 0)
{
hasPos = true;
}
else
{
hasNeg = true;
}
}
}
if (!hasPos || !hasNeg)
{
//Pout<< "**Detected feature string end at "
// << pp.localPoints()[pointI] << endl;
// No string. Assign best choice on either side
label bestPosPointI = -1;
scalar minPosDistSqr = GREAT;
label bestNegPointI = -1;
scalar minNegDistSqr = GREAT;
forAll(pEdges, pEdgeI)
{
const edge& e = pp.edges()[pEdges[pEdgeI]];
label nbrPointI = e.otherVertex(pointI);
if
(
patchConstraints[nbrPointI].first() <= 1
&& allPatchConstraints[nbrPointI].first() > 1
)
{
const vector& nbrFeatVec =
allPatchConstraints[pointI].second();
if (mag(featVec&nbrFeatVec) > featureCos)
{
// nbrPointI attracted to sameish feature
// Note: also check on position.
scalar d2 = magSqr
(
allPatchAttraction[nbrPointI]
);
const point featPt =
pp.localPoints()[nbrPointI]
+ allPatchAttraction[nbrPointI];
const scalar cosAngle =
(featVec & (featPt-pt));
if (cosAngle > 0)
{
if (!hasPos && d2 < minPosDistSqr)
{
minPosDistSqr = d2;
bestPosPointI = nbrPointI;
}
}
else
{
if (!hasNeg && d2 < minNegDistSqr)
{
minNegDistSqr = d2;
bestNegPointI = nbrPointI;
}
}
}
}
}
if (bestPosPointI != -1)
{
// Use reconstructed-feature attraction. Use only
// part of it since not sure...
//const point& bestPt =
// pp.localPoints()[bestPosPointI];
//Pout<< "**Overriding point " << bestPt
// << " on reconstructed feature edge at "
// << allPatchAttraction[bestPosPointI]+bestPt
// << " to attracted-to-feature-edge." << endl;
patchAttraction[bestPosPointI] =
0.5*allPatchAttraction[bestPosPointI];
patchConstraints[bestPosPointI] =
allPatchConstraints[bestPosPointI];
nChanged++;
}
if (bestNegPointI != -1)
{
// Use reconstructed-feature attraction. Use only
// part of it since not sure...
//const point& bestPt =
// pp.localPoints()[bestNegPointI];
//Pout<< "**Overriding point " << bestPt
// << " on reconstructed feature edge at "
// << allPatchAttraction[bestNegPointI]+bestPt
// << " to attracted-to-feature-edge." << endl;
patchAttraction[bestNegPointI] =
0.5*allPatchAttraction[bestNegPointI];
patchConstraints[bestNegPointI] =
allPatchConstraints[bestNegPointI];
nChanged++;
}
}
}
}
reduce(nChanged, sumOp<label>());
Info<< "Stringing feature edges : changed " << nChanged << " points"
<< endl;
if (nChanged == 0)
{
break;
}
}
allPatchAttraction,
allPatchConstraints,
patchAttraction,
patchConstraints
);
// Avoid diagonal attraction

View File

@ -61,6 +61,12 @@ Foam::layerParameters::layerParameters
readScalar(dict.lookup("minThickness"))
),
featureAngle_(readScalar(dict.lookup("featureAngle"))),
slipFeatureAngle_
(
dict.found("slipFeatureAngle")
? readScalar(dict.lookup("slipFeatureAngle"))
: 0.5*featureAngle_
),
concaveAngle_
(
dict.lookupOrDefault("concaveAngle", defaultConcaveAngle)

View File

@ -79,6 +79,8 @@ class layerParameters
scalar featureAngle_;
scalar slipFeatureAngle_;
scalar concaveAngle_;
label nGrow_;
@ -178,6 +180,13 @@ public:
return featureAngle_;
}
//- At non-patched sides allow mesh to slip if extrusion
// direction makes angle larger than slipFeatureAngle.
scalar slipFeatureAngle() const
{
return slipFeatureAngle_;
}
scalar concaveAngle() const
{
return concaveAngle_;

View File

@ -312,7 +312,8 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
{
Pout<< "Adding particle from point:" << pointI
<< " coord:" << featureMesh.points()[pointI]
<< " pEdges:" << pointEdges[pointI]
<< " since number of emanating edges:"
<< pointEdges[pointI].size()
<< endl;
}

View File

@ -69,7 +69,7 @@ void Foam::regionSplit::transferCoupledFaceRegion
"regionSplit::transferCoupledFaceRegion"
"(const label, const label, labelList&, labelList&) const"
) << "Problem : coupled face " << faceI
<< " on patch " << mesh_.boundaryMesh().whichPatch(faceI)
<< " on patch " << mesh().boundaryMesh().whichPatch(faceI)
<< " has region " << faceRegion[faceI]
<< " but coupled face " << otherFaceI
<< " has region " << faceRegion[otherFaceI]
@ -109,7 +109,7 @@ void Foam::regionSplit::fillSeedMask
// Collect faces on seed cell
const cell& cFaces = mesh_.cells()[seedCellID];
const cell& cFaces = mesh().cells()[seedCellID];
label nFaces = 0;
@ -144,7 +144,7 @@ void Foam::regionSplit::fillSeedMask
{
label faceI = changedFaces[i];
label own = mesh_.faceOwner()[faceI];
label own = mesh().faceOwner()[faceI];
if (cellRegion[own] == -1)
{
@ -152,9 +152,9 @@ void Foam::regionSplit::fillSeedMask
changedCells.append(own);
}
if (mesh_.isInternalFace(faceI))
if (mesh().isInternalFace(faceI))
{
label nei = mesh_.faceNeighbour()[faceI];
label nei = mesh().faceNeighbour()[faceI];
if (cellRegion[nei] == -1)
{
@ -178,7 +178,7 @@ void Foam::regionSplit::fillSeedMask
{
label cellI = changedCells[i];
const cell& cFaces = mesh_.cells()[cellI];
const cell& cFaces = mesh().cells()[cellI];
forAll(cFaces, cFaceI)
{
@ -203,7 +203,7 @@ void Foam::regionSplit::fillSeedMask
// Check for changes to any locally coupled face.
// Global connections are done later.
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const polyBoundaryMesh& patches = mesh().boundaryMesh();
forAll(patches, patchI)
{
@ -274,7 +274,7 @@ Foam::label Foam::regionSplit::calcLocalRegionSplit
{
// Check that blockedFace is synced.
boolList syncBlockedFace(blockedFace);
syncTools::swapFaceList(mesh_, syncBlockedFace);
syncTools::swapFaceList(mesh(), syncBlockedFace);
forAll(syncBlockedFace, faceI)
{
@ -295,7 +295,7 @@ Foam::label Foam::regionSplit::calcLocalRegionSplit
// Region per face.
// -1 unassigned
// -2 blocked
labelList faceRegion(mesh_.nFaces(), -1);
labelList faceRegion(mesh().nFaces(), -1);
if (blockedFace.size())
{
@ -321,7 +321,7 @@ Foam::label Foam::regionSplit::calcLocalRegionSplit
{
// Find first unset cell
for (; unsetCellI < mesh_.nCells(); unsetCellI++)
for (; unsetCellI < mesh().nCells(); unsetCellI++)
{
if (cellRegion[unsetCellI] == -1)
{
@ -329,7 +329,7 @@ Foam::label Foam::regionSplit::calcLocalRegionSplit
}
}
if (unsetCellI >= mesh_.nCells())
if (unsetCellI >= mesh().nCells())
{
break;
}
@ -430,9 +430,9 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
}
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const polyBoundaryMesh& patches = mesh().boundaryMesh();
labelList nbrRegion(mesh_.nFaces()-mesh_.nInternalFaces(), -1);
labelList nbrRegion(mesh().nFaces()-mesh().nInternalFaces(), -1);
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
@ -444,7 +444,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
(
nbrRegion,
pp.size(),
pp.start()-mesh_.nInternalFaces()
pp.start()-mesh().nInternalFaces()
);
forAll(patchCells, i)
@ -457,9 +457,9 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
}
}
}
syncTools::swapBoundaryFaceList(mesh_, nbrRegion);
syncTools::swapBoundaryFaceList(mesh(), nbrRegion);
Map<label> globalToMerged(mesh_.nFaces()-mesh_.nInternalFaces());
Map<label> globalToMerged(mesh().nFaces()-mesh().nInternalFaces());
forAll(patches, patchI)
{
@ -472,7 +472,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
(
nbrRegion,
pp.size(),
pp.start()-mesh_.nInternalFaces()
pp.start()-mesh().nInternalFaces()
);
forAll(patchCells, i)
@ -486,7 +486,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
//Pout<< "on patch:" << pp.name()
// << " cell:" << patchCells[i]
// << " at:"
// << mesh_.cellCentres()[patchCells[i]]
// << mesh().cellCentres()[patchCells[i]]
// << " was:" << cellRegion[patchCells[i]]
// << " nbr:" << patchNbrRegion[i]
// << endl;
@ -534,7 +534,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
// 4a: count. Use a labelHashSet to count regions only once.
label nCompact = 0;
{
labelHashSet localRegion(mesh_.nFaces()-mesh_.nInternalFaces());
labelHashSet localRegion(mesh().nFaces()-mesh().nInternalFaces());
forAll(cellRegion, cellI)
{
if
@ -692,8 +692,8 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
Foam::regionSplit::regionSplit(const polyMesh& mesh)
:
labelList(mesh.nCells(), -1),
mesh_(mesh)
MeshObject<polyMesh, regionSplit>(mesh),
labelList(mesh.nCells(), -1)
{
globalNumberingPtr_ = calcRegionSplit
(
@ -710,8 +710,8 @@ Foam::regionSplit::regionSplit
const boolList& blockedFace
)
:
labelList(mesh.nCells(), -1),
mesh_(mesh)
MeshObject<polyMesh, regionSplit>(mesh),
labelList(mesh.nCells(), -1)
{
globalNumberingPtr_ = calcRegionSplit
(
@ -729,8 +729,8 @@ Foam::regionSplit::regionSplit
const List<labelPair>& explicitConnections
)
:
labelList(mesh.nCells(), -1),
mesh_(mesh)
MeshObject<polyMesh, regionSplit>(mesh),
labelList(mesh.nCells(), -1)
{
globalNumberingPtr_ = calcRegionSplit
(

View File

@ -98,6 +98,7 @@ SourceFiles
#include "globalIndex.H"
#include "labelPair.H"
#include "boolList.H"
#include "MeshObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -112,13 +113,11 @@ class polyMesh;
class regionSplit
:
public MeshObject<polyMesh, regionSplit>,
public labelList
{
// Private data
//- Reference to mesh
const polyMesh& mesh_;
mutable autoPtr<globalIndex> globalNumberingPtr_;
@ -161,11 +160,13 @@ class regionSplit
labelList& cellRegion
) const;
public:
//- Runtime type information
ClassName("regionSplit");
// Constructors
//- Construct from mesh
@ -185,6 +186,7 @@ public:
const List<labelPair>&
);
// Member Functions
//- Return global region numbering
@ -198,7 +200,6 @@ public:
{
return globalNumbering().size();
}
};

View File

@ -141,7 +141,7 @@ void Foam::turbulenceFields::read(const dictionary& dict)
Info<< "storing fields:" << nl;
forAllConstIter(wordHashSet, fieldSet_, iter)
{
Info<< " " << modelName << "::" << iter.key() << nl;
Info<< " " << modelName << '.' << iter.key() << nl;
}
Info<< endl;
}

View File

@ -36,7 +36,7 @@ void Foam::turbulenceFields::processField
{
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
const word scopedName = modelName + "::" + fieldName;
const word scopedName = modelName + '.' + fieldName;
if (obr_.foundObject<FieldType>(scopedName))
{

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,34 +30,27 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
inline Foam::label Foam::Kmesh::index
(
const label i,
const label j,
const label k,
const labelList& nn
)
{
//! \cond fileScope
inline label rep
(
const label i,
const label j,
const label k,
const labelList& nn
)
{
return (k + j*nn[2] + i*nn[1]*nn[2]);
}
//! \endcond
} // End namespace Foam
return (k + j*nn[2] + i*nn[1]*nn[2]);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// from fvMesh
Foam::Kmesh::Kmesh(const fvMesh& mesh)
:
vectorField(mesh.V().size()),
NN(vector::dim)
nn_(vector::dim)
{
boundBox box = mesh.bounds();
L = box.span();
l_ = box.span();
vector cornerCellCentre = ::Foam::max(mesh.C().internalField());
vector cellL = 2*(box.max() - cornerCellCentre);
@ -65,18 +58,17 @@ Foam::Kmesh::Kmesh(const fvMesh& mesh)
vector rdeltaByL;
label nTot = 1;
label i;
forAll(NN, i)
forAll(nn_, i)
{
NN[i] = label(L[i]/cellL[i] + 0.5);
nTot *= NN[i];
nn_[i] = label(l_[i]/cellL[i] + 0.5);
nTot *= nn_[i];
if (NN[i] > 1)
if (nn_[i] > 1)
{
L[i] -= cellL[i];
l_[i] -= cellL[i];
}
rdeltaByL[i] = NN[i]/(L[i]*L[i]);
rdeltaByL[i] = nn_[i]/(l_[i]*l_[i]);
}
if (nTot != mesh.nCells())
@ -86,24 +78,31 @@ Foam::Kmesh::Kmesh(const fvMesh& mesh)
<< abort(FatalError);
}
for (i=0; i<NN[0]; i++)
for (label i=0; i<nn_[0]; i++)
{
scalar k1 = (i - NN[0]/2)*constant::mathematical::twoPi/L[0];
scalar k1 = (i - nn_[0]/2)*constant::mathematical::twoPi/l_[0];
for (label j=0; j<NN[1]; j++)
for (label j=0; j<nn_[1]; j++)
{
scalar k2 = (j - NN[1]/2)*constant::mathematical::twoPi/L[1];
scalar k2 = (j - nn_[1]/2)*constant::mathematical::twoPi/l_[1];
for (label k=0; k<NN[2]; k++)
for (label k=0; k<nn_[2]; k++)
{
scalar k3 = (k - NN[2]/2)*constant::mathematical::twoPi/L[2];
scalar k3 = (k - nn_[2]/2)*constant::mathematical::twoPi/l_[2];
(*this)[rep(i, j, k, NN)] = vector(k1, k2, k3);
(*this)[index(i, j, k, nn_)] = vector(k1, k2, k3);
}
}
}
Kmax = mag((*this)[rep(NN[0]-1, NN[1]-1, NN[2]-1, NN)]);
kmax_ = mag
(
Foam::max
(
cmptMag((*this)[index(nn_[0]-1, nn_[1]-1, nn_[2]-1, nn_)]),
cmptMag((*this)[index(0, 0, 0, nn_)])
)
);
}

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,17 +51,29 @@ class Kmesh
:
public vectorField
{
// Private data
//- Dimensions of box
vector L;
vector l_;
//- Multi-dimensional addressing array
labelList NN;
labelList nn_;
//- Maximum wavenumber
scalar Kmax;
scalar kmax_;
// Private functions
//- Return the linear index from the i-j-k indices
static inline label index
(
const label i,
const label j,
const label k,
const labelList& nn
);
public:
@ -77,17 +89,17 @@ public:
const vector& sizeOfBox() const
{
return L;
return l_;
}
const labelList& nn() const
{
return NN;
return nn_;
}
scalar max() const
{
return Kmax;
return kmax_;
}
};

View File

@ -7,6 +7,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidChemistryModel/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 \
@ -26,4 +27,5 @@ LIB_LIBS = \
-lcompressibleRASModels \
-lcompressibleLESModels \
-lLESdeltas \
-lregionModels
-lregionModels \
-lradiationModels

View File

@ -51,7 +51,8 @@ void noPyrolysis::constructThermoChemistry()
solidChemistryModel::New(regionMesh()).ptr()
);
solidThermo_.reset(&solidChemistry_->solid());
solidThermo_.reset(&solidChemistry_->solidThermo());
radiation_.reset(radiation::radiationModel::New(solidThermo_->T()).ptr());
}
bool noPyrolysis::read()
@ -88,7 +89,8 @@ noPyrolysis::noPyrolysis(const word& modelType, const fvMesh& mesh)
:
pyrolysisModel(mesh),
solidChemistry_(NULL),
solidThermo_(NULL)
solidThermo_(NULL),
radiation_(NULL)
{
if (active())
{
@ -105,7 +107,8 @@ noPyrolysis::noPyrolysis
):
pyrolysisModel(mesh),
solidChemistry_(NULL),
solidThermo_(NULL)
solidThermo_(NULL),
radiation_(NULL)
{
if (active())
{
@ -135,31 +138,31 @@ void noPyrolysis::evolveRegion()
const volScalarField& noPyrolysis::rho() const
{
return (solidThermo_->rho());
return solidThermo_->rho();
}
const volScalarField& noPyrolysis::T() const
{
return (solidThermo_->T());
return solidThermo_->T();
}
const tmp<volScalarField> noPyrolysis::Cp() const
{
return (solidThermo_->Cp());
return solidThermo_->Cp();
}
tmp<volScalarField> noPyrolysis::kappaRad() const
{
return (solidThermo_->kappaRad());
return radiation_->absorptionEmission().a();
}
tmp<volScalarField> noPyrolysis::kappa() const
{
return (solidThermo_->kappa());
return solidThermo_->kappa();
}

View File

@ -38,6 +38,7 @@ SourceFiles
#include "pyrolysisModel.H"
#include "volFieldsFwd.H"
#include "solidChemistryModel.H"
#include "radiationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -86,6 +87,9 @@ protected:
//- Reference to solid thermo
autoPtr<solidReactionThermo> solidThermo_;
//- Pointer to radiation model
autoPtr<radiation::radiationModel> radiation_;
public:

View File

@ -363,7 +363,8 @@ reactingOneDim::reactingOneDim(const word& modelType, const fvMesh& mesh)
:
pyrolysisModel(modelType, mesh),
solidChemistry_(solidChemistryModel::New(regionMesh())),
solidThermo_(solidChemistry_->solid()),
solidThermo_(solidChemistry_->solidThermo()),
radiation_(radiation::radiationModel::New(solidThermo_.T())),
rho_
(
IOobject
@ -474,7 +475,8 @@ reactingOneDim::reactingOneDim
:
pyrolysisModel(modelType, mesh, dict),
solidChemistry_(solidChemistryModel::New(regionMesh())),
solidThermo_(solidChemistry_->solid()),
solidThermo_(solidChemistry_->solidThermo()),
radiation_(radiation::radiationModel::New(solidThermo_.T())),
rho_
(
IOobject
@ -656,7 +658,7 @@ const tmp<volScalarField> reactingOneDim::Cp() const
tmp<volScalarField> reactingOneDim::kappaRad() const
{
return solidThermo_.kappaRad();
return radiation_->absorptionEmission().a();
}

View File

@ -37,7 +37,7 @@ SourceFiles
#include "pyrolysisModel.H"
#include "solidChemistryModel.H"
#include "radiationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -81,6 +81,9 @@ protected:
//- Reference to solid thermo
solidReactionThermo& solidThermo_;
//- Pointer to radiation model
autoPtr<radiation::radiationModel> radiation_;
// Reference to solid thermo properties
@ -90,7 +93,7 @@ protected:
//- List of solid components
PtrList<volScalarField>& Ys_;
// Non-const access to temperature
// Non-const access to enthalpy
volScalarField& h_;

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -82,7 +82,7 @@ tmp<volScalarField> noRadiation::Shs()
(
IOobject
(
typeName + "::Shs",
typeName + ".Shs",
owner().time().timeName(),
owner().regionMesh(),
IOobject::NO_READ,

View File

@ -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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -115,7 +115,7 @@ tmp<volScalarField> standardRadiation::Shs()
(
IOobject
(
typeName + "::Shs",
typeName + ".Shs",
owner().time().timeName(),
owner().regionMesh(),
IOobject::NO_READ,

Some files were not shown because too many files have changed in this diff Show More