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) + betav*fvc::ddt(rho, K) + fvc::div(phi, K)
+ ( + (
hea.name() == "ea" hea.name() == "ea"
? fvc::div(phi, volScalarField("Ep", p/rho)) ? fvc::div
(
phi/fvc::interpolate(rho),
p,
"div(phiv,p)"
)
: -betav*dpdt : -betav*dpdt
) )
- fvm::laplacian(Db, hea) - 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() + (betav*fvc::ddt(rho, K) + fvc::div(phi, K))*rho/thermo.rhou()
+ ( + (
heau.name() == "eau" 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() : -betav*dpdt*rho/thermo.rhou()
) )
- fvm::laplacian(Db, heau) - fvm::laplacian(Db, heau)

View File

@ -116,7 +116,7 @@ void PDRkEpsilon::correct()
} }
tmp<volTensorField> tgradU = fvc::grad(U_); 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(); tgradU.clear();
// Update espsilon and G at the wall // Update espsilon and G at the wall

View File

@ -7,7 +7,12 @@
+ fvc::ddt(rho, K) + fvc::div(phi, K) + fvc::ddt(rho, K) + fvc::div(phi, K)
+ ( + (
hea.name() == "ea" hea.name() == "ea"
? fvc::div(phi, volScalarField("Ep", p/rho)) ? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt : -dpdt
) )
- fvm::laplacian(turbulence->alphaEff(), hea) - 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() + (fvc::ddt(rho, K) + fvc::div(phi, K))*rho/thermo.rhou()
+ ( + (
heau.name() == "eau" 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() : -dpdt*rho/thermo.rhou()
) )
- fvm::laplacian(turbulence->alphaEff(), heau) - fvm::laplacian(turbulence->alphaEff(), heau)

View File

@ -66,5 +66,5 @@ K = 0.5*magSqr(U);
if (thermo.dpdt()) 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) + fvc::ddt(rho, K) + fvc::div(phi, K)
+ ( + (
he.name() == "e" he.name() == "e"
? fvc::div(phi, volScalarField("Ep", p/rho)) ? fvc::div
(
fvc::absolute(phi/fvc::interpolate(rho), U),
p,
"div(phiv,p)"
)
: -dpdt : -dpdt
) )
- fvm::laplacian(turbulence->alphaEff(), he) - fvm::laplacian(turbulence->alphaEff(), he)

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -195,10 +195,8 @@ void maxwellSlipUFvPatchVectorField::write(Ostream& os) const
<< thermalCreep_ << token::END_STATEMENT << nl; << thermalCreep_ << token::END_STATEMENT << nl;
os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl; os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl;
os.writeKeyword("refValue") refValue().writeEntry("refValue", os);
<< refValue() << token::END_STATEMENT << nl; valueFraction().writeEntry("valueFraction", os);
os.writeKeyword("valueFraction")
<< valueFraction() << token::END_STATEMENT << nl;
writeEntry("value", os); writeEntry("value", os);
} }

View File

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

View File

