ENH: add read-option for polyTopoChanger (issue #608)

- avoid meshModifier contents from being read immediately upon
  construction, since this recreates an existing modifier instead of
  allowing us to specify our own.
This commit is contained in:
Mark Olesen
2017-10-04 08:19:39 +02:00
parent b9d97d96c1
commit 1cfb59fe1a
3 changed files with 49 additions and 37 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,7 +27,6 @@ Application
Group
grpMeshManipulationUtilities
Description
'Stitches' a mesh.
@ -332,7 +331,8 @@ int main(int argc, char *argv[])
isf[i] = masterPatch.start() + i;
}
polyTopoChanger stitcher(mesh);
polyTopoChanger stitcher(mesh, IOobject::NO_READ);
stitcher.clear();
stitcher.setSize(1);
mesh.pointZones().clearAddressing();
@ -414,7 +414,6 @@ int main(int argc, char *argv[])
);
}
// Search for list of objects for this time
IOobjectList objects(mesh, runTime.timeName());
@ -435,7 +434,7 @@ int main(int argc, char *argv[])
PtrList<volTensorField> volTensorFields;
ReadFields(mesh, objects, volTensorFields);
//- Uncomment if you want to interpolate surface fields (usually bad idea)
//- Uncomment if you want to interpolate surface fields (usually a bad idea)
//Info<< "Reading all current surfaceFields" << endl;
//PtrList<surfaceScalarField> surfaceScalarFields;
//ReadFields(mesh, objects, surfaceScalarFields);
@ -469,7 +468,7 @@ int main(int argc, char *argv[])
// Bypass runTime write (since only writes at writeTime)
if
(
!runTime.objectRegistry::writeObject
!runTime.objectRegistry::writeObject
(
runTime.writeFormat(),
IOstream::currentVersion,

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,7 +36,7 @@ namespace Foam
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::polyTopoChanger::readModifiers()
{
@ -73,7 +73,6 @@ void Foam::polyTopoChanger::readModifiers()
);
}
// Check state of IOstream
is.check(FUNCTION_NAME);
close();
@ -81,6 +80,8 @@ void Foam::polyTopoChanger::readModifiers()
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::polyTopoChanger::polyTopoChanger
(
const IOobject& io,
@ -95,10 +96,14 @@ Foam::polyTopoChanger::polyTopoChanger
}
Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh)
Foam::polyTopoChanger::polyTopoChanger
(
polyMesh& mesh,
const IOobject::readOption rOpt
)
:
PtrList<polyMeshModifier>(),
regIOobject
polyTopoChanger
(
IOobject
(
@ -107,32 +112,36 @@ Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh)
(
mesh.meshDir(),
"meshModifiers",
IOobject::READ_IF_PRESENT
rOpt
),
mesh.meshSubDir,
mesh,
IOobject::READ_IF_PRESENT,
rOpt,
IOobject::NO_WRITE
)
),
mesh_(mesh)
{
readModifiers();
}
),
mesh
)
{}
Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh)
:
polyTopoChanger(mesh, IOobject::readOption::READ_IF_PRESENT)
{}
Foam::wordList Foam::polyTopoChanger::types() const
{
const PtrList<polyMeshModifier>& modifiers = *this;
wordList t(modifiers.size());
wordList lst(modifiers.size());
forAll(modifiers, modifierI)
forAll(modifiers, i)
{
t[modifierI] = modifiers[modifierI].type();
lst[i] = modifiers[i].type();
}
return t;
return lst;
}
@ -140,14 +149,14 @@ Foam::wordList Foam::polyTopoChanger::names() const
{
const PtrList<polyMeshModifier>& modifiers = *this;
wordList t(modifiers.size());
wordList lst(modifiers.size());
forAll(modifiers, modifierI)
forAll(modifiers, i)
{
t[modifierI] = modifiers[modifierI].name();
lst[i] = modifiers[i].name();
}
return t;
return lst;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,13 +69,13 @@ class polyTopoChanger
{
// Private Member Functions
void readModifiers();
//- Disallow default bitwise copy construct
polyTopoChanger(const polyTopoChanger&);
polyTopoChanger(const polyTopoChanger&) = delete;
//- Disallow default bitwise assignment
void operator=(const polyTopoChanger&);
void readModifiers();
void operator=(const polyTopoChanger&) = delete;
protected:
@ -93,11 +93,15 @@ public:
// Constructors
//- Read constructor given IOobject and a polyMesh
polyTopoChanger(const IOobject&, polyMesh&);
//- Read construct given IOobject and a polyMesh
polyTopoChanger(const IOobject& io, polyMesh& mesh);
//- Read constructor for given polyMesh
explicit polyTopoChanger(polyMesh&);
//- Read construct for given polyMesh and read-option
polyTopoChanger(polyMesh& mesh, const IOobject::readOption rOpt);
//- Read construct for given polyMesh.
// Uses read-option READ_IF_PRESENT
explicit polyTopoChanger(polyMesh& mesh);
//- Destructor