Merge branch 'master' into cvm

This commit is contained in:
graham
2009-02-12 10:24:58 +00:00
553 changed files with 7858 additions and 3298 deletions

View File

@ -0,0 +1,3 @@
buoyantBoussinesqFoam.C
EXE = $(FOAM_APPBIN)/buoyantBoussinesqFoam

View File

@ -0,0 +1,12 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lincompressibleRASModels \
-lincompressibleTransportModels

View File

@ -0,0 +1,18 @@
{
volScalarField kappaEff
(
"kappaEff",
turbulence->nu() + turbulence->nut()/Prt
);
fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(kappaEff, T)
);
TEqn.relax();
TEqn.solve();
}

View File

@ -0,0 +1,23 @@
// Solve the momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
+ turbulence->divDevReff(U)
);
UEqn().relax();
solve
(
UEqn()
==
-fvc::reconstruct
(
(
fvc::snGrad(pd)
- betaghf*fvc::snGrad(T)
) * mesh.magSf()
)
);

View File

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
buoyantBoussinesqSimpleFoam
Description
Steady-state solver for buoyant, turbulent flow of incompressible fluids
Uses the Boussinesq approximation:
\f[
rho_{eff} = 1 - beta(T - T_{ref})
\f]
where:
\f$ rho_{eff} \f$ = the effective (driving) density
beta = thermal expansion coefficient [1/K]
T = temperature [K]
\f$ T_{ref} \f$ = reference temperature [K]
Valid when:
\f[
rho_{eff} << 1
\f]
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "RASModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "readEnvironmentalProperties.H"
# include "createFields.H"
# include "initContinuityErrs.H"
# include "readTimeControls.H"
# include "CourantNo.H"
# include "setInitialDeltaT.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
for (runTime++; !runTime.end(); runTime++)
{
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readTimeControls.H"
# include "readPISOControls.H"
# include "CourantNo.H"
# include "setDeltaT.H"
# include "UEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
# include "TEqn.H"
# include "pdEqn.H"
}
turbulence->correct();
if (runTime.write())
{
# include "writeAdditionalFields.H"
}
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,67 @@
Info<< "Reading thermophysical properties\n" << endl;
Info<< "Reading field T\n" << endl;
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
// kinematic pd
Info<< "Reading field pd\n" << endl;
volScalarField pd
(
IOobject
(
"pd",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "createPhi.H"
# include "readTransportProperties.H"
Info<< "Creating turbulence model\n" << endl;
autoPtr<incompressible::RASModel> turbulence
(
incompressible::RASModel::New(U, phi, laminarTransport)
);
Info<< "Calculating field beta*(g.h)\n" << endl;
surfaceScalarField betaghf("betagh", beta*(g & mesh.Cf()));
label pdRefCell = 0;
scalar pdRefValue = 0.0;
setRefCell
(
pd,
mesh.solutionDict().subDict("SIMPLE"),
pdRefCell,
pdRefValue
);

View File

@ -0,0 +1,42 @@
{
volScalarField rUA("rUA", 1.0/UEqn().A());
surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA));
U = rUA*UEqn().H();
UEqn.clear();
surfaceScalarField phiU
(
(fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi)
);
phi = phiU + betaghf*fvc::snGrad(T)*rUAf*mesh.magSf();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pdEqn
(
fvm::laplacian(rUAf, pd) == fvc::div(phi)
);
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
{
pdEqn.solve(mesh.solver(pd.name() + "Final"));
}
else
{
pdEqn.solve(mesh.solver(pd.name()));
}
if (nonOrth == nNonOrthCorr)
{
phi += pdEqn.flux();
}
}
U -= rUA*fvc::reconstruct((phi - phiU)/rUAf);
U.correctBoundaryConditions();
#include "continuityErrs.H"
}

View File

@ -0,0 +1,13 @@
singlePhaseTransportModel laminarTransport(U, phi);
// thermal expansion coefficient [1/K]
dimensionedScalar beta(laminarTransport.lookup("beta"));
// reference temperature [K]
dimensionedScalar TRef(laminarTransport.lookup("TRef"));
// reference kinematic pressure [m2/s2]
dimensionedScalar pRef(laminarTransport.lookup("pRef"));
// turbulent Prandtl number
dimensionedScalar Prt(laminarTransport.lookup("Prt"));

View File

@ -0,0 +1,29 @@
{
volScalarField rhoEff
(
IOobject
(
"rhoEff",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
1.0 - beta*(T - TRef)
);
rhoEff.write();
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pd + rhoEff*(g & mesh.C()) + pRef
);
p.write();
}

View File

@ -47,6 +47,7 @@ int main(int argc, char *argv[])
# include "createMesh.H"
# include "readEnvironmentalProperties.H"
# include "createFields.H"
# include "createRadiationModel.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,9 +0,0 @@
// check convergence
if (maxResidual < convergenceCriterion)
{
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}

View File

@ -1,97 +0,0 @@
Info<< "Reading thermophysical properties\n" << endl;
autoPtr<basicThermo> thermo
(
basicThermo::New(mesh)
);
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermo->rho()
);
volScalarField& p = thermo->p();
volScalarField& h = thermo->h();
const volScalarField& T = thermo->T();
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "compressibleCreatePhi.H"
Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::RASModel> turbulence
(
compressible::RASModel::New
(
rho,
U,
phi,
thermo()
)
);
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));
Info<< "Creating field pd\n" << endl;
volScalarField pd
(
IOobject
(
"pd",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
p = pd + rho*gh + pRef;
thermo->correct();
label pdRefCell = 0;
scalar pdRefValue = 0.0;
setRefCell
(
pd,
mesh.solutionDict().subDict("SIMPLE"),
pdRefCell,
pdRefValue
);
Info<< "Creating radiation model\n" << endl;
autoPtr<radiation::radiationModel> radiation
(
radiation::radiationModel::New(T)
);
dimensionedScalar initialMass = fvc::domainIntegrate(rho);

View File

@ -0,0 +1,5 @@
Info<< "Creating radiation model\n" << endl;
autoPtr<radiation::radiationModel> radiation
(
radiation::radiationModel::New(thermo->T())
);

View File

@ -1,7 +0,0 @@
// initialize values for convergence checks
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;
simple.readIfPresent("convergence", convergenceCriterion);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -12,6 +12,6 @@
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T())
<< endl;
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}