@ -2,7 +2,8 @@
solve solve
( (
fvm::ddt(rho, e) + fvm::div(phi, e) 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) - 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 // Initialise solid field pointer lists
PtrList<solidThermo> thermos(solidRegions.size()); PtrList<solidThermo> thermos(solidRegions.size());
PtrList<radiation::radiationModel> radiations(solidRegions.size());
// Populate solid field pointer lists // Populate solid field pointer lists
forAll(solidRegions, i) forAll(solidRegions, i)
@ -13,4 +14,7 @@
i, i,
solidThermo::New(solidRegions[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]; fvMesh& mesh = solidRegions[i];
solidThermo& thermo = thermos[i]; solidThermo& thermo = thermos[i];
const radiation::radiationModel& radiation = radiations[i];
tmp<volScalarField> trho = thermo.rho(); tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho(); const volScalarField& rho = trho();

View File

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

View File

@ -1,5 +1,6 @@
// Initialise solid field pointer lists // Initialise solid field pointer lists
PtrList<solidThermo> thermos(solidRegions.size()); PtrList<solidThermo> thermos(solidRegions.size());
PtrList<radiation::radiationModel> radiations(solidRegions.size());
// Populate solid field pointer lists // Populate solid field pointer lists
forAll(solidRegions, i) forAll(solidRegions, i)
@ -9,4 +10,7 @@
Info<< " Adding to thermos\n" << endl; Info<< " Adding to thermos\n" << endl;
thermos.set(i, solidThermo::New(solidRegions[i])); 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]; fvMesh& mesh = solidRegions[i];
solidThermo& thermo = thermos[i]; solidThermo& thermo = thermos[i];
const radiation::radiationModel& radiation = radiations[i];
tmp<volScalarField> trho = thermo.rho(); tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho(); const volScalarField& rho = trho();

View File

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

View File

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

View File

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

View File

@ -79,5 +79,5 @@ K = 0.5*magSqr(U);
if (thermo.dpdt()) 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,6 +41,45 @@ int main(int argc, char *argv[])
Info<< ds*dt << " " << dt*ds << endl; 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; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -310,6 +310,10 @@ addLayersControls
// make straight angle. // make straight angle.
featureAngle 60; 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 //- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh. // before upon reaching a correct mesh.
nRelaxIter 5; nRelaxIter 5;

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -115,6 +115,7 @@ int main(int argc, char *argv[])
runTimeMaster runTimeMaster
) )
); );
const word oldInstance = masterMesh.pointsInstance();
Info<< "Reading mesh to add for time = " << runTimeToAdd.timeName() << nl; Info<< "Reading mesh to add for time = " << runTimeToAdd.timeName() << nl;
@ -139,7 +140,13 @@ int main(int argc, char *argv[])
masterMesh.addMesh(meshToAdd); masterMesh.addMesh(meshToAdd);
masterMesh.merge(); masterMesh.merge();
masterMesh.polyMesh::write();
if (overwrite)
{
masterMesh.setInstance(oldInstance);
}
masterMesh.write();
Info<< "\nEnd\n" << endl; 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 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. 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. - Should work in parallel.
cellZones can differ on either side of processor boundaries in which case 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> template<class GeoField>
void subsetVolFields void subsetVolFields
( (
@ -987,6 +1023,7 @@ void createAndWriteRegion
const fvMesh& mesh, const fvMesh& mesh,
const labelList& cellRegion, const labelList& cellRegion,
const wordList& regionNames, const wordList& regionNames,
const bool prefixRegion,
const labelList& faceToInterface, const labelList& faceToInterface,
const labelList& interfacePatches, const labelList& interfacePatches,
const label regionI, const label regionI,
@ -1017,6 +1054,7 @@ void createAndWriteRegion
addedPatches.insert(interfacePatches[interfaceI]+1); addedPatches.insert(interfacePatches[interfaceI]+1);
} }
Info<< "Mapping fields" << endl; Info<< "Mapping fields" << endl;
// Map existing fields // Map existing fields
@ -1109,6 +1147,7 @@ void createAndWriteRegion
// Create reordering list to move patches-to-be-deleted to end // Create reordering list to move patches-to-be-deleted to end
labelList oldToNew(newPatches.size(), -1); labelList oldToNew(newPatches.size(), -1);
DynamicList<label> sharedPatches(newPatches.size());
label newI = 0; label newI = 0;
Info<< "Deleting empty patches" << endl; Info<< "Deleting empty patches" << endl;
@ -1122,7 +1161,12 @@ void createAndWriteRegion
{ {
if (returnReduce(pp.size(), sumOp<label>()) > 0) 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); 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; Info<< "Writing new mesh" << endl;
newMesh().setInstance(newMeshInstance); newMesh().setInstance(newMeshInstance);
@ -1672,6 +1725,11 @@ int main(int argc, char *argv[])
"useFaceZones", "useFaceZones",
"use faceZones to patch inter-region faces instead of single patch" "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 "setRootCase.H"
#include "createTime.H" #include "createTime.H"
@ -1696,6 +1754,8 @@ int main(int argc, char *argv[])
const bool detectOnly = args.optionFound("detectOnly"); const bool detectOnly = args.optionFound("detectOnly");
const bool sloppyCellZones = args.optionFound("sloppyCellZones"); const bool sloppyCellZones = args.optionFound("sloppyCellZones");
const bool useFaceZones = args.optionFound("useFaceZones"); const bool useFaceZones = args.optionFound("useFaceZones");
const bool prefixRegion = args.optionFound("prefixRegion");
if if
( (
@ -2226,6 +2286,7 @@ int main(int argc, char *argv[])
mesh, mesh,
cellRegion, cellRegion,
regionNames, regionNames,
prefixRegion,
faceToInterface, faceToInterface,
interfacePatches, interfacePatches,
regionI, regionI,
@ -2246,6 +2307,7 @@ int main(int argc, char *argv[])
mesh, mesh,
cellRegion, cellRegion,
regionNames, regionNames,
prefixRegion,
faceToInterface, faceToInterface,
interfacePatches, interfacePatches,
regionI, regionI,
@ -2266,6 +2328,7 @@ int main(int argc, char *argv[])
mesh, mesh,
cellRegion, cellRegion,
regionNames, regionNames,
prefixRegion,
faceToInterface, faceToInterface,
interfacePatches, interfacePatches,
regionI, regionI,

View File

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

View File

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

View File

@ -136,7 +136,7 @@ int main(int argc, char *argv[])
} }
// Create G field - used by RAS wall functions // 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 //--- Read and modify turbulence fields

View File

@ -721,16 +721,34 @@ int main(int argc, char *argv[])
deleteBox(surf, bb, true, edgeStat); deleteBox(surf, bb, true, edgeStat);
} }
const Switch manifoldEdges = const Switch nonManifoldEdges =
subsetDict.lookupOrDefault<Switch>("manifoldEdges", "no"); 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) 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; edgeStat[edgeI] = surfaceFeatures::NONE;
} }

