BUG: incorrect symmTensor order for some ensight output (fixes #243)

- affects foamToEnsightParts, sampled surfaces

- Use ensightPTraits mechanism throughout to avoid this issue
This commit is contained in:
Mark Olesen
2016-09-23 09:10:57 +02:00
parent 0c168c43fa
commit 3c25f26aab
3 changed files with 24 additions and 34 deletions

View File

@ -57,10 +57,10 @@ void Foam::writeCloudField
val = Zero; val = Zero;
} }
for (direction i=0; i < pTraits<Type>::nComponents; ++i) for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[i]; label cmpt = ensightPTraits<Type>::componentOrder[d];
os.write( component(val, cmpt) ); os.write(component(val, cmpt));
if (++count % 6 == 0) if (++count % 6 == 0)
{ {
@ -84,10 +84,10 @@ void Foam::writeCloudField
val = Zero; val = Zero;
} }
for (direction i=0; i < pTraits<Type>::nComponents; ++i) for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[i]; label cmpt = ensightPTraits<Type>::componentOrder[d];
os.write( component(val, cmpt) ); os.write(component(val, cmpt));
if (++count % 6 == 0) if (++count % 6 == 0)
{ {
@ -168,9 +168,9 @@ void Foam::ensightCloudField
} }
filePtr = new ensightFile(dataDir, postFileName, format); filePtr = new ensightFile(dataDir, postFileName, format);
// description
filePtr->write filePtr->write
( (
// description
string(postFileName + " <" + pTraits<Type>::typeName + ">") string(postFileName + " <" + pTraits<Type>::typeName + ">")
); );
filePtr->newline(); filePtr->newline();

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ensightOutputFunctions.H" #include "ensightOutputFunctions.H"
#include "ensightPTraits.H"
#include "passiveParticle.H" #include "passiveParticle.H"
#include "IOField.H" #include "IOField.H"
@ -171,11 +172,8 @@ void Foam::ensightLagrangianField
// when writing positions // when writing positions
ensightFile os(dataDir, postFileName, format); ensightFile os(dataDir, postFileName, format);
os.write
(
// description // description
string(postFileName + " with " + pTraits<Type>::typeName + " values") os.write(string(postFileName + " <" + pTraits<Type>::typeName + ">"));
);
os.newline(); os.newline();
IOField<Type> field(fieldObject); IOField<Type> field(fieldObject);
@ -187,23 +185,22 @@ void Foam::ensightLagrangianField
{ {
Type val = field[i]; Type val = field[i];
if (mag(val) < 1.0e-90) if (mag(val) < 1e-90)
{ {
val = Zero; val = Zero;
} }
for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; cmpt++) for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{ {
os.write( component(val, cmpt) ); label cmpt = ensightPTraits<Type>::componentOrder[d];
} os.write(component(val, cmpt));
count += pTraits<Type>::nComponents; if (++count % 6 == 0)
if (count % 6 == 0)
{ {
os.newline(); os.newline();
} }
} }
}
// add final newline if required // add final newline if required
if (count % 6) if (count % 6)

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,6 +27,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ensightPart.H" #include "ensightPart.H"
#include "ensightPTraits.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
@ -45,13 +46,9 @@ void Foam::ensightPart::writeField
if (perNode) if (perNode)
{ {
os.writeKeyword("coordinates"); os.writeKeyword("coordinates");
for for (direction d=0; d < pTraits<Type>::nComponents; ++d)
(
direction cmpt=0;
cmpt < pTraits<Type>::nComponents;
++cmpt
)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[d];
writeFieldList(os, field.component(cmpt), labelUList::null()); writeFieldList(os, field.component(cmpt), labelUList::null());
} }
} }
@ -65,13 +62,9 @@ void Foam::ensightPart::writeField
{ {
os.writeKeyword(elementTypes()[elemI]); os.writeKeyword(elementTypes()[elemI]);
for for (direction d=0; d < pTraits<Type>::nComponents; ++d)
(
direction cmpt=0;
cmpt < pTraits<Type>::nComponents;
++cmpt
)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[d];
writeFieldList(os, field.component(cmpt), idList); writeFieldList(os, field.component(cmpt), idList);
} }
} }