View File

@ -52,27 +52,47 @@ int main(int argc, char *argv[])
list1 = -1;
list1.print(Info);
Info<< "\ntest zero\n";
list1 = 0;
list1.print(Info);
Info<< "\ntest set() with default argument (max_value)\n";
list1.set(3);
list1.print(Info);
Info<< "\ntest assign between references\n";
list1[2] = 3;
list1[4] = list1[2];
list1.print(Info);
Info<< "\ntest assign between references, with chaining\n";
list1[4] = list1[2] = 1;
list1[0] = list1[4] = 1;
list1.print(Info);
Info<< "\ntest assign between references, with chaining and auto-vivify\n";
list1[1] = list1[8] = list1[10] = list1[14] = 2;
list1.print(Info);
{
const PackedList<3>& constLst = list1;
Info<< "\ntest operator[] const with out-of-range index\n";
constLst.print(Info);
if (!constLst[20])
if (constLst[20])
{
Info<< "[20] is true (unexpected)\n";
}
else
{
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
}
constLst.print(Info);
Info<< "\ntest operator[] non-const with out-of-range index\n";
if (!list1[20])
if (list1[20])
{
Info<< "[20] is true (unexpected)\n";
}
else
{
Info<< "[20] is false (expected) but list was resized?? (non-const)\n";
}
@ -91,6 +111,14 @@ int main(int argc, char *argv[])
list1.resize(8, list1.max_value());
list1.print(Info);
Info<< "\ntest flip() function\n";
list1.flip();
list1.print(Info);
Info<< "\nre-flip()\n";
list1.flip();
list1.print(Info);
Info<< "\ntest set() function\n";
list1.set(1, 5);
list1.print(Info);
@ -188,15 +216,23 @@ int main(int argc, char *argv[])
{
Info<< "\ntest assignment of iterator\n";
list1.print(Info);
PackedList<3>::iterator cit = list1[25];
cit.print(Info);
Info<< "cend()\n";
list1.end().print(Info);
PackedList<3>::iterator cit = list1[100];
Info<< "out-of-range: ";
cit.print(Info);
cit = list1[15];
Info<< "in-range: ";
cit.print(Info);
Info<< "out-of-range: ";
cit = list1[1000];
cit.print(Info);
}
for
(
PackedList<3>::iterator cit = list1[5];
PackedList<3>::iterator cit = list1[30];
cit != list1.end();
++cit
)
@ -204,14 +240,19 @@ int main(int argc, char *argv[])
cit.print(Info);
}
// Info<< "\ntest operator[] auto-vivify\n";
// const unsigned int val = list1[45];
//
// Info<< "list[45]:" << val << "\n";
// list1[45] = list1.max_value();
// Info<< "list[45]:" << list1[45] << "\n";
// list1[49] = list1.max_value();
// list1.print(Info);
Info<< "\ntest operator[] auto-vivify\n";
Info<< "size:" << list1.size() << "\n";
const unsigned int val = list1[45];
Info<< "list[45]:" << val << "\n";
Info<< "size after read:" << list1.size() << "\n";
list1[45] = list1.max_value();
Info<< "size after write:" << list1.size() << "\n";
Info<< "list[45]:" << list1[45] << "\n";
list1[49] = list1[100];
list1.print(Info);
Info<< "\ntest copy constructor + append\n";
@ -235,6 +276,23 @@ int main(int argc, char *argv[])
Info<< "removed final value: " << list3.remove() << endl;
list3.print(Info);
List<bool> list4(4, true);
{
const List<bool>& constLst = list4;
Info<< "\ntest operator[] const with out-of-range index\n";
Info<< constLst << endl;
if (constLst[20])
{
Info<< "[20] is true (unexpected)\n";
}
else
{
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
}
Info<< constLst << endl;
}
Info<< "\n\nDone.\n";
return 0;

View File

