BUG: accessing invalid coordinateRotation after move assignment (fixes #884)

- incorrect coordinateSystem clear() after the move

- add Test-coordinateSystem
This commit is contained in:
Mark Olesen
2018-06-19 21:24:38 +02:00
parent 5cd6e4bed4
commit 8295d398aa
8 changed files with 284 additions and 55 deletions

View File

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

View File

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

View File

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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 3 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, see <http://www.gnu.org/licenses/>.
Application
Test-coordinateSystem
Description
Expand coordinate system definitions
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "coordinateSystem.H"
#include "Fstream.H"
#include "IOstreams.H"
using namespace Foam;
void doTest(const dictionary& dict)
{
Info<< dict.dictName() << dict << nl;
// Could fail?
const bool throwingIOError = FatalIOError.throwExceptions();
const bool throwingError = FatalError.throwExceptions();
try
{
coordinateSystem cs1(dict.dictName(), dict);
coordinateSystem cs2;
// Move assign
cs2 = std::move(cs1);
// Info<<cs2 << nl;
cs2.writeDict(Info, true);
Info<< nl;
}
catch (Foam::IOerror& err)
{
Info<< "Caught FatalIOError " << err << nl << endl;
}
catch (Foam::error& err)
{
Info<< "Caught FatalError " << err << nl << endl;
}
FatalError.throwExceptions(throwingError);
FatalIOError.throwExceptions(throwingIOError);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::addArgument("dict .. dictN");
argList args(argc, argv, false, true);
if (args.size() <= 1)
{
Info<<"no coordinateSystem dictionaries to expand" << nl;
}
else
{
for (label argi=1; argi < args.size(); ++argi)
{
const string& dictFile = args[argi];
IFstream is(dictFile);
dictionary inputDict(is);
forAllConstIters(inputDict, iter)
{
if (iter().isDict())
{
doTest(iter().dict());
}
}
}
}
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,112 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Rotate 90 deg around x: y -> z, z -> -y
rot_x90_axesRotation
{
origin (0 0 0);
coordinateRotation
{
type axesRotation;
e1 (1 0 0);
e3 (0 -1 0);
}
}
rot_x90_euler
{
origin (0 0 0);
coordinateRotation
{
type EulerRotation;
rotation (0 90 0); // z-x'-z''
}
}
// Rotate 45 deg around z: x -> (1 1 0), y = (-1 1 0)
rot_z45_axesRotation
{
origin (0 0 0);
coordinateRotation
{
type axesRotation;
e1 (1 1 0);
e3 (0 0 1);
}
}
rot_z45_euler
{
origin (0 0 0);
coordinateRotation
{
type EulerRotation;
rotation (45 0 0); // z-x'-z''
}
}
// Rotate -45 deg around z: x -> (1 -1 0), y = (1 1 0)
rot_zm45_axesRotation
{
origin (0 0 0);
coordinateRotation
{
type axesRotation;
e1 (1 -1 0);
e3 (0 0 1);
}
}
rot_zm45_euler
{
origin (0 0 0);
coordinateRotation
{
type EulerRotation;
rotation (-45 0 0); // z-x'-z''
}
}
// Null transforms
null_axesRotation
{
origin (0 0 0);
coordinateRotation
{
type axesRotation;
e1 (1 0 0);
e3 (0 0 1);
}
}
null_euler
{
origin (0 0 0);
coordinateRotation
{
type EulerRotation;
rotation (0 0 0); // z-x'-z''
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //