本文整理汇总了C++中IOobject类的典型用法代码示例。如果您正苦于以下问题:C++ IOobject类的具体用法?C++ IOobject怎么用?C++ IOobject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IOobject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: regIOobject
Foam::IOList<T>::IOList(const IOobject& io)
:
regIOobject(io)
{
// Temporary warning
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningIn("IOList::IOList(const IOobject&)")
<< "IOList " << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but IOList does not support automatic rereading."
<< endl;
}
if
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
示例2: surfaceRegistry
Foam::surfMesh::surfMesh(const IOobject& io, const word& surfName)
:
surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
Allocator
(
IOobject
(
"points",
time().findInstance(meshDir(), "points"),
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
IOobject
(
"faces",
time().findInstance(meshDir(), "faces"),
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
IOobject
(
"surfZones",
time().findInstance(meshDir(), "surfZones"),
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
MeshReference(this->storedIOFaces(), this->storedIOPoints())
{}
示例3:
Foam::IOobject Foam::IOporosityModelList::createIOobject
(
const fvMesh& mesh
) const
{
IOobject io
(
"porosityProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Creating porosity model list from " << io.name() << nl << endl;
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
return io;
}
else
{
Info<< "No porosity models present" << nl << endl;
io.readOpt() = IOobject::NO_READ;
return io;
}
}
示例4: field
void printSum
(
const fvMesh& mesh,
const IOobject& fieldHeader,
const label patchI,
bool& done
)
{
if (!done && fieldHeader.headerClassName() == FieldType::typeName)
{
Info<< " Reading " << FieldType::typeName << " "
<< fieldHeader.name() << endl;
FieldType field(fieldHeader, mesh);
typename FieldType::value_type sumField = gSum
(
field.boundaryField()[patchI]
);
Info<< " Integral of " << fieldHeader.name() << " over patch "
<< mesh.boundary()[patchI].name() << '[' << patchI << ']' << " = "
<< sumField << nl;
done = true;
}
}
示例5: field
void Foam::calcTypes::curl::writeCurlField
(
const IOobject& header,
const fvMesh& mesh,
bool& processed
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (header.headerClassName() == fieldType::typeName)
{
Info<< " Reading " << header.name() << endl;
fieldType field(header, mesh);
Info<< " Calculating curl" << header.name() << endl;
volVectorField curlField
(
IOobject
(
"curl" + header.name(),
mesh.time().timeName(),
mesh,
IOobject::NO_READ
),
Foam::fvc::curl(field)
);
curlField.write();
processed = true;
}
}
示例6: field
void Foam::calcTypes::interpolate::writeInterpolateField
(
const IOobject& header,
const fvMesh& mesh,
bool& processed
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> surfaceFieldType;
if (header.headerClassName() == fieldType::typeName)
{
Info<< " Reading " << header.name() << endl;
fieldType field(header, mesh);
Info<< " Calculating interpolate" << header.name() << endl;
surfaceFieldType interpolateField
(
IOobject
(
"interpolate" + header.name(),
mesh.time().timeName(),
mesh,
IOobject::NO_READ
),
fvc::interpolate(field)
);
interpolateField.write();
processed = true;
}
}
示例7: forAll
bool addFieldsToList
(
const fvMesh& mesh,
PtrList<GeometricField<Type, fvPatchField, volMesh>>& list,
const wordList& fieldNames
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
label index = 0;
forAll(fieldNames, i)
{
IOobject obj
(
fieldNames[i],
mesh.time().timeName(),
mesh,
IOobject::MUST_READ
);
if (obj.headerOk() && obj.headerClassName() == fieldType::typeName)
{
list.set(index++, new fieldType(obj, mesh));
}
else
{
Info<< "Could not find " << fieldNames[i] << endl;
return false;
}
}
示例8: fieldTypes
bool Foam::sampledSets::checkFieldTypes()
{
wordList fieldTypes(fieldNames_.size());
// check files for a particular time
if (loadFromFiles_)
{
forAll(fieldNames_, fieldi)
{
IOobject io
(
fieldNames_[fieldi],
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[fieldi] = io.headerClassName();
}
else
{
fieldTypes[fieldi] = "(notFound)";
}
}
}
示例9: dynamicFvMesh
Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
:
dynamicFvMesh(io),
dynamicMeshCoeffs_
(
IOdictionary
(
IOobject
(
"dynamicMeshDict",
io.time().constant(),
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
).subDict(typeName + "Coeffs")
),
SBMFPtr_(solidBodyMotionFunction::New(dynamicMeshCoeffs_, io.time())),
undisplacedPoints_
(
IOobject
(
"points",
io.time().constant(),
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
{}
示例10: writeScalarMultValues
void Foam::calcTypes::scalarMult::calc
(
const argList& args,
const Time& runTime,
const fvMesh& mesh
)
{
IOobject baseFieldHeader
(
baseFieldName_,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
if (baseFieldHeader.headerOk())
{
writeScalarMultValues(runTime, mesh, baseFieldHeader);
}
else
{
FatalErrorIn("calcTypes::scalarMult::calc")
<< "Unable to read base field: " << baseFieldName_
<< nl << exit(FatalError);
}
}
示例11: main
int main(int argc, char *argv[])
{
timeSelector::addOptions();
#include "addRegionOption.H"
argList::validArgs.append("fieldName");
#include "setRootCase.H"
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createNamedMesh.H"
const word fieldName = args[1];
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
IOobject fieldHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Check field exists
if (fieldHeader.headerOk())
{
mesh.readUpdate();
// Give fluid volume
Info<< " Volume of fluid = "
<< gSum(mesh.V()) << " [m3]" << endl;
// Read field and calc integral
bool done = false;
printIntegrate<volScalarField>(mesh,fieldHeader,done);
printIntegrate<volVectorField>(mesh,fieldHeader,done);
printIntegrate<volSphericalTensorField>(mesh,fieldHeader,done);
printIntegrate<volSymmTensorField>(mesh,fieldHeader,done);
printIntegrate<volTensorField>(mesh,fieldHeader,done);
if (!done)
{
FatalError
<< "Only possible to integrate volFields."
<< " Field " << fieldName << " is of type "
<< fieldHeader.headerClassName()
<< nl << exit(FatalError);
}
}
else
{
Info<< " No field " << fieldName << endl;
}
Info<< endl;
}
示例12: main
int main(int argc, char *argv[])
{
argList::validArgs.append("scaling factor");
# include <OpenFOAM/setRootCase.H>
scalar scaleFactor(readScalar(IStringStream(args.additionalArgs()[0])()));
# include <OpenFOAM/createTime.H>
# include <OpenFOAM/createMesh.H>
volPointInterpolation pInterp(mesh);
// Get times list
instantList Times = runTime.times();
pointField zeroPoints(mesh.points());
// skip "constant" time
for (label timeI = 1; timeI < Times.size(); ++timeI)
{
runTime.setTime(Times[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
IOobject Uheader
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Check U exists
if (Uheader.headerOk())
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
pointField newPoints =
zeroPoints
+ scaleFactor*pInterp.interpolate(U)().internalField();
mesh.polyMesh::movePoints(newPoints);
mesh.write();
}
else
{
Info<< " No U" << endl;
}
Info<< endl;
}
Info<< "End\n" << endl;
return 0;
}
示例13: U
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
bool writeResults = !args.optionFound("noWrite");
IOobject Uheader
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
if (Uheader.headerOk())
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
Info<< " Calculating vorticity" << endl;
volVectorField vorticity
(
IOobject
(
"vorticity",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
fvc::curl(U)
);
volScalarField magVorticity
(
IOobject
(
"magVorticity",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
mag(vorticity)
);
Info<< "vorticity max/min : "
<< max(magVorticity).value() << " "
<< min(magVorticity).value() << endl;
if (writeResults)
{
vorticity.write();
magVorticity.write();
}
}
else
{
Info<< " No U" << endl;
}
Info<< "\nEnd\n" << endl;
}
示例14: regIOobject
Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict)
:
regIOobject(io)
{
// Temporary warning
if (debug && io.readOpt() == IOobject::MUST_READ)
{
WarningInFunction
<< "Dictionary " << name()
<< " constructed with IOobject::MUST_READ"
" instead of IOobject::MUST_READ_IF_MODIFIED." << nl
<< "Use MUST_READ_IF_MODIFIED if you need automatic rereading."
<< endl;
}
// Everyone check or just master
bool masterOnly =
regIOobject::fileModificationChecking == timeStampMaster
|| regIOobject::fileModificationChecking == inotifyMaster;
// Check if header is ok for READ_IF_PRESENT
bool isHeaderOk = false;
if (io.readOpt() == IOobject::READ_IF_PRESENT)
{
if (masterOnly)
{
if (Pstream::master())
{
isHeaderOk = headerOk();
}
Pstream::scatter(isHeaderOk);
}
else
{
isHeaderOk = headerOk();
}
}
if
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| isHeaderOk
)
{
readFile(masterOnly);
}
else
{
dictionary::operator=(dict);
}
dictionary::name() = IOobject::objectPath();
}
示例15: main
int main(int argc, char *argv[])
{
timeSelector::addOptions();
argList::validArgs.append("patchName");
#include "setRootCase.H"
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
const word vecFieldName = "wallShearStress";
#include "createMesh.H"
runTime.setTime(timeDirs.last(), timeDirs.size()-1);
const word patchName = args[1];
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
Info << " Read vector field " << vecFieldName << endl;
IOobject vecFieldHeader
(
vecFieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (!vecFieldHeader.headerOk())
{
Info << "Unable to read vector field" << vecFieldName << endl;
return EXIT_FAILURE;
}
const label patchI = mesh.boundaryMesh().findPatchID(patchName);
if (patchI < 0)
{
FatalError << "Unable to find patch " << patchName << nl
<< exit(FatalError);
}
const volVectorField vectorField(vecFieldHeader, mesh);
const scalarField magVecField = magSqr(vectorField.boundaryField()[patchI]);
const scalar area = gSum(mesh.magSf().boundaryField()[patchI]);
scalar meanSqr = gSum(magVecField * mesh.magSf().boundaryField()[patchI]) / area;
Info << " RMS(mag(" << vecFieldName << ")) = " << Foam::sqrt(meanSqr) << endl;
Info << " max(mag(" << vecFieldName << ")) = " << Foam::sqrt(Foam::gMax(magVecField));
Info << endl;
}