diff --git a/ReleaseNotes-dev b/ReleaseNotes-dev
new file mode 100644
index 0000000000..d35d1b518e
--- /dev/null
+++ b/ReleaseNotes-dev
@@ -0,0 +1,130 @@
+# -*- mode: org; -*-
+#
+#+TITLE: OpenFOAM release notes for version dev
+#+AUTHOR: OpenCFD Ltd.
+#+DATE: TBA
+#+LINK: http://www.openfoam.com
+#+OPTIONS: author:nil ^:{}
+# Copyright (c) 2010 OpenCFD Ltd.
+
+* Overview
+ OpenFOAM-dev is the latest major release of OpenFOAM including many new
+ developments a number of bug-fixes. This release passes our standard tests
+ and the tutorials have been broadly checked. Please report any bugs by
+ following the link: http://www.openfoam.com/bugs.
+
+* GNU/Linux version
+ This release of OpenFOAM is distributed primarily in 2 ways: (1) as a Debian
+ pack containing binaries and source; (2) from the SourceForge source code
+ repository (see [[./README.org][README]]).
+
+ The Ubuntu/Debian pack is available for 32 and 64 bit versions of the 10.04
+ LTS operating system using the system compiler and libraries that will be
+ installed automatically from standard Debian packs.
+
+ To use the source version from the SourceForge repository, we provide a source
+ pack of third-party packages that can be compiled on the user's system. This
+ does not include =gcc=, since the system installed version is typically
+ sufficient, but includes =paraview-3.8.0=, =openmpi-1.4.1=, =scotch_5.1=,
+ =metis-5.0pre2=, =ParMetis-3.1= and =ParMGridGen-1.0=.
+
+* Library developments
+ There have been a number of developments to the libraries to support the
+ extension of functionality in solver and utility applications.
+*** Core library
+ + Large number of code refinements and consistency improvements to support
+ other developments.
+*** Turbulence modelling
+*** Thermo-physical Models
+*** DSMC
+*** Dynamic Mesh
+*** Numerics
+*** *Updated* command line help, e.g. `snappyHexMesh -help' now gives:
+
+ Usage: snappyHexMesh [OPTIONS]
+ options:
+ -case
specify alternate case directory, default is the cwd
+ -overwrite overwrite existing mesh/results files
+ -parallel run in parallel
+ -srcDoc display source code in browser
+ -doc display application documentation in browser
+ -help print the usage
+
+*** *New* Surface film library
+ + Creation of films by particle addition, or initial film distribution
+ + Coupled with the lagrangian/intermediate cloud hierarchy library
+ + Hierarchical design, consisting of
+ + kinematic film: mass, momentum
+ + constant thermodynamic properties
+ + thermodynamic film: mass, momentum and enthalpy
+ + constant, or temperature dependant thermodynamic properties
+ + Sub-models:
+ + detachment/dripping whereby particles (re)enter the originating cloud
+ + particle sizes set according to PDF
+ + other properties set to ensure mass, momentum and energy conservation
+ + heat transfer to/from walls and film surface
+ + film evaporation and boiling
+ + Additional wall functions for primary region momentum and temperature
+ taking film into account
+ + Parallel aware
+*** *Updated* particle tracking algorithm
+
+* Solvers
+ A number of new solvers have been developed for a range of engineering
+ applications. There has been a set of improvements to certain classes of
+ solver that are introduced in this release.
+*** *New* Solvers
+ + =reactingParcelFilmFoam=: Lagrangian cloud and film transport in a
+ reacting gas phase system
+*** Modifications to multiphase and buoyant solvers
+ + ...
+*** Modifications to solvers for sensible enthalpy
+ + ...
+*** Modifications to steady-state compressible solvers
+ + ...
+*** Other modifications
+ + ...
+
+* Boundary conditions
+ New boundary conditions have been introduced to support new applications in
+ OpenFOAM.
+ + *New* wall functions:
+ + kappatJayatillekeWallFunction: incompressible RAS thermal wall function
+
+* Utilities
+ There have been some utilities added and updated in this release.
+*** *New* utilities
+ + =extrudeToRegionMesh=: Extrude faceZones into separate mesh (as a
+ different region)
+ + used to e.g. extrude baffles (extrude internal faces) or create
+ liquid film regions
+ + if extruding internal faces:
+ + create baffles in original mesh with directMappedWall patches
+ + if extruding boundary faces:
+ + convert boundary faces to directMappedWall patches
+ + extrude edges of faceZone as a _sidePatch
+ + extrude edges inbetween different faceZones as a
+ (nonuniformTransform)cyclic _
+ + extrudes into master direction (i.e. away from the owner cell
+ if flipMap is false)
+*** Updated utilities
+ + ...
+
+* Post-processing
+ + =foamToEnsight=: new =-nodeValues= option to generate and output nodal
+ field data.
+ + Function objects:
+ + =residualControl=: new function object to allow users to terminate steady
+ state calculations when the defined residual levels are achieved
+ + =abortCalculation=: watches for presence of the named file in the
+ $FOAM_CASE directory and aborts the calculation if it is present
+ + =timeActivatedFileUpdate=: performs a file copy/replacement once a
+ specified time has been reached, e.g. to automagically change fvSchemes and
+ fvSolution during a calculation
+ + =streamLine=: generate streamlines; ouputs both trajectory and field data
+
+* New tutorials
+ There is a large number of new tutorials to support the new solvers in the
+ release.
+ + =reactingParcelFilmFoam= tutorials:
+ + multipleBoxes, hotBoxes, panel, evaporationTest
diff --git a/applications/solvers/combustion/fireFoam/UEqn.H b/applications/solvers/combustion/fireFoam/UEqn.H
index 4a2d03490d..a77c262831 100644
--- a/applications/solvers/combustion/fireFoam/UEqn.H
+++ b/applications/solvers/combustion/fireFoam/UEqn.H
@@ -13,7 +13,9 @@ solve
==
fvc::reconstruct
(
- fvc::interpolate(rho)*(g & mesh.Sf())
- - fvc::snGrad(p)*mesh.magSf()
+ (
+ - ghf*fvc::snGrad(rho)
+ - fvc::snGrad(p_rgh)
+ )*mesh.magSf()
)
);
diff --git a/applications/solvers/combustion/fireFoam/combustionModels/Make/files b/applications/solvers/combustion/fireFoam/combustionModels/Make/files
index 86696b0709..5b1262b70d 100644
--- a/applications/solvers/combustion/fireFoam/combustionModels/Make/files
+++ b/applications/solvers/combustion/fireFoam/combustionModels/Make/files
@@ -1,5 +1,5 @@
combustionModel/combustionModel.C
-combustionModel/combustionModelNew.C
+combustionModel/newCombustionModel.C
infinitelyFastChemistry/infinitelyFastChemistry.C
diff --git a/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModelNew.C b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C
similarity index 77%
rename from applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModelNew.C
rename to applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C
index e23386589c..62781b0fdb 100644
--- a/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModelNew.C
+++ b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C
@@ -29,19 +29,22 @@ License
Foam::autoPtr Foam::combustionModel::New
(
- const dictionary& propDict,
+ const dictionary& combustionProperties,
const hsCombustionThermo& thermo,
const compressible::turbulenceModel& turbulence,
const surfaceScalarField& phi,
const volScalarField& rho
)
{
- const word modelType(propDict.lookup("combustionModel"));
+ word combustionModelTypeName = combustionProperties.lookup
+ (
+ "combustionModel"
+ );
- Info<< "Selecting combustion model " << modelType << endl;
+ Info<< "Selecting combustion model " << combustionModelTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
- dictionaryConstructorTablePtr_->find(modelType);
+ dictionaryConstructorTablePtr_->find(combustionModelTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
@@ -49,14 +52,14 @@ Foam::autoPtr Foam::combustionModel::New
(
"combustionModel::New"
) << "Unknown combustionModel type "
- << modelType << nl << nl
- << "Valid combustionModels are : " << endl
- << dictionaryConstructorTablePtr_->toc()
+ << combustionModelTypeName << endl << endl
+ << "Valid combustionModels are : " << endl
+ << dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr
- (cstrIter()(propDict, thermo, turbulence, phi, rho));
+ (cstrIter()(combustionProperties, thermo, turbulence, phi, rho));
}
diff --git a/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H b/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H
index 851f119feb..53832f21b9 100644
--- a/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H
+++ b/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H
@@ -88,8 +88,9 @@ public:
);
- //- Destructor
- virtual ~infinitelyFastChemistry();
+ // Destructor
+
+ virtual ~infinitelyFastChemistry();
// Member Functions
diff --git a/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H b/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H
index 9e15f0d300..b3f8bb225e 100644
--- a/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H
+++ b/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H
@@ -83,8 +83,9 @@ public:
);
- //- Destructor
- virtual ~noCombustion();
+ // Destructor
+
+ virtual ~noCombustion();
// Member Functions
diff --git a/applications/solvers/combustion/fireFoam/createFields.H b/applications/solvers/combustion/fireFoam/createFields.H
index 9a6274bb1a..6a1a40b777 100644
--- a/applications/solvers/combustion/fireFoam/createFields.H
+++ b/applications/solvers/combustion/fireFoam/createFields.H
@@ -35,6 +35,7 @@ const volScalarField& psi = thermo.psi();
volScalarField& ft = composition.Y("ft");
volScalarField& fu = composition.Y("fu");
+
Info<< "Reading field U\n" << endl;
volVectorField U
@@ -73,7 +74,7 @@ IOdictionary combustionProperties
Info<< "Creating combustion model\n" << endl;
autoPtr combustion
(
- combustionModel::New
+ combustionModel::combustionModel::New
(
combustionProperties,
thermo,
@@ -83,6 +84,29 @@ autoPtr combustion
)
);
+
+Info<< "Calculating field g.h\n" << endl;
+volScalarField gh("gh", g & mesh.C());
+surfaceScalarField ghf("gh", g & mesh.Cf());
+
+Info<< "Reading field p_rgh\n" << endl;
+volScalarField p_rgh
+(
+ IOobject
+ (
+ "p_rgh",
+ runTime.timeName(),
+ mesh,
+ IOobject::MUST_READ,
+ IOobject::AUTO_WRITE
+ ),
+ mesh
+);
+
+// Force p_rgh to be consistent with p
+p_rgh = p - rho*gh;
+
+
volScalarField dQ
(
IOobject
@@ -103,15 +127,6 @@ volScalarField DpDt =
fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
-Info<< "Calculating field g.h\n" << endl;
-volScalarField gh("gh", g & mesh.C());
-
-surfaceScalarField ghf("gh", g & mesh.Cf());
-
-p += rho*gh;
-
-thermo.correct();
-
dimensionedScalar initialMass = fvc::domainIntegrate(rho);
diff --git a/applications/solvers/combustion/fireFoam/pEqn.H b/applications/solvers/combustion/fireFoam/pEqn.H
index 8d1ed0d9f8..b31a7c6636 100644
--- a/applications/solvers/combustion/fireFoam/pEqn.H
+++ b/applications/solvers/combustion/fireFoam/pEqn.H
@@ -1,5 +1,3 @@
-bool closedVolume = false;
-
rho = thermo.rho();
volScalarField rUA = 1.0/UEqn.A();
@@ -15,43 +13,41 @@ surfaceScalarField phiU
)
);
-phi = phiU + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf());
+phi = phiU - rhorUAf*ghf*fvc::snGrad(rho)*mesh.magSf();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
- surfaceScalarField rhorUAf = fvc::interpolate(rho*rUA);
+ surfaceScalarField rhorUAf = fvc::interpolate(rho*rUA);
- fvScalarMatrix pEqn
+ fvScalarMatrix p_rghEqn
+ (
+ fvm::ddt(psi, p_rgh) + fvc::ddt(psi, rho)*gh
+ + fvc::div(phi)
+ - fvm::laplacian(rhorUAf, p_rgh)
+ );
+
+ p_rghEqn.solve
+ (
+ mesh.solver
(
- fvm::ddt(psi,p)
- + fvc::div(phi)
- - fvm::laplacian(rhorUAf, p)
- );
-
- closedVolume = p.needReference();
-
- pEqn.solve
- (
- mesh.solver
+ p_rgh.select
(
- p.select
(
- (
- finalIter
- && corr == nCorr-1
- && nonOrth == nNonOrthCorr
- )
+ finalIter
+ && corr == nCorr-1
+ && nonOrth == nNonOrthCorr
)
)
- );
+ )
+ );
- if (nonOrth == nNonOrthCorr)
- {
- phi += pEqn.flux();
- }
+ if (nonOrth == nNonOrthCorr)
+ {
+ phi += p_rghEqn.flux();
+ }
}
-DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
+p = p_rgh + rho*gh;
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
@@ -59,12 +55,4 @@ DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf);
U.correctBoundaryConditions();
-// For closed-volume cases adjust the pressure and density levels
-// to obey overall mass continuity
-if (closedVolume)
-{
- p +=
- (initialMass - fvc::domainIntegrate(thermo.psi()*p))
- /fvc::domainIntegrate(thermo.psi());
- rho = thermo.rho();
-}
+DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H
index b9a86ef995..cc8f6436a1 100644
--- a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H
+++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H
@@ -39,9 +39,14 @@
#include "compressibleCreatePhi.H"
- dimensionedScalar pMin
+ dimensionedScalar rhoMax
(
- mesh.solutionDict().subDict("PIMPLE").lookup("pMin")
+ mesh.solutionDict().subDict("PIMPLE").lookup("rhoMax")
+ );
+
+ dimensionedScalar rhoMin
+ (
+ mesh.solutionDict().subDict("PIMPLE").lookup("rhoMin")
);
Info<< "Creating turbulence model\n" << endl;
diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/pEqn.H b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/pEqn.H
index 56f8e9f3b5..6be6584202 100644
--- a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/pEqn.H
+++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/pEqn.H
@@ -102,6 +102,8 @@ else
p.relax();
rho = thermo.rho();
+ rho = max(rho, rhoMin);
+ rho = min(rho, rhoMax);
rho.relax();
Info<< "rho max/min : " << max(rho).value()
<< " " << min(rho).value() << endl;
@@ -112,8 +114,6 @@ U.correctBoundaryConditions();
DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
-bound(p, pMin);
-
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
/*
diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H b/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H
index d7a6b97ac1..1a242bdfff 100644
--- a/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H
+++ b/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H
@@ -70,16 +70,29 @@
dimensionedScalar initialMass = fvc::domainIntegrate(rho);
thermalPorousZones pZones(mesh);
+ Switch pressureImplicitPorosity(false);
// nUCorrectors used for pressureImplicitPorosity
int nUCorr = 0;
- const bool pressureImplicitPorosity =
- (
- pZones.size()
- && mesh.solutionDict().subDict("SIMPLE").readIfPresent
- (
- "nUCorrectors",
- nUCorr
- )
- && (nUCorr > 0)
- );
+ if (pZones.size())
+ {
+ // nUCorrectors for pressureImplicitPorosity
+ if (mesh.solutionDict().subDict("SIMPLE").found("nUCorrectors"))
+ {
+ nUCorr = readInt
+ (
+ mesh.solutionDict().subDict("SIMPLE").lookup("nUCorrectors")
+ );
+ }
+
+ if (nUCorr > 0)
+ {
+ pressureImplicitPorosity = true;
+ Info<< "Using pressure implicit porosity" << endl;
+ }
+ else
+ {
+ Info<< "Using pressure explicit porosity" << endl;
+ }
+ }
+
diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/hEqn.H b/applications/solvers/compressible/rhoPorousSimpleFoam/hEqn.H
index ff0b91bcb7..9e5138de8a 100644
--- a/applications/solvers/compressible/rhoPorousSimpleFoam/hEqn.H
+++ b/applications/solvers/compressible/rhoPorousSimpleFoam/hEqn.H
@@ -5,8 +5,8 @@
- fvm::Sp(fvc::div(phi), h)
- fvm::laplacian(turbulence->alphaEff(), h)
==
- fvc::div(phi/fvc::interpolate(rho), rho/psi, "div(U,p)")
- - (rho/psi)*fvc::div(phi/fvc::interpolate(rho))
+ fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p, "div(U,p)"))
+ - p*fvc::div(phi/fvc::interpolate(rho))
);
pZones.addEnthalpySource(thermo, rho, hEqn);
diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/pEqn.H b/applications/solvers/compressible/rhoPorousSimpleFoam/pEqn.H
index 0386899612..fe69384c8b 100644
--- a/applications/solvers/compressible/rhoPorousSimpleFoam/pEqn.H
+++ b/applications/solvers/compressible/rhoPorousSimpleFoam/pEqn.H
@@ -1,8 +1,3 @@
-rho = thermo.rho();
-rho = max(rho, rhoMin);
-rho = min(rho, rhoMax);
-rho.relax();
-
if (pressureImplicitPorosity)
{
U = trTU()&UEqn().H();
diff --git a/applications/solvers/compressible/rhoSimpleFoam/pEqn.H b/applications/solvers/compressible/rhoSimpleFoam/pEqn.H
index f43ec6cf62..96d8280559 100644
--- a/applications/solvers/compressible/rhoSimpleFoam/pEqn.H
+++ b/applications/solvers/compressible/rhoSimpleFoam/pEqn.H
@@ -30,15 +30,7 @@ if (transonic)
pEqn.setReference(pRefCell, pRefValue);
- // Retain the residual from the first iteration
- if (nonOrth == 0)
- {
- pEqn.solve();
- }
- else
- {
- pEqn.solve();
- }
+ pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
@@ -60,15 +52,7 @@ else
pEqn.setReference(pRefCell, pRefValue);
- // Retain the residual from the first iteration
- if (nonOrth == 0)
- {
- pEqn.solve();
- }
- else
- {
- pEqn.solve();
- }
+ pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
diff --git a/applications/solvers/compressible/rhoSimplecFoam/createFields.H b/applications/solvers/compressible/rhoSimplecFoam/createFields.H
index d97ee4705b..fab7b70048 100644
--- a/applications/solvers/compressible/rhoSimplecFoam/createFields.H
+++ b/applications/solvers/compressible/rhoSimplecFoam/createFields.H
@@ -43,9 +43,14 @@
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue);
- dimensionedScalar pMin
+ dimensionedScalar rhoMax
(
- mesh.solutionDict().subDict("SIMPLE").lookup("pMin")
+ mesh.solutionDict().subDict("SIMPLE").lookup("rhoMax")
+ );
+
+ dimensionedScalar rhoMin
+ (
+ mesh.solutionDict().subDict("SIMPLE").lookup("rhoMin")
);
Info<< "Creating turbulence model\n" << endl;
diff --git a/applications/solvers/compressible/rhoSimplecFoam/pEqn.H b/applications/solvers/compressible/rhoSimplecFoam/pEqn.H
index a0f17e78bc..43443a507b 100644
--- a/applications/solvers/compressible/rhoSimplecFoam/pEqn.H
+++ b/applications/solvers/compressible/rhoSimplecFoam/pEqn.H
@@ -101,8 +101,6 @@ U -= (fvc::grad(p0)*(1.0/AU - 1.0/AtU) + fvc::grad(p)/AtU);
U.correctBoundaryConditions();
-bound(p, pMin);
-
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
@@ -112,6 +110,8 @@ if (closedVolume)
}
rho = thermo.rho();
+rho = max(rho, rhoMin);
+rho = min(rho, rhoMax);
if (!transonic)
{
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/TEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/TEqn.H
index dbfc61739f..9a835792a4 100644
--- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/TEqn.H
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/TEqn.H
@@ -12,7 +12,7 @@
);
TEqn.relax();
- TEqn.solve();
+ TEqn.solve(mesh.solver(T.select(finalIter)));
rhok = 1.0 - beta*(T - TRef);
}
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/UEqn.H
index 35387f4ff4..20a05e5cd4 100644
--- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/UEqn.H
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/UEqn.H
@@ -18,9 +18,10 @@
fvc::reconstruct
(
(
- fvc::interpolate(rhok)*(g & mesh.Sf())
- - fvc::snGrad(p)*mesh.magSf()
- )
- )
+ - ghf*fvc::snGrad(rhok)
+ - fvc::snGrad(p_rgh)
+ )*mesh.magSf()
+ ),
+ mesh.solver(U.select(finalIter))
);
}
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/buoyantBoussinesqPimpleFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/buoyantBoussinesqPimpleFoam.C
index ebf68d409c..54519906a4 100644
--- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/buoyantBoussinesqPimpleFoam.C
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/buoyantBoussinesqPimpleFoam.C
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
if (nOuterCorr != 1)
{
- p.storePrevIter();
+ p_rgh.storePrevIter();
}
#include "UEqn.H"
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/createFields.H
index 23d20cfa96..342af079d8 100644
--- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/createFields.H
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/createFields.H
@@ -14,12 +14,12 @@
mesh
);
- Info<< "Reading field p\n" << endl;
- volScalarField p
+ Info<< "Reading field p_rgh\n" << endl;
+ volScalarField p_rgh
(
IOobject
(
- "p",
+ "p_rgh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
@@ -52,6 +52,18 @@
incompressible::RASModel::New(U, phi, laminarTransport)
);
+ // Kinematic density for buoyancy force
+ volScalarField rhok
+ (
+ IOobject
+ (
+ "rhok",
+ runTime.timeName(),
+ mesh
+ ),
+ 1.0 - beta*(T - TRef)
+ );
+
// kinematic turbulent thermal thermal conductivity m2/s
Info<< "Reading field kappat\n" << endl;
volScalarField kappat
@@ -67,25 +79,41 @@
mesh
);
+ Info<< "Calculating field g.h\n" << endl;
+ volScalarField gh("gh", g & mesh.C());
+ surfaceScalarField ghf("ghf", g & mesh.Cf());
+
+ volScalarField p
+ (
+ IOobject
+ (
+ "p",
+ runTime.timeName(),
+ mesh,
+ IOobject::NO_READ,
+ IOobject::AUTO_WRITE
+ ),
+ p_rgh + rhok*gh
+ );
+
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
+ p_rgh,
mesh.solutionDict().subDict("PIMPLE"),
pRefCell,
pRefValue
);
-
- // Kinematic density for buoyancy force
- volScalarField rhok
- (
- IOobject
+ if (p_rgh.needReference())
+ {
+ p += dimensionedScalar
(
- "rhok",
- runTime.timeName(),
- mesh
- ),
- 1.0 - beta*(T - TRef)
- );
+ "p",
+ p.dimensions(),
+ pRefValue - getRefCellValue(p, pRefCell)
+ );
+ }
+
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/pEqn.H
index 21be033f9b..60828e18dc 100644
--- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/pEqn.H
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/pEqn.H
@@ -7,22 +7,23 @@
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi);
- surfaceScalarField buoyancyPhi =
- rUAf*fvc::interpolate(rhok)*(g & mesh.Sf());
- phi += buoyancyPhi;
+ surfaceScalarField buoyancyPhi = rUAf*ghf*fvc::snGrad(rhok)*mesh.magSf();
+ phi -= buoyancyPhi;
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
- fvScalarMatrix pEqn
+ fvScalarMatrix p_rghEqn
(
- fvm::laplacian(rUAf, p) == fvc::div(phi)
+ fvm::laplacian(rUAf, p_rgh) == fvc::div(phi)
);
- pEqn.solve
+ p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
+
+ p_rghEqn.solve
(
mesh.solver
(
- p.select
+ p_rgh.select
(
(
finalIter
@@ -36,17 +37,30 @@
if (nonOrth == nNonOrthCorr)
{
// Calculate the conservative fluxes
- phi -= pEqn.flux();
+ phi -= p_rghEqn.flux();
// Explicitly relax pressure for momentum corrector
- p.relax();
+ p_rgh.relax();
// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
- U += rUA*fvc::reconstruct((buoyancyPhi - pEqn.flux())/rUAf);
+ U -= rUA*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rUAf);
U.correctBoundaryConditions();
}
}
#include "continuityErrs.H"
+
+ p = p_rgh + rhok*gh;
+
+ if (p_rgh.needReference())
+ {
+ p += dimensionedScalar
+ (
+ "p",
+ p.dimensions(),
+ pRefValue - getRefCellValue(p, pRefCell)
+ );
+ p_rgh = p - rhok*gh;
+ }
}
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H
index 76cc4da8ba..477a322833 100644
--- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H
@@ -96,29 +96,23 @@
p_rgh + rhok*gh
);
- label p_rghRefCell = 0;
- scalar p_rghRefValue = 0.0;
+ label pRefCell = 0;
+ scalar pRefValue = 0.0;
setRefCell
(
+ p,
p_rgh,
mesh.solutionDict().subDict("SIMPLE"),
- p_rghRefCell,
- p_rghRefValue
+ pRefCell,
+ pRefValue
);
- scalar pRefValue = 0.0;
-
if (p_rgh.needReference())
{
- pRefValue = readScalar
- (
- mesh.solutionDict().subDict("SIMPLE").lookup("pRefValue")
- );
-
p += dimensionedScalar
(
"p",
p.dimensions(),
- pRefValue - getRefCellValue(p, p_rghRefCell)
+ pRefValue - getRefCellValue(p, pRefCell)
);
}
diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H
index 5664bb2154..50149ed360 100644
--- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H
+++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H
@@ -18,17 +18,9 @@
fvm::laplacian(rUAf, p_rgh) == fvc::div(phi)
);
- p_rghEqn.setReference(p_rghRefCell, p_rghRefValue);
+ p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
- // retain the residual from the first iteration
- if (nonOrth == 0)
- {
- p_rghEqn.solve();
- }
- else
- {
- p_rghEqn.solve();
- }
+ p_rghEqn.solve();
if (nonOrth == nNonOrthCorr)
{
@@ -55,7 +47,8 @@
(
"p",
p.dimensions(),
- pRefValue - getRefCellValue(p, p_rghRefCell)
+ pRefValue - getRefCellValue(p, pRefCell)
);
+ p_rgh = p - rhok*gh;
}
}
diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/UEqn.H
index d4878d063d..8c6a3f7671 100644
--- a/applications/solvers/heatTransfer/buoyantPimpleFoam/UEqn.H
+++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/UEqn.H
@@ -17,8 +17,11 @@
==
fvc::reconstruct
(
- fvc::interpolate(rho)*(g & mesh.Sf())
- - fvc::snGrad(p)*mesh.magSf()
- )
+ (
+ - ghf*fvc::snGrad(rho)
+ - fvc::snGrad(p_rgh)
+ )*mesh.magSf()
+ ),
+ mesh.solver(U.select(finalIter))
);
}
diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/buoyantPimpleFoam.C b/applications/solvers/heatTransfer/buoyantPimpleFoam/buoyantPimpleFoam.C
index 0075c1e3ed..cb4c4d34f6 100644
--- a/applications/solvers/heatTransfer/buoyantPimpleFoam/buoyantPimpleFoam.C
+++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/buoyantPimpleFoam.C
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
if (nOuterCorr != 1)
{
- p.storePrevIter();
+ p_rgh.storePrevIter();
}
#include "UEqn.H"
diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/createFields.H
index b8ac5595e4..e39d0bb803 100644
--- a/applications/solvers/heatTransfer/buoyantPimpleFoam/createFields.H
+++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/createFields.H
@@ -53,15 +53,30 @@
)
);
+ Info<< "Calculating field g.h\n" << endl;
+ volScalarField gh("gh", g & mesh.C());
+ surfaceScalarField ghf("ghf", g & mesh.Cf());
+
+ Info<< "Reading field p_rgh\n" << endl;
+ volScalarField p_rgh
+ (
+ IOobject
+ (
+ "p_rgh",
+ runTime.timeName(),
+ mesh,
+ IOobject::MUST_READ,
+ IOobject::AUTO_WRITE
+ ),
+ mesh
+ );
+
+ // Force p_rgh to be consistent with p
+ p_rgh = p - rho*gh;
+
Info<< "Creating field DpDt\n" << endl;
volScalarField DpDt
(
"DpDt",
fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p)
);
-
- thermo.correct();
-
- dimensionedScalar initialMass = fvc::domainIntegrate(rho);
-
- dimensionedScalar totalVolume = sum(mesh.V());
diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/hEqn.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/hEqn.H
index 3125cc3ffa..94537508b3 100644
--- a/applications/solvers/heatTransfer/buoyantPimpleFoam/hEqn.H
+++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/hEqn.H
@@ -9,7 +9,7 @@
);
hEqn.relax();
- hEqn.solve();
+ hEqn.solve(mesh.solver(h.select(finalIter)));
thermo.correct();
}
diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H
index a1c3dbfed5..e625f122a3 100644
--- a/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H
+++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H
@@ -1,11 +1,9 @@
{
- bool closedVolume = p.needReference();
-
rho = thermo.rho();
// Thermodynamic density needs to be updated by psi*d(p) after the
// pressure solution - done in 2 parts. Part 1:
- thermo.rho() -= psi*p;
+ thermo.rho() -= psi*p_rgh;
volScalarField rUA = 1.0/UEqn.A();
surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
@@ -18,24 +16,23 @@
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
);
- surfaceScalarField buoyancyPhi =
- rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf());
+ surfaceScalarField buoyancyPhi = -rhorUAf*ghf*fvc::snGrad(rho)*mesh.magSf();
phi += buoyancyPhi;
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
- fvScalarMatrix pEqn
+ fvScalarMatrix p_rghEqn
(
- fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
+ fvc::div(phi)
- - fvm::laplacian(rhorUAf, p)
+ - fvm::laplacian(rhorUAf, p_rgh)
);
- pEqn.solve
+ p_rghEqn.solve
(
mesh.solver
(
- p.select
+ p_rgh.select
(
(
finalIter
@@ -49,34 +46,25 @@
if (nonOrth == nNonOrthCorr)
{
// Calculate the conservative fluxes
- phi += pEqn.flux();
+ phi += p_rghEqn.flux();
// Explicitly relax pressure for momentum corrector
- p.relax();
+ p_rgh.relax();
// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
- U += rUA*fvc::reconstruct((buoyancyPhi + pEqn.flux())/rhorUAf);
+ U += rUA*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rhorUAf);
U.correctBoundaryConditions();
}
}
+ p = p_rgh + rho*gh;
+
// Second part of thermodynamic density update
- thermo.rho() += psi*p;
+ thermo.rho() += psi*p_rgh;
DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
-
- // For closed-volume cases adjust the pressure and density levels
- // to obey overall mass continuity
- if (closedVolume)
- {
- p +=
- (initialMass - fvc::domainIntegrate(psi*p))
- /fvc::domainIntegrate(psi);
- thermo.rho() = psi*p;
- rho += (initialMass - fvc::domainIntegrate(rho))/totalVolume;
- }
}
diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C
index 06fa5d12a0..64cc110cec 100644
--- a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C
+++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C
@@ -62,10 +62,7 @@ int main(int argc, char *argv[])
{
#include "UEqn.H"
#include "hEqn.H"
- for (int i=0; i<3; i++)
- {
#include "pEqn.H"
- }
}
turbulence->correct();
diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H
index cf23150332..d6fa9acee9 100644
--- a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H
+++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H
@@ -23,20 +23,6 @@
volScalarField& h = thermo.h();
const volScalarField& psi = thermo.psi();
- Info<< "Reading field p_rgh\n" << endl;
- volScalarField p_rgh
- (
- IOobject
- (
- "p_rgh",
- runTime.timeName(),
- mesh,
- IOobject::MUST_READ,
- IOobject::AUTO_WRITE
- ),
- mesh
- );
-
Info<< "Reading field U\n" << endl;
volVectorField U
(
@@ -53,7 +39,6 @@
#include "compressibleCreatePhi.H"
-
Info<< "Creating turbulence model\n" << endl;
autoPtr turbulence
(
@@ -66,40 +51,39 @@
)
);
+
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("ghf", g & mesh.Cf());
- p = p_rgh + rho*gh;
- thermo.correct();
- rho = thermo.rho();
- p_rgh = p - rho*gh;
-
- label p_rghRefCell = 0;
- scalar p_rghRefValue = 0.0;
- setRefCell
+ Info<< "Reading field p_rgh\n" << endl;
+ volScalarField p_rgh
(
- p_rgh,
- mesh.solutionDict().subDict("SIMPLE"),
- p_rghRefCell,
- p_rghRefValue
+ IOobject
+ (
+ "p_rgh",
+ runTime.timeName(),
+ mesh,
+ IOobject::MUST_READ,
+ IOobject::AUTO_WRITE
+ ),
+ mesh
);
+ // Force p_rgh to be consistent with p
+ p_rgh = p - rho*gh;
+
+
+ label pRefCell = 0;
scalar pRefValue = 0.0;
-
- if (p_rgh.needReference())
- {
- pRefValue = readScalar
- (
- mesh.solutionDict().subDict("SIMPLE").lookup("pRefValue")
- );
-
- p += dimensionedScalar
- (
- "p",
- p.dimensions(),
- pRefValue - getRefCellValue(p, p_rghRefCell)
- );
- }
+ setRefCell
+ (
+ p,
+ p_rgh,
+ mesh.solutionDict().subDict("SIMPLE"),
+ pRefCell,
+ pRefValue
+ );
dimensionedScalar initialMass = fvc::domainIntegrate(rho);
+ dimensionedScalar totalVolume = sum(mesh.V());
diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H
index 3088b42c69..f1a62d4770 100644
--- a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H
+++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H
@@ -1,11 +1,12 @@
{
rho = thermo.rho();
+ rho.relax();
volScalarField rUA = 1.0/UEqn().A();
surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
U = rUA*UEqn().H();
- //UEqn.clear();
+ UEqn.clear();
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
bool closedVolume = adjustPhi(phi, U, p_rgh);
@@ -20,7 +21,7 @@
fvm::laplacian(rhorUAf, p_rgh) == fvc::div(phi)
);
- p_rghEqn.setReference(p_rghRefCell, p_rghRefValue);
+ p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
p_rghEqn.solve();
if (nonOrth == nNonOrthCorr)
@@ -42,13 +43,13 @@
p = p_rgh + rho*gh;
- // For closed-volume cases adjust the pressure and density levels
+ // For closed-volume cases adjust the pressure level
// to obey overall mass continuity
if (closedVolume)
{
p += (initialMass - fvc::domainIntegrate(psi*p))
/fvc::domainIntegrate(psi);
- p_rgh == p - rho*gh;
+ p_rgh = p - rho*gh;
}
rho = thermo.rho();
diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C
index 0dbe80c67c..6c35536333 100644
--- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C
+++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
#include "readSIMPLEControls.H"
- p.storePrevIter();
+ p_rgh.storePrevIter();
rho.storePrevIter();
// Pressure-velocity SIMPLE corrector
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C
index a81b0faaf3..36b3f1c3b0 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C
@@ -93,6 +93,8 @@ int main(int argc, char *argv[])
// --- PIMPLE loop
for (int oCorr=0; oCorr phiFluid(fluidRegions.size());
PtrList gFluid(fluidRegions.size());
PtrList turbulence(fluidRegions.size());
- PtrList DpDtf(fluidRegions.size());
+ PtrList p_rghFluid(fluidRegions.size());
+ PtrList ghFluid(fluidRegions.size());
+ PtrList ghfFluid(fluidRegions.size());
List initialMassFluid(fluidRegions.size());
List pRefCellFluid(fluidRegions.size(),0);
List pRefValueFluid(fluidRegions.size(),0.0);
+ PtrList rhoMax(fluidRegions.size());
+ PtrList rhoMin(fluidRegions.size());
// Populate fluid field pointer lists
forAll(fluidRegions, i)
@@ -130,15 +134,74 @@
).ptr()
);
+ Info<< " Adding to ghFluid\n" << endl;
+ ghFluid.set
+ (
+ i,
+ new volScalarField("gh", gFluid[i] & fluidRegions[i].C())
+ );
+
+ Info<< " Adding to ghfFluid\n" << endl;
+ ghfFluid.set
+ (
+ i,
+ new surfaceScalarField("ghf", gFluid[i] & fluidRegions[i].Cf())
+ );
+
+ p_rghFluid.set
+ (
+ i,
+ new volScalarField
+ (
+ IOobject
+ (
+ "p_rgh",
+ runTime.timeName(),
+ fluidRegions[i],
+ IOobject::MUST_READ,
+ IOobject::AUTO_WRITE
+ ),
+ fluidRegions[i]
+ )
+ );
+
+ // Force p_rgh to be consistent with p
+ p_rghFluid[i] = thermoFluid[i].p() - rhoFluid[i]*ghFluid[i];
+
initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value();
setRefCell
(
thermoFluid[i].p(),
+ p_rghFluid[i],
fluidRegions[i].solutionDict().subDict("SIMPLE"),
pRefCellFluid[i],
pRefValueFluid[i]
);
+
+ rhoMax.set
+ (
+ i,
+ new dimensionedScalar
+ (
+ fluidRegions[i].solutionDict().subDict("SIMPLE").lookup
+ (
+ "rhoMax"
+ )
+ )
+ );
+
+ rhoMin.set
+ (
+ i,
+ new dimensionedScalar
+ (
+ fluidRegions[i].solutionDict().subDict("SIMPLE").lookup
+ (
+ "rhoMin"
+ )
+ )
+ );
}
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H
index cef0122928..7869046fa0 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H
@@ -5,8 +5,8 @@
- fvm::Sp(fvc::div(phi), h)
- fvm::laplacian(turb.alphaEff(), h)
==
- fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p))
- - p*fvc::div(phi/fvc::interpolate(rho))
+ fvc::div(phi/fvc::interpolate(rho), rho/psi, "div(U,p)")
+ - (rho/psi)*fvc::div(phi/fvc::interpolate(rho))
);
hEqn.relax();
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
index 9462dc2c39..317d377f1b 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
@@ -1,7 +1,9 @@
{
// From buoyantSimpleFoam
-
rho = thermo.rho();
+ rho = max(rho, rhoMin[i]);
+ rho = min(rho, rhoMax[i]);
+ rho.relax();
volScalarField rUA = 1.0/UEqn().A();
surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
@@ -10,59 +12,54 @@
UEqn.clear();
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
- bool closedVolume = adjustPhi(phi, U, p);
+ bool closedVolume = adjustPhi(phi, U, p_rgh);
- surfaceScalarField buoyancyPhi =
- rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf());
- phi += buoyancyPhi;
+ surfaceScalarField buoyancyPhi = rhorUAf*ghf*fvc::snGrad(rho)*mesh.magSf();
+ phi -= buoyancyPhi;
// Solve pressure
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
- fvScalarMatrix pEqn
+ fvScalarMatrix p_rghEqn
(
- fvm::laplacian(rhorUAf, p) == fvc::div(phi)
+ fvm::laplacian(rhorUAf, p_rgh) == fvc::div(phi)
);
- pEqn.setReference(pRefCell, pRefValue);
+ p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
- // retain the residual from the first iteration
- if (nonOrth == 0)
- {
- pEqn.solve();
- }
- else
- {
- pEqn.solve();
- }
+ p_rghEqn.solve();
if (nonOrth == nNonOrthCorr)
{
- // For closed-volume cases adjust the pressure and density levels
- // to obey overall mass continuity
- if (closedVolume)
- {
- p += (initialMass - fvc::domainIntegrate(psi*p))
- /fvc::domainIntegrate(psi);
- }
-
// Calculate the conservative fluxes
- phi -= pEqn.flux();
+ phi -= p_rghEqn.flux();
// Explicitly relax pressure for momentum corrector
- p.relax();
+ p_rgh.relax();
// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
- U += rUA*fvc::reconstruct((buoyancyPhi - pEqn.flux())/rhorUAf);
+ U -= rUA*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rhorUAf);
U.correctBoundaryConditions();
}
}
+ p = p_rgh + rho*gh;
#include "continuityErrs.H"
+ // For closed-volume cases adjust the pressure level
+ // to obey overall mass continuity
+ if (closedVolume)
+ {
+ p += (initialMass - fvc::domainIntegrate(psi*p))
+ /fvc::domainIntegrate(psi);
+ p_rgh = p - rho*gh;
+ }
+
rho = thermo.rho();
+ rho = max(rho, rhoMin[i]);
+ rho = min(rho, rhoMax[i]);
rho.relax();
Info<< "Min/max rho:" << min(rho).value() << ' '
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H
index 8491056ea3..cac7750e97 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H
@@ -5,7 +5,6 @@
volScalarField& K = KFluid[i];
volVectorField& U = UFluid[i];
surfaceScalarField& phi = phiFluid[i];
- const dimensionedVector& g = gFluid[i];
compressible::turbulenceModel& turb = turbulence[i];
@@ -22,3 +21,7 @@
const label pRefCell = pRefCellFluid[i];
const scalar pRefValue = pRefValueFluid[i];
+
+ volScalarField& p_rgh = p_rghFluid[i];
+ const volScalarField& gh = ghFluid[i];
+ const surfaceScalarField& ghf = ghfFluid[i];
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/solveFluid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/solveFluid.H
index 5198941366..2b6de83ca3 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/solveFluid.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/solveFluid.H
@@ -1,6 +1,6 @@
// Pressure-velocity SIMPLE corrector
- p.storePrevIter();
+ p_rgh.storePrevIter();
rho.storePrevIter();
{
#include "UEqn.H"
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H
index 65467f8086..119eeb4fd7 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H
@@ -16,8 +16,11 @@
==
fvc::reconstruct
(
- fvc::interpolate(rho)*(g & mesh.Sf())
- - fvc::snGrad(p)*mesh.magSf()
- )
+ (
+ - ghf*fvc::snGrad(rho)
+ - fvc::snGrad(p_rgh)
+ )*mesh.magSf()
+ ),
+ mesh.solver(U.select(finalIter))
);
}
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H
index 1826a77217..b0a7f95912 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H
@@ -6,6 +6,9 @@
PtrList phiFluid(fluidRegions.size());
PtrList gFluid(fluidRegions.size());
PtrList turbulence(fluidRegions.size());
+ PtrList p_rghFluid(fluidRegions.size());
+ PtrList ghFluid(fluidRegions.size());
+ PtrList ghfFluid(fluidRegions.size());
PtrList DpDtFluid(fluidRegions.size());
List initialMassFluid(fluidRegions.size());
@@ -129,6 +132,42 @@
).ptr()
);
+ Info<< " Adding to ghFluid\n" << endl;
+ ghFluid.set
+ (
+ i,
+ new volScalarField("gh", gFluid[i] & fluidRegions[i].C())
+ );
+
+ Info<< " Adding to ghfFluid\n" << endl;
+ ghfFluid.set
+ (
+ i,
+ new surfaceScalarField("ghf", gFluid[i] & fluidRegions[i].Cf())
+ );
+
+ p_rghFluid.set
+ (
+ i,
+ new volScalarField
+ (
+ IOobject
+ (
+ "p_rgh",
+ runTime.timeName(),
+ fluidRegions[i],
+ IOobject::MUST_READ,
+ IOobject::AUTO_WRITE
+ ),
+ fluidRegions[i]
+ )
+ );
+
+ // Force p_rgh to be consistent with p
+ p_rghFluid[i] = thermoFluid[i].p() - rhoFluid[i]*ghFluid[i];
+
+ initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value();
+
Info<< " Adding to DpDtFluid\n" << endl;
DpDtFluid.set
(
@@ -147,6 +186,4 @@
)
)
);
-
- initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value();
}
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H
index e070537db2..16ba36f7dc 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H
@@ -7,16 +7,9 @@
==
DpDt
);
- if (oCorr == nOuterCorr-1)
- {
- hEqn.relax();
- hEqn.solve(mesh.solver("hFinal"));
- }
- else
- {
- hEqn.relax();
- hEqn.solve();
- }
+
+ hEqn.relax();
+ hEqn.solve(mesh.solver(h.select(finalIter)));
thermo.correct();
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H
index a264b68fe5..9bf3c4acc5 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H
@@ -1,5 +1,5 @@
{
- bool closedVolume = p.needReference();
+ bool closedVolume = p_rgh.needReference();
rho = thermo.rho();
@@ -17,34 +17,35 @@
)
);
- phi = phiU + fvc::interpolate(rho)*(g & mesh.Sf())*rhorUAf;
+ phi = phiU - rhorUAf*ghf*fvc::snGrad(rho)*mesh.magSf();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
- fvScalarMatrix pEqn
+ fvScalarMatrix p_rghEqn
(
- fvm::ddt(psi, p)
+ fvm::ddt(psi, p_rgh) + fvc::ddt(psi, rho)*gh
+ fvc::div(phi)
- - fvm::laplacian(rhorUAf, p)
+ - fvm::laplacian(rhorUAf, p_rgh)
);
- if
+ p_rghEqn.solve
(
- oCorr == nOuterCorr-1
- && corr == nCorr-1
- && nonOrth == nNonOrthCorr
- )
- {
- pEqn.solve(mesh.solver(p.name() + "Final"));
- }
- else
- {
- pEqn.solve(mesh.solver(p.name()));
- }
+ mesh.solver
+ (
+ p_rgh.select
+ (
+ (
+ oCorr == nOuterCorr-1
+ && corr == nCorr-1
+ && nonOrth == nNonOrthCorr
+ )
+ )
+ )
+ );
if (nonOrth == nNonOrthCorr)
{
- phi += pEqn.flux();
+ phi += p_rghEqn.flux();
}
}
@@ -52,6 +53,8 @@
U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf);
U.correctBoundaryConditions();
+ p = p_rgh + rho*gh;
+
// Update pressure substantive derivative
DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
@@ -65,9 +68,10 @@
// to obey overall mass continuity
if (closedVolume)
{
- p += (massIni - fvc::domainIntegrate(psi*p))
+ p += (initialMass - fvc::domainIntegrate(psi*p))
/fvc::domainIntegrate(psi);
rho = thermo.rho();
+ p_rgh = p - rho*gh;
}
// Update thermal conductivity
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H
deleted file mode 100644
index 1f8cdb82a3..0000000000
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H
+++ /dev/null
@@ -1,17 +0,0 @@
- const dictionary& piso = fluidRegions[i].solutionDict().subDict("PISO");
-
- const int nOuterCorr =
- piso.lookupOrDefault("nOuterCorrectors", 1);
-
- const int nCorr =
- piso.lookupOrDefault("nCorrectors", 1);
-
- const int nNonOrthCorr =
- piso.lookupOrDefault("nNonOrthogonalCorrectors", 0);
-
- const bool momentumPredictor =
- piso.lookupOrDefault("momentumPredictor", true);
-
- const bool transonic =
- piso.lookupOrDefault("transonic", false);
-
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H
index 50a3011484..89aaec4737 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H
@@ -1,11 +1,10 @@
- const fvMesh& mesh = fluidRegions[i];
+ fvMesh& mesh = fluidRegions[i];
basicPsiThermo& thermo = thermoFluid[i];
volScalarField& rho = rhoFluid[i];
volScalarField& K = KFluid[i];
volVectorField& U = UFluid[i];
surfaceScalarField& phi = phiFluid[i];
- const dimensionedVector& g = gFluid[i];
compressible::turbulenceModel& turb = turbulence[i];
volScalarField& DpDt = DpDtFluid[i];
@@ -14,4 +13,13 @@
const volScalarField& psi = thermo.psi();
volScalarField& h = thermo.h();
- const dimensionedScalar massIni("massIni", dimMass, initialMassFluid[i]);
+ volScalarField& p_rgh = p_rghFluid[i];
+ const volScalarField& gh = ghFluid[i];
+ const surfaceScalarField& ghf = ghfFluid[i];
+
+ const dimensionedScalar initialMass
+ (
+ "initialMass",
+ dimMass,
+ initialMassFluid[i]
+ );
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H
index 86dd4344c1..b36cf89d34 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H
@@ -1,3 +1,8 @@
+if (finalIter)
+{
+ mesh.data::add("finalIteration", true);
+}
+
if (oCorr == 0)
{
#include "rhoEqn.H"
@@ -16,3 +21,8 @@ for (int corr=0; corr UEqn
UEqn().relax();
-volScalarField rUA = 1.0/UEqn().A();
+volScalarField rAU = 1.0/UEqn().A();
if (momentumPredictor)
{
@@ -17,6 +17,6 @@ if (momentumPredictor)
}
else
{
- U = rUA*(UEqn().H() - fvc::grad(p));
+ U = rAU*(UEqn().H() - fvc::grad(p));
U.correctBoundaryConditions();
}
diff --git a/applications/solvers/incompressible/pimpleFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/pEqn.H
index b5dc23a58c..acd86ed4b0 100644
--- a/applications/solvers/incompressible/pimpleFoam/pEqn.H
+++ b/applications/solvers/incompressible/pimpleFoam/pEqn.H
@@ -1,4 +1,4 @@
-U = rUA*UEqn().H();
+U = rAU*UEqn().H();
if (nCorr <= 1)
{
@@ -6,7 +6,7 @@ if (nCorr <= 1)
}
phi = (fvc::interpolate(U) & mesh.Sf())
- + fvc::ddtPhiCorr(rUA, U, phi);
+ + fvc::ddtPhiCorr(rAU, U, phi);
adjustPhi(phi, U, p);
@@ -16,7 +16,7 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
// Pressure corrector
fvScalarMatrix pEqn
(
- fvm::laplacian(rUA, p) == fvc::div(phi)
+ fvm::laplacian(rAU, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
@@ -47,5 +47,5 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
// Explicitly relax pressure for momentum corrector
p.relax();
-U -= rUA*fvc::grad(p);
+U -= rAU*fvc::grad(p);
U.correctBoundaryConditions();
diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/createFields.H b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/createFields.H
index bc798ba988..16b3bd977d 100644
--- a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/createFields.H
+++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/createFields.H
@@ -27,7 +27,7 @@
mesh
);
-# include "createPhi.H"
+ #include "createPhi.H"
label pRefCell = 0;
diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pEqn.H
index 155f43a632..74045cabb7 100644
--- a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pEqn.H
+++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/pEqn.H
@@ -46,6 +46,7 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
#include "continuityErrs.H"
+// Explicitly relax pressure for momentum corrector
p.relax();
// Make the fluxes relative to the mesh motion
diff --git a/applications/solvers/incompressible/porousSimpleFoam/createFields.H b/applications/solvers/incompressible/porousSimpleFoam/createFields.H
index d9bd0b5bac..2de8fbf737 100644
--- a/applications/solvers/incompressible/porousSimpleFoam/createFields.H
+++ b/applications/solvers/incompressible/porousSimpleFoam/createFields.H
@@ -43,16 +43,28 @@
porousZones pZones(mesh);
+ Switch pressureImplicitPorosity(false);
// nUCorrectors used for pressureImplicitPorosity
int nUCorr = 0;
- const bool pressureImplicitPorosity =
- (
- pZones.size()
- && mesh.solutionDict().subDict("SIMPLE").readIfPresent
- (
- "nUCorrectors",
- nUCorr
- )
- && (nUCorr > 0)
- );
+ if (pZones.size())
+ {
+ // nUCorrectors for pressureImplicitPorosity
+ if (mesh.solutionDict().subDict("SIMPLE").found("nUCorrectors"))
+ {
+ nUCorr = readInt
+ (
+ mesh.solutionDict().subDict("SIMPLE").lookup("nUCorrectors")
+ );
+ }
+
+ if (nUCorr > 0)
+ {
+ pressureImplicitPorosity = true;
+ Info<< "Using pressure implicit porosity" << endl;
+ }
+ else
+ {
+ Info<< "Using pressure explicit porosity" << endl;
+ }
+ }
diff --git a/applications/solvers/incompressible/simpleFoam/pEqn.H b/applications/solvers/incompressible/simpleFoam/pEqn.H
index 91f4e1a140..313f20cbb4 100644
--- a/applications/solvers/incompressible/simpleFoam/pEqn.H
+++ b/applications/solvers/incompressible/simpleFoam/pEqn.H
@@ -15,15 +15,8 @@
);
pEqn.setReference(pRefCell, pRefValue);
- // retain the residual from the first iteration
- if (nonOrth == 0)
- {
- pEqn.solve();
- }
- else
- {
- pEqn.solve();
- }
+
+ pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/UEqn.H b/applications/solvers/lagrangian/coalChemistryFoam/UEqn.H
index b02a7c61e8..5851cdcf95 100644
--- a/applications/solvers/lagrangian/coalChemistryFoam/UEqn.H
+++ b/applications/solvers/lagrangian/coalChemistryFoam/UEqn.H
@@ -13,5 +13,5 @@
if (momentumPredictor)
{
- solve(UEqn == -fvc::grad(p));
+ solve(UEqn == -fvc::grad(p), mesh.solver(U.select(finalIter)));
}
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C b/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C
index 5f373cc224..f32be6214b 100644
--- a/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C
+++ b/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C
@@ -90,17 +90,28 @@ int main(int argc, char *argv[])
#include "rhoEqn.H"
// --- PIMPLE loop
- for (int ocorr=1; ocorr<=nOuterCorr; ocorr++)
+ for (int oCorr=0; oCorrcorrect();
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/hsEqn.H b/applications/solvers/lagrangian/coalChemistryFoam/hsEqn.H
index ced6b64004..40eb26709e 100644
--- a/applications/solvers/lagrangian/coalChemistryFoam/hsEqn.H
+++ b/applications/solvers/lagrangian/coalChemistryFoam/hsEqn.H
@@ -15,7 +15,7 @@
hsEqn.relax();
- hsEqn.solve();
+ hsEqn.solve(mesh.solver(hs.select(finalIter)));
thermo.correct();
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/pEqn.H b/applications/solvers/lagrangian/coalChemistryFoam/pEqn.H
index b31ad45ed4..d3efde0b34 100644
--- a/applications/solvers/lagrangian/coalChemistryFoam/pEqn.H
+++ b/applications/solvers/lagrangian/coalChemistryFoam/pEqn.H
@@ -26,7 +26,20 @@ if (transonic)
coalParcels.Srho()
);
- pEqn.solve();
+ pEqn.solve
+ (
+ mesh.solver
+ (
+ p.select
+ (
+ (
+ finalIter
+ && corr == nCorr-1
+ && nonOrth == nNonOrthCorr
+ )
+ )
+ )
+ );
if (nonOrth == nNonOrthCorr)
{
@@ -54,7 +67,20 @@ else
coalParcels.Srho()
);
- pEqn.solve();
+ pEqn.solve
+ (
+ mesh.solver
+ (
+ p.select
+ (
+ (
+ finalIter
+ && corr == nCorr-1
+ && nonOrth == nNonOrthCorr
+ )
+ )
+ )
+ );
if (nonOrth == nNonOrthCorr)
{
diff --git a/applications/solvers/multiphase/interFoam/alphaCourantNo.H b/applications/solvers/multiphase/interFoam/alphaCourantNo.H
index b970d4ce23..12d1b933d4 100644
--- a/applications/solvers/multiphase/interFoam/alphaCourantNo.H
+++ b/applications/solvers/multiphase/interFoam/alphaCourantNo.H
@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see .
Global
- CourantNo
+ alphaCourantNo
Description
Calculates and outputs the mean and maximum Courant Numbers.
@@ -39,17 +39,14 @@ scalar meanAlphaCoNum = 0.0;
if (mesh.nInternalFaces())
{
- surfaceScalarField alphaf = fvc::interpolate(alpha1);
+ scalarField sumPhi =
+ pos(alpha1 - 0.01)*pos(0.99 - alpha1)
+ *fvc::surfaceSum(mag(phi))().internalField();
- surfaceScalarField SfUfbyDelta =
- pos(alphaf - 0.01)*pos(0.99 - alphaf)
- *mesh.surfaceInterpolation::deltaCoeffs()*mag(phi);
+ alphaCoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaT().value();
- alphaCoNum = max(SfUfbyDelta/mesh.magSf())
- .value()*runTime.deltaT().value();
-
- meanAlphaCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf()))
- .value()*runTime.deltaT().value();
+ meanAlphaCoNum =
+ 0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaT().value();
}
Info<< "Interface Courant Number mean: " << meanAlphaCoNum
diff --git a/applications/test/CompactIOList/Make/files b/applications/test/CompactIOList/Make/files
new file mode 100644
index 0000000000..7e2cf985bf
--- /dev/null
+++ b/applications/test/CompactIOList/Make/files
@@ -0,0 +1,4 @@
+
+testCompactIOList.C
+
+EXE = $(FOAM_APPBIN)/CompactIOList
diff --git a/applications/test/CompactIOList/Make/options b/applications/test/CompactIOList/Make/options
new file mode 100644
index 0000000000..4c3dd783cb
--- /dev/null
+++ b/applications/test/CompactIOList/Make/options
@@ -0,0 +1,3 @@
+EXE_INC =
+
+EXE_LIBS =
diff --git a/applications/test/CompactIOList/testCompactIOList.C b/applications/test/CompactIOList/testCompactIOList.C
new file mode 100644
index 0000000000..e8c8248aae
--- /dev/null
+++ b/applications/test/CompactIOList/testCompactIOList.C
@@ -0,0 +1,181 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
+ \\/ 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 .
+
+Application
+ testCompactIOList
+
+Description
+ Simple demonstration and test application for the CompactIOList container
+
+\*---------------------------------------------------------------------------*/
+
+#include "IOstreams.H"
+#include "argList.H"
+#include "Time.H"
+#include "polyMesh.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+
+// Main program:
+
+int main(int argc, char *argv[])
+{
+# include "setRootCase.H"
+# include "createTime.H"
+
+ IOstream::streamFormat format=IOstream::BINARY;
+ // IOstream::streamFormat format=IOstream::ASCII;
+
+ const label size = 20000000;
+
+ // Old format
+ // ~~~~~~~~~~
+
+ {
+ // Construct big faceList in old format
+ faceIOList faces2
+ (
+ IOobject
+ (
+ "faces2",
+ runTime.constant(),
+ polyMesh::meshSubDir,
+ runTime,
+ IOobject::NO_READ,
+ IOobject::NO_WRITE,
+ false
+ ),
+ size
+ );
+
+ const face f(identity(4));
+
+ forAll(faces2, i)
+ {
+ faces2[i] = f;
+ }
+
+ Info<< "Constructed faceList in = "
+ << runTime.cpuTimeIncrement() << " s" << nl << endl;
+
+
+ // Write binary
+ faces2.writeObject
+ (
+ format,
+ IOstream::currentVersion,
+ IOstream::UNCOMPRESSED
+ );
+
+ Info<< "Written old format faceList in = "
+ << runTime.cpuTimeIncrement() << " s" << nl << endl;
+
+ // Read
+ faceIOList faces3
+ (
+ IOobject
+ (
+ "faces2",
+ runTime.constant(),
+ polyMesh::meshSubDir,
+ runTime,
+ IOobject::MUST_READ,
+ IOobject::NO_WRITE,
+ false
+ )
+ );
+
+ Info<< "Read old format " << faces3.size() << " faceList in = "
+ << runTime.cpuTimeIncrement() << " s" << nl << endl;
+ }
+
+
+ // New format
+ // ~~~~~~~~~~
+
+ {
+ // Construct big faceList in new format
+ faceCompactIOList faces2
+ (
+ IOobject
+ (
+ "faces2",
+ runTime.constant(),
+ polyMesh::meshSubDir,
+ runTime,
+ IOobject::NO_READ,
+ IOobject::NO_WRITE,
+ false
+ ),
+ size
+ );
+
+ const face f(identity(4));
+
+ forAll(faces2, i)
+ {
+ faces2[i] = f;
+ }
+
+ Info<< "Constructed new format faceList in = "
+ << runTime.cpuTimeIncrement() << " s" << nl << endl;
+
+
+ // Write binary
+ faces2.writeObject
+ (
+ format,
+ IOstream::currentVersion,
+ IOstream::UNCOMPRESSED
+ );
+
+ Info<< "Written new format faceList in = "
+ << runTime.cpuTimeIncrement() << " s" << nl << endl;
+
+ // Read
+ faceCompactIOList faces3
+ (
+ IOobject
+ (
+ "faces2",
+ runTime.constant(),
+ polyMesh::meshSubDir,
+ runTime,
+ IOobject::MUST_READ,
+ IOobject::NO_WRITE,
+ false
+ )
+ );
+
+ Info<< "Read new format " << faces3.size() << " faceList in = "
+ << runTime.cpuTimeIncrement() << " s" << nl << endl;
+ }
+
+ return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/IndirectList/IndirectListTest.C b/applications/test/IndirectList/IndirectListTest.C
index 44589f57c0..5fe724cc1b 100644
--- a/applications/test/IndirectList/IndirectListTest.C
+++ b/applications/test/IndirectList/IndirectListTest.C
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -30,6 +30,15 @@ Description
using namespace Foam;
+template
+void printInfo(const ListType& lst)
+{
+ Info<< "addr: " << lst.addressing() << nl
+ << "list: " << lst << nl
+ << endl;
+}
+
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
@@ -42,8 +51,7 @@ int main(int argc, char *argv[])
completeList[i] = 0.1*i;
}
- Info<< "raw : " << completeList << nl
- << endl;
+ Info<< "raw : " << completeList << nl << endl;
List addresses(5);
@@ -53,11 +61,9 @@ int main(int argc, char *argv[])
addresses[3] = 8;
addresses[4] = 5;
- IndirectList idl(completeList, addresses);
+ IndirectList idl1(completeList, addresses);
- Info<< "addr: " << idl.addressing() << nl
- << "list: " << idl() << nl
- << endl;
+ printInfo(idl1);
addresses[4] = 1;
addresses[3] = 0;
@@ -65,11 +71,26 @@ int main(int argc, char *argv[])
addresses[1] = 8;
addresses[0] = 5;
- idl.resetAddressing(addresses.xfer());
+ idl1.resetAddressing(addresses.xfer());
- Info<< "addr: " << idl.addressing() << nl
- << "list: " << idl() << nl
- << endl;
+ printInfo(idl1);
+
+ // test copying
+ UIndirectList uidl1(idl1);
+ IndirectList idl2(uidl1);
+ IndirectList idl3(idl2);
+
+ printInfo(uidl1);
+
+ idl1.resetAddressing(List());
+// idl2.resetAddressing(List());
+
+ Info<<"after resetAddressing:" << nl << endl;
+
+ printInfo(uidl1);
+ printInfo(idl1);
+ printInfo(idl2);
+ printInfo(idl3);
Info<< "End\n" << endl;
diff --git a/applications/test/IndirectList2/IndirectList2.H b/applications/test/IndirectList2/IndirectList2.H
deleted file mode 100644
index 3eb11d0e04..0000000000
--- a/applications/test/IndirectList2/IndirectList2.H
+++ /dev/null
@@ -1,164 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
- \\/ 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 .
-
-Class
- Foam::IndirectList2
-
-Description
- A List with indirect addressing.
-
-SourceFiles
- IndirectListI.H
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef IndirectList2_H
-#define IndirectList2_H
-
-#include "UIndirectList.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-/*---------------------------------------------------------------------------*\
- Class IndirectListAddressing Declaration
-\*---------------------------------------------------------------------------*/
-
-//- A helper class for storing addresses.
-class IndirectListAddressing
-{
- // Private data
-
- //- Storage for the list addressing
- List addressing_;
-
-
- // Private Member Functions
-
- //- Disallow default bitwise copy construct
- IndirectListAddressing(const IndirectListAddressing&);
-
- //- Disallow default bitwise assignment
- void operator=(const IndirectListAddressing&);
-
-
-protected:
-
- // Constructors
-
- //- Construct by copying the addressing array
- explicit inline IndirectListAddressing(const UList& addr);
-
- //- Construct by transferring addressing array
- explicit inline IndirectListAddressing(const Xfer >& addr);
-
-
- // Member Functions
-
- // Access
-
- //- Return the list addressing
- inline const List& addressing() const;
-
- // Edit
-
- //- Reset addressing
- inline void resetAddressing(const UList&);
- inline void resetAddressing(const Xfer >&);
-
-};
-
-
-/*---------------------------------------------------------------------------*\
- Class IndirectList2 Declaration
-\*---------------------------------------------------------------------------*/
-
-template
-class IndirectList2
-:
- private IndirectListAddressing,
- public UIndirectList
-{
- // Private Member Functions
-
- //- Disable default assignment operator
- void operator=(const IndirectList2&);
-
- //- Disable assignment from UIndirectList
- void operator=(const UIndirectList&);
-
-
-public:
-
- // Constructors
-
- //- Construct given the complete list and the addressing array
- inline IndirectList2(const UList&, const UList&);
-
- //- Construct given the complete list and by transferring addressing
- inline IndirectList2(const UList&, const Xfer >&);
-
- //- Copy constructor
- inline IndirectList2(const IndirectList2&);
-
- //- Construct from UIndirectList
- explicit inline IndirectList2(const UIndirectList&);
-
-
- // Member Functions
-
-
- // Access
-
- //- Return the list addressing
- using UIndirectList::addressing;
-
-
- // Edit
-
- //- Reset addressing
- using IndirectListAddressing::resetAddressing;
-
-
- // Member Operators
-
- //- Assignment operator
- using UIndirectList::operator=;
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#include "IndirectList2I.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/applications/test/IndirectList2/IndirectList2I.H b/applications/test/IndirectList2/IndirectList2I.H
deleted file mode 100644
index 66b4e0de84..0000000000
--- a/applications/test/IndirectList2/IndirectList2I.H
+++ /dev/null
@@ -1,136 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
- \\/ 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 .
-
-\*---------------------------------------------------------------------------*/
-
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-
-inline Foam::IndirectListAddressing::IndirectListAddressing
-(
- const UList& addr
-)
-:
- addressing_(addr)
-{}
-
-
-inline Foam::IndirectListAddressing::IndirectListAddressing
-(
- const Xfer >& addr
-)
-:
- addressing_(addr)
-{}
-
-
-template
-inline Foam::IndirectList2::IndirectList2
-(
- const UList& completeList,
- const UList& addr
-)
-:
- IndirectListAddressing(addr),
- UIndirectList
- (
- completeList,
- IndirectListAddressing::addressing()
- )
-{}
-
-
-template
-inline Foam::IndirectList2::IndirectList2
-(
- const UList& completeList,
- const Xfer >& addr
-)
-:
- IndirectListAddressing(addr),
- UIndirectList
- (
- completeList,
- IndirectListAddressing::addressing()
- )
-{}
-
-
-template
-inline Foam::IndirectList2::IndirectList2
-(
- const IndirectList2& lst
-)
-:
- IndirectListAddressing(lst.addressing()),
- UIndirectList
- (
- lst.completeList(),
- IndirectListAddressing::addressing()
- )
-{}
-
-
-template
-inline Foam::IndirectList2::IndirectList2
-(
- const UIndirectList& lst
-)
-:
- IndirectListAddressing(lst.addressing()),
- UIndirectList
- (
- lst.completeList(),
- IndirectListAddressing::addressing()
- )
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-
-inline const Foam::List&
-Foam::IndirectListAddressing::addressing() const
-{
- return addressing_;
-}
-
-
-inline void Foam::IndirectListAddressing::resetAddressing
-(
- const UList& addr
-)
-{
- addressing_ = addr;
-}
-
-
-inline void Foam::IndirectListAddressing::resetAddressing
-(
- const Xfer >& addr
-)
-{
- addressing_.transfer(addr());
-}
-
-
-// ************************************************************************* //
diff --git a/applications/test/IndirectList2/Make/files b/applications/test/IndirectList2/Make/files
deleted file mode 100644
index c6dab96e20..0000000000
--- a/applications/test/IndirectList2/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-IndirectListTest2.C
-
-EXE = $(FOAM_USER_APPBIN)/IndirectListTest2
diff --git a/applications/test/IndirectList2/Make/options b/applications/test/IndirectList2/Make/options
deleted file mode 100644
index 6a9e9810b3..0000000000
--- a/applications/test/IndirectList2/Make/options
+++ /dev/null
@@ -1,2 +0,0 @@
-/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
-/* EXE_LIBS = -lfiniteVolume */
diff --git a/applications/test/Polynomial/Make/options b/applications/test/Polynomial/Make/options
index 1b98398577..4c3dd783cb 100644
--- a/applications/test/Polynomial/Make/options
+++ b/applications/test/Polynomial/Make/options
@@ -1,3 +1,3 @@
-EXE_INC = \
+EXE_INC =
-EXE_LIBS = \
+EXE_LIBS =
diff --git a/applications/test/Polynomial/PolynomialTest.C b/applications/test/Polynomial/PolynomialTest.C
index 4b7db7ef6f..fbfbcc2000 100644
--- a/applications/test/Polynomial/PolynomialTest.C
+++ b/applications/test/Polynomial/PolynomialTest.C
@@ -29,24 +29,30 @@ Description
\*---------------------------------------------------------------------------*/
-#include "IFstream.H"
+#include "IStringStream.H"
#include "Polynomial.H"
#include "Random.H"
+#include "cpuTime.H"
using namespace Foam;
+const int PolySize = 8;
+const scalar coeff[] = { 0.11, 0.45, -0.94, 1.58, -2.58, 0.08, 3.15, -4.78 };
+const char* polyDef = "testPoly (0.11 0.45 -0.94 1.58 -2.58 0.08 3.15 -4.78)";
+
+
scalar polyValue(const scalar x)
{
// Hard-coded polynomial 8 coeff (7th order)
return
- 0.11
- + 0.45*x
- - 0.94*sqr(x)
- + 1.58*pow3(x)
- - 2.58*pow4(x)
- + 0.08*pow5(x)
- + 3.15*pow6(x)
- - 4.78*x*pow6(x);
+ coeff[0]
+ + coeff[1]*x
+ + coeff[2]*sqr(x)
+ + coeff[3]*pow3(x)
+ + coeff[4]*pow4(x)
+ + coeff[5]*pow5(x)
+ + coeff[6]*pow6(x)
+ + coeff[7]*x*pow6(x);
}
@@ -54,14 +60,44 @@ scalar intPolyValue(const scalar x)
{
// Hard-coded integrated form of above polynomial
return
- 0.11*x
- + 0.45/2.0*sqr(x)
- - 0.94/3.0*pow3(x)
- + 1.58/4.0*pow4(x)
- - 2.58/5.0*pow5(x)
- + 0.08/6.0*pow6(x)
- + 3.15/7.0*x*pow6(x)
- - 4.78/8.0*x*x*pow6(x);
+ coeff[0]*x
+ + coeff[1]/2.0*sqr(x)
+ + coeff[2]/3.0*pow3(x)
+ + coeff[3]/4.0*pow4(x)
+ + coeff[4]/5.0*pow5(x)
+ + coeff[5]/6.0*pow6(x)
+ + coeff[6]/7.0*x*pow6(x)
+ + coeff[7]/8.0*x*x*pow6(x);
+}
+
+
+scalar polyValue1(const scalar x)
+{
+ // "normal" evaluation using pow()
+ scalar value = coeff[0];
+
+ for (int i=1; i < PolySize; ++i)
+ {
+ value += coeff[i]*pow(x, i);
+ }
+
+ return value;
+}
+
+
+scalar polyValue2(const scalar x)
+{
+ // calculation avoiding pow()
+ scalar value = coeff[0];
+
+ scalar powX = x;
+ for (int i=1; i < PolySize; ++i)
+ {
+ value += coeff[i] * powX;
+ powX *= x;
+ }
+
+ return value;
}
@@ -69,9 +105,14 @@ scalar intPolyValue(const scalar x)
int main(int argc, char *argv[])
{
- IFstream is("polyTestInput");
+ const label n = 10000;
+ const label nIters = 1000;
+ scalar sum = 0.0;
- Polynomial<8> poly("testPoly", is);
+ Info<< "null poly = " << (Polynomial<8>()) << nl << endl;
+
+ // Polynomial<8> poly("testPoly", IStringStream(polyDef)());
+ Polynomial<8> poly(coeff);
Polynomial<9> intPoly(poly.integrate(0.0));
Info<< "poly = " << poly << endl;
@@ -118,6 +159,62 @@ int main(int argc, char *argv[])
Info<< endl;
}
+
+ //
+ // test speed of Polynomial:
+ //
+ Info<< "start timing loops" << nl
+ << "~~~~~~~~~~~~~~~~~~" << endl;
+
+ cpuTime timer;
+
+ for (int loop = 0; loop < n; ++loop)
+ {
+ sum = 0.0;
+ for (label iter = 0; iter < nIters; ++iter)
+ {
+ sum += poly.evaluate(loop+iter);
+ }
+ }
+ Info<< "evaluate: " << sum
+ << " in " << timer.cpuTimeIncrement() << " s\n";
+
+
+ for (int loop = 0; loop < n; ++loop)
+ {
+ sum = 0.0;
+ for (label iter = 0; iter < nIters; ++iter)
+ {
+ sum += polyValue(loop+iter);
+ }
+ }
+ Info<< "hard-coded 0: " << sum
+ << " in " << timer.cpuTimeIncrement() << " s\n";
+
+
+ for (int loop = 0; loop < n; ++loop)
+ {
+ sum = 0.0;
+ for (label iter = 0; iter < nIters; ++iter)
+ {
+ sum += polyValue1(loop+iter);
+ }
+ }
+ Info<< "hard-coded 1: " << sum
+ << " in " << timer.cpuTimeIncrement() << " s\n";
+
+ for (int loop = 0; loop < n; ++loop)
+ {
+ sum = 0.0;
+ for (label iter = 0; iter < nIters; ++iter)
+ {
+ sum += polyValue2(loop+iter);
+ }
+ }
+ Info<< "hard-coded 2: " << sum
+ << " in " << timer.cpuTimeIncrement() << " s\n";
+
+
Info<< nl << "Done." << endl;
return 0;
diff --git a/applications/test/Polynomial/polyTestInput b/applications/test/Polynomial/polyTestInput
deleted file mode 100644
index 4ba8f65e51..0000000000
--- a/applications/test/Polynomial/polyTestInput
+++ /dev/null
@@ -1,11 +0,0 @@
- testPoly
- (
- 0.11
- 0.45
- -0.94
- 1.58
- -2.58
- 0.08
- 3.15
- -4.78
- )
diff --git a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L
index ddd97c3a05..c49dc5db31 100644
--- a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L
+++ b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L
@@ -475,7 +475,7 @@ int main(int argc, char *argv[])
{-1, -1, -1, -1, -1, -1}, // 1
{-1, -1, -1, -1, -1, -1}, // 2
{-1, -1, -1, -1, -1, -1}, // 3
- {-1, 2, 0, 3, 1, -1}, // tet (version 2.0)
+ { 3, 2, 0, -1, 1, -1}, // tet (version 2.0)
{ 0, 4, 3, -1, 2, 1}, // prism
{ 4, 2, 1, 3, 0, 5}, // hex
};
@@ -500,12 +500,14 @@ int main(int argc, char *argv[])
++cellIter, ++faceIter
)
{
+ const cellShape& shape = cellShapes[cellMap[cellIter()]];
+
patchFaces.append
(
- cellShapes[cellMap[cellIter()] ].faces()
+ shape.faces()
[
faceIndex
- [cellShapes[cellMap[cellIter()] ].nFaces()]
+ [shape.nFaces()]
[faceIter()-1]
]
);
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
index 78e39e9df6..44c513a079 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
@@ -2,6 +2,5 @@ itoa.C
ensightMesh.C
ensightParticlePositions.C
foamToEnsight.C
-ensightWriteBinary.C
EXE = $(FOAM_APPBIN)/foamToEnsight
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
index 2c9755ef43..86eaa03d88 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/cellSets.H
@@ -44,21 +44,12 @@ namespace Foam
class cellSets
{
- // Private Member Functions
-
- //- Disallow default bitwise copy construct
- cellSets(const cellSets&);
-
- //- Disallow default bitwise assignment
- void operator=(const cellSets&);
-
-
public:
- label nHexesWedges;
- label nPrisms;
- label nPyrs;
label nTets;
+ label nPyrs;
+ label nPrisms;
+ label nHexesWedges;
label nPolys;
labelList tets;
@@ -66,6 +57,7 @@ public:
labelList prisms;
labelList wedges;
labelList hexes;
+ labelList hexesWedges;
labelList polys;
@@ -74,10 +66,10 @@ public:
//- Construct given the number ov cells
cellSets(const label nCells)
:
- nHexesWedges(0),
- nPrisms(0),
- nPyrs(0),
nTets(0),
+ nPyrs(0),
+ nPrisms(0),
+ nHexesWedges(0),
nPolys(0),
tets(nCells),
@@ -85,6 +77,7 @@ public:
prisms(nCells),
wedges(nCells),
hexes(nCells),
+ hexesWedges(nCells),
polys(nCells)
{}
};
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightAsciiStream.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightAsciiStream.H
new file mode 100644
index 0000000000..9a7f53e6b3
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightAsciiStream.H
@@ -0,0 +1,161 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
+ \\/ 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 .
+
+Class
+ Foam::ensightAsciiStream
+
+Description
+
+SourceFiles
+ ensightAsciiStream.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef ensightAsciiStream_H
+#define ensightAsciiStream_H
+
+#include "ensightStream.H"
+#include "OFstream.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class ensightAsciiStream Declaration
+\*---------------------------------------------------------------------------*/
+
+class ensightAsciiStream
+:
+ public ensightStream
+{
+ // Private data
+
+ //- Description of data_
+ OFstream str_;
+
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ ensightAsciiStream(const ensightAsciiStream&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const ensightAsciiStream&);
+
+
+public:
+
+ // Constructors
+
+ //- Construct from components
+ ensightAsciiStream(const fileName& f, const Time& runTime)
+ :
+ ensightStream(f),
+ str_
+ (
+ f,
+ runTime.writeFormat(),
+ runTime.writeVersion(),
+ IOstream::UNCOMPRESSED
+ )
+ {
+
+ str_.setf(ios_base::scientific, ios_base::floatfield);
+ str_.precision(5);
+ }
+
+
+ //- Destructor
+ virtual ~ensightAsciiStream()
+ {}
+
+
+ // Member Functions
+
+ virtual bool ascii() const
+ {
+ return true;
+ }
+
+ virtual void write(const char* c)
+ {
+ str_ << c << nl;
+ }
+
+ virtual void write(const int v)
+ {
+ str_ << setw(10) << v << nl;
+ }
+
+ virtual void write(const scalarField& sf)
+ {
+ forAll(sf, i)
+ {
+ if (mag(sf[i]) >= scalar(floatScalarVSMALL))
+ {
+ str_ << setw(12) << sf[i] << nl;
+ }
+ else
+ {
+ str_ << setw(12) << scalar(0) << nl;
+ }
+ }
+ }
+
+ virtual void write(const List& sf)
+ {
+ forAll(sf, i)
+ {
+ str_ << setw(10) << sf[i];
+ }
+ str_<< nl;
+ }
+
+ virtual void writePartHeader(const label partI)
+ {
+ str_<< "part" << nl
+ << setw(10) << partI << nl;
+ }
+
+ // Member Operators
+
+ // Friend Functions
+
+ // Friend Operators
+
+ // IOstream Operators
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H
new file mode 100644
index 0000000000..749b47b702
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H
@@ -0,0 +1,163 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
+ \\/ 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 .
+
+Class
+ Foam::ensightBinaryStream
+
+Description
+
+SourceFiles
+ ensightBinaryStream.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef ensightBinaryStream_H
+#define ensightBinaryStream_H
+
+#include "ensightStream.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class ensightBinaryStream Declaration
+\*---------------------------------------------------------------------------*/
+
+class ensightBinaryStream
+:
+ public ensightStream
+{
+ // Private data
+
+ //- Description of data_
+ autoPtr str_;
+
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ ensightBinaryStream(const ensightBinaryStream&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const ensightBinaryStream&);
+
+
+public:
+
+ // Constructors
+
+ //- Construct from components
+ ensightBinaryStream(const fileName& f, const Time&)
+ :
+ ensightStream(f),
+ str_
+ (
+ new std::ofstream
+ (
+ f.c_str(),
+ ios_base::out | ios_base::binary | ios_base::trunc
+ )
+ )
+ {}
+
+
+ //- Destructor
+ virtual ~ensightBinaryStream()
+ {}
+
+
+ // Member Functions
+
+ virtual bool ascii() const
+ {
+ return false;
+ }
+
+ virtual void write(const char* val)
+ {
+ char buffer[80] = {0};
+ strcpy(buffer, val);
+ str_().write(buffer, 80*sizeof(char));
+ }
+
+ virtual void write(const int val)
+ {
+ str_().write(reinterpret_cast(&val), sizeof(int));
+ }
+
+ virtual void write(const scalarField& sf)
+ {
+ if (sf.size())
+ {
+ List temp(sf.size());
+
+ forAll(sf, i)
+ {
+ temp[i] = float(sf[i]);
+ }
+
+ str_().write
+ (
+ reinterpret_cast(temp.begin()),
+ sf.size()*sizeof(float)
+ );
+ }
+ }
+
+ virtual void write(const List& sf)
+ {
+ str_().write
+ (
+ reinterpret_cast(sf.begin()),
+ sf.size()*sizeof(int)
+ );
+ }
+
+ virtual void writePartHeader(const label partI)
+ {
+ write("part");
+ write(partI);
+ }
+
+ // Member Operators
+
+ // Friend Functions
+
+ // Friend Operators
+
+ // IOstream Operators
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C
index 680d5ff894..8a79f54d96 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C
@@ -29,99 +29,38 @@ License
#include "OFstream.H"
#include "IOmanip.H"
#include "itoa.H"
-#include "ensightWriteBinary.H"
+#include "volPointInterpolation.H"
+#include "ensightBinaryStream.H"
+#include "ensightAsciiStream.H"
+#include "globalIndex.H"
using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
-void writeData(const scalarField& sf, OFstream& ensightFile)
-{
- forAll(sf, i)
- {
- if (mag( sf[i] ) >= scalar(floatScalarVSMALL))
- {
- ensightFile << setw(12) << sf[i] << nl;
- }
- else
- {
- ensightFile << setw(12) << scalar(0) << nl;
- }
- }
-}
-
-
template
-scalarField map
-(
- const Field& vf,
- const labelList& map,
- const label cmpt
-)
-{
- scalarField mf(map.size());
-
- forAll(map, i)
- {
- mf[i] = component(vf[map[i]], cmpt);
- }
-
- return mf;
-}
-
-
-template
-scalarField map
-(
- const Field& vf,
- const labelList& map1,
- const labelList& map2,
- const label cmpt
-)
-{
- scalarField mf(map1.size() + map2.size());
-
- forAll(map1, i)
- {
- mf[i] = component(vf[map1[i]], cmpt);
- }
-
- label offset = map1.size();
-
- forAll(map2, i)
- {
- mf[i + offset] = component(vf[map2[i]], cmpt);
- }
-
- return mf;
-}
-
-
-template
-void writeAllData
+void writeField
(
const char* key,
const Field& vf,
- const labelList& prims,
- const label nPrims,
- OFstream& ensightFile
+ ensightStream& ensightFile
)
{
- if (nPrims)
+ if (returnReduce(vf.size(), sumOp()) > 0)
{
if (Pstream::master())
{
- ensightFile << key << nl;
+ ensightFile.write(key);
for (direction cmpt=0; cmpt::nComponents; cmpt++)
{
- writeData(map(vf, prims, cmpt), ensightFile);
+ ensightFile.write(vf.component(cmpt));
for (int slave=1; slave::nComponents; cmpt++)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
- toMaster<< map(vf, prims, cmpt);
- }
- }
- }
-}
-
-
-template
-void writeAllDataBinary
-(
- const char* key,
- const Field& vf,
- const labelList& prims,
- const label nPrims,
- std::ofstream& ensightFile
-)
-{
- if (nPrims)
- {
- if (Pstream::master())
- {
- writeEnsDataBinary(key,ensightFile);
-
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
- {
- writeEnsDataBinary(map(vf, prims, cmpt), ensightFile);
-
- for (int slave=1; slave::nComponents; cmpt++)
- {
- OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
- toMaster<< map(vf, prims, cmpt);
- }
- }
- }
-}
-
-
-template
-void writeAllFaceData
-(
- const char* key,
- const labelList& prims,
- const label nPrims,
- const Field& pf,
- OFstream& ensightFile
-)
-{
- if (nPrims)
- {
- if (Pstream::master())
- {
- ensightFile << key << nl;
-
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
- {
- writeData(map(pf, prims, cmpt), ensightFile);
-
- for (int slave=1; slave::nComponents; cmpt++)
- {
- OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
- toMaster<< map(pf, prims, cmpt);
- }
- }
- }
-}
-
-
-template
-void writeAllFaceDataBinary
-(
- const char* key,
- const labelList& prims,
- const label nPrims,
- const Field& pf,
- std::ofstream& ensightFile
-)
-{
- if (nPrims)
- {
- if (Pstream::master())
- {
- writeEnsDataBinary(key,ensightFile);
-
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
- {
- writeEnsDataBinary(map(pf, prims, cmpt), ensightFile);
-
- for (int slave=1; slave::nComponents; cmpt++)
- {
- OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
- toMaster<< map(pf, prims, cmpt);
+ toMaster<< vf.component(cmpt);
}
}
}
@@ -267,97 +84,34 @@ bool writePatchField
const Foam::label ensightPatchI,
const Foam::faceSets& boundaryFaceSet,
const Foam::ensightMesh::nFacePrimitives& nfp,
- Foam::OFstream& ensightFile
+ ensightStream& ensightFile
)
{
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
if (Pstream::master())
{
- ensightFile
- << "part" << nl
- << setw(10) << ensightPatchI << nl;
+ ensightFile.writePartHeader(ensightPatchI);
}
- writeAllFaceData
+ writeField
(
"tria3",
- boundaryFaceSet.tris,
- nfp.nTris,
- pf,
+ Field(pf, boundaryFaceSet.tris),
ensightFile
);
- writeAllFaceData
+ writeField
(
"quad4",
- boundaryFaceSet.quads,
- nfp.nQuads,
- pf,
+ Field(pf, boundaryFaceSet.quads),
ensightFile
);
- writeAllFaceData
+ writeField
(
"nsided",
- boundaryFaceSet.polys,
- nfp.nPolys,
- pf,
- ensightFile
- );
-
- return true;
- }
- else
- {
- return false;
- }
-}
-
-
-template
-bool writePatchFieldBinary
-(
- const Foam::Field& pf,
- const Foam::label patchi,
- const Foam::label ensightPatchI,
- const Foam::faceSets& boundaryFaceSet,
- const Foam::ensightMesh::nFacePrimitives& nfp,
- std::ofstream& ensightFile
-)
-{
- if (nfp.nTris || nfp.nQuads || nfp.nPolys)
- {
- if (Pstream::master())
- {
- writeEnsDataBinary("part",ensightFile);
- writeEnsDataBinary(ensightPatchI,ensightFile);
- }
-
- writeAllFaceDataBinary
- (
- "tria3",
- boundaryFaceSet.tris,
- nfp.nTris,
- pf,
- ensightFile
- );
-
- writeAllFaceDataBinary
- (
- "quad4",
- boundaryFaceSet.quads,
- nfp.nQuads,
- pf,
- ensightFile
- );
-
- writeAllFaceDataBinary
- (
- "nsided",
- boundaryFaceSet.polys,
- nfp.nPolys,
- pf,
+ Field(pf, boundaryFaceSet.polys),
ensightFile
);
@@ -380,6 +134,7 @@ void writePatchField
const Foam::fileName& postProcPath,
const Foam::word& prepend,
const Foam::label timeIndex,
+ const bool binary,
Foam::Ostream& ensightCaseFile
)
{
@@ -409,7 +164,7 @@ void writePatchField
word timeFile = prepend + itoa(timeIndex);
- OFstream *ensightFilePtr = NULL;
+ ensightStream* ensightFilePtr = NULL;
if (Pstream::master())
{
if (timeIndex == 0)
@@ -426,20 +181,30 @@ void writePatchField
// set the filename of the ensight file
fileName ensightFileName(timeFile + "." + pfName);
- ensightFilePtr = new OFstream
- (
- postProcPath/ensightFileName,
- runTime.writeFormat(),
- runTime.writeVersion(),
- runTime.writeCompression()
- );
+
+ if (binary)
+ {
+ ensightFilePtr = new ensightBinaryStream
+ (
+ postProcPath/ensightFileName,
+ runTime
+ );
+ }
+ else
+ {
+ ensightFilePtr = new ensightAsciiStream
+ (
+ postProcPath/ensightFileName,
+ runTime
+ );
+ }
}
- OFstream& ensightFile = *ensightFilePtr;
+ ensightStream& ensightFile = *ensightFilePtr;
if (Pstream::master())
{
- ensightFile << pTraits::typeName << nl;
+ ensightFile.write(pTraits::typeName);
}
if (patchi >= 0)
@@ -477,17 +242,18 @@ void writePatchField
template
-void ensightFieldAscii
+void ensightField
(
- const Foam::IOobject& fieldObject,
+ const GeometricField& vf,
const Foam::ensightMesh& eMesh,
const Foam::fileName& postProcPath,
const Foam::word& prepend,
const Foam::label timeIndex,
+ const bool binary,
Foam::Ostream& ensightCaseFile
)
{
- Info<< "Converting field " << fieldObject.name() << endl;
+ Info<< "Converting field " << vf.name() << endl;
word timeFile = prepend + itoa(timeIndex);
@@ -508,27 +274,34 @@ void ensightFieldAscii
const labelList& tets = meshCellSets.tets;
const labelList& pyrs = meshCellSets.pyrs;
const labelList& prisms = meshCellSets.prisms;
- const labelList& wedges = meshCellSets.wedges;
- const labelList& hexes = meshCellSets.hexes;
+ const labelList& hexesWedges = meshCellSets.hexesWedges;
const labelList& polys = meshCellSets.polys;
- OFstream *ensightFilePtr = NULL;
+ ensightStream* ensightFilePtr = NULL;
if (Pstream::master())
{
// set the filename of the ensight file
- fileName ensightFileName(timeFile + "." + fieldObject.name());
- ensightFilePtr = new OFstream
- (
- postProcPath/ensightFileName,
- runTime.writeFormat(),
- runTime.writeVersion(),
- IOstream::UNCOMPRESSED
- );
+ fileName ensightFileName(timeFile + "." + vf.name());
+
+ if (binary)
+ {
+ ensightFilePtr = new ensightBinaryStream
+ (
+ postProcPath/ensightFileName,
+ runTime
+ );
+ }
+ else
+ {
+ ensightFilePtr = new ensightAsciiStream
+ (
+ postProcPath/ensightFileName,
+ runTime
+ );
+ }
}
- OFstream& ensightFile = *ensightFilePtr;
-
- GeometricField vf(fieldObject, mesh);
+ ensightStream& ensightFile = *ensightFilePtr;
if (patchNames.empty())
{
@@ -548,80 +321,42 @@ void ensightFieldAscii
<< nl;
}
+ ensightFile.write(pTraits::typeName);
+ ensightFile.writePartHeader(1);
+ }
+
+ writeField
+ (
+ "hexa8",
+ Field(vf, hexesWedges),
ensightFile
- << pTraits::typeName << nl
- << "part" << nl
- << setw(10) << 1 << nl;
+ );
- ensightFile.setf(ios_base::scientific, ios_base::floatfield);
- ensightFile.precision(5);
- }
-
- if (meshCellSets.nHexesWedges)
- {
- if (Pstream::master())
- {
- ensightFile << "hexa8" << nl;
-
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
- {
- writeData
- (
- map(vf, hexes, wedges, cmpt),
- ensightFile
- );
-
- for (int slave=1; slave::nComponents; cmpt++)
- {
- OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
- toMaster<< map(vf, hexes, wedges, cmpt);
- }
- }
- }
-
- writeAllData
+ writeField
(
"penta6",
- vf,
- prisms,
- meshCellSets.nPrisms,
+ Field(vf, prisms),
ensightFile
);
- writeAllData
+ writeField
(
"pyramid5",
- vf,
- pyrs,
- meshCellSets.nPyrs,
+ Field(vf, pyrs),
ensightFile
);
- writeAllData
+ writeField
(
"tetra4",
- vf,
- tets,
- meshCellSets.nTets,
+ Field(vf, tets),
ensightFile
);
- writeAllData
+ writeField
(
"nfaced",
- vf,
- polys,
- meshCellSets.nPolys,
+ Field(vf, polys),
ensightFile
);
}
@@ -727,7 +462,6 @@ void ensightFieldAscii
}
}
}
-
if (Pstream::master())
{
delete ensightFilePtr;
@@ -736,59 +470,54 @@ void ensightFieldAscii
template
-void ensightFieldBinary
+void ensightPointField
(
- const Foam::IOobject& fieldObject,
+ const GeometricField& pf,
const Foam::ensightMesh& eMesh,
const Foam::fileName& postProcPath,
const Foam::word& prepend,
const Foam::label timeIndex,
+ const bool binary,
Foam::Ostream& ensightCaseFile
)
{
- Info<< "Converting field (binary) " << fieldObject.name() << endl;
+ Info<< "Converting field " << pf.name() << endl;
word timeFile = prepend + itoa(timeIndex);
const fvMesh& mesh = eMesh.mesh();
- //const Time& runTime = mesh.time();
-
- const cellSets& meshCellSets = eMesh.meshCellSets();
- const List& boundaryFaceSets = eMesh.boundaryFaceSets();
const wordList& allPatchNames = eMesh.allPatchNames();
const wordHashSet& patchNames = eMesh.patchNames();
- const HashTable&
- nPatchPrims = eMesh.nPatchPrims();
- const List& faceZoneFaceSets = eMesh.faceZoneFaceSets();
const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
- const HashTable&
- nFaceZonePrims = eMesh.nFaceZonePrims();
- const labelList& tets = meshCellSets.tets;
- const labelList& pyrs = meshCellSets.pyrs;
- const labelList& prisms = meshCellSets.prisms;
- const labelList& wedges = meshCellSets.wedges;
- const labelList& hexes = meshCellSets.hexes;
- const labelList& polys = meshCellSets.polys;
- std::ofstream *ensightFilePtr = NULL;
+ ensightStream* ensightFilePtr = NULL;
if (Pstream::master())
{
// set the filename of the ensight file
- fileName ensightFileName(timeFile + "." + fieldObject.name());
- ensightFilePtr = new std::ofstream
- (
- (postProcPath/ensightFileName).c_str(),
- ios_base::out | ios_base::binary | ios_base::trunc
- );
- // Check on file opened?
+ fileName ensightFileName(timeFile + "." + pf.name());
+
+ if (binary)
+ {
+ ensightFilePtr = new ensightBinaryStream
+ (
+ postProcPath/ensightFileName,
+ mesh.time()
+ );
+ }
+ else
+ {
+ ensightFilePtr = new ensightAsciiStream
+ (
+ postProcPath/ensightFileName,
+ mesh.time()
+ );
+ }
}
- std::ofstream& ensightFile = *ensightFilePtr;
+ ensightStream& ensightFile = *ensightFilePtr;
- GeometricField vf(fieldObject, mesh);
-
- if (patchNames.empty())
+ if (eMesh.patchNames().empty())
{
eMesh.barrier();
@@ -800,192 +529,122 @@ void ensightFieldBinary
ensightCaseFile
<< pTraits::typeName
- << " per element: 1 "
- << setw(15) << vf.name()
- << (' ' + prepend + "***." + vf.name()).c_str()
+ << " per node: 1 "
+ << setw(15) << pf.name()
+ << (' ' + prepend + "***." + pf.name()).c_str()
<< nl;
}
- writeEnsDataBinary(pTraits::typeName,ensightFile);
- writeEnsDataBinary("part",ensightFile);
- writeEnsDataBinary(1,ensightFile);
+ ensightFile.write(pTraits::typeName);
+ ensightFile.writePartHeader(1);
}
- if (meshCellSets.nHexesWedges)
- {
- if (Pstream::master())
- {
- writeEnsDataBinary("hexa8",ensightFile);
-
- for (direction cmpt=0; cmpt::nComponents; cmpt++)
- {
- writeEnsDataBinary
- (
- map(vf, hexes, wedges, cmpt),
- ensightFile
- );
-
- for (int slave=1; slave::nComponents; cmpt++)
- {
- OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
- toMaster<< map(vf, hexes, wedges, cmpt);
- }
- }
- }
-
- writeAllDataBinary
+ writeField
(
- "penta6",
- vf,
- prisms,
- meshCellSets.nPrisms,
- ensightFile
- );
-
- writeAllDataBinary
- (
- "pyramid5",
- vf,
- pyrs,
- meshCellSets.nPyrs,
- ensightFile
- );
-
- writeAllDataBinary
- (
- "tetra4",
- vf,
- tets,
- meshCellSets.nTets,
- ensightFile
- );
-
- writeAllDataBinary
- (
- "nfaced",
- vf,
- polys,
- meshCellSets.nPolys,
+ "coordinates",
+ Field(pf.internalField(), eMesh.uniquePointMap()),
ensightFile
);
}
- label ensightPatchI = eMesh.patchPartOffset();
- forAll(allPatchNames, patchi)
- {
- const word& patchName = allPatchNames[patchi];
-
- eMesh.barrier();
-
- if (patchNames.empty() || patchNames.found(patchName))
- {
- if
- (
- writePatchFieldBinary
- (
- vf.boundaryField()[patchi],
- patchi,
- ensightPatchI,
- boundaryFaceSets[patchi],
- nPatchPrims.find(patchName)(),
- ensightFile
- )
- )
- {
- ensightPatchI++;
- }
- }
-
- }
-
- // write faceZones, if requested
- if (faceZoneNames.size())
- {
- // Interpolates cell values to faces - needed only when exporting
- // faceZones...
- GeometricField sf
- (
- linearInterpolate(vf)
- );
-
- forAllConstIter(wordHashSet, faceZoneNames, iter)
- {
- const word& faceZoneName = iter.key();
-
- eMesh.barrier();
-
- label zoneID = mesh.faceZones().findZoneID(faceZoneName);
-
- const faceZone& fz = mesh.faceZones()[zoneID];
-
- // Prepare data to write
- label nIncluded = 0;
- forAll(fz, i)
- {
- if (eMesh.faceToBeIncluded(fz[i]))
- {
- ++nIncluded;
- }
- }
-
- Field values(nIncluded);
-
- // Loop on the faceZone and store the needed field values
- label j = 0;
- forAll(fz, i)
- {
- label faceI = fz[i];
- if (mesh.isInternalFace(faceI))
- {
- values[j] = sf[faceI];
- ++j;
- }
- else
- {
- if (eMesh.faceToBeIncluded(faceI))
- {
- label patchI = mesh.boundaryMesh().whichPatch(faceI);
- const polyPatch& pp = mesh.boundaryMesh()[patchI];
- label patchFaceI = pp.whichFace(faceI);
- Type value = sf.boundaryField()[patchI][patchFaceI];
- values[j] = value;
- ++j;
- }
- }
- }
-
- if
- (
- writePatchFieldBinary
- (
- values,
- zoneID,
- ensightPatchI,
- faceZoneFaceSets[zoneID],
- nFaceZonePrims.find(faceZoneName)(),
- ensightFile
- )
- )
- {
- ensightPatchI++;
- }
- }
- }
+ label ensightPatchI = eMesh.patchPartOffset();
+
+ forAll(allPatchNames, patchi)
+ {
+ const word& patchName = allPatchNames[patchi];
+
+ eMesh.barrier();
+
+ if (patchNames.empty() || patchNames.found(patchName))
+ {
+ const fvPatch& p = mesh.boundary()[patchi];
+ if
+ (
+ returnReduce(p.size(), sumOp())
+ > 0
+ )
+ {
+ // Renumber the patch points/faces into unique points
+ labelList pointToGlobal;
+ labelList uniqueMeshPointLabels;
+ autoPtr globalPointsPtr =
+ mesh.globalData().mergePoints
+ (
+ p.patch().meshPoints(),
+ p.patch().meshPointMap(),
+ pointToGlobal,
+ uniqueMeshPointLabels
+ );
+
+ if (Pstream::master())
+ {
+ ensightFile.writePartHeader(ensightPatchI);
+ }
+
+ writeField
+ (
+ "coordinates",
+ Field(pf.internalField(), uniqueMeshPointLabels),
+ ensightFile
+ );
+
+ ensightPatchI++;
+ }
+ }
+ }
+
+ // write faceZones, if requested
+ if (faceZoneNames.size())
+ {
+ forAllConstIter(wordHashSet, faceZoneNames, iter)
+ {
+ const word& faceZoneName = iter.key();
+
+ eMesh.barrier();
+
+ label zoneID = mesh.faceZones().findZoneID(faceZoneName);
+
+ const faceZone& fz = mesh.faceZones()[zoneID];
+
+ if (returnReduce(fz().nPoints(), sumOp()) > 0)
+ {
+ // Renumber the faceZone points/faces into unique points
+ labelList pointToGlobal;
+ labelList uniqueMeshPointLabels;
+ autoPtr globalPointsPtr =
+ mesh.globalData().mergePoints
+ (
+ fz().meshPoints(),
+ fz().meshPointMap(),
+ pointToGlobal,
+ uniqueMeshPointLabels
+ );
+
+ if (Pstream::master())
+ {
+ ensightFile.writePartHeader(ensightPatchI);
+ }
+
+ writeField
+ (
+ "coordinates",
+ Field
+ (
+ pf.internalField(),
+ uniqueMeshPointLabels
+ ),
+ ensightFile
+ );
+
+ ensightPatchI++;
+ }
+ }
+ }
if (Pstream::master())
{
- ensightFile.close();
+ delete ensightFilePtr;
}
}
@@ -999,30 +658,42 @@ void ensightField
const Foam::word& prepend,
const Foam::label timeIndex,
const bool binary,
+ const bool nodeValues,
Foam::Ostream& ensightCaseFile
)
{
- if (binary)
+ // Read field
+ GeometricField vf(fieldObject, eMesh.mesh());
+
+ if (nodeValues)
{
- ensightFieldBinary
+ tmp > pfld
(
- fieldObject,
+ volPointInterpolation::New(eMesh.mesh()).interpolate(vf)
+ );
+ pfld().rename(vf.name());
+
+ ensightPointField
+ (
+ pfld,
eMesh,
postProcPath,
prepend,
timeIndex,
+ binary,
ensightCaseFile
);
}
else
{
- ensightFieldAscii
+ ensightField
(
- fieldObject,
+ vf,
eMesh,
postProcPath,
prepend,
timeIndex,
+ binary,
ensightCaseFile
);
}
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.H
index 69130eee5e..0add60513b 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.H
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.H
@@ -35,7 +35,6 @@ SourceFiles
#define ensightField_H
#include "ensightMesh.H"
-#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -48,6 +47,7 @@ void ensightField
const Foam::word& prepend,
const Foam::label timeIndex,
const bool binary,
+ const bool nodeValues,
Foam::Ostream& ensightCaseFile
);
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
index 00c733890a..06aeb3291a 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C
@@ -23,9 +23,9 @@ License
\*---------------------------------------------------------------------------*/
+#include "ensightMesh.H"
#include "argList.H"
#include "Time.H"
-#include "ensightMesh.H"
#include "fvMesh.H"
#include "globalMeshData.H"
#include "PstreamCombineReduceOps.H"
@@ -33,38 +33,31 @@ License
#include "cellModeller.H"
#include "IOmanip.H"
#include "itoa.H"
-#include "ensightWriteBinary.H"
#include "globalIndex.H"
#include "mapDistribute.H"
#include "stringListOps.H"
+#include "ensightBinaryStream.H"
+#include "ensightAsciiStream.H"
+
#include
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-Foam::ensightMesh::ensightMesh
-(
- const fvMesh& mesh,
- const argList& args,
- const bool binary
-)
-:
- mesh_(mesh),
- binary_(binary),
- patchPartOffset_(2),
- meshCellSets_(mesh_.nCells()),
- boundaryFaceSets_(mesh_.boundary().size()),
- allPatchNames_(0),
- patchNames_(0),
- nPatchPrims_(0),
- faceZoneFaceSets_(mesh_.faceZones().size()),
- faceZoneNames_(0),
- nFaceZonePrims_(0),
- boundaryFaceToBeIncluded_(0)
+void Foam::ensightMesh::correct()
{
- const cellShapeList& cellShapes = mesh.cellShapes();
+ patchPartOffset_ = 2;
+ meshCellSets_ = mesh_.nCells();
+ boundaryFaceSets_.setSize(mesh_.boundary().size());
+ allPatchNames_.clear();
+ patchNames_.clear();
+ nPatchPrims_ = 0;
+ faceZoneFaceSets_.setSize(mesh_.faceZones().size());
+ faceZoneNames_.clear();
+ nFaceZonePrims_ = 0;
+ boundaryFaceToBeIncluded_.clear();
+
+ const cellShapeList& cellShapes = mesh_.cellShapes();
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
@@ -72,7 +65,7 @@ Foam::ensightMesh::ensightMesh
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
- if (!args.optionFound("noPatches"))
+ if (!noPatches_)
{
// Patches are output. Check that they're synced.
mesh_.boundaryMesh().checkParallelSync(true);
@@ -84,11 +77,9 @@ Foam::ensightMesh::ensightMesh
- mesh_.globalData().processorPatches().size()
);
- if (args.optionFound("patches"))
+ if (patches_)
{
- wordReList patterns(args.optionLookup("patches")());
-
- if (patterns.empty())
+ if (patchPatterns_.empty())
{
forAll(allPatchNames_, nameI)
{
@@ -101,7 +92,7 @@ Foam::ensightMesh::ensightMesh
forAll(allPatchNames_, nameI)
{
const word& patchName = allPatchNames_[nameI];
- if (findStrings(patterns, patchName))
+ if (findStrings(patchPatterns_, patchName))
{
patchNames_.insert(patchName);
}
@@ -123,6 +114,7 @@ Foam::ensightMesh::ensightMesh
labelList& prisms = meshCellSets_.prisms;
labelList& wedges = meshCellSets_.wedges;
labelList& hexes = meshCellSets_.hexes;
+ labelList& hexesWedges = meshCellSets_.hexesWedges;
labelList& polys = meshCellSets_.polys;
label nTets = 0;
@@ -130,6 +122,7 @@ Foam::ensightMesh::ensightMesh
label nPrisms = 0;
label nWedges = 0;
label nHexes = 0;
+ label nHexesWedges = 0;
label nPolys = 0;
forAll(cellShapes, cellI)
@@ -152,10 +145,12 @@ Foam::ensightMesh::ensightMesh
else if (cellModel == wedge)
{
wedges[nWedges++] = cellI;
+ hexesWedges[nHexesWedges++] = cellI;
}
else if (cellModel == hex)
{
hexes[nHexes++] = cellI;
+ hexesWedges[nHexesWedges++] = cellI;
}
else
{
@@ -179,20 +174,28 @@ Foam::ensightMesh::ensightMesh
meshCellSets_.nPrisms = nPrisms;
reduce(meshCellSets_.nPrisms, sumOp());
- meshCellSets_.nHexesWedges = nHexes + nWedges;
+ meshCellSets_.nHexesWedges = nHexesWedges;
reduce(meshCellSets_.nHexesWedges, sumOp());
meshCellSets_.nPolys = nPolys;
reduce(meshCellSets_.nPolys, sumOp());
+
+
+ // Determine parallel shared points
+ globalPointsPtr_ = mesh_.globalData().mergePoints
+ (
+ pointToGlobal_,
+ uniquePointMap_
+ );
}
- if (!args.optionFound("noPatches"))
+ if (!noPatches_)
{
- forAll(mesh.boundary(), patchi)
+ forAll(mesh_.boundary(), patchi)
{
- if (mesh.boundary()[patchi].size())
+ if (mesh_.boundary()[patchi].size())
{
- const polyPatch& p = mesh.boundaryMesh()[patchi];
+ const polyPatch& p = mesh_.boundaryMesh()[patchi];
labelList& tris = boundaryFaceSets_[patchi].tris;
labelList& quads = boundaryFaceSets_[patchi].quads;
@@ -238,7 +241,7 @@ Foam::ensightMesh::ensightMesh
if (patchNames_.empty() || patchNames_.found(patchName))
{
- if (mesh.boundary()[patchi].size())
+ if (mesh_.boundary()[patchi].size())
{
nfp.nTris = boundaryFaceSets_[patchi].tris.size();
nfp.nQuads = boundaryFaceSets_[patchi].quads.size();
@@ -254,17 +257,15 @@ Foam::ensightMesh::ensightMesh
}
// faceZones
- if (args.optionFound("faceZones"))
+ if (faceZones_)
{
- wordReList patterns(args.optionLookup("faceZones")());
-
const wordList faceZoneNamesAll = mesh_.faceZones().names();
// Find faceZone names which match that requested at command-line
forAll(faceZoneNamesAll, nameI)
{
const word& zoneName = faceZoneNamesAll[nameI];
- if (findStrings(patterns, zoneName))
+ if (findStrings(faceZonePatterns_, zoneName))
{
faceZoneNames_.insert(zoneName);
}
@@ -300,7 +301,7 @@ Foam::ensightMesh::ensightMesh
{
//const word& zoneName = faceZoneNamesAll[zoneI];
- const faceZone& fz = mesh.faceZones()[zoneI];
+ const faceZone& fz = mesh_.faceZones()[zoneI];
if (fz.size())
{
@@ -380,6 +381,35 @@ Foam::ensightMesh::ensightMesh
}
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::ensightMesh::ensightMesh
+(
+ const fvMesh& mesh,
+ const bool noPatches,
+
+ const bool patches,
+ const wordReList& patchPatterns,
+
+ const bool faceZones,
+ const wordReList& faceZonePatterns,
+
+ const bool binary
+)
+:
+ mesh_(mesh),
+ noPatches_(noPatches),
+ patches_(patches),
+ patchPatterns_(patchPatterns),
+ faceZones_(faceZones),
+ faceZonePatterns_(faceZonePatterns),
+ binary_(binary),
+ meshCellSets_(mesh.nCells())
+{
+ correct();
+}
+
+
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightMesh::~ensightMesh()
@@ -412,19 +442,6 @@ void Foam::ensightMesh::barrier()
}
-void Foam::ensightMesh::writePoints
-(
- const scalarField& pointsComponent,
- OFstream& ensightGeometryFile
-) const
-{
- forAll(pointsComponent, pointI)
- {
- ensightGeometryFile<< setw(12) << float(pointsComponent[pointI]) << nl;
- }
-}
-
-
Foam::cellShapeList Foam::ensightMesh::map
(
const cellShapeList& cellShapes,
@@ -489,59 +506,49 @@ Foam::cellShapeList Foam::ensightMesh::map
void Foam::ensightMesh::writePrims
(
const cellShapeList& cellShapes,
- OFstream& ensightGeometryFile
-) const
-{
- forAll(cellShapes, i)
- {
- const cellShape& cellPoints = cellShapes[i];
-
- forAll(cellPoints, pointI)
- {
- ensightGeometryFile
- << setw(10)
- << cellPoints[pointI] + 1;
- }
- ensightGeometryFile << nl;
- }
-}
-
-
-void Foam::ensightMesh::writePrimsBinary
-(
- const cellShapeList& cellShapes,
- std::ofstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
// Create a temp int array
- int numElem;
-
- numElem = cellShapes.size();
-
if (cellShapes.size())
{
- // All the cellShapes have the same number of elements!
- int numIntElem = cellShapes.size()*cellShapes[0].size();
- List temp(numIntElem);
-
- int n = 0;
-
- forAll(cellShapes, i)
+ if (ensightGeometryFile.ascii())
{
- const cellShape& cellPoints = cellShapes[i];
+ // Workaround for paraview issue : write one cell per line
- forAll(cellPoints, pointI)
+ forAll(cellShapes, i)
{
- temp[n] = cellPoints[pointI] + 1;
- n++;
+ const cellShape& cellPoints = cellShapes[i];
+
+ List temp(cellPoints.size());
+
+ forAll(cellPoints, pointI)
+ {
+ temp[pointI] = cellPoints[pointI] + 1;
+ }
+ ensightGeometryFile.write(temp);
}
}
+ else
+ {
+ // All the cellShapes have the same number of elements!
+ int numIntElem = cellShapes.size()*cellShapes[0].size();
+ List temp(numIntElem);
- ensightGeometryFile.write
- (
- reinterpret_cast(temp.begin()),
- numIntElem*sizeof(int)
- );
+ int n = 0;
+
+ forAll(cellShapes, i)
+ {
+ const cellShape& cellPoints = cellShapes[i];
+
+ forAll(cellPoints, pointI)
+ {
+ temp[n] = cellPoints[pointI] + 1;
+ n++;
+ }
+ }
+ ensightGeometryFile.write(temp);
+ }
}
}
@@ -550,13 +557,12 @@ void Foam::ensightMesh::writePolysNFaces
(
const labelList& polys,
const cellList& cellFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
forAll(polys, i)
{
- ensightGeometryFile
- << setw(10) << cellFaces[polys[i]].size() << nl;
+ ensightGeometryFile.write(cellFaces[polys[i]].size());
}
}
@@ -566,7 +572,7 @@ void Foam::ensightMesh::writePolysNPointsPerFace
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
forAll(polys, i)
@@ -575,8 +581,7 @@ void Foam::ensightMesh::writePolysNPointsPerFace
forAll(cf, faceI)
{
- ensightGeometryFile
- << setw(10) << faces[cf[faceI]].size() << nl;
+ ensightGeometryFile.write(faces[cf[faceI]].size());
}
}
}
@@ -587,7 +592,7 @@ void Foam::ensightMesh::writePolysPoints
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
forAll(polys, i)
@@ -598,11 +603,12 @@ void Foam::ensightMesh::writePolysPoints
{
const face& f = faces[cf[faceI]];
+ List temp(f.size());
forAll(f, pointI)
{
- ensightGeometryFile << setw(10) << f[pointI] + 1;
+ temp[pointI] = f[pointI] + 1;
}
- ensightGeometryFile << nl;
+ ensightGeometryFile.write(temp);
}
}
}
@@ -611,7 +617,7 @@ void Foam::ensightMesh::writePolysPoints
void Foam::ensightMesh::writeAllPolys
(
const labelList& pointToGlobal,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
if (meshCellSets_.nPolys)
@@ -626,8 +632,8 @@ void Foam::ensightMesh::writeAllPolys
if (Pstream::master())
{
- ensightGeometryFile
- << "nfaced" << nl << setw(10) << meshCellSets_.nPolys << nl;
+ ensightGeometryFile.write("nfaced");
+ ensightGeometryFile.write(meshCellSets_.nPolys);
}
// Number of faces for each poly cell
@@ -735,210 +741,20 @@ void Foam::ensightMesh::writeAllPolys
}
-void Foam::ensightMesh::writePolysNFacesBinary
-(
- const labelList& polys,
- const cellList& cellFaces,
- std::ofstream& ensightGeometryFile
-) const
-{
- forAll(polys, i)
- {
- writeEnsDataBinary
- (
- cellFaces[polys[i]].size(),
- ensightGeometryFile
- );
- }
-}
-
-
-void Foam::ensightMesh::writePolysNPointsPerFaceBinary
-(
- const labelList& polys,
- const cellList& cellFaces,
- const faceList& faces,
- std::ofstream& ensightGeometryFile
-) const
-{
- forAll(polys, i)
- {
- const labelList& cf = cellFaces[polys[i]];
-
- forAll(cf, faceI)
- {
- writeEnsDataBinary
- (
- faces[cf[faceI]].size(),
- ensightGeometryFile
- );
- }
- }
-}
-
-
-void Foam::ensightMesh::writePolysPointsBinary
-(
- const labelList& polys,
- const cellList& cellFaces,
- const faceList& faces,
- std::ofstream& ensightGeometryFile
-) const
-{
- forAll(polys, i)
- {
- const labelList& cf = cellFaces[polys[i]];
-
- forAll(cf, faceI)
- {
- const face& f = faces[cf[faceI]];
-
- forAll(f, pointI)
- {
- writeEnsDataBinary(f[pointI] + 1,ensightGeometryFile);
- }
- }
- }
-}
-
-
-void Foam::ensightMesh::writeAllPolysBinary
-(
- const labelList& pointToGlobal,
- std::ofstream& ensightGeometryFile
-) const
-{
- if (meshCellSets_.nPolys)
- {
- const cellList& cellFaces = mesh_.cells();
- // Renumber faces to use global point numbers
- faceList faces(mesh_.faces());
- forAll(faces, i)
- {
- inplaceRenumber(pointToGlobal, faces[i]);
- }
-
- if (Pstream::master())
- {
- writeEnsDataBinary("nfaced",ensightGeometryFile);
- writeEnsDataBinary(meshCellSets_.nPolys,ensightGeometryFile);
- }
-
- // Number of faces for each poly cell
- if (Pstream::master())
- {
- // Master
- writePolysNFacesBinary
- (
- meshCellSets_.polys,
- cellFaces,
- ensightGeometryFile
- );
- // Slaves
- for (int slave=1; slave temp(patchFace.size());
forAll(patchFace, pointI)
{
- ensightGeometryFile << setw(10) << patchFace[pointI] + 1;
+ temp[pointI] = patchFace[pointI] + 1;
}
- ensightGeometryFile << nl;
- }
-}
-
-void Foam::ensightMesh::writeFacePrimsBinary
-(
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
-) const
-{
- forAll(patchFaces, i)
- {
- const face& patchFace = patchFaces[i];
-
- forAll(patchFace, pointI)
- {
- writeEnsDataBinary(patchFace[pointI] + 1, ensightGeometryFile);
- }
+ ensightGeometryFile.write(temp);
}
}
@@ -1036,14 +802,15 @@ void Foam::ensightMesh::writeAllFacePrims
const labelList& prims,
const label nPrims,
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
if (nPrims)
{
if (Pstream::master())
{
- ensightGeometryFile << key << nl << setw(10) << nPrims << nl;
+ ensightGeometryFile.write(key);
+ ensightGeometryFile.write(nPrims);
writeFacePrims
(
@@ -1071,12 +838,12 @@ void Foam::ensightMesh::writeAllFacePrims
void Foam::ensightMesh::writeNSidedNPointsPerFace
(
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
forAll(patchFaces, i)
{
- ensightGeometryFile << setw(10) << patchFaces[i].size() << nl;
+ ensightGeometryFile.write(patchFaces[i].size());
}
}
@@ -1084,7 +851,7 @@ void Foam::ensightMesh::writeNSidedNPointsPerFace
void Foam::ensightMesh::writeNSidedPoints
(
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
writeFacePrims(patchFaces, ensightGeometryFile);
@@ -1096,15 +863,15 @@ void Foam::ensightMesh::writeAllNSided
const labelList& prims,
const label nPrims,
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const
{
if (nPrims)
{
if (Pstream::master())
{
- ensightGeometryFile
- << "nsided" << nl << setw(10) << nPrims << nl;
+ ensightGeometryFile.write("nsided");
+ ensightGeometryFile.write(nPrims);
}
// Number of points for each face
@@ -1160,132 +927,84 @@ void Foam::ensightMesh::writeAllNSided
}
-void Foam::ensightMesh::writeNSidedPointsBinary
+void Foam::ensightMesh::writeAllInternalPoints
(
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
+ const pointField& uniquePoints,
+ const label nPoints,
+ ensightStream& ensightGeometryFile
) const
{
- writeFacePrimsBinary(patchFaces, ensightGeometryFile);
-}
+ barrier();
-
-void Foam::ensightMesh::writeNSidedNPointsPerFaceBinary
-(
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
-) const
-{
- forAll(patchFaces, i)
+ if (Pstream::master())
{
- writeEnsDataBinary(patchFaces[i].size(), ensightGeometryFile);
+ ensightGeometryFile.writePartHeader(1);
+ ensightGeometryFile.write("internalMesh");
+ ensightGeometryFile.write("coordinates");
+ ensightGeometryFile.write(nPoints);
+
+ for (direction d=0; d(patchFaces, prims)(),
- ensightGeometryFile
- );
-
- for (int slave=1; slave(patchFaces, prims);
- }
-
- // List of points id for each face
- if (Pstream::master())
- {
- writeNSidedPointsBinary
- (
- UIndirectList(patchFaces, prims)(),
- ensightGeometryFile
- );
-
- for (int slave=1; slave(patchFaces, prims);
+ toMaster<< uniquePoints.component(d);
}
}
}
-void Foam::ensightMesh::writeAllFacePrimsBinary
+void Foam::ensightMesh::writeAllPatchPoints
(
- const char* key,
- const labelList& prims,
- const label nPrims,
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
+ const label ensightPatchI,
+ const word& patchName,
+ const pointField& uniquePoints,
+ const label nPoints,
+ ensightStream& ensightGeometryFile
) const
{
- if (nPrims)
+ barrier();
+
+ if (Pstream::master())
{
- if (Pstream::master())
+ ensightGeometryFile.writePartHeader(ensightPatchI);
+ ensightGeometryFile.write(patchName.c_str());
+ ensightGeometryFile.write("coordinates");
+ ensightGeometryFile.write(nPoints);
+
+ for (direction d=0; d(patchFaces, prims)(),
- ensightGeometryFile
- );
-
+ ensightGeometryFile.write(uniquePoints.component(d));
for (int slave=1; slave(patchFaces, prims);
+ OPstream toMaster
+ (
+ Pstream::scheduled,
+ Pstream::masterNo()
+ );
+ toMaster<< uniquePoints.component(d);
}
}
}
@@ -1298,260 +1017,8 @@ void Foam::ensightMesh::write
const label timeIndex,
Ostream& ensightCaseFile
) const
-{
- // Find global point numbering
- labelList pointToGlobal;
- labelList uniquePointMap;
- autoPtr globalPoints = mesh_.globalData().mergePoints
- (
- pointToGlobal,
- uniquePointMap
- );
-
- const pointField uniquePoints(mesh_.points(), uniquePointMap);
-
- if (binary_)
- {
- writeBinary
- (
- postProcPath,
- prepend,
- timeIndex,
- ensightCaseFile,
- pointToGlobal,
- uniquePoints,
- globalPoints()
- );
- }
- else
- {
- writeAscii
- (
- postProcPath,
- prepend,
- timeIndex,
- ensightCaseFile,
- pointToGlobal,
- uniquePoints,
- globalPoints()
- );
- }
-}
-
-void Foam::ensightMesh::writeAllInternalPoints
-(
- const pointField& uniquePoints,
- const label nPoints,
- OFstream& ensightGeometryFile
-) const
-{
- barrier();
-
- if (Pstream::master())
- {
- ensightGeometryFile
- << "part" << nl
- << setw(10) << 1 << nl
- << "internalMesh" << nl
- << "coordinates" << nl
- << setw(10) << nPoints
- << endl;
-
- for (direction d=0; dwrite("C binary");
+ }
+ else
+ {
+ ensightGeometryFilePtr = new ensightAsciiStream
+ (
+ postProcPath/ensightGeometryFileName,
+ runTime
+ );
+ }
}
- OFstream& ensightGeometryFile = *ensightGeometryFilePtr;
+ ensightStream& ensightGeometryFile = *ensightGeometryFilePtr;
if (Pstream::master())
{
- // Set Format
- ensightGeometryFile.setf
- (
- ios_base::scientific,
- ios_base::floatfield
- );
- ensightGeometryFile.precision(5);
+ string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
- ensightGeometryFile
- << "EnSight Geometry File" << nl
- << "written by OpenFOAM-" << Foam::FOAMversion << nl
- << "node id assign" << nl
- << "element id assign" << nl;
+ ensightGeometryFile.write("EnSight Geometry File");
+ ensightGeometryFile.write(desc.c_str());
+ ensightGeometryFile.write("node id assign");
+ ensightGeometryFile.write("element id assign");
}
if (patchNames_.empty())
{
- label nPoints = globalPoints.size();
+ label nPoints = globalPoints().size();
+
+ const pointField uniquePoints(mesh_.points(), uniquePointMap_);
writeAllInternalPoints
(
@@ -1620,7 +1092,7 @@ void Foam::ensightMesh::writeAscii
cellShapes,
meshCellSets_.hexes,
meshCellSets_.wedges,
- pointToGlobal
+ pointToGlobal_
),
ensightGeometryFile
);
@@ -1629,7 +1101,7 @@ void Foam::ensightMesh::writeAscii
(
"penta6",
meshCellSets_.nPrisms,
- map(cellShapes, meshCellSets_.prisms, pointToGlobal),
+ map(cellShapes, meshCellSets_.prisms, pointToGlobal_),
ensightGeometryFile
);
@@ -1637,7 +1109,7 @@ void Foam::ensightMesh::writeAscii
(
"pyramid5",
meshCellSets_.nPyrs,
- map(cellShapes, meshCellSets_.pyrs, pointToGlobal),
+ map(cellShapes, meshCellSets_.pyrs, pointToGlobal_),
ensightGeometryFile
);
@@ -1645,13 +1117,13 @@ void Foam::ensightMesh::writeAscii
(
"tetra4",
meshCellSets_.nTets,
- map(cellShapes, meshCellSets_.tets, pointToGlobal),
+ map(cellShapes, meshCellSets_.tets, pointToGlobal_),
ensightGeometryFile
);
writeAllPolys
(
- pointToGlobal,
+ pointToGlobal_,
ensightGeometryFile
);
}
@@ -1836,304 +1308,6 @@ void Foam::ensightMesh::writeAscii
}
}
-
- if (Pstream::master())
- {
- delete ensightGeometryFilePtr;
- }
-}
-
-
-void Foam::ensightMesh::writeBinary
-(
- const fileName& postProcPath,
- const word& prepend,
- const label timeIndex,
- Ostream& ensightCaseFile,
- const labelList& pointToGlobal,
- const pointField& uniquePoints,
- const globalIndex& globalPoints
-) const
-{
- const cellShapeList& cellShapes = mesh_.cellShapes();
-
- word timeFile = prepend;
-
- if (timeIndex == 0)
- {
- timeFile += "000.";
- }
- else if (mesh_.moving())
- {
- timeFile += itoa(timeIndex) + '.';
- }
-
- // set the filename of the ensight file
- fileName ensightGeometryFileName = timeFile + "mesh";
-
- std::ofstream *ensightGeometryFilePtr = NULL;
-
- if (Pstream::master())
- {
- ensightGeometryFilePtr = new std::ofstream
- (
- (postProcPath/ensightGeometryFileName).c_str(),
- ios_base::out | ios_base::binary | ios_base::trunc
- );
- // Check on file opened?
- }
-
- std::ofstream& ensightGeometryFile = *ensightGeometryFilePtr;
-
- if (Pstream::master())
- {
- string description = string("written by OpenFOAM-") + Foam::FOAMversion;
- writeEnsDataBinary("C binary", ensightGeometryFile);
- writeEnsDataBinary("EnSight Geometry File", ensightGeometryFile);
- writeEnsDataBinary(description.c_str(), ensightGeometryFile);
- writeEnsDataBinary("node id assign", ensightGeometryFile);
- writeEnsDataBinary("element id assign", ensightGeometryFile);
- }
-
-
- if (patchNames_.empty())
- {
- label nPoints = globalPoints.size();
-
- writeAllInternalPointsBinary
- (
- uniquePoints,
- nPoints,
- ensightGeometryFile
- );
-
- writeAllPrimsBinary
- (
- "hexa8",
- meshCellSets_.nHexesWedges,
- map // Rewrite cellShapes to global numbering
- (
- cellShapes,
- meshCellSets_.hexes,
- meshCellSets_.wedges,
- pointToGlobal
- ),
- ensightGeometryFile
- );
-
- writeAllPrimsBinary
- (
- "penta6",
- meshCellSets_.nPrisms,
- map(cellShapes, meshCellSets_.prisms, pointToGlobal),
- ensightGeometryFile
- );
-
- writeAllPrimsBinary
- (
- "pyramid5",
- meshCellSets_.nPyrs,
- map(cellShapes, meshCellSets_.pyrs, pointToGlobal),
- ensightGeometryFile
- );
-
- writeAllPrimsBinary
- (
- "tetra4",
- meshCellSets_.nTets,
- map(cellShapes, meshCellSets_.tets, pointToGlobal),
- ensightGeometryFile
- );
-
- writeAllPolysBinary
- (
- pointToGlobal,
- ensightGeometryFile
- );
- }
-
- label ensightPatchI = patchPartOffset_;
- label iCount = 0;
-
- forAll(allPatchNames_, patchi)
- {
- iCount ++;
- const word& patchName = allPatchNames_[patchi];
-
- if (patchNames_.empty() || patchNames_.found(patchName))
- {
- const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
-
- if (nfp.nTris || nfp.nQuads || nfp.nPolys)
- {
- const polyPatch& p = mesh_.boundaryMesh()[patchi];
- const labelList& tris = boundaryFaceSets_[patchi].tris;
- const labelList& quads = boundaryFaceSets_[patchi].quads;
- const labelList& polys = boundaryFaceSets_[patchi].polys;
-
- // Renumber the patch points/faces into unique points
- labelList pointToGlobal;
- labelList uniqueMeshPointLabels;
- autoPtr globalPointsPtr =
- mesh_.globalData().mergePoints
- (
- p.meshPoints(),
- p.meshPointMap(),
- pointToGlobal,
- uniqueMeshPointLabels
- );
- pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
- // Renumber the patch faces
- faceList patchFaces(p.localFaces());
- forAll(patchFaces, i)
- {
- inplaceRenumber(pointToGlobal, patchFaces[i]);
- }
-
- writeAllPatchPointsBinary
- (
- ensightPatchI++,
- patchName,
- uniquePoints,
- globalPointsPtr().size(),
- ensightGeometryFile
- );
-
- writeAllFacePrimsBinary
- (
- "tria3",
- tris,
- nfp.nTris,
- patchFaces,
- ensightGeometryFile
- );
-
- writeAllFacePrimsBinary
- (
- "quad4",
- quads,
- nfp.nQuads,
- patchFaces,
- ensightGeometryFile
- );
-
- writeAllNSidedBinary
- (
- polys,
- nfp.nPolys,
- patchFaces,
- ensightGeometryFile
- );
- }
- }
- }
-
- // write faceZones, if requested
- forAllConstIter(wordHashSet, faceZoneNames_, iter)
- {
- const word& faceZoneName = iter.key();
-
- label faceID = mesh_.faceZones().findZoneID(faceZoneName);
-
- const faceZone& fz = mesh_.faceZones()[faceID];
-
- const nFacePrimitives& nfp = nFaceZonePrims_[faceZoneName];
-
- if (nfp.nTris || nfp.nQuads || nfp.nPolys)
- {
- const labelList& tris = faceZoneFaceSets_[faceID].tris;
- const labelList& quads = faceZoneFaceSets_[faceID].quads;
- const labelList& polys = faceZoneFaceSets_[faceID].polys;
-
- // Renumber the faceZone points/faces into unique points
- labelList pointToGlobal;
- labelList uniqueMeshPointLabels;
- autoPtr globalPointsPtr =
- mesh_.globalData().mergePoints
- (
- fz().meshPoints(),
- fz().meshPointMap(),
- pointToGlobal,
- uniqueMeshPointLabels
- );
-
- pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
-
- // Find the list of master faces belonging to the faceZone,
- // in loacal numbering
- faceList faceZoneFaces(fz().localFaces());
-
- // Count how many master faces belong to the faceZone. Is there
- // a better way of doing this?
- label nMasterFaces = 0;
-
- forAll(fz, faceI)
- {
- if (faceToBeIncluded(fz[faceI]))
- {
- ++nMasterFaces;
- }
- }
-
- // Create the faceList for the master faces only and fill it.
- faceList faceZoneMasterFaces(nMasterFaces);
-
- label currentFace = 0;
-
- forAll(fz, faceI)
- {
- if (faceToBeIncluded(fz[faceI]))
- {
- faceZoneMasterFaces[currentFace] = faceZoneFaces[faceI];
- ++currentFace;
- }
- }
-
- // Renumber the faceZone master faces
-
- forAll(faceZoneMasterFaces, i)
- {
- inplaceRenumber(pointToGlobal, faceZoneMasterFaces[i]);
- }
-
- writeAllPatchPointsBinary
- (
- ensightPatchI++,
- faceZoneName,
- uniquePoints,
- globalPointsPtr().size(),
- ensightGeometryFile
- );
-
- writeAllFacePrimsBinary
- (
- "tria3",
- tris,
- nfp.nTris,
- faceZoneMasterFaces,
- ensightGeometryFile
- );
-
- writeAllFacePrimsBinary
- (
- "quad4",
- quads,
- nfp.nQuads,
- faceZoneMasterFaces,
- ensightGeometryFile
- );
-
- writeAllNSidedBinary
- (
- polys,
- nfp.nPolys,
- faceZoneMasterFaces,
- ensightGeometryFile
- );
- }
- }
-
-
if (Pstream::master())
{
delete ensightGeometryFilePtr;
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H
index 46442efc59..f7db81bbc1 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H
@@ -38,10 +38,13 @@ SourceFiles
#include "faceSets.H"
#include "HashTable.H"
#include "HashSet.H"
-#include "fvMesh.H"
-#include "OFstream.H"
-#include
#include "PackedBoolList.H"
+#include "wordReList.H"
+#include "scalarField.H"
+#include "cellShapeList.H"
+#include "cellList.H"
+
+#include
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -51,6 +54,7 @@ namespace Foam
class fvMesh;
class argList;
class globalIndex;
+class ensightStream;
/*---------------------------------------------------------------------------*\
Class ensightMesh Declaration
@@ -82,8 +86,19 @@ private:
//- Reference to the OpenFOAM mesh
const fvMesh& mesh_;
+ //- Suppress patches
+ const bool noPatches_;
+
+ //- Output selected patches only
+ const bool patches_;
+ const wordReList patchPatterns_;
+
+ //- Output selected faceZones
+ const bool faceZones_;
+ const wordReList faceZonePatterns_;
+
//- Set binary file output
- bool binary_;
+ const bool binary_;
//- The ensight part id for the first patch
label patchPartOffset_;
@@ -109,6 +124,19 @@ private:
PackedBoolList boundaryFaceToBeIncluded_;
+ // Parallel merged points
+
+ //- Global numbering for merged points
+ autoPtr globalPointsPtr_;
+
+ //- From mesh point to global merged point
+ labelList pointToGlobal_;
+
+ //- Local points that are unique
+ labelList uniquePointMap_;
+
+
+
// Private Member Functions
//- Disallow default bitwise copy construct
@@ -120,7 +148,7 @@ private:
void writePoints
(
const scalarField& pointsComponent,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
cellShapeList map
@@ -141,14 +169,14 @@ private:
void writePrims
(
const cellShapeList& cellShapes,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writePolysNFaces
(
const labelList& polys,
const cellList& cellFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writePolysNPointsPerFace
@@ -156,7 +184,7 @@ private:
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writePolysPoints
@@ -164,13 +192,13 @@ private:
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeAllPolys
(
const labelList& pointToGlobal,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeAllPrims
@@ -178,13 +206,13 @@ private:
const char* key,
const label nPrims,
const cellShapeList& cellShapes,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeFacePrims
(
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeAllFacePrims
@@ -193,19 +221,19 @@ private:
const labelList& prims,
const label nPrims,
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeNSidedNPointsPerFace
(
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeNSidedPoints
(
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeAllNSided
@@ -213,14 +241,14 @@ private:
const labelList& prims,
const label nPrims,
const faceList& patchFaces,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeAllInternalPoints
(
const pointField& uniquePoints,
const label nPoints,
- OFstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
void writeAllPatchPoints
@@ -229,123 +257,7 @@ private:
const word& patchName,
const pointField& uniquePoints,
const label nPoints,
- OFstream& ensightGeometryFile
- ) const;
-
- void writeAllInternalPointsBinary
- (
- const pointField& uniquePoints,
- const label nPoints,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeAllPatchPointsBinary
- (
- label ensightPatchI,
- const word& patchName,
- const pointField& uniquePoints,
- const label nPoints,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeAscii
- (
- const fileName& postProcPath,
- const word& prepend,
- const label timeIndex,
- Ostream& ensightCaseFile,
- const labelList& pointToGlobal,
- const pointField& uniquePoints,
- const globalIndex& globalPoints
- ) const;
-
- void writeBinary
- (
- const fileName& postProcPath,
- const word& prepend,
- const label timeIndex,
- Ostream& ensightCaseFile,
- const labelList& pointToGlobal,
- const pointField& uniquePoints,
- const globalIndex& globalPoints
- ) const;
-
- void writePrimsBinary
- (
- const cellShapeList& cellShapes,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeAllPrimsBinary
- (
- const char* key,
- const label nPrims,
- const cellShapeList& cellShapes,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writePolysNFacesBinary
- (
- const labelList& polys,
- const cellList& cellFaces,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writePolysNPointsPerFaceBinary
- (
- const labelList& polys,
- const cellList& cellFaces,
- const faceList& faces,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writePolysPointsBinary
- (
- const labelList& polys,
- const cellList& cellFaces,
- const faceList& faces,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeAllPolysBinary
- (
- const labelList& pointToGlobal,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeAllFacePrimsBinary
- (
- const char* key,
- const labelList& prims,
- const label nPrims,
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeFacePrimsBinary
- (
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeNSidedPointsBinary
- (
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeNSidedNPointsPerFaceBinary
- (
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
- ) const;
-
- void writeAllNSidedBinary
- (
- const labelList& prims,
- const label nPrims,
- const faceList& patchFaces,
- std::ofstream& ensightGeometryFile
+ ensightStream& ensightGeometryFile
) const;
public:
@@ -355,8 +267,12 @@ public:
//- Construct from fvMesh
ensightMesh
(
- const fvMesh&,
- const argList& args,
+ const fvMesh& mesh,
+ const bool noPatches,
+ const bool patches,
+ const wordReList& patchPatterns,
+ const bool faceZones,
+ const wordReList& faceZonePatterns,
const bool binary
);
@@ -420,8 +336,35 @@ public:
return patchPartOffset_;
}
+
+ // Parallel point merging
+
+ //- Global numbering for merged points
+ const globalIndex& globalPoints() const
+ {
+ return globalPointsPtr_();
+ }
+
+ //- From mesh point to global merged point
+ const labelList& pointToGlobal() const
+ {
+ return pointToGlobal_;
+ }
+
+ //- Local points that are unique
+ const labelList& uniquePointMap() const
+ {
+ return uniquePointMap_;
+ }
+
+
+
+
// Other
+ //- Update for new mesh
+ void correct();
+
//- When exporting faceZones, check if a given face has to be included
// or not (i.e. faces on processor boundaries)
bool faceToBeIncluded(const label faceI) const;
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightStream.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightStream.H
new file mode 100644
index 0000000000..acc0ff25d0
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightStream.H
@@ -0,0 +1,114 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
+ \\/ 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 .
+
+Class
+ Foam::ensightStream
+
+Description
+ Abstract base class for writing Ensight data
+
+SourceFiles
+ ensightStream.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef ensightStream_H
+#define ensightStream_H
+
+#include "fileName.H"
+#include "scalarField.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+
+/*---------------------------------------------------------------------------*\
+ Class ensightStream Declaration
+\*---------------------------------------------------------------------------*/
+
+class ensightStream
+{
+ // Private data
+
+ const fileName name_;
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ ensightStream(const ensightStream&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const ensightStream&);
+
+
+public:
+
+ // Constructors
+
+ //- Construct from components
+ ensightStream(const fileName& f)
+ :
+ name_(f)
+ {}
+
+
+ //- Destructor
+ virtual ~ensightStream()
+ {}
+
+
+ // Member Functions
+
+ const fileName& name() const
+ {
+ return name_;
+ }
+
+ virtual bool ascii() const = 0;
+
+ virtual void write(const char*) = 0;
+
+ virtual void write(const int) = 0;
+
+ virtual void write(const scalarField&) = 0;
+
+ virtual void write(const List&) = 0;
+
+ virtual void writePartHeader(const label) = 0;
+
+
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/faceSets.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/faceSets.H
index edf25fa34d..f5d396b86e 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/faceSets.H
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/faceSets.H
@@ -44,15 +44,6 @@ namespace Foam
class faceSets
{
- // Private Member Functions
-
- //- Disallow default bitwise copy construct
- faceSets(const faceSets&);
-
- //- Disallow default bitwise assignment
- void operator=(const faceSets&);
-
-
public:
label nTris;
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C
index dff5d8b8c8..ba2bfccf9a 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C
@@ -104,6 +104,11 @@ int main(int argc, char *argv[])
"write in ASCII format instead of 'C Binary'"
);
argList::addBoolOption
+ (
+ "nodeValues",
+ "write values in nodes"
+ );
+ argList::addBoolOption
(
"noPatches",
"suppress writing any patches"
@@ -126,6 +131,7 @@ int main(int argc, char *argv[])
// Check options
const bool binary = !args.optionFound("ascii");
+ const bool nodeValues = args.optionFound("nodeValues");
# include "createTime.H"
@@ -191,7 +197,29 @@ int main(int argc, char *argv[])
OFstream& ensightCaseFile = *ensightCaseFilePtr;
// Construct the EnSight mesh
- ensightMesh eMesh(mesh, args, binary);
+ const bool selectedPatches = args.optionFound("patches");
+ wordReList patchPatterns;
+ if (selectedPatches)
+ {
+ patchPatterns = wordReList(args.optionLookup("patches")());
+ }
+ const bool selectedZones = args.optionFound("faceZones");
+ wordReList zonePatterns;
+ if (selectedZones)
+ {
+ zonePatterns = wordReList(args.optionLookup("faceZones")());
+ }
+
+ ensightMesh eMesh
+ (
+ mesh,
+ args.optionFound("noPatches"),
+ selectedPatches,
+ patchPatterns,
+ selectedZones,
+ zonePatterns,
+ binary
+ );
// Set Time to the last time before looking for the lagrangian objects
runTime.setTime(Times.last(), Times.size()-1);
@@ -313,6 +341,11 @@ int main(int argc, char *argv[])
polyMesh::readUpdateState meshState = mesh.readUpdate();
+ if (meshState != polyMesh::UNCHANGED)
+ {
+ eMesh.correct();
+ }
+
if (timeIndex == 0 || (meshState != polyMesh::UNCHANGED))
{
eMesh.write
@@ -371,6 +404,7 @@ int main(int argc, char *argv[])
prepend,
timeIndex,
binary,
+ nodeValues,
ensightCaseFile
);
}
@@ -384,6 +418,7 @@ int main(int argc, char *argv[])
prepend,
timeIndex,
binary,
+ nodeValues,
ensightCaseFile
);
}
@@ -397,6 +432,7 @@ int main(int argc, char *argv[])
prepend,
timeIndex,
binary,
+ nodeValues,
ensightCaseFile
);
}
@@ -410,6 +446,7 @@ int main(int argc, char *argv[])
prepend,
timeIndex,
binary,
+ nodeValues,
ensightCaseFile
);
}
@@ -423,6 +460,7 @@ int main(int argc, char *argv[])
prepend,
timeIndex,
binary,
+ nodeValues,
ensightCaseFile
);
}
diff --git a/applications/utilities/postProcessing/sampling/sample/sample.C b/applications/utilities/postProcessing/sampling/sample/sample.C
index a68ab0b8fb..2b4f7ab008 100644
--- a/applications/utilities/postProcessing/sampling/sample/sample.C
+++ b/applications/utilities/postProcessing/sampling/sample/sample.C
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
sampledSets::typeName,
mesh,
sampleDict,
- IOobject::MUST_READ,
+ IOobject::MUST_READ_IF_MODIFIED,
true
);
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
sampledSurfaces::typeName,
mesh,
sampleDict,
- IOobject::MUST_READ,
+ IOobject::MUST_READ_IF_MODIFIED,
true
);
diff --git a/applications/utilities/postProcessing/velocityField/Co/Co.C b/applications/utilities/postProcessing/velocityField/Co/Co.C
index c64ca9e2b1..73653e3726 100644
--- a/applications/utilities/postProcessing/velocityField/Co/Co.C
+++ b/applications/utilities/postProcessing/velocityField/Co/Co.C
@@ -25,7 +25,7 @@ Application
Co
Description
- Calculates and writes the Co number as a surfaceScalarField obtained
+ Calculates and writes the Co number as a volScalarField obtained
from field phi.
The -noWrite option just outputs the max values without writing the
@@ -38,52 +38,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-namespace Foam
-{
- tmp Co(const surfaceScalarField& Cof)
- {
- const fvMesh& mesh = Cof.mesh();
-
- tmp tCo
- (
- new volScalarField
- (
- IOobject
- (
- "Co",
- mesh.time().timeName(),
- mesh
- ),
- mesh,
- dimensionedScalar("0", Cof.dimensions(), 0)
- )
- );
-
- volScalarField& Co = tCo();
-
- // Set local references to mesh data
- const unallocLabelList& owner = mesh.owner();
- const unallocLabelList& neighbour = mesh.neighbour();
-
- forAll(owner, facei)
- {
- label own = owner[facei];
- label nei = neighbour[facei];
-
- Co[own] = max(Co[own], Cof[facei]);
- Co[nei] = max(Co[nei], Cof[facei]);
- }
-
- forAll(Co.boundaryField(), patchi)
- {
- Co.boundaryField()[patchi] = Cof.boundaryField()[patchi];
- }
-
- return tCo;
- }
-}
-
-
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
bool writeResults = !args.optionFound("noWrite");
@@ -98,15 +52,28 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
if (phiHeader.headerOk())
{
- autoPtr CoPtr;
+ volScalarField Co
+ (
+ IOobject
+ (
+ "Co",
+ runTime.timeName(),
+ mesh,
+ IOobject::NO_READ
+ ),
+ mesh,
+ dimensionedScalar("0", dimless, 0),
+ zeroGradientFvPatchScalarField::typeName
+ );
Info<< " Reading phi" << endl;
surfaceScalarField phi(phiHeader, mesh);
- Info<< " Calculating Co" << endl;
if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0))
{
- // compressible
+ Info<< " Calculating compressible Co" << endl;
+
+ Info<< " Reading rho" << endl;
volScalarField rho
(
IOobject
@@ -119,60 +86,34 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
mesh
);
- CoPtr.set
- (
- new surfaceScalarField
- (
- IOobject
- (
- "Cof",
- runTime.timeName(),
- mesh,
- IOobject::NO_READ
- ),
- (
- mesh.surfaceInterpolation::deltaCoeffs()
- * (mag(phi)/(fvc::interpolate(rho)*mesh.magSf()))
- * runTime.deltaT()
- )
- )
- );
+ Co.dimensionedInternalField() =
+ (0.5*runTime.deltaT())
+ *fvc::surfaceSum(mag(phi))().dimensionedInternalField()
+ /(rho*mesh.V());
+ Co.correctBoundaryConditions();
}
else if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
{
- // incompressible
- CoPtr.set
- (
- new surfaceScalarField
- (
- IOobject
- (
- "Cof",
- runTime.timeName(),
- mesh,
- IOobject::NO_READ
- ),
- (
- mesh.surfaceInterpolation::deltaCoeffs()
- * (mag(phi)/mesh.magSf())
- * runTime.deltaT()
- )
- )
- );
+ Info<< " Calculating incompressible Co" << endl;
+
+ Co.dimensionedInternalField() =
+ (0.5*runTime.deltaT())
+ *fvc::surfaceSum(mag(phi))().dimensionedInternalField()
+ /mesh.V();
+ Co.correctBoundaryConditions();
}
else
{
FatalErrorIn(args.executable())
<< "Incorrect dimensions of phi: " << phi.dimensions()
- << abort(FatalError);
+ << abort(FatalError);
}
- Info<< "Co max : " << max(CoPtr()).value() << endl;
+ Info<< "Co max : " << max(Co).value() << endl;
if (writeResults)
{
- CoPtr().write();
- Co(CoPtr())().write();
+ Co.write();
}
}
else
@@ -183,4 +124,5 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
Info<< "\nEnd\n" << endl;
}
+
// ************************************************************************* //
diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions
index e40da98d01..3256ff4ba6 100644
--- a/bin/tools/CleanFunctions
+++ b/bin/tools/CleanFunctions
@@ -76,6 +76,11 @@ cleanCase()
sets/streamLines \
> /dev/null 2>&1
+ if [ -e constant/polyMesh/blockMeshDict.m4 ]
+ then
+ rm -f constant/polyMesh/blockMeshDict > /dev/null 2>&1
+ fi
+
for f in `find . -name "*Dict"`
do
sed -e /arguments/d $f > temp.$$
diff --git a/doc/changes/splitCyclic.txt b/doc/changes/splitCyclic.txt
index 814dfe0850..3d0ffb71cf 100644
--- a/doc/changes/splitCyclic.txt
+++ b/doc/changes/splitCyclic.txt
@@ -20,7 +20,8 @@ The disadvantages:
- a patch-wise loop now might need to store data to go to the neighbour half
since it is no longer handled in a single patch.
- decomposed cyclics now require overlapping communications so will
-only work in non-blocking mode. Hence the underlying message passing library
+only work in 'nonBlocking' mode or 'blocking' (=buffered) mode but not
+in 'scheduled' mode. The underlying message passing library
will require overlapping communications with message tags.
- it is quite a code-change and there might be some oversights.
- once converted (see foamUpgradeCyclics below) cases are not backwards
@@ -103,19 +104,14 @@ type 'processorCyclic'.
- processor patches use overlapping communication using a different message
-tag. This maps straight through into the MPI message tag.
-See processorCyclicPolyPatch::tag(). This needs to be calculated the
-same on both sides so is calculated as
- Pstream::nProcs()*max(myProcNo, neighbProcNo)
- + min(myProcNo, neighbProcNo)
-which is
-- unique
-- commutative
-- does not interfere with the default tag (= 1)
+tag. This maps straight through into the MPI message tag. Each processor
+'interface' (processorPolyPatch, processorFvPatch, etc.) has a 'tag()'
+to use for communication.
- when constructing a GeometricField from a dictionary it will explicitly
check for non-existing entries for cyclic patches and exit with an error message
-warning to run foamUpgradeCyclics.
+warning to run foamUpgradeCyclics. (1.7.x will check if you are trying
+to run a case which has split cyclics)
diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index d9548b67b1..97513b339d 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -85,6 +85,7 @@ $(primitiveLists)/vectorListIOList.C
$(primitiveLists)/sphericalTensorList.C
$(primitiveLists)/symmTensorList.C
$(primitiveLists)/tensorList.C
+$(primitiveLists)/hashedWordList.C
Streams = db/IOstreams
$(Streams)/token/tokenIO.C
@@ -296,6 +297,7 @@ primitiveShapes = meshes/primitiveShapes
$(primitiveShapes)/line/line.C
$(primitiveShapes)/plane/plane.C
$(primitiveShapes)/triangle/intersection.C
+$(primitiveShapes)/objectHit/pointIndexHitIOList.C
meshShapes = meshes/meshShapes
$(meshShapes)/edge/edge.C
diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H
index 0d41f70c15..ec65a14a1b 100644
--- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H
+++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -25,7 +25,11 @@ Class
Foam::IndirectList
Description
- A List with indirect addressing
+ A List with indirect addressing.
+
+SeeAlso
+ Foam::UIndirectList for a version without any allocation for the
+ addressing.
SourceFiles
IndirectListI.H
@@ -35,24 +39,79 @@ SourceFiles
#ifndef IndirectList_H
#define IndirectList_H
-#include "List.H"
+#include "UIndirectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
+/*---------------------------------------------------------------------------*\
+ Class IndirectListAddressing Declaration
+\*---------------------------------------------------------------------------*/
+
+//- A helper class for storing addresses.
+class IndirectListAddressing
+{
+ // Private data
+
+ //- Storage for the list addressing
+ List addressing_;
+
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ IndirectListAddressing(const IndirectListAddressing&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const IndirectListAddressing&);
+
+
+protected:
+
+ // Constructors
+
+ //- Construct by copying the addressing array
+ explicit inline IndirectListAddressing(const UList& addr);
+
+ //- Construct by transferring addressing array
+ explicit inline IndirectListAddressing(const Xfer >& addr);
+
+
+ // Member Functions
+
+ // Access
+
+ //- Return the list addressing
+ inline const List& addressing() const;
+
+ // Edit
+
+ //- Reset addressing
+ inline void resetAddressing(const UList&);
+ inline void resetAddressing(const Xfer >&);
+
+};
+
+
/*---------------------------------------------------------------------------*\
Class IndirectList Declaration
\*---------------------------------------------------------------------------*/
template
class IndirectList
+:
+ private IndirectListAddressing,
+ public UIndirectList
{
- // Private data
+ // Private Member Functions
- UList& completeList_;
- List addressing_;
+ //- Disable default assignment operator
+ void operator=(const IndirectList&);
+
+ //- Disable assignment from UIndirectList
+ void operator=(const UIndirectList&);
public:
@@ -65,59 +124,32 @@ public:
//- Construct given the complete list and by transferring addressing
inline IndirectList(const UList&, const Xfer >&);
+ //- Copy constructor
+ inline IndirectList(const IndirectList&);
+
+ //- Construct from UIndirectList
+ explicit inline IndirectList(const UIndirectList&);
+
// Member Functions
+
// Access
- //- Return the number of elements in the list
- inline label size() const;
-
- //- Return true if the list is empty (ie, size() is zero).
- inline bool empty() const;
-
- //- Return the first element of the list.
- inline T& first();
-
- //- Return first element of the list.
- inline const T& first() const;
-
- //- Return the last element of the list.
- inline T& last();
-
- //- Return the last element of the list.
- inline const T& last() const;
-
- //- Return the complete list
- inline const UList& completeList() const;
-
//- Return the list addressing
- inline const List& addressing() const;
+ using UIndirectList::addressing;
// Edit
//- Reset addressing
- inline void resetAddressing(const UList&);
- inline void resetAddressing(const Xfer >&);
+ using IndirectListAddressing::resetAddressing;
// Member Operators
- //- Return the addressed elements as a List
- inline List operator()() const;
-
- //- Return non-const access to an element
- inline T& operator[](const label);
-
- //- Return const access to an element
- inline const T& operator[](const label) const;
-
- //- Assignment from UList of addressed elements
- inline void operator=(const UList&);
-
- //- Assignment of all entries to the given value
- inline void operator=(const T&);
+ //- Assignment operator
+ using UIndirectList::operator=;
};
diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H
index dfcc20d537..0303ba2d5e 100644
--- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H
+++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -25,6 +25,25 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+inline Foam::IndirectListAddressing::IndirectListAddressing
+(
+ const UList& addr
+)
+:
+ addressing_(addr)
+{}
+
+
+inline Foam::IndirectListAddressing::IndirectListAddressing
+(
+ const Xfer >& addr
+)
+:
+ addressing_(addr)
+{}
+
+
template
inline Foam::IndirectList::IndirectList
(
@@ -32,8 +51,12 @@ inline Foam::IndirectList::IndirectList
const UList& addr
)
:
- completeList_(const_cast&>(completeList)),
- addressing_(addr)
+ IndirectListAddressing(addr),
+ UIndirectList
+ (
+ completeList,
+ IndirectListAddressing::addressing()
+ )
{}
@@ -44,71 +67,55 @@ inline Foam::IndirectList::IndirectList
const Xfer >& addr
)
:
- completeList_(const_cast&>(completeList)),
- addressing_(addr)
+ IndirectListAddressing(addr),
+ UIndirectList
+ (
+ completeList,
+ IndirectListAddressing::addressing()
+ )
+{}
+
+
+template
+inline Foam::IndirectList::IndirectList
+(
+ const IndirectList& lst
+)
+:
+ IndirectListAddressing(lst.addressing()),
+ UIndirectList
+ (
+ lst.completeList(),
+ IndirectListAddressing::addressing()
+ )
+{}
+
+
+template
+inline Foam::IndirectList::IndirectList
+(
+ const UIndirectList& lst
+)
+:
+ IndirectListAddressing(lst.addressing()),
+ UIndirectList
+ (
+ lst.completeList(),
+ IndirectListAddressing::addressing()
+ )
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-template
-inline Foam::label Foam::IndirectList::size() const
-{
- return addressing_.size();
-}
-
-
-template
-inline bool Foam::IndirectList::empty() const
-{
- return addressing_.empty();
-}
-
-
-template
-inline T& Foam::IndirectList::first()
-{
- return completeList_[addressing_.first()];
-}
-
-
-template
-inline const T& Foam::IndirectList::first() const
-{
- return completeList_[addressing_.first()];
-}
-
-
-template
-inline T& Foam::IndirectList::last()
-{
- return completeList_[addressing_.last()];
-}
-
-
-template
-inline const T& Foam::IndirectList::last() const
-{
- return completeList_[addressing_.last()];
-}
-
-
-template
-inline const Foam::UList& Foam::IndirectList::completeList() const
-{
- return completeList_;
-}
-
-
-template
-inline const Foam::List& Foam::IndirectList::addressing() const
+inline const Foam::List&
+Foam::IndirectListAddressing::addressing() const
{
return addressing_;
}
-template
-inline void Foam::IndirectList::resetAddressing
+inline void Foam::IndirectListAddressing::resetAddressing
(
const UList& addr
)
@@ -117,8 +124,7 @@ inline void Foam::IndirectList::resetAddressing
}
-template