@ -32,6 +32,7 @@ Description
#include "fileName.H"
#include "SubList.H"
#include "IOobject.H"
#include "IOstreams.H"
#include "OSspecific.H"
@ -61,7 +62,8 @@ int main()
<< endl;
// try with different combination
for (label start = 0; start < wrdList.size(); ++start)
// The final one should emit warnings
for (label start = 0; start <= wrdList.size(); ++start)
{
fileName instance, local;
word name;
@ -69,26 +71,28 @@ int main()
fileName path(SubList<word>(wrdList, wrdList.size()-start, start));
fileName path2 = "." / path;
path.IOobjectComponents
IOobject::fileNameComponents
(
path,
instance,
local,
name
);
Info<< "IOobjectComponents for " << path << nl
Info<< "IOobject::fileNameComponents for " << path << nl
<< " instance = " << instance << nl
<< " local = " << local << nl
<< " name = " << name << endl;
path2.IOobjectComponents
IOobject::fileNameComponents
(
path2,
instance,
local,
name
);
Info<< "IOobjectComponents for " << path2 << nl
Info<< "IOobject::fileNameComponents for " << path2 << nl
<< " instance = " << instance << nl
<< " local = " << local << nl
<< " name = " << name << endl;

View File

@ -69,7 +69,7 @@ void checkFaceEdges
forAll(f, fp)
{
label fp1 = (fp + 1) % f.size();
label fp1 = f.fcIndex(fp);
if (edges[myEdges[fp]] != edge(f[fp], f[fp1]))
{

View File

@ -0,0 +1,3 @@
testSHA1.C
EXE = $(FOAM_USER_APPBIN)/testSHA1

View File

View File

@ -0,0 +1,135 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
testSHA1
Description
\*---------------------------------------------------------------------------*/
#include "OSHA1stream.H"
#include "IStringStream.H"
#include "dictionary.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char * argv[])
{
SHA1 sha;
SHA1Digest shaDig;
std::string str("The quick brown fox jumps over the lazy dog");
Info<< shaDig << nl;
Info<< SHA1("The quick brown fox jumps over the lazy dog") << nl;
sha.append("The quick brown fox jumps over the lazy dog");
Info<< sha << nl;
sha.clear();
sha.append("The quick brown fox jumps over the lazy dog");
shaDig = sha;
sha.append("\n");
Info<< sha << nl;
Info<< shaDig << nl;
if (sha == shaDig)
{
Info<<"SHA1 digests are identical\n";
}
else
{
Info<<"SHA1 digests are different\n";
}
Info<<"lhs:" << sha << " rhs:" << shaDig << endl;
// start over:
sha.clear();
sha.append(str);
SHA1Digest shaDig_A = sha;
SHA1 sha_A = sha;
sha.append("\n");
Info<< "digest1: " << sha_A << nl;
Info<< "digest2: " << sha << nl;
// start over:
sha.clear();
sha.append("\"");
sha.append(str);
sha.append("\"");
Info<< "digest3: " << sha << nl;
// try the output buffer interface
{
OSHA1stream os;
os << str;
Info<< os.digest() << endl;
os << str;
Info<< os.digest() << endl;
os.rewind();
os << "The quick brown fox jumps over the lazy dog";
Info<< os.digest() << endl;
}
{
dictionary dict
(
IStringStream
(
"parent { Default_Boundary_Region { type zeroGradient; } }"
"inlet_1 { value inlet_1; }"
"inlet_2 { value inlet_2; }"
"inlet_3 { value inlet_3; }"
"\"inlet_.*\" { value XXX; }"
) ()
);
Info<< "dict:" << endl;
dict.write(Info, false);
dictionary dict2(dict);
OSHA1stream os;
dict.write(os, false);
Info<< os.digest() << endl;
Info<< dict2.digest() << endl;
}
return 0;
}

View File

@ -74,20 +74,17 @@ labelList getSortedEdges
const edge& e = edges[edgeI];
label fp = findIndex(f, e[0]);
label fp1 = (fp+1) % f.size();
label fp1 = f.fcIndex(fp);
if (f[fp1] == e[1])
{
// Edgei in fp-fp1 order
// EdgeI between fp -> fp1
faceEdges[fp] = edgeI;
}
else
{
// Edgei between fp-1 and fp
label fpMin1 = (fp == 0 ? f.size()-1 : fp-1);
faceEdges[fpMin1] = edgeI;
// EdgeI between fp-1 -> fp
faceEdges[f.rcIndex(fp)] = edgeI;
}
}

View File

@ -211,7 +211,7 @@ void Foam::cellSplitter::setRefinement
// Add other pyramids
for (label i = 1; i < cFaces.size(); i++)
{
{
label addedCellI =
meshMod.setAction
(
@ -277,7 +277,7 @@ void Foam::cellSplitter::setRefinement
label index = findIndex(f0, e[0]);
bool edgeInFaceOrder = (f0[(index+1) % f0.size()] == e[1]);
bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]);
// Check if cellI is the face owner
@ -323,7 +323,7 @@ void Foam::cellSplitter::setRefinement
label index = findIndex(f1, e[0]);
bool edgeInFaceOrder = (f1[(index+1) % f1.size()] == e[1]);
bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]);
// Check if cellI is the face owner
@ -362,7 +362,7 @@ void Foam::cellSplitter::setRefinement
}
}
}
//
// Update all existing faces for split owner or neighbour.
@ -441,7 +441,7 @@ void Foam::cellSplitter::setRefinement
label patchID, zoneID, zoneFlip;
getFaceInfo(faceI, patchID, zoneID, zoneFlip);
meshMod.setAction
(
polyModifyFace
@ -458,7 +458,7 @@ void Foam::cellSplitter::setRefinement
)
);
}
faceUpToDate[faceI] = true;
}
}

View File

