mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added finiteArea support to foamToVTK
This commit is contained in:
committed by
Andrew Heather
parent
a14eb71160
commit
c2ff8ea99e
@ -97,25 +97,6 @@ using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// file-scope helper
|
||||
static bool inFileNameList
|
||||
(
|
||||
const fileNameList& nameList,
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
forAll(nameList, i)
|
||||
{
|
||||
if (nameList[i] == name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions();
|
||||
@ -641,7 +622,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Write " << cloudName << " (";
|
||||
|
||||
bool cloudExists = inFileNameList(currentCloudDirs, cloudName);
|
||||
bool cloudExists = currentCloudDirs.found(cloudName);
|
||||
reduce(cloudExists, orOp<bool>());
|
||||
|
||||
{
|
||||
|
||||
@ -3,11 +3,13 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/conversion/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lconversion \
|
||||
-ldynamicMesh \
|
||||
-lfiniteArea \
|
||||
-llagrangian \
|
||||
-lgenericPatchFields
|
||||
|
||||
@ -155,6 +155,7 @@ Note
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "stringOps.H"
|
||||
#include "areaFields.H"
|
||||
|
||||
#include "meshSubsetHelper.H"
|
||||
#include "readFields.H"
|
||||
@ -862,6 +863,119 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
|
||||
// Finite-area mesh and fields - need not exist
|
||||
|
||||
autoPtr<faMesh> aMeshPtr;
|
||||
{
|
||||
const bool throwing = FatalError.throwExceptions();
|
||||
try
|
||||
{
|
||||
aMeshPtr.reset(new faMesh(meshRef.baseMesh()));
|
||||
}
|
||||
catch (Foam::error& err)
|
||||
{
|
||||
aMeshPtr.clear();
|
||||
}
|
||||
FatalError.throwExceptions(throwing);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
writer.write(aScalarFld);
|
||||
writer.write(aVectorFld);
|
||||
writer.write(aSphTensorf);
|
||||
writer.write(aSymTensorFld);
|
||||
writer.write(aTensorFld);
|
||||
|
||||
writer.endCellData();
|
||||
|
||||
writer.writeFooter();
|
||||
}
|
||||
|
||||
PtrList<const pointScalarField> pScalarFld;
|
||||
PtrList<const pointVectorField> pVectorFld;
|
||||
PtrList<const pointSphericalTensorField> pSphTensorFld;
|
||||
|
||||
@ -72,6 +72,38 @@ label readFields
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<const GeoField>& fields
|
||||
)
|
||||
{
|
||||
// Search list of objects for fields of type GeomField
|
||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||
|
||||
// Construct the fields
|
||||
fields.setSize(fieldObjects.size());
|
||||
label nFields = 0;
|
||||
|
||||
forAllIters(fieldObjects, iter)
|
||||
{
|
||||
if (selectedFields.empty() || selectedFields.found(iter()->name()))
|
||||
{
|
||||
fields.set
|
||||
(
|
||||
nFields++,
|
||||
new GeoField(*iter(), mesh)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fields.setSize(nFields);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
Reference in New Issue
Block a user