View File

@ -59,15 +59,21 @@ surface2.nas
{ {
// Use a plane to select feature edges // Use a plane to select feature edges
// (normal)(basePoint) // (normal)(basePoint)
// Keep only edges that intersect the plane will be included
plane (1 0 0)(0 0 0); plane (1 0 0)(0 0 0);
// Select feature edges using a box // Select feature edges using a box
// (minPt)(maxPt) // (minPt)(maxPt)
// Keep edges inside the box:
insideBox (0 0 0)(1 1 1); insideBox (0 0 0)(1 1 1);
// Keep edges outside the box:
outsideBox (0 0 0)(1 1 1); outsideBox (0 0 0)(1 1 1);
// Remove any non-manifold (open or > 2 connected faces) edges // Keep nonManifold edges (edges with >2 connected faces)
manifoldEdges no; nonManifoldEdges yes;
// Keep open edges (edges with 1 connected face)
openEdges yes;
} }
addFeatures 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; Cd Cd [ 0 0 0 0 0 0 1 ] 1.0;
// Derived units // 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 // Some non-symbolic ones
mm mm [ kg^1 m^-2 ] 1e-3; 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 // Set of units used for printing. Can be any basic or derived
// but not scaled (only supported for dimensionedScalar, etc) // 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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) void error::printStack(Ostream& os)
{ {
// Reads the starting addresses for the dynamically linked libraries // Reads the starting addresses for the dynamically linked libraries

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,8 +29,7 @@ Description
SourceFiles SourceFiles
ISstreamI.H ISstreamI.H
ISread.C ISstream.C
ISreadToken.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -77,7 +77,7 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Read the include fileName from Istream, expand and return //- Read the include fileName from Istream, expand and return
static fileName includeFileName(Istream&); static fileName includeFileName(Istream&, const dictionary&);
public: public:

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,7 +69,7 @@ bool Foam::functionEntries::includeIfPresentEntry::execute
Istream& is Istream& is
) )
{ {
const fileName fName(includeFileName(is)); const fileName fName(includeFileName(is, parentDict));
IFstream ifs(fName); IFstream ifs(fName);
if (ifs) if (ifs)
@ -92,7 +92,7 @@ bool Foam::functionEntries::includeIfPresentEntry::execute
Istream& is Istream& is
) )
{ {
const fileName fName(includeFileName(is)); const fileName fName(includeFileName(is, parentDict));
IFstream ifs(fName); IFstream ifs(fName);
if (ifs) if (ifs)

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -162,6 +162,10 @@ public:
operator dictionary() const; 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 //- Helper function to print a stack
static void printStack(Ostream&); static void printStack(Ostream&);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -82,7 +82,13 @@ Description
) \ ) \
{ \ { \
construct##argNames##ConstructorTables(); \ 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() \ ~add##argNames##ConstructorToTable() \
@ -167,11 +173,20 @@ Description
) \ ) \
{ \ { \
construct##argNames##ConstructorTables(); \ construct##argNames##ConstructorTables(); \
argNames##ConstructorTablePtr_->insert \ if \
( \
!argNames##ConstructorTablePtr_->insert \
( \ ( \
lookup, \ lookup, \
New##baseType \ New##baseType \
); \ ) \
) \
{ \
std::cerr<< "Duplicate entry " << lookup \
<< " in runtime selection table " << #baseType \
<< std::endl; \
error::safePrintStack(std::cerr); \
} \
} \ } \
\ \
~add##argNames##ConstructorToTable() \ ~add##argNames##ConstructorToTable() \

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
Foam::scalar Foam::dimensionSet::operator[](const dimensionType type) const 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 bool Foam::dimensionSet::operator==(const dimensionSet& ds) const
{ {
for (int Dimension=0; Dimension < nDimensions; ++Dimension) for (int Dimension=0; Dimension < nDimensions; ++Dimension)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -40,10 +40,12 @@ SourceFiles
#ifndef dimensionSet_H #ifndef dimensionSet_H
#define dimensionSet_H #define dimensionSet_H
#include "scalar.H"
#include "bool.H" #include "bool.H"
#include "dimensionedScalarFwd.H" #include "dimensionedScalarFwd.H"
#include "className.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 // Forward declaration of friend functions and operators
class dimensionSet; class dimensionSet;
class dimensionSets;
// Friend functions // Friend functions
@ -140,6 +143,64 @@ public:
private: 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 // private data
// dimensionSet stored as an array of dimension exponents // dimensionSet stored as an array of dimension exponents
@ -189,14 +250,56 @@ public:
void reset(const dimensionSet&); 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 // Member operators
scalar operator[](const dimensionType) const; scalar operator[](const dimensionType) const;
scalar& operator[](const dimensionType); scalar& operator[](const dimensionType);
scalar operator[](const label) const;
scalar& operator[](const label);
bool operator==(const dimensionSet&) const; bool operator==(const dimensionSet&) const;
bool operator!=(const dimensionSet&) const; bool operator!=(const dimensionSet&) const;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,6 +25,7 @@ License
#include "dimensionSet.H" #include "dimensionSet.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "dimensionedScalar.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -34,21 +35,401 @@ 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 label end = (start_+size_)%tokens_.size();
if (token(is) != token::BEGIN_SQR) tokens_[end] = t;
if (size_ == tokens_.size())
{ {
Info<< "expected a " << token::BEGIN_SQR << " in dimensionSet" start_ = tokens_.fcIndex(start_);
<< endl << "in stream " << is.info() << endl; }
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);
} }
// Read first five dimensions ds.dimensions() *= sub.dimensions();
for (int Dimension=0; Dimension<dimensionSet::CURRENT; Dimension++) ds.value() *= sub.value();
haveReadSymbol = true;
}
else if (nextToken.pToken() == token::END_LIST)
{ {
is >> dset.exponents_[Dimension]; 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);
}
}
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)
{
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 (!nextToken.isNumber())
{
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
{
// Read first five dimensions
exponents_[dimensionSet::MASS] = nextToken.number();
for (int Dimension=1; Dimension<dimensionSet::CURRENT; Dimension++)
{
is >> exponents_[Dimension];
} }
// Read next token // Read next token
@ -59,21 +440,265 @@ Foam::Istream& Foam::operator>>(Istream& is, dimensionSet& dset)
// and then read another token for the end of the dimensionSet // and then read another token for the end of the dimensionSet
if (nextToken.isNumber()) if (nextToken.isNumber())
{ {
dset.exponents_[dimensionSet::CURRENT] = nextToken.number(); exponents_[dimensionSet::CURRENT] = nextToken.number();
is >> dset.exponents_[dimensionSet::LUMINOUS_INTENSITY]; is >> nextToken;
exponents_[dimensionSet::LUMINOUS_INTENSITY] = nextToken.number();
is >> nextToken; is >> nextToken;
} }
else else
{ {
dset.exponents_[dimensionSet::CURRENT] = 0; exponents_[dimensionSet::CURRENT] = 0;
dset.exponents_[dimensionSet::LUMINOUS_INTENSITY] = 0; exponents_[dimensionSet::LUMINOUS_INTENSITY] = 0;
} }
// Check end of dimensionSet // Check end of dimensionSet
if (nextToken != token::END_SQR) if (nextToken != token::END_SQR)
{ {
Info<< "expected a " << token::END_SQR << " in dimensionSet" FatalIOErrorIn
<< endl << "in stream " << is.info() << endl; (
"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);
}
// Read next token
token nextToken(is);
if (nextToken.isWord())
{
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 // 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) Foam::Ostream& Foam::operator<<(Ostream& os, const dimensionSet& dset)
{ {
os << token::BEGIN_SQR; scalar multiplier;
dset.write(os, multiplier);
for (int Dimension=0; Dimension<dimensionSet::nDimensions-1; Dimension++)
{
os << dset.exponents_[Dimension] << token::SPACE;
}
os << dset.exponents_[dimensionSet::nDimensions-1] << token::END_SQR;
// Check state of Ostream // Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const dimensionSet&)"); os.check("Ostream& operator<<(Ostream&, const dimensionSet&)");

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,34 +24,210 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "dimensionSet.H" #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)); dictionary* dimensionSystemsPtr_(NULL);
const Foam::dimensionSet Foam::dimVolume(pow3(dimLength));
const Foam::dimensionSet Foam::dimVol(dimVolume);
const Foam::dimensionSet Foam::dimVelocity(dimLength/dimTime); dictionary& dimensionSystems()
const Foam::dimensionSet Foam::dimAcceleration(dimVelocity/dimTime); {
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); /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
const Foam::dimensionSet Foam::dimGasConstant(dimEnergy/dimMass/dimTemperature);
const Foam::dimensionSet Foam::dimSpecificHeatCapacity(dimGasConstant);
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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,6 +36,10 @@ SourceFiles
#ifndef dimensionSets_H #ifndef dimensionSets_H
#define dimensionSets_H #define dimensionSets_H
#include "scalarMatrices.H"
#include "dimensionedScalarFwd.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -69,6 +73,65 @@ extern const dimensionSet dimGasConstant;
extern const dimensionSet dimSpecificHeatCapacity; 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 } // End namespace Foam

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -163,6 +163,17 @@ public:
bool readIfPresent(const dictionary&); 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 // Member operators
//- Return a component as a dimensioned<cmptType> //- Return a component as a dimensioned<cmptType>

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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 // Member operators
// Disable assignment operators // Disable assignment operators

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -278,6 +278,12 @@ public:
return internalField_; 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 //- Return true if this patch field is coupled
virtual bool coupled() const virtual bool coupled() const
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -79,6 +79,9 @@ public:
//- Construct copy and increment reference count //- Construct copy and increment reference count
inline tmp(const tmp<T>&); 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 //- Destructor, delete object when reference count == 0
inline ~tmp(); inline ~tmp();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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> template<class T>
inline Foam::tmp<T>::~tmp() inline Foam::tmp<T>::~tmp()
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -322,7 +322,12 @@ Foam::string& Foam::stringOps::inplaceExpand
// lookup in the dictionary // 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 defined - copy its entries
if (ePtr) if (ePtr)

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,10 +58,6 @@ class basicSymmetryFvPatchField
public: public:
//- Runtime type information
TypeName(symmetryFvPatch::typeName_());
// Constructors // Constructors
//- Construct from patch and internal field //- Construct from patch and internal field

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -269,98 +269,98 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
( (
ITstream ITstream
( (
objectPath() + "::ddtSchemes", objectPath() + ".ddtSchemes",
tokenList() tokenList()
)() )()
), ),
defaultDdtScheme_ defaultDdtScheme_
( (
ddtSchemes_.name() + "::default", ddtSchemes_.name() + ".default",
tokenList() tokenList()
), ),
d2dt2Schemes_ d2dt2Schemes_
( (
ITstream ITstream
( (
objectPath() + "::d2dt2Schemes", objectPath() + ".d2dt2Schemes",
tokenList() tokenList()
)() )()
), ),
defaultD2dt2Scheme_ defaultD2dt2Scheme_
( (
d2dt2Schemes_.name() + "::default", d2dt2Schemes_.name() + ".default",
tokenList() tokenList()
), ),
interpolationSchemes_ interpolationSchemes_
( (
ITstream ITstream
( (
objectPath() + "::interpolationSchemes", objectPath() + ".interpolationSchemes",
tokenList() tokenList()
)() )()
), ),
defaultInterpolationScheme_ defaultInterpolationScheme_
( (
interpolationSchemes_.name() + "::default", interpolationSchemes_.name() + ".default",
tokenList() tokenList()
), ),
divSchemes_ divSchemes_
( (
ITstream ITstream
( (
objectPath() + "::divSchemes", objectPath() + ".divSchemes",
tokenList() tokenList()
)() )()
), ),
defaultDivScheme_ defaultDivScheme_
( (
divSchemes_.name() + "::default", divSchemes_.name() + ".default",
tokenList() tokenList()
), ),
gradSchemes_ gradSchemes_
( (
ITstream ITstream
( (
objectPath() + "::gradSchemes", objectPath() + ".gradSchemes",
tokenList() tokenList()
)() )()
), ),
defaultGradScheme_ defaultGradScheme_
( (
gradSchemes_.name() + "::default", gradSchemes_.name() + ".default",
tokenList() tokenList()
), ),
snGradSchemes_ snGradSchemes_
( (
ITstream ITstream
( (
objectPath() + "::snGradSchemes", objectPath() + ".snGradSchemes",
tokenList() tokenList()
)() )()
), ),
defaultSnGradScheme_ defaultSnGradScheme_
( (
snGradSchemes_.name() + "::default", snGradSchemes_.name() + ".default",
tokenList() tokenList()
), ),
laplacianSchemes_ laplacianSchemes_
( (
ITstream ITstream
( (
objectPath() + "::laplacianSchemes", objectPath() + ".laplacianSchemes",
tokenList() tokenList()
)() )()
), ),
defaultLaplacianScheme_ defaultLaplacianScheme_
( (
laplacianSchemes_.name() + "::default", laplacianSchemes_.name() + ".default",
tokenList() tokenList()
), ),
fluxRequired_ fluxRequired_
( (
ITstream ITstream
( (
objectPath() + "::fluxRequired", objectPath() + ".fluxRequired",
tokenList() tokenList()
)() )()
), ),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -116,6 +116,22 @@ namespace fvc
const volScalarField& rho, const volScalarField& rho,
const volVectorField& U 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -54,6 +54,7 @@ namespace Foam
scalar scalar
) )
/*
makeLimitedSurfaceInterpolationTypeScheme makeLimitedSurfaceInterpolationTypeScheme
( (
MUSCL, MUSCL,
@ -71,6 +72,7 @@ namespace Foam
rhoMagSqr, rhoMagSqr,
vector vector
) )
*/
} }
// ************************************************************************* // // ************************************************************************* //

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,9 +33,10 @@ Description
#include "motionSmoother.H" #include "motionSmoother.H"
#include "pointData.H" #include "pointData.H"
#include "PointEdgeWave.H" #include "PointEdgeWave.H"
#include "OFstream.H" #include "OBJstream.H"
#include "meshTools.H" #include "meshTools.H"
#include "PatchTools.H" #include "PatchTools.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -775,6 +776,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
const label nSmoothNormals, const label nSmoothNormals,
const label nSmoothSurfaceNormals, const label nSmoothSurfaceNormals,
const scalar minMedianAxisAngleCos, const scalar minMedianAxisAngleCos,
const scalar featureAngle,
pointVectorField& dispVec, pointVectorField& dispVec,
pointScalarField& medialRatio, pointScalarField& medialRatio,
@ -904,7 +906,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
const edge& e = edges[edgeI]; const edge& e = edges[edgeI];
// Approximate medial axis location on edge. // Approximate medial axis location on edge.
//const point medialAxisPt = e.centre(points); //const point medialAxisPt = e.centre(points);
vector eVec = e.vec(mesh.points()); vector eVec = e.vec(points);
scalar eMag = mag(eVec); scalar eMag = mag(eVec);
if (eMag > VSMALL) if (eMag > VSMALL)
{ {
@ -961,28 +963,36 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
labelHashSet adaptPatches(meshMover.adaptPatchIDs()); labelHashSet adaptPatches(meshMover.adaptPatchIDs());
forAll(patches, patchI) forAll(patches, patchI)
{ {
const polyPatch& pp = patches[patchI]; const polyPatch& pp = patches[patchI];
//const pointPatchVectorField& pvf = const pointPatchVectorField& pvf =
// meshMover.displacement().boundaryField()[patchI]; meshMover.displacement().boundaryField()[patchI];
if if
( (
!pp.coupled() !pp.coupled()
&& !isA<emptyPolyPatch>(pp) && !isA<emptyPolyPatch>(pp)
//&& pvf.constraintType() != word::null //exclude fixedValue
&& !adaptPatches.found(patchI) && !adaptPatches.found(patchI)
) )
{ {
Info<< "Inserting points on patch " << pp.name() << endl;
const labelList& meshPoints = pp.meshPoints(); const labelList& meshPoints = pp.meshPoints();
// 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())
{
// Disable all movement on fixedValue patchFields
Info<< "Inserting all points on patch " << pp.name()
<< endl;
forAll(meshPoints, i) forAll(meshPoints, i)
{ {
label pointI = meshPoints[i]; label pointI = meshPoints[i];
if (!pointMedialDist[pointI].valid(dummyTrackData)) if (!pointMedialDist[pointI].valid(dummyTrackData))
{ {
maxPoints.append(pointI); maxPoints.append(pointI);
@ -1000,6 +1010,67 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
} }
} }
} }
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
}
}
}
}
}
} }
maxInfo.shrink(); maxInfo.shrink();
@ -1141,13 +1212,12 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
// reduce thickness where thickness/medial axis distance large // reduce thickness where thickness/medial axis distance large
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autoPtr<OFstream> str; autoPtr<OBJstream> str;
label vertI = 0;
if (debug) if (debug)
{ {
str.reset str.reset
( (
new OFstream new OBJstream
( (
mesh.time().path() mesh.time().path()
/ "thicknessRatioExcludePoints_" / "thicknessRatioExcludePoints_"
@ -1159,13 +1229,12 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
<< str().name() << endl; << str().name() << endl;
} }
autoPtr<OFstream> medialVecStr; autoPtr<OBJstream> medialVecStr;
label medialVertI = 0;
if (debug) if (debug)
{ {
medialVecStr.reset medialVecStr.reset
( (
new OFstream new OBJstream
( (
mesh.time().path() mesh.time().path()
/ "thicknessRatioExcludeMedialVec_" / "thicknessRatioExcludeMedialVec_"
@ -1227,21 +1296,19 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
if (str.valid()) if (str.valid())
{ {
const point& pt = mesh.points()[pointI]; const point& pt = mesh.points()[pointI];
meshTools::writeOBJ(str(), pt); str().write(linePointRef(pt, pt+patchDisp[patchPointI]));
vertI++;
meshTools::writeOBJ(str(), pt+patchDisp[patchPointI]);
vertI++;
str()<< "l " << vertI-1 << ' ' << vertI << nl;
} }
if (medialVecStr.valid()) if (medialVecStr.valid())
{ {
const point& pt = mesh.points()[pointI]; const point& pt = mesh.points()[pointI];
meshTools::writeOBJ(medialVecStr(), pt); medialVecStr().write
medialVertI++; (
meshTools::writeOBJ(medialVecStr(), medialVec[pointI]); linePointRef
medialVertI++; (
medialVecStr()<< "l " << medialVertI-1 pt,
<< ' ' << medialVertI << nl; medialVec[pointI]
)
);
} }
} }
} }

View File

@ -178,6 +178,24 @@ class autoSnapDriver
vector& edgeOffset // offset from pt to point on edge vector& edgeOffset // offset from pt to point on edge
) const; ) 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 //- Return hit if on multiple points
pointIndexHit findMultiPatchPoint pointIndexHit findMultiPatchPoint
( (

View File

@ -848,17 +848,17 @@ void Foam::autoSnapDriver::featureAttractionUsingReconstruction
vector d = r.refPoint()-pt; vector d = r.refPoint()-pt;
d -= (d&n)*n; d -= (d&n)*n;
// Correct for attraction to non-dominant face //// Correct for attraction to non-dominant face
correctAttraction //correctAttraction
( //(
surfacePoints, // surfacePoints,
surfaceCount, // surfaceCount,
r.refPoint(), // r.refPoint(),
n, // normalised normal // n, // normalised normal
pt, // pt,
//
d // perpendicular offset vector // d // perpendicular offset vector
); //);
// Trim to snap distance // Trim to snap distance
if (magSqr(d) > sqr(snapDist[pointI])) if (magSqr(d) > sqr(snapDist[pointI]))
@ -893,6 +893,15 @@ void Foam::autoSnapDriver::featureAttractionUsingReconstruction
patchConstraint.applyConstraint(surfaceNormals[0]); patchConstraint.applyConstraint(surfaceNormals[0]);
patchConstraint.applyConstraint(surfaceNormals[1]); patchConstraint.applyConstraint(surfaceNormals[1]);
patchConstraint.applyConstraint(surfaceNormals[2]); 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 Foam::pointIndexHit Foam::autoSnapDriver::findNearFeatureEdge
( (
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
@ -1125,7 +1323,7 @@ Foam::labelPair Foam::autoSnapDriver::findNearFeaturePoint
patchConstraints[oldPointI] = pointConstraint(); patchConstraints[oldPointI] = pointConstraint();
label edgeFeatI; label edgeFeatI;
const pointIndexHit nearInfo = findNearFeatureEdge findNearFeatureEdge
( (
pp, pp,
snapDist, snapDist,
@ -1721,7 +1919,7 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
// the old point to attract to nearest edge // the old point to attract to nearest edge
// instead. // instead.
label edgeFeatI; label edgeFeatI;
const pointIndexHit nearInfo = findNearFeatureEdge findNearFeatureEdge
( (
pp, pp,
snapDist, snapDist,
@ -1752,7 +1950,7 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
// << endl; // << endl;
label featI; label featI;
const pointIndexHit nearInfo = findNearFeatureEdge findNearFeatureEdge
( (
pp, pp,
snapDist, snapDist,
@ -2113,157 +2311,21 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
// Walk existing edges and snap remaining ones (that are marked as // Walk existing edges and snap remaining ones (that are marked as
// feature edges in allPatchConstraints) // feature edges in allPatchConstraints)
while (true) stringFeatureEdges
{
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 iter,
&& allPatchConstraints[nbrPointI].first() > 1 featureCos,
)
{
const vector& nbrFeatVec =
allPatchConstraints[pointI].second();
if (mag(featVec&nbrFeatVec) > featureCos) pp,
{ snapDist,
// nbrPointI attracted to sameish feature
// Note: also check on position.
scalar d2 = magSqr allPatchAttraction,
( allPatchConstraints,
allPatchAttraction[nbrPointI]
patchAttraction,
patchConstraints
); );
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;
}
}
// Avoid diagonal attraction // Avoid diagonal attraction
// ~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~

View File

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

View File

@ -79,6 +79,8 @@ class layerParameters
scalar featureAngle_; scalar featureAngle_;
scalar slipFeatureAngle_;
scalar concaveAngle_; scalar concaveAngle_;
label nGrow_; label nGrow_;
@ -178,6 +180,13 @@ public:
return featureAngle_; 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 scalar concaveAngle() const
{ {
return concaveAngle_; return concaveAngle_;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,34 +30,27 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam inline Foam::label Foam::Kmesh::index
{ (
//! \cond fileScope
inline label rep
(
const label i, const label i,
const label j, const label j,
const label k, const label k,
const labelList& nn const labelList& nn
) )
{ {
return (k + j*nn[2] + i*nn[1]*nn[2]); return (k + j*nn[2] + i*nn[1]*nn[2]);
} }
//! \endcond
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// from fvMesh
Foam::Kmesh::Kmesh(const fvMesh& mesh) Foam::Kmesh::Kmesh(const fvMesh& mesh)
: :
vectorField(mesh.V().size()), vectorField(mesh.V().size()),
NN(vector::dim) nn_(vector::dim)
{ {
boundBox box = mesh.bounds(); boundBox box = mesh.bounds();
L = box.span(); l_ = box.span();
vector cornerCellCentre = ::Foam::max(mesh.C().internalField()); vector cornerCellCentre = ::Foam::max(mesh.C().internalField());
vector cellL = 2*(box.max() - cornerCellCentre); vector cellL = 2*(box.max() - cornerCellCentre);
@ -65,18 +58,17 @@ Foam::Kmesh::Kmesh(const fvMesh& mesh)
vector rdeltaByL; vector rdeltaByL;
label nTot = 1; label nTot = 1;
label i; forAll(nn_, i)
forAll(NN, i)
{ {
NN[i] = label(L[i]/cellL[i] + 0.5); nn_[i] = label(l_[i]/cellL[i] + 0.5);
nTot *= NN[i]; 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()) if (nTot != mesh.nCells())
@ -86,24 +78,31 @@ Foam::Kmesh::Kmesh(const fvMesh& mesh)
<< abort(FatalError); << 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 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,17 +51,29 @@ class Kmesh
: :
public vectorField public vectorField
{ {
// Private data // Private data
//- Dimensions of box //- Dimensions of box
vector L; vector l_;
//- Multi-dimensional addressing array //- Multi-dimensional addressing array
labelList NN; labelList nn_;
//- Maximum wavenumber //- 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: public:
@ -77,17 +89,17 @@ public:
const vector& sizeOfBox() const const vector& sizeOfBox() const
{ {
return L; return l_;
} }
const labelList& nn() const const labelList& nn() const
{ {
return NN; return nn_;
} }
scalar max() const 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/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidChemistryModel/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidChemistryModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \ -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \ -I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
@ -26,4 +27,5 @@ LIB_LIBS = \
-lcompressibleRASModels \ -lcompressibleRASModels \
-lcompressibleLESModels \ -lcompressibleLESModels \
-lLESdeltas \ -lLESdeltas \
-lregionModels -lregionModels \
-lradiationModels

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -82,7 +82,7 @@ tmp<volScalarField> noRadiation::Shs()
( (
IOobject IOobject
( (
typeName + "::Shs", typeName + ".Shs",
owner().time().timeName(), owner().time().timeName(),
owner().regionMesh(), owner().regionMesh(),
IOobject::NO_READ, IOobject::NO_READ,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -115,7 +115,7 @@ tmp<volScalarField> standardRadiation::Shs()
( (
IOobject IOobject
( (
typeName + "::Shs", typeName + ".Shs",
owner().time().timeName(), owner().time().timeName(),
owner().regionMesh(), owner().regionMesh(),
IOobject::NO_READ, IOobject::NO_READ,

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