@ -615,7 +615,7 @@ int main(int argc, char *argv[])
{
fileName ccmFile(args.additionalArgs()[0]);
if (!exists(ccmFile))
if (!isFile(ccmFile))
{
FatalErrorIn(args.executable())
<< "Cannot read file " << ccmFile

View File

@ -129,14 +129,14 @@ int main(int argc, char *argv[])
Info<< "Reading .face file for boundary information" << nl << endl;
}
if (!exists(nodeFile) || !exists(eleFile))
if (!isFile(nodeFile) || !isFile(eleFile))
{
FatalErrorIn(args.executable())
<< "Cannot read " << nodeFile << " or " << eleFile
<< exit(FatalError);
}
if (readFaceFile && !exists(faceFile))
if (readFaceFile && !isFile(faceFile))
{
FatalErrorIn(args.executable())
<< "Cannot read " << faceFile << endl

View File

@ -108,7 +108,11 @@ int main(int argc, char *argv[])
(
new IOobject
(
( dictPath.isDir() ? dictPath/dictName : dictPath ),
(
isDir(dictPath)
? dictPath/dictName
: dictPath
),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,

View File

@ -79,6 +79,22 @@ topoSetSources
k (10 10 10);
}
// Cells with centre within cylinder
cylinderToCell
{
p1 (0.2 0.2 -10); // start point on cylinder axis
p2 (0.2 0.2 0); // end point on cylinder axis
radius 5.0;
}
// Cells with centre within sphere
sphereToCell
{
centre (0.2 0.2 -10);
radius 5.0;
}
// Cells in cell zone
zoneToCell
{

View File

@ -746,7 +746,8 @@ int main(int argc, char *argv[])
Pout<< "Reading commands from file " << batchFile << endl;
if (!exists(batchFile))
// we also cannot handle .gz files
if (!isFile(batchFile, false))
{
FatalErrorIn(args.executable())
<< "Cannot open file " << batchFile << exit(FatalError);

View File

@ -627,7 +627,7 @@ autoPtr<mapPolyMesh> createRegionMesh
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
//if (!exists(io.objectPath()))
// if (!exists(io.objectPath()))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;

View File

@ -63,7 +63,6 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
const IOobjectList fieldObjs(mesh, runTime.timeName());
const wordList objNames = fieldObjs.names();
PtrList<volScalarField> vsf(objNames.size());
@ -99,7 +98,7 @@ int main(int argc, char *argv[])
const polyBoundaryMesh& bm = mesh.boundaryMesh();
forAll(bm, patchI)
{
Info<< "Patch: " << bm[patchI].name() << nl;
Info<< bm[patchI].type() << ": " << bm[patchI].name() << nl;
outputFieldList<scalar>(vsf, patchI);
outputFieldList<vector>(vvf, patchI);
outputFieldList<sphericalTensor>(vsptf, patchI);

View File

@ -105,7 +105,7 @@ int main(int argc, char *argv[])
// determine the existing processor count directly
label nProcs = 0;
while (dir(runTime.path()/(word("processor") + name(nProcs))))
while (isDir(runTime.path()/(word("processor") + name(nProcs))))
{
++nProcs;
}
@ -480,7 +480,7 @@ int main(int argc, char *argv[])
// Any uniform data to copy/link?
fileName uniformDir("uniform");
if (dir(runTime.timePath()/uniformDir))
if (isDir(runTime.timePath()/uniformDir))
{
Info<< "Detected additional non-decomposed files in "
<< runTime.timePath()/uniformDir

View File

@ -59,7 +59,7 @@ manualCoeffs
}
//// Is the case distributred
//// Is the case distributed
//distributed yes;
//// Per slave (so nProcs-1 entries) the directory above the case.
//roots

View File

@ -63,7 +63,7 @@ int main(int argc, char *argv[])
// determine the processor count directly
label nProcs = 0;
while (dir(args.path()/(word("processor") + name(nProcs))))
while (isDir(args.path()/(word("processor") + name(nProcs))))
{
++nProcs;
}
@ -383,7 +383,7 @@ int main(int argc, char *argv[])
// the master processor.
fileName uniformDir0 = databases[0].timePath()/"uniform";
if (dir(uniformDir0))
if (isDir(uniformDir0))
{
cp(uniformDir0, runTime.timePath());
}

View File

@ -355,7 +355,7 @@ int main(int argc, char *argv[])
while
(
exists
isDir
(
args.rootPath()
/ args.caseName()

View File

@ -503,7 +503,7 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
// Create processor directory if non-existing
if (!Pstream::master() && !dir(args.path()))
if (!Pstream::master() && !isDir(args.path()))
{
Pout<< "Creating case directory " << args.path() << endl;
mkDir(args.path());
@ -525,7 +525,7 @@ int main(int argc, char *argv[])
const fileName meshDir = runTime.path()/masterInstDir/polyMesh::meshSubDir;
boolList haveMesh(Pstream::nProcs(), false);
haveMesh[Pstream::myProcNo()] = dir(meshDir);
haveMesh[Pstream::myProcNo()] = isDir(meshDir);
Pstream::gatherList(haveMesh);
Pstream::scatterList(haveMesh);
Info<< "Per processor mesh availability : " << haveMesh << endl;

View File

@ -131,7 +131,7 @@ int main(int argc, char *argv[])
if (Pstream::master())
{
if (dir(postProcPath))
if (isDir(postProcPath))
{
rmDir(postProcPath);
}

View File

@ -136,7 +136,7 @@ int main(int argc, char *argv[])
// Ensight and Ensight/data directories must exist
// do not remove old data - we might wish to convert new results
// or a particular time interval
if (dir(ensightDir))
if (isDir(ensightDir))
{
Info<<"Warning: reusing existing directory" << nl
<< " " << ensightDir << endl;
@ -324,7 +324,7 @@ int main(int argc, char *argv[])
{
const word& cloudName = cloudIter.key();
if (!dir(runTime.timePath()/regionPrefix/"lagrangian"/cloudName))
if (!isDir(runTime.timePath()/regionPrefix/"lagrangian"/cloudName))
{
continue;
}

View File

@ -260,7 +260,7 @@ int main(int argc, char *argv[])
// make a directory called FieldView in the case
fileName fvPath(runTime.path()/"Fieldview");
if (dir(fvPath))
if (isDir(fvPath))
{
rmDir(fvPath);
}
@ -346,7 +346,7 @@ int main(int argc, char *argv[])
// Output the magic number.
writeInt(fvFile, FV_MAGIC);
// Output file header and version number.
writeStr80(fvFile, "FIELDVIEW");
@ -417,7 +417,7 @@ int main(int argc, char *argv[])
{
if (volFieldPtrs[fieldI] == NULL)
{
Info<< " dummy field for "
Info<< " dummy field for "
<< volFieldNames[fieldI].c_str() << endl;
}

View File

@ -333,7 +333,7 @@ int main(int argc, char *argv[])
regionPrefix = regionName;
}
if (dir(fvPath))
if (isDir(fvPath))
{
if
(

View File

@ -228,7 +228,7 @@ Foam::vtkPV3Foam::vtkPV3Foam
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path());
if (!dir(fullCasePath))
if (!isDir(fullCasePath))
{
return;
}
@ -518,7 +518,7 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
if
(
file(runTime.path()/timeName/meshDir_/"points")
isFile(runTime.path()/timeName/meshDir_/"points")
&& IOobject("points", timeName, meshDir_, runTime).headerOk()
)
{

View File

@ -156,7 +156,7 @@ class vtkPV3Foam
bool empty() const
{
return (size_ == 0);
return !size_;
}
void reset()

View File

@ -194,7 +194,7 @@ void Foam::vtkFoam::updateSelectedRegions()
// Read the selected patches and add to the region list
for (int i=0; i<nRegions; i++)
{
selectedRegions_[i] =
selectedRegions_[i] =
reader_->GetRegionSelection()->GetArraySetting(i);
}
}
@ -282,7 +282,7 @@ void Foam::vtkFoam::convertMesh()
else
{
// A patch already existent in the list and which
// continues to exist found
// continues to exist found
regioni++;
}
}
@ -391,7 +391,7 @@ Foam::vtkFoam::vtkFoam(const char* const FileName, vtkFoamReader* reader)
{
fileName fullCasePath(fileName(FileName).path());
if (!dir(fullCasePath))
if (!isDir(fullCasePath))
{
return;
}
@ -572,7 +572,7 @@ void Foam::vtkFoam::Update()
{
Info<< "Reading Mesh" << endl;
}
meshPtr_ =
meshPtr_ =
new fvMesh
(
IOobject

View File

@ -47,7 +47,7 @@ int USERD_set_filenames
}
caseDir = tmp;
if (!dir(rootDir/caseDir))
if (!isDir(rootDir/caseDir))
{
Info<< rootDir/caseDir << " is not a valid directory."
<< endl;
@ -144,7 +144,7 @@ int USERD_set_filenames
}
isTensor[n] = isitTensor;
}
bool lagrangianNamesFound = false;
label n = 0;
while (!lagrangianNamesFound && n < Num_time_steps)
@ -176,7 +176,7 @@ int USERD_set_filenames
Info << "[Found lagrangian]" << endl;
delete sprayPtr;
sprayPtr = new Cloud<passiveParticle>(*meshPtr);
IOobjectList objects(*meshPtr, runTime.timeName(), "lagrangian");

View File

@ -132,8 +132,8 @@ static void errorMsg(const string& msg)
// Simple check if directory is valid case directory.
static bool validCase(const fileName& rootAndCase)
{
//if (dir(rootAndCase/"system") && dir(rootAndCase/"constant"))
if (dir(rootAndCase/"constant"))
//if (isDir(rootAndCase/"system") && isDir(rootAndCase/"constant"))
if (isDir(rootAndCase/"constant"))
{
return true;
}
@ -528,7 +528,7 @@ void user_query_file_function
return;
}
}
fileName rootDir(rootAndCase.path());

View File

@ -180,7 +180,7 @@ surfaces
triangleCut
{
// Cutingplaneusing iso surface
// Cutingplane using iso surface
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict

View File

@ -63,7 +63,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
volVectorField U(Uheader, mesh);
if (file(runTime.constantPath()/"thermophysicalProperties"))
if (isFile(runTime.constantPath()/"thermophysicalProperties"))
{
// thermophysical Mach
autoPtr<basicThermo> thermo

View File

@ -1,3 +0,0 @@
surfaceCoordinateSystemTransform.C
EXE = $(FOAM_APPBIN)/surfaceCoordinateSystemTransform

View File

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
EXE_LIBS = -lsurfMesh
EXE_LIBS = -lmeshTools -lsurfMesh

View File

@ -26,25 +26,30 @@ Application
surfaceMeshConvert
Description
Converts from one surface mesh format to another
Convert between surface formats with optional scaling or
transformations (rotate/translate) on a coordinateSystem.
Usage
- surfaceMeshConvert inputFile outputFile [OPTION]
@param -clean \n
Perform some surface checking/cleanup on the input surface
Perform some surface checking/cleanup on the input surface.
@param -orient \n
Check face orientation on the input surface
@param -scaleIn \<scale\> \n
Specify a scaling factor when reading files.
@param -scale \<scale\> \n
Specify a scaling factor for writing the files
@param -scaleOut \<scale\> \n
Specify a scaling factor when writing files.
@param -triSurface \n
Use triSurface library for input/output
@param -dict \<dictionary\> \n
Specify an alternative dictionary for constant/coordinateSystems.
@param -keyed \n
Use keyedSurface for input/output
@param -from \<coordinateSystem\> \n
Specify a coordinate System when reading files.
@param -to \<coordinateSystem\> \n
Specify a coordinate System when writing files.
Note
The filename extensions are used to determine the file format type.
@ -54,12 +59,9 @@ Note
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "triSurface.H"
#include "PackedBoolList.H"
#include "MeshedSurfaces.H"
#include "UnsortedMeshedSurfaces.H"
#include "coordinateSystems.H"
using namespace Foam;
@ -71,24 +73,21 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validArgs.append("outputFile");
argList::validOptions.insert("clean", "");
argList::validOptions.insert("orient", "");
argList::validOptions.insert("scale", "scale");
argList::validOptions.insert("triSurface", "");
argList::validOptions.insert("unsorted", "");
argList::validOptions.insert("triFace", "");
# include "setRootCase.H"
const stringList& params = args.additionalArgs();
argList::validOptions.insert("clean", "scale");
argList::validOptions.insert("scaleIn", "scale");
argList::validOptions.insert("scaleOut", "scale");
argList::validOptions.insert("dict", "coordinateSystemsDict");
argList::validOptions.insert("from", "sourceCoordinateSystem");
argList::validOptions.insert("to", "targetCoordinateSystem");
scalar scaleFactor = 0;
if (args.options().found("scale"))
{
IStringStream(args.options()["scale"])() >> scaleFactor;
}
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
const stringList& params = args.additionalArgs();
fileName importName(params[0]);
fileName exportName(params[1]);
// disable inplace editing
if (importName == exportName)
{
FatalErrorIn(args.executable())
@ -96,165 +95,161 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
// check that reading/writing is supported
if
(
!meshedSurface::canRead(importName, true)
|| !meshedSurface::canWriteType(exportName.ext(), true)
!MeshedSurface<face>::canRead(importName, true)
|| !MeshedSurface<face>::canWriteType(exportName.ext(), true)
)
{
return 1;
}
if (args.options().found("triSurface"))
// get the coordinate transformations
autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys;
if (args.options().found("from") || args.options().found("to"))
{
triSurface surf(importName);
autoPtr<IOobject> csDictIoPtr;
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
if (args.options().found("dict"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
fileName dictPath(args.options()["dict"]);
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
csDictIoPtr.set
(
new IOobject
(
(
isDir(dictPath)
? dictPath/coordinateSystems::typeName
: dictPath
),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
csDictIoPtr.set
(
new IOobject
(
coordinateSystems::typeName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
// write sorted by region
surf.write(exportName, true);
if (!csDictIoPtr->headerOk())
{
FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n "
<< csDictIoPtr->objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(csDictIoPtr());
if (args.options().found("from"))
{
const word csName(args.options()["from"]);
label csId = csLst.find(csName);
if (csId < 0)
{
FatalErrorIn(args.executable())
<< "Cannot find -from " << csName << nl
<< "available coordinateSystems: " << csLst.toc() << nl
<< exit(FatalError);
}
fromCsys.reset(new coordinateSystem(csLst[csId]));
}
if (args.options().found("to"))
{
const word csName(args.options()["to"]);
label csId = csLst.find(csName);
if (csId < 0)
{
FatalErrorIn(args.executable())
<< "Cannot find -to " << csName << nl
<< "available coordinateSystems: " << csLst.toc() << nl
<< exit(FatalError);
}
toCsys.reset(new coordinateSystem(csLst[csId]));
}
// maybe fix this later
if (fromCsys.valid() && toCsys.valid())
{
FatalErrorIn(args.executable())
<< "Only allowed '-from' or '-to' option at the moment."
<< exit(FatalError);
}
}
else if (args.options().found("unsorted"))
scalar scaleIn = 0;
scalar scaleOut = 0;
if (args.options().found("scaleIn"))
{
UnsortedMeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
IStringStream(args.options()["scaleIn"])() >> scaleIn;
}
#if 1
else if (args.options().found("triFace"))
if (args.options().found("scaleOut"))
{
MeshedSurface<triFace> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
IStringStream(args.options()["scaleOut"])() >> scaleOut;
}
#endif
else
{
MeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
if (scaleIn > 0)
{
Info<< " -scaleIn " << scaleIn << endl;
surf.scalePoints(scaleIn);
}
if (fromCsys.valid())
{
Info<< " -from " << fromCsys().name() << endl;
tmp<pointField> tpf = fromCsys().localPosition(surf.points());
surf.movePoints(tpf());
}
if (toCsys.valid())
{
Info<< " -to " << toCsys().name() << endl;
tmp<pointField> tpf = toCsys().globalPosition(surf.points());
surf.movePoints(tpf());
}
if (scaleOut > 0)
{
Info<< " -scaleOut " << scaleOut << endl;
surf.scalePoints(scaleOut);
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}

View File

@ -0,0 +1,3 @@
surfaceMeshConvertTesting.C
EXE = $(FOAM_APPBIN)/surfaceMeshConvertTesting

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
EXE_LIBS = -ltriSurface -lsurfMesh

View File

@ -0,0 +1,348 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
surfaceMeshConvertTesting
Description
Converts from one surface mesh format to another, but primarily
used for testing functionality.
Usage
- surfaceMeshConvertTesting inputFile outputFile [OPTION]
@param -clean \n
Perform some surface checking/cleanup on the input surface
@param -orient \n
Check face orientation on the input surface
@param -scale \<scale\> \n
Specify a scaling factor for writing the files
@param -triSurface \n
Use triSurface library for input/output
@param -keyed \n
Use keyedSurface for input/output
Note
The filename extensions are used to determine the file format type.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "triSurface.H"
#include "surfMesh.H"
#include "surfFields.H"
#include "surfPointFields.H"
#include "PackedBoolList.H"
#include "MeshedSurfaces.H"
#include "UnsortedMeshedSurfaces.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validArgs.append("outputFile");
argList::validOptions.insert("clean", "");
argList::validOptions.insert("orient", "");
argList::validOptions.insert("surfMesh", "");
argList::validOptions.insert("scale", "scale");
argList::validOptions.insert("triSurface", "");
argList::validOptions.insert("unsorted", "");
argList::validOptions.insert("triFace", "");
# include "setRootCase.H"
const stringList& params = args.additionalArgs();
scalar scaleFactor = 0;
if (args.options().found("scale"))
{
IStringStream(args.options()["scale"])() >> scaleFactor;
}
fileName importName(params[0]);
fileName exportName(params[1]);
if (importName == exportName)
{
FatalErrorIn(args.executable())
<< "Output file " << exportName << " would overwrite input file."
<< exit(FatalError);
}
if
(
!MeshedSurface<face>::canRead(importName, true)
|| !MeshedSurface<face>::canWriteType(exportName.ext(), true)
)
{
return 1;
}
if (args.options().found("triSurface"))
{
triSurface surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
// write sorted by region
surf.write(exportName, true);
}
else if (args.options().found("unsorted"))
{
UnsortedMeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}
#if 1
else if (args.options().found("triFace"))
{
MeshedSurface<triFace> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}
#endif
else
{
MeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
if (args.options().found("surfMesh"))
{
Foam::Time runTime
(
args.rootPath(),
args.caseName()
);
surfMesh surfOut
(
IOobject
(
"mySurf",
runTime.instance(),
runTime
),
surf.xfer()
);
Info<< "writing surfMesh as well: " << surfOut.objectPath() << endl;
surfOut.write();
surfLabelField zoneIds
(
IOobject
(
"zoneIds",
surfOut.instance(),
surfOut,
IOobject::NO_READ,
IOobject::NO_WRITE
),
surfOut,
dimless
);
const surfZoneList& zones = surfOut.surfZones();
forAll(zones, zoneI)
{
SubList<label>
(
zoneIds,
zones[zoneI].size(),
zones[zoneI].start()
) = zoneI;
}
Info<< "write zoneIds (for testing only): "
<< zoneIds.objectPath() << endl;
zoneIds.write();
surfPointLabelField pointIds
(
IOobject
(
"pointIds",
surfOut.instance(),
"pointFields",
surfOut,
IOobject::NO_READ,
IOobject::NO_WRITE
),
surfOut,
dimless
);
forAll(pointIds, i)
{
pointIds[i] = i;
}
Info<< "write pointIds (for testing only): "
<< pointIds.objectPath() << endl;
pointIds.write();
}
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
surfaceMeshExport.C
EXE = $(FOAM_APPBIN)/surfaceMeshExport

View File

@ -23,27 +23,36 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
surfaceMeshCoordinateSystemTransform
surfaceMeshExport
Description
Transform (scale/rotate/translate) a surface based on
a coordinateSystem.
Export from surfMesh to various third-party surface formats with
optional scaling or transformations (rotate/translate) on a
coordinateSystem.
Usage
- surfaceMeshCoordinateSystemTransform inputFile outputFile [OPTION]
- surfaceMeshExport outputFile [OPTION]
@param -clean \n
Perform some surface checking/cleanup on the input surface
Perform some surface checking/cleanup on the input surface.
@param -scale \<scale\> \n
Specify a scaling factor for writing the files
@param -name \<name\> \n
Specify an alternative surface name when writing.
@param -triSurface \n
Use triSurface library for input/output
@param -scaleIn \<scale\> \n
Specify a scaling factor when reading files.
@param -scaleOut \<scale\> \n
Specify a scaling factor when writing files.
@param -dict \<dictionary\> \n
Specify an alternative dictionary for coordinateSystems.
Specify an alternative dictionary for constant/coordinateSystems.
@param -from \<coordinateSystem\> \n
Specify a coordinate System when reading files.
@param -to \<coordinateSystem\> \n
Specify a coordinate System when writing files.
Note
The filename extensions are used to determine the file format type.
@ -55,7 +64,6 @@ Note
#include "Time.H"
#include "MeshedSurfaces.H"
#include "UnsortedMeshedSurfaces.H"
#include "coordinateSystems.H"
using namespace Foam;
@ -66,36 +74,55 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validArgs.append("outputFile");
argList::validOptions.insert("scale", "scale");
argList::validOptions.insert("unsorted", "");
argList::validOptions.insert("name", "name");
argList::validOptions.insert("clean", "scale");
argList::validOptions.insert("scaleIn", "scale");
argList::validOptions.insert("scaleOut", "scale");
argList::validOptions.insert("dict", "coordinateSystemsDict");
argList::validOptions.insert("from", "sourceCoordinateSystem");
argList::validOptions.insert("to", "targetCoordinateSystem");
argList::validOptions.insert("dict", "dictionary");
argList::validOptions.insert("to", "targetCoordinateSystem");
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
const stringList& params = args.additionalArgs();
const word dictName("coordinateSystems");
fileName exportName(params[0]);
word importName("default");
// check that writing is supported
if (!MeshedSurface<face>::canWriteType(exportName.ext(), true))
{
return 1;
}
if (args.options().found("name"))
{
importName = args.options()["name"];
}
// get the coordinate transformations
autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys;
if (args.options().found("from") || args.options().found("to"))
{
autoPtr<IOobject> csDictIoPtr;
autoPtr<IOobject> ioPtr;
if (args.options().found("dict"))
{
fileName dictPath(args.options()["dict"]);
csDictIoPtr.set
ioPtr.set
(
new IOobject
(
( dictPath.isDir() ? dictPath/dictName : dictPath ),
(
isDir(dictPath)
? dictPath/coordinateSystems::typeName
: dictPath
),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
@ -105,11 +132,11 @@ int main(int argc, char *argv[])
}
else
{
csDictIoPtr.set
ioPtr.set
(
new IOobject
(
dictName,
coordinateSystems::typeName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
@ -120,15 +147,15 @@ int main(int argc, char *argv[])
}
if (!csDictIoPtr->headerOk())
if (!ioPtr->headerOk())
{
FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n "
<< csDictIoPtr->objectPath() << nl
<< ioPtr->objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(csDictIoPtr());
coordinateSystems csLst(ioPtr());
if (args.options().found("from"))
{
@ -167,70 +194,81 @@ int main(int argc, char *argv[])
if (fromCsys.valid() && toCsys.valid())
{
FatalErrorIn(args.executable())
<< "Only allowed -from or -to option at the moment."
<< "Only allowed '-from' or '-to' option at the moment."
<< exit(FatalError);
}
}
scalar scaleFactor = 0;
if (args.options().found("scale"))
{
IStringStream(args.options()["scale"])() >> scaleFactor;
}
fileName importName(params[0]);
fileName exportName(params[1]);
if (importName == exportName)
{
FatalErrorIn(args.executable())
<< "Output file " << exportName << " would overwrite input file."
<< exit(FatalError);
}
if
surfMesh smesh
(
!meshedSurface::canRead(importName, true)
|| !meshedSurface::canWriteType(exportName.ext(), true)
)
IOobject
(
importName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
Info<< "read surfMesh:\n " << smesh.objectPath() << endl;
// Simply copy for now, but really should have a separate write method
MeshedSurface<face> surf(smesh);
if (args.options().found("clean"))
{
return 1;
surf.cleanup(true);
}
scalar scaleIn = 0;
scalar scaleOut = 0;
if (args.options().found("scaleIn"))
{
IStringStream(args.options()["scaleIn"])() >> scaleIn;
}
if (args.options().found("scaleOut"))
{
IStringStream(args.options()["scaleOut"])() >> scaleOut;
}
if (scaleIn > 0)
{
MeshedSurface<face> surf(importName);
if (args.options().found("clean"))
{
surf.cleanup(true);
}
if (fromCsys.valid())
{
tmp<pointField> tpf = fromCsys().localPosition(surf.points());
surf.movePoints(tpf());
}
if (toCsys.valid())
{
tmp<pointField> tpf = toCsys().globalPosition(surf.points());
surf.movePoints(tpf());
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
}
surf.write(exportName);
Info<< " -scaleIn " << scaleIn << endl;
surf.scalePoints(scaleIn);
}
if (fromCsys.valid())
{
Info<< " -from " << fromCsys().name() << endl;
tmp<pointField> tpf = fromCsys().localPosition(surf.points());
surf.movePoints(tpf());
}
if (toCsys.valid())
{
Info<< " -to " << toCsys().name() << endl;
tmp<pointField> tpf = toCsys().globalPosition(surf.points());
surf.movePoints(tpf());
}
if (scaleOut > 0)
{
Info<< " -scaleOut " << scaleOut << endl;
surf.scalePoints(scaleOut);
}
surf.writeStats(Info);
Info<< endl;
Info<< "writing " << exportName << endl;
surf.write(exportName);
Info<< "\nEnd\n" << endl;
return 0;

View File

@ -0,0 +1,3 @@
surfaceMeshImport.C
EXE = $(FOAM_APPBIN)/surfaceMeshImport

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
EXE_LIBS = -lmeshTools -lsurfMesh

View File

@ -0,0 +1,284 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
surfaceMeshImport
Description
Import from various third-party surface formats into surfMesh
with optional scaling or transformations (rotate/translate)
on a coordinateSystem.
Usage
- surfaceMeshImport inputFile [OPTION]
@param -clean \n
Perform some surface checking/cleanup on the input surface.
@param -name \<name\> \n
Specify an alternative surface name when writing.
@param -scaleIn \<scale\> \n
Specify a scaling factor when reading files.
@param -scaleOut \<scale\> \n
Specify a scaling factor when writing files.
@param -dict \<dictionary\> \n
Specify an alternative dictionary for constant/coordinateSystems.
@param -from \<coordinateSystem\> \n
Specify a coordinate System when reading files.
@param -to \<coordinateSystem\> \n
Specify a coordinate System when writing files.
Note
The filename extensions are used to determine the file format type.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "MeshedSurfaces.H"
#include "coordinateSystems.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validOptions.insert("name", "name");
argList::validOptions.insert("clean", "scale");
argList::validOptions.insert("scaleIn", "scale");
argList::validOptions.insert("scaleOut", "scale");
argList::validOptions.insert("dict", "coordinateSystemsDict");
argList::validOptions.insert("from", "sourceCoordinateSystem");
argList::validOptions.insert("to", "targetCoordinateSystem");
# include "setRootCase.H"
# include "createTime.H"
const stringList& params = args.additionalArgs();
// try for the latestTime, but create "constant" as needed
instantList Times = runTime.times();
if (Times.size())
{
label startTime = Times.size()-1;
runTime.setTime(Times[startTime], startTime);
}
else
{
runTime.setTime(instant(0, runTime.constant()), 0);
}
fileName importName(params[0]);
word exportName("default");
// check that reading is supported
if (!MeshedSurface<face>::canRead(importName, true))
{
return 1;
}
if (args.options().found("name"))
{
exportName = args.options()["name"];
}
// get the coordinate transformations
autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys;
if (args.options().found("from") || args.options().found("to"))
{
autoPtr<IOobject> ioPtr;
if (args.options().found("dict"))
{
fileName dictPath(args.options()["dict"]);
ioPtr.set
(
new IOobject
(
(
isDir(dictPath)
? dictPath/coordinateSystems::typeName
: dictPath
),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
else
{
ioPtr.set
(
new IOobject
(
coordinateSystems::typeName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
if (!ioPtr->headerOk())
{
FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n "
<< ioPtr->objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(ioPtr());
if (args.options().found("from"))
{
const word csName(args.options()["from"]);
label csId = csLst.find(csName);
if (csId < 0)
{
FatalErrorIn(args.executable())
<< "Cannot find -from " << csName << nl
<< "available coordinateSystems: " << csLst.toc() << nl
<< exit(FatalError);
}
fromCsys.reset(new coordinateSystem(csLst[csId]));
}
if (args.options().found("to"))
{
const word csName(args.options()["to"]);
label csId = csLst.find(csName);
if (csId < 0)
{
FatalErrorIn(args.executable())
<< "Cannot find -to " << csName << nl
<< "available coordinateSystems: " << csLst.toc() << nl
<< exit(FatalError);
}
toCsys.reset(new coordinateSystem(csLst[csId]));
}
// maybe fix this later
if (fromCsys.valid() && toCsys.valid())
{
FatalErrorIn(args.executable())
<< "Only allowed '-from' or '-to' option at the moment."
<< exit(FatalError);
}
}
MeshedSurface<face> surf(importName);
if (args.options().found("clean"))
{
surf.cleanup(true);
}
scalar scaleIn = 0;
scalar scaleOut = 0;
if (args.options().found("scaleIn"))
{
IStringStream(args.options()["scaleIn"])() >> scaleIn;
}
if (args.options().found("scaleOut"))
{
IStringStream(args.options()["scaleOut"])() >> scaleOut;
}
if (scaleIn > 0)
{
Info<< " -scaleIn " << scaleIn << endl;
surf.scalePoints(scaleIn);
}
if (fromCsys.valid())
{
Info<< " -from " << fromCsys().name() << endl;
tmp<pointField> tpf = fromCsys().localPosition(surf.points());
surf.movePoints(tpf());
}
if (toCsys.valid())
{
Info<< " -to " << toCsys().name() << endl;
tmp<pointField> tpf = toCsys().globalPosition(surf.points());
surf.movePoints(tpf());
}
if (scaleOut > 0)
{
Info<< " -scaleOut " << scaleOut << endl;
surf.scalePoints(scaleOut);
}
surfMesh smesh
(
IOobject
(
exportName,
runTime.constant(),
runTime
),
surf.xfer()
);
Info<< "writing surfMesh:\n " << smesh.objectPath() << endl;
smesh.write();
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -351,7 +351,7 @@ label otherEdge
return -1;
}
// Starting from startPoint on startEdge on startFace walk along border
// and insert faces along the way. Walk keeps always one point or one edge
@ -461,18 +461,8 @@ label sharedFace
label startIndex = findIndex(f, e.start());
bool edgeOrder;
if (f[(startIndex + 1) % f.size()] == e.end())
{
// points in face in same order as edge
edgeOrder = true;
}
else
{
// points in face in reverse order as edge
edgeOrder = false;
}
// points in face in same order as edge
bool edgeOrder = (f[f.fcIndex(startIndex)] == e.end());
// Get faces using edge in sorted order. (sorted such that walking
// around them in anti-clockwise order corresponds to edge vector
@ -485,25 +475,18 @@ label sharedFace
if (edgeOrder)
{
// Get face before firstFaceI
if (faceIndex == 0)
{
return eFaces[eFaces.size() - 1];
}
else
{
return eFaces[faceIndex - 1];
}
return eFaces[eFaces.rcIndex(faceIndex)];
}
else
{
// Get face after firstFaceI
return eFaces[(faceIndex+1) % eFaces.size()];
return eFaces[eFaces.fcIndex(faceIndex)];
}
}
// Calculate (inward pointing) normals on edges shared by faces in faceToEdge and
// averages them to pointNormals.
// averages them to pointNormals.
void calcPointVecs
(
const triSurface& surf,
@ -602,7 +585,7 @@ void calcPointVecs
}
scalar magMidVec = mag(midVec);
if (magMidVec > SMALL)
{
midVec /= magMidVec;
@ -925,7 +908,7 @@ int main(int argc, char *argv[])
newPoints[newPointI] = newPoints[pointI] + 0.1 * minLen * n;
}
}
//
// Renumber all faces in connectedFaces