Commit 6f72f345 authored by Andrew Heather's avatar Andrew Heather
Browse files

BUG: foamToVTK - only convert finte area if -finiteAreaFields option is specified. Fixes #687

parent 3b840040
......@@ -400,6 +400,11 @@ int main(int argc, char *argv[])
"write surfaceScalarFields (e.g., phi)"
);
argList::addBoolOption
(
"finiteAreaFields",
"write finite area fields"
);
argList::addBoolOption
(
"nearCellValue",
"use cell value on patches instead of patch value itself"
......@@ -865,115 +870,118 @@ int main(int argc, char *argv[])
// Finite-area mesh and fields - need not exist
autoPtr<faMesh> aMeshPtr;
if (args.optionFound("finiteAreaFields"))
{
const bool throwing = FatalError.throwExceptions();
try
autoPtr<faMesh> aMeshPtr;
{
aMeshPtr.reset(new faMesh(meshRef.baseMesh()));
const bool throwing = FatalError.throwExceptions();
try
{
aMeshPtr.reset(new faMesh(meshRef.baseMesh()));
}
catch (Foam::error& err)
{
aMeshPtr.clear();
}
FatalError.throwExceptions(throwing);
}
catch (Foam::error& err)
if (aMeshPtr.valid())
{
aMeshPtr.clear();
}
FatalError.throwExceptions(throwing);
}
// Construct the area fields
if (aMeshPtr.valid())
{
// Construct the area fields
PtrList<const areaScalarField> aScalarFld;
PtrList<const areaVectorField> aVectorFld;
PtrList<const areaSphericalTensorField> aSphTensorf;
PtrList<const areaSymmTensorField> aSymTensorFld;
PtrList<const areaTensorField> aTensorFld;
PtrList<const areaScalarField> aScalarFld;
PtrList<const areaVectorField> aVectorFld;
PtrList<const areaSphericalTensorField> aSphTensorf;
PtrList<const areaSymmTensorField> aSymTensorFld;
PtrList<const areaTensorField> aTensorFld;
const faMesh& aMesh = aMeshPtr();
const faMesh& aMesh = aMeshPtr();
if (!specifiedFields || selectedFields.size())
{
readFields
(
aMesh,
objects,
selectedFields,
aScalarFld
);
print(" areaScalar :", Info, aScalarFld);
readFields
(
aMesh,
objects,
selectedFields,
aVectorFld
);
print(" areaVector :", Info, aVectorFld);
readFields
(
aMesh,
objects,
selectedFields,
aSphTensorf
);
print(" areaSphericalTensor :", Info, aSphTensorf);
readFields
(
aMesh,
objects,
selectedFields,
aSymTensorFld
);
print(" areaSymmTensor :", Info, aSymTensorFld);
readFields
(
aMesh,
objects,
selectedFields,
aTensorFld
);
print(" areaTensor :", Info, aTensorFld);
}
if (!specifiedFields || selectedFields.size())
{
readFields
const label nAreaFields =
(
aMesh,
objects,
selectedFields,
aScalarFld
aScalarFld.size()
+ aVectorFld.size()
+ aSphTensorf.size()
+ aSymTensorFld.size()
+ aTensorFld.size()
);
print(" areaScalar :", Info, aScalarFld);
readFields
(
aMesh,
objects,
selectedFields,
aVectorFld
);
print(" areaVector :", Info, aVectorFld);
fileName outputName(fvPath/"finiteArea");
readFields
(
aMesh,
objects,
selectedFields,
aSphTensorf
);
print(" areaSphericalTensor :", Info, aSphTensorf);
mkDir(outputName);
readFields
(
aMesh,
objects,
selectedFields,
aSymTensorFld
);
print(" areaSymmTensor :", Info, aSymTensorFld);
const auto& pp = aMesh.patch();
readFields
vtk::surfaceMeshWriter writer
(
aMesh,
objects,
selectedFields,
aTensorFld
pp,
aMesh.name(),
outputName/"finiteArea" + "_" + timeDesc,
fmtType
);
print(" areaTensor :", Info, aTensorFld);
}
const label nAreaFields =
(
aScalarFld.size()
+ aVectorFld.size()
+ aSphTensorf.size()
+ aSymTensorFld.size()
+ aTensorFld.size()
);
fileName outputName(fvPath/"finiteArea");
mkDir(outputName);
const auto& pp = aMesh.patch();
vtk::surfaceMeshWriter writer
(
pp,
aMesh.name(),
outputName/"finiteArea" + "_" + timeDesc,
fmtType
);
// Number of fields
writer.beginCellData(nAreaFields);
// Number of fields
writer.beginCellData(nAreaFields);
writer.write(aScalarFld);
writer.write(aVectorFld);
writer.write(aSphTensorf);
writer.write(aSymTensorFld);
writer.write(aTensorFld);
writer.write(aScalarFld);
writer.write(aVectorFld);
writer.write(aSphTensorf);
writer.write(aSymTensorFld);
writer.write(aTensorFld);
writer.endCellData();
writer.endCellData();
writer.writeFooter();
writer.writeFooter();
}
}
PtrList<const pointScalarField> pScalarFld;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment