mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
25
Allwmake
25
Allwmake
@ -1,21 +1,20 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
# Run from OPENFOAM top-level directory only
|
||||
cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null || {
|
||||
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR"
|
||||
echo " Check your OpenFOAM environment and installation"
|
||||
exit 1
|
||||
}
|
||||
[ -n "$FOAM_EXT_LIBBIN" ] || {
|
||||
echo "Error (${0##*/}) : FOAM_EXT_LIBBIN not set"
|
||||
echo " Check your OpenFOAM environment and installation"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
wmakeCheckPwd "$WM_PROJECT_DIR" || {
|
||||
echo "Allwmake error: Current directory is not \$WM_PROJECT_DIR"
|
||||
echo " The environment variables are inconsistent with the installation."
|
||||
echo " Check the OpenFOAM entries in your dot-files and source them."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -n "$FOAM_EXT_LIBBIN" ] || {
|
||||
echo "Allwmake error: FOAM_EXT_LIBBIN not set"
|
||||
echo " Check the OpenFOAM entries in your dot-files and source them."
|
||||
exit 1
|
||||
}
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Compile wmake support applications
|
||||
(cd wmake/src && make)
|
||||
|
||||
@ -1,21 +1,20 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
# Run from OPENFOAM applications/ directory only
|
||||
cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR/applications" 2>/dev/null || {
|
||||
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR/applications"
|
||||
echo " Check your OpenFOAM environment and installation"
|
||||
exit 1
|
||||
}
|
||||
[ -n "$FOAM_EXT_LIBBIN" ] || {
|
||||
echo "Error (${0##*/}) : FOAM_EXT_LIBBIN not set"
|
||||
echo " Check your OpenFOAM environment and installation"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
wmakeCheckPwd "$WM_PROJECT_DIR/applications" || {
|
||||
echo "Allwmake error: Current directory is not \$WM_PROJECT_DIR/applications"
|
||||
echo " The environment variables are inconsistent with the installation."
|
||||
echo " Check the OpenFOAM entries in your dot-files and source them."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -n "$FOAM_EXT_LIBBIN" ] || {
|
||||
echo "Allwmake error: FOAM_EXT_LIBBIN not set"
|
||||
echo " Check the OpenFOAM entries in your dot-files and source them."
|
||||
exit 1
|
||||
}
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
wmake -all $targetType solvers
|
||||
wmake -all $targetType utilities
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,15 +31,53 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
template<class T>
|
||||
void printTable(const HashPtrTable<T>& table)
|
||||
{
|
||||
Info<< table.size() << nl << "(" << nl;
|
||||
|
||||
for
|
||||
(
|
||||
typename HashPtrTable<T>::const_iterator iter = table.cbegin();
|
||||
iter != table.cend();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
const T* ptr = *iter;
|
||||
Info<< iter.key() << " = ";
|
||||
if (ptr)
|
||||
{
|
||||
Info<< *ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "nullptr";
|
||||
}
|
||||
Info<< nl;
|
||||
}
|
||||
|
||||
Info<< ")" << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main()
|
||||
{
|
||||
Foam::HashPtrTable<double> myTable;
|
||||
myTable.insert("hello", new double(42.1));
|
||||
HashPtrTable<double> myTable;
|
||||
myTable.insert("abc", new double(42.1));
|
||||
myTable.insert("def", nullptr);
|
||||
myTable.insert("ghi", new double(3.14159));
|
||||
|
||||
Info<< myTable << endl;
|
||||
// Info<< myTable << endl;
|
||||
printTable(myTable);
|
||||
|
||||
HashPtrTable<double> copy(myTable);
|
||||
|
||||
// Info<< copy << endl;
|
||||
printTable(copy);
|
||||
Info<< copy << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -49,6 +49,8 @@ int main()
|
||||
{"aec", 10.0}
|
||||
};
|
||||
|
||||
// Info<< "\ntable1: " << table1<< endl;
|
||||
|
||||
// Erase by key
|
||||
table1.erase("aaw");
|
||||
|
||||
@ -60,7 +62,7 @@ int main()
|
||||
Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl;
|
||||
table1.printInfo(Info)
|
||||
<< "table1 [" << table1.size() << "] " << endl;
|
||||
forAllIter(HashTable<scalar>, table1, iter)
|
||||
forAllConstIter(HashTable<scalar>, table1, iter)
|
||||
{
|
||||
Info<< iter.key() << " => " << iter() << nl;
|
||||
}
|
||||
@ -106,7 +108,7 @@ int main()
|
||||
Info<< "\nerase table2 by iterator" << nl;
|
||||
forAllIter(HashTable<scalar>, table2, iter)
|
||||
{
|
||||
Info<< "erasing " << iter.key() << " => " << iter() << " ... ";
|
||||
Info<< "erasing " << iter.key() << " => " << iter.object() << " ... ";
|
||||
table2.erase(iter);
|
||||
Info<< "erased" << endl;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -42,7 +42,11 @@ See also
|
||||
#include "vector.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
#include<list>
|
||||
#include "labelRange.H"
|
||||
#include "ListOps.H"
|
||||
#include "SubList.H"
|
||||
|
||||
#include <list>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -61,6 +65,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
if (false)
|
||||
{
|
||||
labelList intlist(IStringStream("(0 1 2)")());
|
||||
Info<<"construct from Istream: " << intlist << endl;
|
||||
|
||||
IStringStream("(3 4 5)")() >> static_cast<labelUList&>(intlist);
|
||||
Info<<"is >>: " << intlist << endl;
|
||||
|
||||
IStringStream("(6 7 8)")() >> intlist;
|
||||
Info<<"is >>: " << intlist << endl;
|
||||
}
|
||||
|
||||
|
||||
List<vector> list1(IStringStream("1 ((0 1 2))")());
|
||||
Info<< "list1: " << list1 << endl;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -40,8 +40,8 @@ boundBox cube(scalar start, scalar width)
|
||||
{
|
||||
return boundBox
|
||||
(
|
||||
point(start, start, start),
|
||||
point(start + width, start + width, start + width)
|
||||
point::uniform(start),
|
||||
point::uniform(start + width)
|
||||
);
|
||||
}
|
||||
|
||||
@ -59,6 +59,69 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<<"boundBox faces: " << boundBox::faces << endl;
|
||||
Info<<"hex faces: " << hex.modelFaces() << endl;
|
||||
Info<<"tree-bb faces: " << treeBoundBox::faces << endl;
|
||||
Info<<"tree-bb edges: " << treeBoundBox::edges << endl;
|
||||
|
||||
boundBox bb = boundBox::greatBox;
|
||||
Info<<"great box: " << bb << endl;
|
||||
|
||||
// bb.clear();
|
||||
// Info<<"zero box: " << bb << endl;
|
||||
|
||||
bb = boundBox::invertedBox;
|
||||
Info<<"invalid box: " << bb << endl;
|
||||
Info<< nl << endl;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
bb = cube(Pstream::myProcNo(), 1.1);
|
||||
Pout<<"box: " << bb << endl;
|
||||
|
||||
bb.reduce();
|
||||
Pout<<"reduced: " << bb << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
bb = cube(0, 1);
|
||||
Info<<"starting box: " << bb << endl;
|
||||
|
||||
point pt(Zero);
|
||||
bb.add(pt);
|
||||
Info<<"enclose point " << pt << " -> " << bb << endl;
|
||||
|
||||
pt = point(0,1.5,0.5);
|
||||
bb.add(pt);
|
||||
Info<<"enclose point " << pt << " -> " << bb << endl;
|
||||
|
||||
pt = point(5,2,-2);
|
||||
bb.add(pt);
|
||||
Info<<"enclose point " << pt << " -> " << bb << endl;
|
||||
|
||||
// restart with same points
|
||||
bb = boundBox::invertedBox;
|
||||
bb.add(point(1,1,1));
|
||||
bb.add(point::zero);
|
||||
bb.add(point(0,1.5,0.5));
|
||||
bb.add(point(5,2,-2));
|
||||
|
||||
Info<<"repeated " << bb << endl;
|
||||
|
||||
boundBox box1 = cube(0, 1);
|
||||
boundBox box2 = cube(0, 0.75);
|
||||
boundBox box3 = cube(0.5, 1);
|
||||
boundBox box4 = cube(-1, 0.5);
|
||||
|
||||
Info<<"union of " << box1 << " and " << box2 << " => ";
|
||||
|
||||
box1.add(box2);
|
||||
Info<< box1 << endl;
|
||||
|
||||
box1.add(box3);
|
||||
Info<<"union with " << box3 << " => " << box1 << endl;
|
||||
|
||||
box1.add(box4);
|
||||
Info<<"union with " << box4 << " => " << box1 << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -58,6 +58,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
labelRange range;
|
||||
labelRanges ranges;
|
||||
|
||||
bool removeMode = false;
|
||||
@ -74,14 +75,16 @@ int main(int argc, char *argv[])
|
||||
continue;
|
||||
}
|
||||
|
||||
label start = 0;
|
||||
label size = 0;
|
||||
{
|
||||
label start = 0;
|
||||
label size = 0;
|
||||
|
||||
IStringStream(args[argI])() >> start;
|
||||
++argI;
|
||||
IStringStream(args[argI])() >> size;
|
||||
IStringStream(args[argI])() >> start;
|
||||
++argI;
|
||||
IStringStream(args[argI])() >> size;
|
||||
|
||||
labelRange range(start, size);
|
||||
range.reset(start, size);
|
||||
}
|
||||
|
||||
Info<< "---------------" << nl;
|
||||
if (removeMode)
|
||||
@ -107,10 +110,11 @@ int main(int argc, char *argv[])
|
||||
ranges.add(range);
|
||||
}
|
||||
|
||||
Info<< "<list>" << ranges << "</list>" << nl;
|
||||
forAllConstIter(labelRanges, ranges, iter)
|
||||
Info<< "<list>" << ranges << "</list>" << nl
|
||||
<< "content:";
|
||||
for (auto i : ranges)
|
||||
{
|
||||
Info<< " " << iter();
|
||||
Info<< " " << i;
|
||||
}
|
||||
Info<< nl;
|
||||
}
|
||||
|
||||
@ -69,6 +69,13 @@ int main(int argc, char *argv[])
|
||||
Info<<"trimRight: " << stringOps::trimRight(test) << endl;
|
||||
Info<<"trim: " << stringOps::trim(test) << endl;
|
||||
|
||||
Info<< nl;
|
||||
Info<<"camel-case => " << (word("camel") & "case") << nl;
|
||||
for (const auto& s : { " text with \"spaces'", "08/15 value" })
|
||||
{
|
||||
Info<<"validated \"" << s << "\" => " << word::validated(s) << nl;
|
||||
}
|
||||
Info<< nl;
|
||||
|
||||
// test sub-strings via iterators
|
||||
string::const_iterator iter = test.end();
|
||||
|
||||
@ -66,14 +66,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
pointField newPoints(mesh.points());
|
||||
|
||||
const point half(0.5*(meshBb.min() + meshBb.max()));
|
||||
const point half = meshBb.midpoint();
|
||||
|
||||
forAll(newPoints, pointi)
|
||||
{
|
||||
point& pt = newPoints[pointi];
|
||||
|
||||
// expand around half
|
||||
pt.y() += pt.y() - half.y();
|
||||
pt.y() += pt.y() - half.y();
|
||||
}
|
||||
|
||||
mesh.movePoints(newPoints);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,6 +49,9 @@ Usage
|
||||
- \par -dict \<filename\>
|
||||
Specify alternative dictionary for the block mesh description.
|
||||
|
||||
- \par -sets
|
||||
Write cellZones as cellSets too (for processing purposes)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Time.H"
|
||||
@ -85,7 +88,11 @@ int main(int argc, char *argv[])
|
||||
"file",
|
||||
"specify alternative dictionary for the blockMesh description"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"sets",
|
||||
"write cellZones as cellSets too (for processing purposes)"
|
||||
);
|
||||
argList::addNote
|
||||
(
|
||||
"Block description\n"
|
||||
@ -187,7 +194,6 @@ int main(int argc, char *argv[])
|
||||
IOdictionary meshDict(meshDictIO);
|
||||
blockMesh blocks(meshDict, regionName);
|
||||
|
||||
|
||||
if (args.optionFound("blockTopology"))
|
||||
{
|
||||
// Write mesh as edges.
|
||||
@ -251,7 +257,6 @@ int main(int argc, char *argv[])
|
||||
defaultFacesType
|
||||
);
|
||||
|
||||
|
||||
// Read in a list of dictionaries for the merge patch pairs
|
||||
if (meshDict.found("mergePatchPairs"))
|
||||
{
|
||||
@ -271,8 +276,7 @@ int main(int argc, char *argv[])
|
||||
// Set any cellZones (note: cell labelling unaffected by above
|
||||
// mergePatchPairs)
|
||||
|
||||
label nZones = blocks.numZonedBlocks();
|
||||
|
||||
const label nZones = blocks.numZonedBlocks();
|
||||
if (nZones > 0)
|
||||
{
|
||||
Info<< nl << "Adding cell zones" << endl;
|
||||
@ -325,11 +329,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<cellZone*> cz(zoneMap.size());
|
||||
|
||||
Info<< nl << "Writing cell zones as cellSets" << endl;
|
||||
|
||||
forAllConstIter(HashTable<label>, zoneMap, iter)
|
||||
{
|
||||
label zoneI = iter();
|
||||
@ -341,10 +341,6 @@ int main(int argc, char *argv[])
|
||||
zoneI,
|
||||
mesh.cellZones()
|
||||
);
|
||||
|
||||
// Write as cellSet for ease of processing
|
||||
cellSet cset(mesh, iter.key(), zoneCells[zoneI].shrink());
|
||||
cset.write();
|
||||
}
|
||||
|
||||
mesh.pointZones().setSize(0);
|
||||
@ -356,7 +352,14 @@ int main(int argc, char *argv[])
|
||||
// Set the precision of the points data to 10
|
||||
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
|
||||
|
||||
Info<< nl << "Writing polyMesh" << endl;
|
||||
Info<< nl << "Writing polyMesh with "
|
||||
<< mesh.cellZones().size() << " cellZones";
|
||||
if (args.optionFound("sets") && !mesh.cellZones().empty())
|
||||
{
|
||||
Info<< " (written as cellSets too)";
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
mesh.removeFiles();
|
||||
if (!mesh.write())
|
||||
{
|
||||
@ -365,6 +368,14 @@ int main(int argc, char *argv[])
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (args.optionFound("sets"))
|
||||
{
|
||||
forAll(mesh.cellZones(), zonei)
|
||||
{
|
||||
const cellZone& cz = mesh.cellZones()[zonei];
|
||||
cellSet(mesh, cz.name(), cz).write();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// write some information
|
||||
|
||||
@ -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.
|
||||
@ -719,17 +719,13 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree()
|
||||
Pstream::gatherList(allBackgroundMeshBounds_);
|
||||
Pstream::scatterList(allBackgroundMeshBounds_);
|
||||
|
||||
point bbMin(GREAT, GREAT, GREAT);
|
||||
point bbMax(-GREAT, -GREAT, -GREAT);
|
||||
|
||||
// find global bounding box
|
||||
globalBackgroundBounds_ = treeBoundBox(boundBox::invertedBox);
|
||||
forAll(allBackgroundMeshBounds_, proci)
|
||||
{
|
||||
bbMin = min(bbMin, allBackgroundMeshBounds_[proci].min());
|
||||
bbMax = max(bbMax, allBackgroundMeshBounds_[proci].max());
|
||||
globalBackgroundBounds_.add(allBackgroundMeshBounds_[proci]);
|
||||
}
|
||||
|
||||
globalBackgroundBounds_ = treeBoundBox(bbMin, bbMax);
|
||||
|
||||
if (false)
|
||||
{
|
||||
OFstream fStr
|
||||
|
||||
@ -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.
|
||||
@ -558,19 +558,11 @@ Foam::label Foam::checkTopology
|
||||
|
||||
if (allGeometry)
|
||||
{
|
||||
const pointField& pts = pp.points();
|
||||
const labelList& mp = pp.meshPoints();
|
||||
|
||||
if (returnReduce(mp.size(), sumOp<label>()) > 0)
|
||||
{
|
||||
boundBox bb(point::max, point::min);
|
||||
forAll(mp, i)
|
||||
{
|
||||
bb.min() = min(bb.min(), pts[mp[i]]);
|
||||
bb.max() = max(bb.max(), pts[mp[i]]);
|
||||
}
|
||||
reduce(bb.min(), minOp<vector>());
|
||||
reduce(bb.max(), maxOp<vector>());
|
||||
boundBox bb(pp.points(), mp, true); // reduce
|
||||
Info<< ' ' << bb;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -336,10 +336,7 @@ boundBox procBounds
|
||||
)
|
||||
);
|
||||
|
||||
boundBox domainBb(points, false);
|
||||
|
||||
bb.min() = min(bb.min(), domainBb.min());
|
||||
bb.max() = max(bb.max(), domainBb.max());
|
||||
bb.add(points);
|
||||
}
|
||||
|
||||
return bb;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
wclean libso vtkPVReaders
|
||||
wclean libso foamPv
|
||||
PVblockMeshReader/Allwclean
|
||||
PVFoamReader/Allwclean
|
||||
|
||||
|
||||
@ -7,32 +7,8 @@ export WM_CONTINUE_ON_ERROR=true
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
#
|
||||
# There are several prerequisites for building plugins
|
||||
#
|
||||
#set -x
|
||||
canBuildPlugin()
|
||||
{
|
||||
[ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] || {
|
||||
echo "==> cannot build ParaView plugins without paraview directory"
|
||||
echo " ParaView_DIR=$ParaView_DIR"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -n "$PV_PLUGIN_PATH" ] || {
|
||||
echo "==> ${PWD##*/} : invalid PV_PLUGIN_PATH for building ParaView plugins"
|
||||
echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-unset}"
|
||||
return 1
|
||||
}
|
||||
|
||||
type cmake > /dev/null 2>&1 || {
|
||||
echo "==> cannot build ParaView plugins without cmake"
|
||||
return 1
|
||||
}
|
||||
|
||||
return 0 # success
|
||||
}
|
||||
|
||||
# Source CMake functions
|
||||
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@ -45,9 +21,9 @@ case "$major" in
|
||||
if canBuildPlugin
|
||||
then
|
||||
(
|
||||
wmake $targetType vtkPVReaders
|
||||
wmakeLibPv foamPv
|
||||
PVblockMeshReader/Allwmake $targetType $*
|
||||
PVFoamReader/Allwmake $targetType $*
|
||||
PVFoamReader/Allwmake $targetType $*
|
||||
|
||||
# Dummy directory to trigger proper 'wclean all' behaviour
|
||||
# - the Allwclean will otherwise not be used
|
||||
|
||||
@ -2,17 +2,15 @@
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Source the wmake functions
|
||||
. $WM_DIR/scripts/wmakeFunctions
|
||||
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
|
||||
|
||||
#set -x
|
||||
|
||||
# deal with client/server vs combined plugins
|
||||
# Cleanup client-server and/or combined plugins
|
||||
rm -f $FOAM_LIBBIN/libPVFoamReader* 2>/dev/null
|
||||
|
||||
rm -rf PVFoamReader/Make # safety: old build location
|
||||
wclean libso vtkPVFoam
|
||||
|
||||
# Where are the generated files stored?
|
||||
# Cleanup generated files
|
||||
findObjectDir $PWD # remove entire top-level
|
||||
rm -rf "$objectsDir" > /dev/null 2>&1
|
||||
|
||||
|
||||
@ -4,49 +4,18 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
# Source the wmake functions
|
||||
. $WM_DIR/scripts/wmakeFunctions
|
||||
|
||||
# Ensure CMake gets the correct C/C++ compilers
|
||||
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
||||
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
||||
|
||||
|
||||
# CMake into objectsDir,
|
||||
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
|
||||
doCmake()
|
||||
{
|
||||
local sourceDir="$1"
|
||||
|
||||
findObjectDir $sourceDir # Where are generated files stored?
|
||||
test -f "$objectsDir/CMakeCache.txt"
|
||||
retry=$? # CMakeCache.txt exists, but sources may have moved
|
||||
|
||||
mkdir -p $objectsDir && \
|
||||
(
|
||||
cd $objectsDir || exit 1
|
||||
|
||||
cmake $sourceDir || {
|
||||
if [ $retry -eq 0 ]
|
||||
then
|
||||
echo "Removing CMakeCache.txt and attempt again"
|
||||
rm -f CMakeCache.txt
|
||||
cmake $sourceDir
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
} && make
|
||||
)
|
||||
}
|
||||
# Source CMake functions
|
||||
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
if [ -d "$ParaView_DIR" ]
|
||||
then
|
||||
wmake $targetType vtkPVFoam
|
||||
wmakeLibPv vtkPVFoam
|
||||
|
||||
if [ "$targetType" != objects ]
|
||||
then
|
||||
doCmake $PWD/PVFoamReader || {
|
||||
cmakePv $PWD/PVFoamReader || {
|
||||
echo
|
||||
echo " WARNING: incomplete build of ParaView OpenFOAM plugin"
|
||||
echo
|
||||
|
||||
@ -1,84 +1,70 @@
|
||||
# Create a plugin that adds a reader to the ParaView GUI
|
||||
# it is added in the file dialog when doing opens/saves.
|
||||
# Create a plugin to add a reader to the ParaView GUI
|
||||
|
||||
# The qrc file is processed by Qt's resource compiler (rcc)
|
||||
# the qrc file must have a resource prefix of "/ParaViewResources"
|
||||
# and ParaView will read anything contained under that prefix
|
||||
# the pqReader.xml file contains xml defining readers with their
|
||||
# file extensions and descriptions.
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
find_package(ParaView REQUIRED)
|
||||
include(${PARAVIEW_USE_FILE})
|
||||
|
||||
FIND_PACKAGE(ParaView REQUIRED)
|
||||
INCLUDE(${PARAVIEW_USE_FILE})
|
||||
|
||||
LINK_DIRECTORIES(
|
||||
link_directories(
|
||||
$ENV{FOAM_LIBBIN}
|
||||
$ENV{FOAM_EXT_LIBBIN}
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
include_directories(
|
||||
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
|
||||
${PROJECT_SOURCE_DIR}/../vtkPVFoam
|
||||
${PROJECT_SOURCE_DIR}/../../foamPv/lnInclude
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-std=c++0x
|
||||
add_definitions(
|
||||
-std=c++11
|
||||
-DWM_$ENV{WM_PRECISION_OPTION}
|
||||
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
|
||||
)
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
SET(
|
||||
set(
|
||||
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
|
||||
CACHE INTERNAL
|
||||
"Single output directory for building all libraries."
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Defined combined plugin
|
||||
#
|
||||
if (PARAVIEW_QT_VERSION VERSION_GREATER "4")
|
||||
qt5_wrap_cpp(MOC_SRCS
|
||||
pqFoamReaderControls.h
|
||||
)
|
||||
else()
|
||||
qt4_wrap_cpp(MOC_SRCS
|
||||
pqFoamReaderControls.h
|
||||
)
|
||||
endif()
|
||||
|
||||
# Extend the auto-generated panel
|
||||
QT4_WRAP_CPP(MOC_SRCS pqPVFoamReaderPanel.h)
|
||||
|
||||
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
|
||||
CLASS_NAME pqPVFoamReaderPanel
|
||||
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
|
||||
XML_GROUP sources
|
||||
add_paraview_property_group_widget(IFACES0 IFACES0_SRCS
|
||||
TYPE "openfoam_reader_general_controls"
|
||||
CLASS_NAME pqFoamReaderControls
|
||||
)
|
||||
|
||||
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
|
||||
# so check if version < 4.4
|
||||
add_paraview_plugin(
|
||||
PVFoamReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVFoamReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVFoamReader.cxx
|
||||
GUI_INTERFACES
|
||||
${IFACES0}
|
||||
SOURCES
|
||||
${IFACES0_SRCS}
|
||||
${MOC_SRCS}
|
||||
pqFoamReaderControls.cxx
|
||||
)
|
||||
|
||||
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVFoamReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVFoamReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVFoamReader.cxx
|
||||
GUI_INTERFACES ${IFACES}
|
||||
GUI_SOURCES pqPVFoamReaderPanel.cxx
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
GUI_RESOURCE_FILES PVFoamReader.xml
|
||||
)
|
||||
ELSE()
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVFoamReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVFoamReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVFoamReader.cxx
|
||||
GUI_INTERFACES ${IFACES}
|
||||
GUI_SOURCES pqPVFoamReaderPanel.cxx
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
TARGET_LINK_LIBRARIES(
|
||||
target_link_libraries(
|
||||
PVFoamReader_SM
|
||||
LINK_PUBLIC
|
||||
vtkPVFoam
|
||||
vtkPVFoam-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
|
||||
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
|
||||
finiteVolume
|
||||
OpenFOAM
|
||||
)
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/ParaViewResources" >
|
||||
<file>PVFoamReader.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@ -1,7 +0,0 @@
|
||||
<ParaViewReaders>
|
||||
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
|
||||
<Reader name="PVFoamReader"
|
||||
extensions="OpenFOAM"
|
||||
file_description="OpenFOAM Reader">
|
||||
</Reader>
|
||||
</ParaViewReaders>
|
||||
@ -5,14 +5,14 @@
|
||||
class="vtkPVFoamReader">
|
||||
|
||||
<!-- File name - compulsory -->
|
||||
<StringVectorProperty
|
||||
<StringVectorProperty animateable="0"
|
||||
name="FileName"
|
||||
command="SetFileName"
|
||||
number_of_elements="1"
|
||||
animateable="0">
|
||||
panel_visibility="never">
|
||||
<FileListDomain name="files"/>
|
||||
<Documentation>
|
||||
Specifies the filename for the OpenFOAM Reader.
|
||||
The filename for the OpenFOAM reader module.
|
||||
</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
@ -27,163 +27,168 @@
|
||||
</Documentation>
|
||||
</DoubleVectorProperty>
|
||||
|
||||
<!-- Cache Mesh check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiCacheMesh"
|
||||
command="SetCacheMesh"
|
||||
number_of_elements="1"
|
||||
is_internal="1"
|
||||
default_values="1"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Cache the fvMesh in memory.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
<!-- Refresh (push button) -->
|
||||
<Property
|
||||
name="Refresh"
|
||||
command="Refresh"
|
||||
panel_visibility="default">
|
||||
<Documentation>Rescan for updated times/fields.</Documentation>
|
||||
</Property>
|
||||
|
||||
<!-- Refresh button -->
|
||||
<IntVectorProperty
|
||||
name="UiRefresh"
|
||||
command="SetRefresh"
|
||||
number_of_elements="1"
|
||||
is_internal="0"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Rescan for updated timesteps/fields.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
<!-- General Controls -->
|
||||
|
||||
<!-- Skip Zero Time check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiZeroTime"
|
||||
<!-- Skip Zero Time (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="ZeroTime"
|
||||
label="Skip Zero Time"
|
||||
command="SetSkipZeroTime"
|
||||
number_of_elements="1"
|
||||
is_internal="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Skip including the 0/ time directory
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Interpolate Fields check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiInterpolateVolFields"
|
||||
command="SetInterpolateVolFields"
|
||||
number_of_elements="1"
|
||||
is_internal="1"
|
||||
default_values="1"
|
||||
animateable="0">
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Interpolate volume fields into point fields
|
||||
Ignore the 0/ time directory.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Extrapolate Patches check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiExtrapolatePatches"
|
||||
<!-- Include Sets (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="IncludeSets"
|
||||
command="SetIncludeSets"
|
||||
default_values="0"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Search the polyMesh/sets/ directory
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Include Zones (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="IncludeZones"
|
||||
command="SetIncludeZones"
|
||||
default_values="0"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
ZoneMesh information is used to find {cell,face,point}Zones.
|
||||
The polyMesh/ directory is only checked on startup.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Show Groups Only (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="ShowGroupsOnly"
|
||||
label="Groups Only"
|
||||
command="SetShowGroupsOnly"
|
||||
default_values="0"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Show patchGroups only.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Show Patch Names (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="ShowPatchNames"
|
||||
label="Patch Names"
|
||||
command="SetShowPatchNames"
|
||||
default_values="0"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Show patch names in render window.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Interpolate Fields (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="InterpolateFields"
|
||||
command="SetInterpolateVolFields"
|
||||
default_values="1"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Interpolate volFields into pointFields.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Extrapolate Patches (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="ExtrapolatePatches"
|
||||
command="SetExtrapolatePatches"
|
||||
number_of_elements="1"
|
||||
is_internal="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Extrapolate internalField to non-constraint patches
|
||||
Extrapolate internalField to non-constraint patches.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Use VTK Polyhedron check-box -->
|
||||
<IntVectorProperty
|
||||
name="UseVTKPolyhedron"
|
||||
command="SetUseVTKPolyhedron"
|
||||
number_of_elements="1"
|
||||
<!-- Force GUI update (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="UpdateGUI"
|
||||
command="SetUpdateGUI"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Force reader GUI update.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Use VTK Polyhedron (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="UseVTKPolyhedron"
|
||||
label="Use VTK Polyhedron"
|
||||
command="SetUseVTKPolyhedron"
|
||||
default_values="0"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Use vtkPolyhedron instead of decomposing polyhedra.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Include Sets check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiIncludeSets"
|
||||
command="SetIncludeSets"
|
||||
<!-- Cache Mesh (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="CacheMesh"
|
||||
command="SetCacheMesh"
|
||||
default_values="1"
|
||||
number_of_elements="1"
|
||||
is_internal="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<Documentation>
|
||||
Search the polyMesh/sets/ directory
|
||||
</Documentation>
|
||||
<BooleanDomain name="bool"/>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Include Zones check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiIncludeZones"
|
||||
command="SetIncludeZones"
|
||||
number_of_elements="1"
|
||||
is_internal="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<Documentation>
|
||||
ZoneMesh information is used to find {cell,face,point}Zones.
|
||||
The polyMesh/ directory is only checked on startup.
|
||||
</Documentation>
|
||||
<BooleanDomain name="bool"/>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Show Patch Names check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiShowPatchNames"
|
||||
command="SetShowPatchNames"
|
||||
number_of_elements="1"
|
||||
default_values="0"
|
||||
is_internal="1"
|
||||
animateable="0">
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Show patch names in render window
|
||||
Cache the fvMesh in memory.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Show Groups Only check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiShowGroupsOnly"
|
||||
command="SetShowGroupsOnly"
|
||||
number_of_elements="1"
|
||||
default_values="0"
|
||||
is_internal="1"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Show groups only
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
<PropertyGroup
|
||||
label="General Controls"
|
||||
panel_widget="openfoam_reader_general_controls">
|
||||
<Property name="Refresh"/>
|
||||
<Property name="ZeroTime"/>
|
||||
<Property name="IncludeSets"/>
|
||||
<Property name="IncludeZones"/>
|
||||
<Property name="InterpolateFields"/>
|
||||
<Property name="ExtrapolatePatches"/>
|
||||
<Property name="ShowGroupsOnly"/>
|
||||
<Property name="ShowPatchNames"/>
|
||||
<Property name="UpdateGUI"/>
|
||||
<Property name="UseVTKPolyhedron"/>
|
||||
<Property name="CacheMesh"/>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Force GUI update check box -->
|
||||
<IntVectorProperty
|
||||
name="UpdateGUI"
|
||||
command="SetUpdateGUI"
|
||||
number_of_elements="1"
|
||||
is_internal="1"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
A simple way to cause a reader GUI modification.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!--
|
||||
| Selections
|
||||
-->
|
||||
<!-- Parts Selections -->
|
||||
|
||||
<!-- Available Parts (volume, patches, lagrangian) array -->
|
||||
<StringVectorProperty
|
||||
@ -191,7 +196,7 @@
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="Part"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
<StringVectorProperty animateable="0"
|
||||
name="PartStatus"
|
||||
label="Mesh Parts"
|
||||
command="SetPartArrayStatus"
|
||||
@ -199,26 +204,31 @@
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="PartArrayStatus"
|
||||
animateable="0">
|
||||
information_property="PartArrayStatus">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="PartArrayStatus" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
<Documentation>
|
||||
This property contains a list of the mesh parts
|
||||
(patches, groups, sets, zones).
|
||||
The list of mesh parts (patches, groups, sets, zones).
|
||||
</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<PropertyGroup label="Parts">
|
||||
<Property name="PartArrayStatus"/>
|
||||
<Property name="PartStatus"/>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Fields Selections -->
|
||||
|
||||
<!-- Available volFields array -->
|
||||
<StringVectorProperty
|
||||
name="VolFieldArrayStatus"
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="VolField"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
<StringVectorProperty animateable="0"
|
||||
name="VolFieldStatus"
|
||||
label="Volume Fields"
|
||||
command="SetVolFieldArrayStatus"
|
||||
@ -226,16 +236,13 @@
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="VolFieldArrayStatus"
|
||||
animateable="0">
|
||||
information_property="VolFieldArrayStatus">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="VolFieldArrayStatus" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
<Documentation>
|
||||
This property contains a list of the volume fields
|
||||
</Documentation>
|
||||
<Documentation>The list of volume fields.</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- Available Lagrangian fields array -->
|
||||
@ -244,7 +251,7 @@
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="LagrangianField"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
<StringVectorProperty animateable="0"
|
||||
name="LagrangianFieldStatus"
|
||||
label="Lagrangian Fields"
|
||||
command="SetLagrangianFieldArrayStatus"
|
||||
@ -252,16 +259,13 @@
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="LagrangianFieldArrayStatus"
|
||||
animateable="0">
|
||||
information_property="LagrangianFieldArrayStatus">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="LagrangianFieldArrayStatus" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
<Documentation>
|
||||
This property contains a list of the lagrangian fields
|
||||
</Documentation>
|
||||
<Documentation>The list of Lagrangian fields.</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- Available pointFields array -->
|
||||
@ -270,7 +274,7 @@
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="PointField"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
<StringVectorProperty animateable="0"
|
||||
name="PointFieldStatus"
|
||||
label="Point Fields"
|
||||
command="SetPointFieldArrayStatus"
|
||||
@ -278,31 +282,42 @@
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="PointFieldArrayStatus"
|
||||
animateable="0">
|
||||
information_property="PointFieldArrayStatus">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="PointFieldArrayStatus" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
<Documentation>
|
||||
This property contains a list of the point fields
|
||||
</Documentation>
|
||||
<Documentation>The list of point fields.</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<Hints>
|
||||
<Property name="FileName" show="0"/>
|
||||
<Property name="UiCacheMesh" show="0"/>
|
||||
<Property name="UiZeroTime" show="0"/>
|
||||
<Property name="UiRefresh" show="0"/>
|
||||
<Property name="UiShowPatchNames" show="0"/>
|
||||
<Property name="UiShowGroupsOnly" show="0"/>
|
||||
<Property name="UiIncludeSets" show="0"/>
|
||||
<Property name="UiIncludeZones" show="0"/>
|
||||
<ReaderFactory extensions="OpenFOAM"
|
||||
file_description="OpenFOAM"/>
|
||||
</Hints>
|
||||
<PropertyGroup label="Fields">
|
||||
<Property name="VolFieldArrayStatus"/>
|
||||
<Property name="VolFieldStatus"/>
|
||||
<Property name="LagrangianFieldArrayStatus"/>
|
||||
<Property name="LagrangianFieldStatus"/>
|
||||
<Property name="PointFieldArrayStatus"/>
|
||||
<Property name="PointFieldStatus"/>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
|
||||
<!-- Print button -->
|
||||
<Property animateable="0"
|
||||
name="PrintInfo"
|
||||
command="PrintInfo"
|
||||
panel_widget="command_button"
|
||||
panel_visibility="advanced">
|
||||
<Documentation>
|
||||
Print basic information to stdout
|
||||
</Documentation>
|
||||
</Property>
|
||||
|
||||
<Hints>
|
||||
<ReaderFactory
|
||||
extensions="OpenFOAM"
|
||||
file_description="OpenFOAM reader module" />
|
||||
</Hints>
|
||||
|
||||
</SourceProxy>
|
||||
</ProxyGroup>
|
||||
|
||||
@ -0,0 +1,368 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pqFoamReaderControls.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "pqPVApplicationCore.h"
|
||||
#include "pqPipelineRepresentation.h"
|
||||
#include "pqView.h"
|
||||
#include "vtkSMDocumentation.h"
|
||||
#include "vtkSMIntVectorProperty.h"
|
||||
#include "vtkSMPropertyGroup.h"
|
||||
#include "vtkSMSourceProxy.h"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// file-scope
|
||||
static QAbstractButton* setButtonProperties
|
||||
(
|
||||
QAbstractButton* b,
|
||||
vtkSMProperty* prop
|
||||
)
|
||||
{
|
||||
QString tip;
|
||||
|
||||
vtkSMDocumentation* doc = prop->GetDocumentation();
|
||||
if (doc)
|
||||
{
|
||||
const char* txt = doc->GetDescription();
|
||||
if (txt)
|
||||
{
|
||||
tip = QString(txt).simplified();
|
||||
}
|
||||
}
|
||||
|
||||
b->setText(prop->GetXMLLabel());
|
||||
if (tip.size())
|
||||
{
|
||||
b->setToolTip(tip);
|
||||
}
|
||||
b->setFocusPolicy(Qt::NoFocus); // avoid dotted border
|
||||
|
||||
vtkSMIntVectorProperty* intProp =
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop);
|
||||
|
||||
// initial checked state for integer (bool) properties
|
||||
if (intProp)
|
||||
{
|
||||
b->setChecked(intProp->GetElement(0));
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
static vtkSMIntVectorProperty* lookupIntProp
|
||||
(
|
||||
vtkSMPropertyGroup* group,
|
||||
const char* name
|
||||
)
|
||||
{
|
||||
vtkSMProperty* prop = group->GetProperty(name);
|
||||
|
||||
if (prop)
|
||||
{
|
||||
return vtkSMIntVectorProperty::SafeDownCast(prop);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void pqFoamReaderControls::fireCommand
|
||||
(
|
||||
vtkSMIntVectorProperty* prop,
|
||||
bool checked
|
||||
)
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
prop->SetElement(0, checked); // Toogle bool
|
||||
|
||||
// Fire off command
|
||||
prop->Modified();
|
||||
pxy->UpdateProperty(pxy->GetPropertyName(prop));
|
||||
}
|
||||
|
||||
|
||||
void pqFoamReaderControls::updateParts()
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
pxy->UpdatePropertyInformation(pxy->GetProperty("PartArrayStatus"));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void pqFoamReaderControls::refreshPressed()
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
// Fire off command
|
||||
refresh_->Modified();
|
||||
pxy->UpdateProperty(pxy->GetPropertyName(refresh_));
|
||||
|
||||
vtkSMSourceProxy::SafeDownCast(pxy)->UpdatePipeline();
|
||||
|
||||
// Trigger a rendering (all views)
|
||||
pqPVApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
void pqFoamReaderControls::cacheMesh(bool checked)
|
||||
{
|
||||
fireCommand(cacheMesh_, checked);
|
||||
}
|
||||
|
||||
|
||||
void pqFoamReaderControls::showPatchNames(bool checked)
|
||||
{
|
||||
fireCommand(showPatchNames_, checked);
|
||||
|
||||
// update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
}
|
||||
// OR: update all views
|
||||
// pqPVApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
void pqFoamReaderControls::showGroupsOnly(bool checked)
|
||||
{
|
||||
fireCommand(showGroupsOnly_, checked);
|
||||
updateParts();
|
||||
}
|
||||
|
||||
|
||||
void pqFoamReaderControls::includeSets(bool checked)
|
||||
{
|
||||
fireCommand(includeSets_, checked);
|
||||
updateParts();
|
||||
}
|
||||
|
||||
|
||||
void pqFoamReaderControls::includeZones(bool checked)
|
||||
{
|
||||
fireCommand(includeZones_, checked);
|
||||
updateParts();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
pqFoamReaderControls::pqFoamReaderControls
|
||||
(
|
||||
vtkSMProxy* proxy,
|
||||
vtkSMPropertyGroup* group,
|
||||
QWidget* parent
|
||||
)
|
||||
:
|
||||
Superclass(proxy, parent),
|
||||
refresh_(group->GetProperty("Refresh")),
|
||||
showPatchNames_(lookupIntProp(group, "ShowPatchNames")),
|
||||
showGroupsOnly_(lookupIntProp(group, "ShowGroupsOnly")),
|
||||
includeSets_(lookupIntProp(group, "IncludeSets")),
|
||||
includeZones_(lookupIntProp(group, "IncludeZones")),
|
||||
cacheMesh_(lookupIntProp(group, "CacheMesh"))
|
||||
{
|
||||
typedef vtkSMIntVectorProperty intProp;
|
||||
|
||||
QGridLayout* form = new QGridLayout(this);
|
||||
|
||||
// ROW
|
||||
// ~~~
|
||||
int row = 0;
|
||||
|
||||
if (refresh_)
|
||||
{
|
||||
QPushButton* b = new QPushButton(this);
|
||||
setButtonProperties(b, refresh_);
|
||||
form->addWidget(b, row, 0, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed()));
|
||||
}
|
||||
|
||||
intProp* zeroTime = lookupIntProp(group, "ZeroTime");
|
||||
if (zeroTime)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, zeroTime);
|
||||
form->addWidget(b, row, 1, Qt::AlignLeft);
|
||||
|
||||
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), zeroTime);
|
||||
}
|
||||
|
||||
// LINE
|
||||
// ~~~~
|
||||
++row;
|
||||
{
|
||||
QFrame* hline = new QFrame(this);
|
||||
hline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||
form->addWidget(hline, row, 0, 1, 4);
|
||||
}
|
||||
|
||||
// ROW
|
||||
// ~~~
|
||||
++row;
|
||||
|
||||
if (includeSets_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, includeSets_);
|
||||
form->addWidget(b, row, 0, Qt::AlignLeft);
|
||||
|
||||
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), includeSets_);
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(includeSets(bool)));
|
||||
}
|
||||
|
||||
if (showGroupsOnly_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, showGroupsOnly_);
|
||||
form->addWidget(b, row, 1, Qt::AlignLeft);
|
||||
|
||||
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), showGroupsOnly_);
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(showGroupsOnly(bool)));
|
||||
}
|
||||
|
||||
|
||||
// ROW
|
||||
// ~~~
|
||||
++row;
|
||||
|
||||
if (includeZones_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, includeZones_);
|
||||
form->addWidget(b, row, 0, Qt::AlignLeft);
|
||||
|
||||
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), includeZones_);
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(includeZones(bool)));
|
||||
}
|
||||
|
||||
if (showPatchNames_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, showPatchNames_);
|
||||
form->addWidget(b, row, 1, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool)));
|
||||
}
|
||||
|
||||
// LINE
|
||||
// ~~~~
|
||||
++row;
|
||||
{
|
||||
QFrame* hline = new QFrame(this);
|
||||
hline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||
form->addWidget(hline, row, 0, 1, 4);
|
||||
}
|
||||
|
||||
// ROW
|
||||
// ~~~
|
||||
++row;
|
||||
|
||||
intProp* interpolate = lookupIntProp(group, "InterpolateFields");
|
||||
if (interpolate)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, interpolate);
|
||||
form->addWidget(b, row, 0, Qt::AlignLeft);
|
||||
|
||||
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), interpolate);
|
||||
}
|
||||
|
||||
intProp* extrapolate = lookupIntProp(group, "ExtrapolatePatches");
|
||||
if (extrapolate)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, extrapolate);
|
||||
form->addWidget(b, row, 1, Qt::AlignLeft);
|
||||
|
||||
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), extrapolate);
|
||||
}
|
||||
|
||||
// LINE
|
||||
// ~~~~
|
||||
++row;
|
||||
{
|
||||
QFrame* hline = new QFrame(this);
|
||||
hline->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||
form->addWidget(hline, row, 0, 1, 4);
|
||||
}
|
||||
|
||||
// ROW
|
||||
// ~~~
|
||||
++row;
|
||||
|
||||
intProp* updateGui = lookupIntProp(group, "UpdateGUI");
|
||||
if (updateGui)
|
||||
{
|
||||
QPushButton* b = new QPushButton(this);
|
||||
setButtonProperties(b, updateGui);
|
||||
form->addWidget(b, row, 0, Qt::AlignLeft);
|
||||
|
||||
addPropertyLink(b, "checked", SIGNAL(clicked()), updateGui);
|
||||
}
|
||||
|
||||
intProp* usePolyhedron = lookupIntProp(group, "UseVTKPolyhedron");
|
||||
if (usePolyhedron)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, usePolyhedron);
|
||||
form->addWidget(b, row, 1, Qt::AlignLeft);
|
||||
|
||||
addPropertyLink(b, "checked", SIGNAL(toggled(bool)), usePolyhedron);
|
||||
}
|
||||
|
||||
if (cacheMesh_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, cacheMesh_);
|
||||
form->addWidget(b, row, 2, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(cacheMesh(bool)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
pqFoamReaderControls::~pqFoamReaderControls()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,132 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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/>.
|
||||
|
||||
Class
|
||||
pqFoamReaderControls
|
||||
|
||||
Description
|
||||
A custom property group widget for the PVFoamReader.
|
||||
|
||||
SourceFiles
|
||||
pqFoamReaderControls.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef pqFoamReaderControls_h
|
||||
#define pqFoamReaderControls_h
|
||||
|
||||
#include "pqPropertyWidget.h"
|
||||
|
||||
// Forward declarations
|
||||
class vtkSMProperty;
|
||||
class vtkSMIntVectorProperty;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pqFoamReaderControls Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pqFoamReaderControls
|
||||
:
|
||||
public pqPropertyWidget
|
||||
{
|
||||
Q_OBJECT;
|
||||
typedef pqPropertyWidget Superclass;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Refresh (push button)
|
||||
vtkSMProperty* refresh_;
|
||||
|
||||
//- Show Patch Names (bool property)
|
||||
vtkSMIntVectorProperty* showPatchNames_;
|
||||
|
||||
//- Show Groups Only (bool property)
|
||||
vtkSMIntVectorProperty* showGroupsOnly_;
|
||||
|
||||
//- IncludeSets (bool property)
|
||||
vtkSMIntVectorProperty* includeSets_;
|
||||
|
||||
//- IncludeZones (bool property)
|
||||
vtkSMIntVectorProperty* includeZones_;
|
||||
|
||||
//- CacheMesh (bool property)
|
||||
vtkSMIntVectorProperty* cacheMesh_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update property
|
||||
void fireCommand(vtkSMProperty* prop);
|
||||
|
||||
//- Toggle and update bool property
|
||||
void fireCommand(vtkSMIntVectorProperty* prop, bool checked);
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pqFoamReaderControls(const pqFoamReaderControls&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const pqFoamReaderControls&) = delete;
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update "PartArrayStatus" property information
|
||||
void updateParts();
|
||||
|
||||
|
||||
protected slots:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
void refreshPressed();
|
||||
void cacheMesh(bool checked);
|
||||
void showPatchNames(bool checked);
|
||||
void showGroupsOnly(bool checked);
|
||||
void includeSets(bool checked);
|
||||
void includeZones(bool checked);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Construct from components
|
||||
pqFoamReaderControls
|
||||
(
|
||||
vtkSMProxy* proxy,
|
||||
vtkSMPropertyGroup* group,
|
||||
QWidget* parent = nullptr
|
||||
);
|
||||
|
||||
//- Destructor
|
||||
virtual ~pqFoamReaderControls();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,485 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pqPVFoamReaderPanel.h"
|
||||
|
||||
// QT
|
||||
#include <QGridLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QString>
|
||||
#include <QPushButton>
|
||||
#include <QtDebug>
|
||||
|
||||
// Paraview <-> QT UI
|
||||
#include "pqAnimationScene.h"
|
||||
#include "pqApplicationCore.h"
|
||||
#include "pqPipelineRepresentation.h"
|
||||
#include "pqServerManagerModel.h"
|
||||
#include "pqView.h"
|
||||
|
||||
// Paraview Server Manager
|
||||
#include "vtkSMDoubleVectorProperty.h"
|
||||
#include "vtkSMIntVectorProperty.h"
|
||||
#include "vtkSMProperty.h"
|
||||
#include "vtkSMSourceProxy.h"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
pqPVFoamReaderPanel::pqPVFoamReaderPanel
|
||||
(
|
||||
pqProxy *proxy,
|
||||
QWidget *p
|
||||
)
|
||||
:
|
||||
pqAutoGeneratedObjectPanel(proxy, p)
|
||||
{
|
||||
// create first sublayout (at top of the panel)
|
||||
QGridLayout* form = new QGridLayout();
|
||||
this->PanelLayout->addLayout(form, 0, 0, 1, -1);
|
||||
|
||||
// ROW 0
|
||||
// ~~~~~
|
||||
|
||||
vtkSMProperty* prop = 0;
|
||||
|
||||
// refresh button for updating times/fields
|
||||
if ((prop = this->proxy()->GetProperty("UiRefresh")) != 0)
|
||||
{
|
||||
prop->SetImmediateUpdate(1);
|
||||
QPushButton* refresh = new QPushButton("Refresh Times");
|
||||
refresh->setToolTip("Rescan for updated times/fields.");
|
||||
|
||||
form->addWidget(refresh, 0, 0, Qt::AlignLeft);
|
||||
QObject::connect
|
||||
(
|
||||
refresh,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(RefreshPressed())
|
||||
);
|
||||
}
|
||||
|
||||
// checkbox for skip zeroTime
|
||||
if ((prop = this->proxy()->GetProperty("UiZeroTime")) != 0)
|
||||
{
|
||||
// immediate update on the Server Manager side
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
ZeroTime_ = new QCheckBox("Skip Zero Time");
|
||||
ZeroTime_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
ZeroTime_->setToolTip
|
||||
(
|
||||
"Skip including the 0/ time directory."
|
||||
);
|
||||
|
||||
form->addWidget(ZeroTime_, 0, 1, Qt::AlignLeft);
|
||||
connect
|
||||
(
|
||||
ZeroTime_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(ZeroTimeToggled())
|
||||
);
|
||||
}
|
||||
|
||||
// ROW 1
|
||||
// ~~~~~
|
||||
|
||||
QFrame* hline1 = new QFrame(this);
|
||||
hline1->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||
form->addWidget(hline1, 1, 0, 1, 3);
|
||||
|
||||
// ROW 2
|
||||
// ~~~~~
|
||||
|
||||
// checkbox for caching mesh
|
||||
if ((prop = this->proxy()->GetProperty("UiCacheMesh")) != 0)
|
||||
{
|
||||
// immediate update on the Server Manager side
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
CacheMesh_ = new QCheckBox("Cache Mesh");
|
||||
CacheMesh_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
CacheMesh_->setToolTip
|
||||
(
|
||||
"Cache the fvMesh in memory."
|
||||
);
|
||||
|
||||
form->addWidget(CacheMesh_, 2, 0, Qt::AlignLeft);
|
||||
connect
|
||||
(
|
||||
CacheMesh_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(CacheMeshToggled())
|
||||
);
|
||||
}
|
||||
|
||||
// cell 2,1 empty
|
||||
|
||||
// ROW 3
|
||||
// ~~~~~
|
||||
|
||||
// checkbox for include sets
|
||||
if ((prop = this->proxy()->GetProperty("UiIncludeSets")) != 0)
|
||||
{
|
||||
// immediate update on the Server Manager side
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
IncludeSets_ = new QCheckBox("Include Sets");
|
||||
IncludeSets_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
IncludeSets_->setToolTip
|
||||
(
|
||||
"Search the polyMesh/sets/ directory."
|
||||
);
|
||||
|
||||
// row/col 1,0
|
||||
form->addWidget(IncludeSets_, 3, 0, Qt::AlignLeft);
|
||||
connect
|
||||
(
|
||||
IncludeSets_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(IncludeSetsToggled())
|
||||
);
|
||||
}
|
||||
|
||||
// checkbox for Groups Only
|
||||
if ((prop = this->proxy()->GetProperty("UiShowGroupsOnly")) != 0)
|
||||
{
|
||||
// immediate update on the Server Manager side
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
ShowGroupsOnly_ = new QCheckBox("Groups Only");
|
||||
ShowGroupsOnly_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
ShowGroupsOnly_->setToolTip
|
||||
(
|
||||
"Show patchGroups only."
|
||||
);
|
||||
|
||||
// row/col 2, 2
|
||||
form->addWidget(ShowGroupsOnly_, 3, 1, Qt::AlignLeft);
|
||||
connect
|
||||
(
|
||||
ShowGroupsOnly_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(ShowGroupsOnlyToggled())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ROW 4
|
||||
// ~~~~~
|
||||
|
||||
// checkbox for include zones
|
||||
if ((prop = this->proxy()->GetProperty("UiIncludeZones")) != 0)
|
||||
{
|
||||
// immediate update on the Server Manager side
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
IncludeZones_ = new QCheckBox("Include Zones");
|
||||
IncludeZones_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
IncludeZones_->setToolTip
|
||||
(
|
||||
"ZoneMesh information is used to find {cell,face,point}Zones. "
|
||||
"The polyMesh/ directory is only checked on startup."
|
||||
);
|
||||
|
||||
// row/col 1,1
|
||||
form->addWidget(IncludeZones_, 4, 0, Qt::AlignLeft);
|
||||
connect
|
||||
(
|
||||
IncludeZones_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(IncludeZonesToggled())
|
||||
);
|
||||
}
|
||||
|
||||
// checkbox for patch names
|
||||
if ((prop = this->proxy()->GetProperty("UiShowPatchNames")) != 0)
|
||||
{
|
||||
// immediate update on the Server Manager side
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
ShowPatchNames_ = new QCheckBox("Patch Names");
|
||||
ShowPatchNames_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
ShowPatchNames_->setToolTip
|
||||
(
|
||||
"Show patch names in render window."
|
||||
);
|
||||
|
||||
// row/col 0,1
|
||||
form->addWidget(ShowPatchNames_, 4, 1, Qt::AlignLeft);
|
||||
connect
|
||||
(
|
||||
ShowPatchNames_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(ShowPatchNamesToggled())
|
||||
);
|
||||
}
|
||||
|
||||
// ROW 5
|
||||
// ~~~~~
|
||||
|
||||
QFrame* hline2 = new QFrame(this);
|
||||
hline2->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||
form->addWidget(hline2, 5, 0, 1, 3);
|
||||
|
||||
// ROW 6
|
||||
// ~~~~~
|
||||
|
||||
// checkbox for vol field interpolation
|
||||
if ((prop = this->proxy()->GetProperty("UiInterpolateVolFields")) != 0)
|
||||
{
|
||||
// immediate update on the Server Manager side
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
InterpolateVolFields_ = new QCheckBox("Interpolate volFields");
|
||||
InterpolateVolFields_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
InterpolateVolFields_->setToolTip
|
||||
(
|
||||
"Interpolate volFields into pointFields"
|
||||
);
|
||||
|
||||
// row/col 1,1
|
||||
form->addWidget(InterpolateVolFields_, 6, 0, Qt::AlignLeft);
|
||||
connect
|
||||
(
|
||||
InterpolateVolFields_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(InterpolateVolFieldsToggled())
|
||||
);
|
||||
}
|
||||
|
||||
// checkbox for extrapolate patches
|
||||
if ((prop = this->proxy()->GetProperty("UiExtrapolatePatches")) != 0)
|
||||
{
|
||||
// immediate update on the Server Manager side
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
ExtrapolatePatches_ = new QCheckBox("Extrapolate Patches");
|
||||
ExtrapolatePatches_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
ExtrapolatePatches_->setToolTip
|
||||
(
|
||||
"Extrapolate internalField to non-constraint patches"
|
||||
);
|
||||
|
||||
// row/col 1,1
|
||||
form->addWidget(ExtrapolatePatches_, 6, 1, Qt::AlignLeft);
|
||||
connect
|
||||
(
|
||||
ExtrapolatePatches_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(ExtrapolatePatchesToggled())
|
||||
);
|
||||
}
|
||||
|
||||
// ROW 7
|
||||
// ~~~~~
|
||||
|
||||
QFrame* hline3 = new QFrame(this);
|
||||
hline3->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||
form->addWidget(hline3, 7, 0, 1, 3);
|
||||
|
||||
// update GUI button
|
||||
if ((prop = this->proxy()->GetProperty("UpdateGUI")) != 0)
|
||||
{
|
||||
prop->SetImmediateUpdate(1);
|
||||
QPushButton* updateGUI = new QPushButton("Update GUI");
|
||||
updateGUI->setToolTip("Update GUI");
|
||||
|
||||
form->addWidget(updateGUI, 8, 0, Qt::AlignLeft);
|
||||
QObject::connect
|
||||
(
|
||||
updateGUI,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(setModified())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void pqPVFoamReaderPanel::CacheMeshToggled()
|
||||
{
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiCacheMesh")
|
||||
)->SetElement(0, CacheMesh_->isChecked());
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::RefreshPressed()
|
||||
{
|
||||
// update everything
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiRefresh")
|
||||
)->Modified();
|
||||
|
||||
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
|
||||
|
||||
// render all views
|
||||
pqApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::ZeroTimeToggled()
|
||||
{
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiZeroTime")
|
||||
)->SetElement(0, ZeroTime_->isChecked());
|
||||
|
||||
this->setModified();
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::ShowPatchNamesToggled()
|
||||
{
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiShowPatchNames")
|
||||
)->SetElement(0, ShowPatchNames_->isChecked());
|
||||
|
||||
// update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
}
|
||||
// OR: update all views
|
||||
// pqApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::ShowGroupsOnlyToggled()
|
||||
{
|
||||
vtkSMProperty* prop;
|
||||
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiShowGroupsOnly")
|
||||
)->SetElement(0, ShowGroupsOnly_->isChecked());
|
||||
|
||||
if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0)
|
||||
{
|
||||
this->proxy()->UpdatePropertyInformation(prop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::IncludeSetsToggled()
|
||||
{
|
||||
vtkSMProperty* prop;
|
||||
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiIncludeSets")
|
||||
)->SetElement(0, IncludeSets_->isChecked());
|
||||
|
||||
if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0)
|
||||
{
|
||||
this->proxy()->UpdatePropertyInformation(prop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::IncludeZonesToggled()
|
||||
{
|
||||
vtkSMProperty* prop;
|
||||
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiIncludeZones")
|
||||
)->SetElement(0, IncludeZones_->isChecked());
|
||||
|
||||
if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0)
|
||||
{
|
||||
this->proxy()->UpdatePropertyInformation(prop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::ExtrapolatePatchesToggled()
|
||||
{
|
||||
vtkSMProperty* prop;
|
||||
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiExtrapolatePatches")
|
||||
)->SetElement(0, ExtrapolatePatches_->isChecked());
|
||||
|
||||
this->setModified();
|
||||
}
|
||||
|
||||
|
||||
void pqPVFoamReaderPanel::InterpolateVolFieldsToggled()
|
||||
{
|
||||
vtkSMProperty* prop;
|
||||
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiInterpolateVolFields")
|
||||
)->SetElement(0, InterpolateVolFields_->isChecked());
|
||||
|
||||
this->setModified();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,116 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Class
|
||||
pqPVFoamReaderPanel
|
||||
|
||||
Description
|
||||
GUI modifications for the ParaView reader panel
|
||||
|
||||
A custom panel for the PVFoamReader.
|
||||
|
||||
SourceFiles
|
||||
pqPVFoamReaderPanel.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef pqPVFoamReaderPanel_h
|
||||
#define pqPVFoamReaderPanel_h
|
||||
|
||||
|
||||
#include "pqAutoGeneratedObjectPanel.h"
|
||||
|
||||
// Forward declaration of QT classes
|
||||
|
||||
class QCheckBox;
|
||||
class QLineEdit;
|
||||
class QTimer;
|
||||
class QToolButton;
|
||||
|
||||
// Forward declaration of ParaView classes
|
||||
class vtkSMSourceProxy;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pqPVFoamReaderPanel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pqPVFoamReaderPanel
|
||||
:
|
||||
public pqAutoGeneratedObjectPanel
|
||||
{
|
||||
// Private data
|
||||
Q_OBJECT;
|
||||
typedef pqAutoGeneratedObjectPanel Superclass;
|
||||
|
||||
//- ZeroTime checkbox
|
||||
QCheckBox* ZeroTime_;
|
||||
|
||||
//- CacheMesh checkbox
|
||||
QCheckBox* CacheMesh_;
|
||||
|
||||
//- Show Patch Names checkbox
|
||||
QCheckBox* ShowPatchNames_;
|
||||
|
||||
//- Show Groups Only checkbox
|
||||
QCheckBox* ShowGroupsOnly_;
|
||||
|
||||
//- IncludeSets checkbox
|
||||
QCheckBox* IncludeSets_;
|
||||
|
||||
//- IncludeZones checkbox
|
||||
QCheckBox* IncludeZones_;
|
||||
|
||||
//- InterpolateVolFields checkbox
|
||||
QCheckBox* InterpolateVolFields_;
|
||||
|
||||
//- ExtrapolatePatches checkbox
|
||||
QCheckBox* ExtrapolatePatches_;
|
||||
|
||||
|
||||
protected slots:
|
||||
|
||||
void CacheMeshToggled();
|
||||
void ZeroTimeToggled();
|
||||
void RefreshPressed();
|
||||
void ShowPatchNamesToggled();
|
||||
void ShowGroupsOnlyToggled();
|
||||
void IncludeSetsToggled();
|
||||
void IncludeZonesToggled();
|
||||
void InterpolateVolFieldsToggled();
|
||||
void ExtrapolatePatchesToggled();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
pqPVFoamReaderPanel(pqProxy*, QWidget*);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -33,6 +33,7 @@ License
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkInformation.h"
|
||||
#include "vtkInformationVector.h"
|
||||
#include "vtkInformationDoubleVectorKey.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkObjectFactory.h"
|
||||
#include "vtkSMRenderViewProxy.h"
|
||||
@ -42,6 +43,9 @@ License
|
||||
// OpenFOAM includes
|
||||
#include "vtkPVFoam.H"
|
||||
|
||||
// STL includes
|
||||
#include <vector>
|
||||
|
||||
#undef EXPERIMENTAL_TIME_CACHING
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -58,10 +62,9 @@ vtkPVFoamReader::vtkPVFoamReader()
|
||||
|
||||
SetNumberOfInputPorts(0);
|
||||
|
||||
FileName = nullptr;
|
||||
foamData_ = nullptr;
|
||||
|
||||
output0_ = nullptr;
|
||||
FileName = nullptr;
|
||||
backend_ = nullptr;
|
||||
output0_ = nullptr;
|
||||
|
||||
#ifdef VTKPVFOAM_DUALPORT
|
||||
// Add second output for the Lagrangian
|
||||
@ -76,19 +79,18 @@ vtkPVFoamReader::vtkPVFoamReader()
|
||||
TimeStepRange[0] = 0;
|
||||
TimeStepRange[1] = 0;
|
||||
|
||||
CacheMesh = 1;
|
||||
Refresh = 0;
|
||||
CacheMesh = true;
|
||||
|
||||
SkipZeroTime = 0;
|
||||
ExtrapolatePatches = 0;
|
||||
UseVTKPolyhedron = 0;
|
||||
IncludeSets = 0;
|
||||
IncludeZones = 0;
|
||||
ShowPatchNames = 0;
|
||||
ShowGroupsOnly = 0;
|
||||
InterpolateVolFields = 1;
|
||||
SkipZeroTime = false;
|
||||
ExtrapolatePatches = false;
|
||||
UseVTKPolyhedron = false;
|
||||
IncludeSets = false;
|
||||
IncludeZones = false;
|
||||
ShowPatchNames = false;
|
||||
ShowGroupsOnly = false;
|
||||
InterpolateVolFields = true;
|
||||
|
||||
UpdateGUI = 0;
|
||||
UpdateGUI = false;
|
||||
|
||||
PartSelection = vtkDataArraySelection::New();
|
||||
VolFieldSelection = vtkDataArraySelection::New();
|
||||
@ -133,11 +135,13 @@ vtkPVFoamReader::~vtkPVFoamReader()
|
||||
{
|
||||
vtkDebugMacro(<<"Deconstructor");
|
||||
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
// remove patch names
|
||||
// Remove text actors
|
||||
updatePatchNamesView(false);
|
||||
delete foamData_;
|
||||
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
}
|
||||
|
||||
if (FileName)
|
||||
@ -151,10 +155,10 @@ vtkPVFoamReader::~vtkPVFoamReader()
|
||||
}
|
||||
|
||||
|
||||
PartSelection->RemoveObserver(this->SelectionObserver);
|
||||
VolFieldSelection->RemoveObserver(this->SelectionObserver);
|
||||
PointFieldSelection->RemoveObserver(this->SelectionObserver);
|
||||
LagrangianFieldSelection->RemoveObserver(this->SelectionObserver);
|
||||
PartSelection->RemoveAllObservers();
|
||||
VolFieldSelection->RemoveAllObservers();
|
||||
PointFieldSelection->RemoveAllObservers();
|
||||
LagrangianFieldSelection->RemoveAllObservers();
|
||||
|
||||
SelectionObserver->Delete();
|
||||
|
||||
@ -188,7 +192,7 @@ int vtkPVFoamReader::RequestInformation
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
const int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPVFoam::debug)
|
||||
{
|
||||
@ -199,60 +203,70 @@ int vtkPVFoamReader::RequestInformation
|
||||
}
|
||||
}
|
||||
|
||||
if (!foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
foamData_ = new Foam::vtkPVFoam(FileName, this);
|
||||
backend_->updateInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_ = new Foam::vtkPVFoam(FileName, this);
|
||||
}
|
||||
|
||||
int nTimeSteps = 0;
|
||||
double* timeSteps = foamData_->findTimes(nTimeSteps);
|
||||
std::vector<double> times = backend_->findTimes(this->SkipZeroTime);
|
||||
|
||||
if (!nTimeSteps)
|
||||
if (times.empty())
|
||||
{
|
||||
vtkErrorMacro("could not find valid OpenFOAM mesh");
|
||||
|
||||
// delete foamData and flag it as fatal error
|
||||
delete foamData_;
|
||||
foamData_ = nullptr;
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// set identical time steps for all ports
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Set
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
||||
|
||||
outInfo->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
|
||||
timeSteps,
|
||||
nTimeSteps
|
||||
times.data(),
|
||||
static_cast<int>(times.size())
|
||||
);
|
||||
|
||||
// Something like this may be useful:
|
||||
// outInfo->Set
|
||||
// (
|
||||
// vtkStreamingDemandDrivenPipeline::TIME_DEPENDENT_INFORMATION(),
|
||||
// 1
|
||||
// );
|
||||
}
|
||||
|
||||
if (nTimeSteps)
|
||||
if (times.size())
|
||||
{
|
||||
double timeRange[2];
|
||||
timeRange[0] = timeSteps[0];
|
||||
timeRange[1] = timeSteps[nTimeSteps-1];
|
||||
double timeRange[2]{ times.front(), times.back() };
|
||||
|
||||
if (Foam::vtkPVFoam::debug > 1)
|
||||
{
|
||||
cout<<"nTimeSteps " << nTimeSteps << "\n"
|
||||
<<"timeRange " << timeRange[0] << " to " << timeRange[1]
|
||||
<< "\n";
|
||||
cout
|
||||
<<"nInfo " << nInfo << "\n"
|
||||
<<"time-range " << times.front() << ':' << times.back() << "\n"
|
||||
<<"times " << times.size() << "(";
|
||||
|
||||
for (int timeI = 0; timeI < nTimeSteps; ++timeI)
|
||||
for (const double& val : times)
|
||||
{
|
||||
cout<< "step[" << timeI << "] = " << timeSteps[timeI] << "\n";
|
||||
cout<< ' ' << val;
|
||||
}
|
||||
cout << " )" << std::endl;
|
||||
}
|
||||
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Set
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
||||
|
||||
outInfo->Set
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
|
||||
timeRange,
|
||||
@ -261,8 +275,6 @@ int vtkPVFoamReader::RequestInformation
|
||||
}
|
||||
}
|
||||
|
||||
delete timeSteps;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -282,15 +294,14 @@ int vtkPVFoamReader::RequestData
|
||||
vtkErrorMacro("FileName has to be specified!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// catch previous error
|
||||
if (!foamData_)
|
||||
if (!backend_)
|
||||
{
|
||||
// catch some previous error
|
||||
vtkErrorMacro("Reader failed - perhaps no mesh?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
const int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPVFoam::debug)
|
||||
{
|
||||
@ -315,23 +326,31 @@ int vtkPVFoamReader::RequestData
|
||||
{
|
||||
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
||||
|
||||
int nsteps = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
|
||||
|
||||
if
|
||||
(
|
||||
outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())
|
||||
&& outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS()) > 0
|
||||
&& nsteps > 0
|
||||
)
|
||||
{
|
||||
requestTime[nRequestTime++] =
|
||||
outInfo->Get
|
||||
(
|
||||
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()
|
||||
);
|
||||
requestTime[nRequestTime] =
|
||||
(
|
||||
1 == nsteps
|
||||
// Only one time-step available, UPDATE_TIME_STEP is unreliable
|
||||
? outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), 0)
|
||||
: outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())
|
||||
);
|
||||
|
||||
// outInfo->Set(vtkDataObject::DATA_TIME_STEP(), requestTime[nRequestTime]);
|
||||
// this->SetTimeValue(requestedTimeValue);
|
||||
++nRequestTime;
|
||||
}
|
||||
}
|
||||
|
||||
if (nRequestTime)
|
||||
{
|
||||
foamData_->setTime(nRequestTime, requestTime);
|
||||
backend_->setTime(nRequestTime, requestTime);
|
||||
}
|
||||
|
||||
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
|
||||
@ -362,7 +381,7 @@ int vtkPVFoamReader::RequestData
|
||||
// but trashes the fields and still triggers the GeometryFilter
|
||||
if (needsUpdate)
|
||||
{
|
||||
foamData_->Update(output);
|
||||
backend_->Update(output);
|
||||
output0_->ShallowCopy(output);
|
||||
}
|
||||
else
|
||||
@ -391,7 +410,7 @@ int vtkPVFoamReader::RequestData
|
||||
#else
|
||||
|
||||
#ifdef VTKPVFOAM_DUALPORT
|
||||
foamData_->Update
|
||||
backend_->Update
|
||||
(
|
||||
output,
|
||||
vtkMultiBlockDataSet::SafeDownCast
|
||||
@ -403,7 +422,7 @@ int vtkPVFoamReader::RequestData
|
||||
);
|
||||
);
|
||||
#else
|
||||
foamData_->Update(output, output);
|
||||
backend_->Update(output, output);
|
||||
#endif
|
||||
|
||||
updatePatchNamesView(ShowPatchNames);
|
||||
@ -411,45 +430,60 @@ int vtkPVFoamReader::RequestData
|
||||
#endif
|
||||
|
||||
// Do any cleanup on the OpenFOAM side
|
||||
foamData_->CleanUp();
|
||||
backend_->CleanUp();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetRefresh(int val)
|
||||
void vtkPVFoamReader::PrintInfo()
|
||||
{
|
||||
if (backend_)
|
||||
{
|
||||
backend_->printInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout
|
||||
<<"OpenFOAM reader not initialized\n"
|
||||
<< std::flush;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::Refresh()
|
||||
{
|
||||
Modified();
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetIncludeSets(int val)
|
||||
void vtkPVFoamReader::SetIncludeSets(bool val)
|
||||
{
|
||||
if (IncludeSets != val)
|
||||
{
|
||||
IncludeSets = val;
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_->updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetIncludeZones(int val)
|
||||
void vtkPVFoamReader::SetIncludeZones(bool val)
|
||||
{
|
||||
if (IncludeZones != val)
|
||||
{
|
||||
IncludeZones = val;
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_->updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetShowPatchNames(int val)
|
||||
void vtkPVFoamReader::SetShowPatchNames(bool val)
|
||||
{
|
||||
if (ShowPatchNames != val)
|
||||
{
|
||||
@ -459,14 +493,14 @@ void vtkPVFoamReader::SetShowPatchNames(int val)
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetShowGroupsOnly(int val)
|
||||
void vtkPVFoamReader::SetShowGroupsOnly(bool val)
|
||||
{
|
||||
if (ShowGroupsOnly != val)
|
||||
{
|
||||
ShowGroupsOnly = val;
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_->updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -485,7 +519,7 @@ void vtkPVFoamReader::updatePatchNamesView(const bool show)
|
||||
// Server manager model for querying items in the server manager
|
||||
pqServerManagerModel* smModel = appCore->getServerManagerModel();
|
||||
|
||||
if (!smModel || !foamData_)
|
||||
if (!smModel || !backend_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -495,14 +529,14 @@ void vtkPVFoamReader::updatePatchNamesView(const bool show)
|
||||
|
||||
for (int viewI=0; viewI < renderViews.size(); ++viewI)
|
||||
{
|
||||
foamData_->renderPatchNames
|
||||
backend_->renderPatchNames
|
||||
(
|
||||
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
|
||||
show
|
||||
);
|
||||
}
|
||||
|
||||
// use refresh here?
|
||||
// Use refresh here?
|
||||
}
|
||||
|
||||
|
||||
@ -514,7 +548,7 @@ void vtkPVFoamReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
os << indent << "File name: "
|
||||
<< (this->FileName ? this->FileName : "(none)") << "\n";
|
||||
|
||||
foamData_->PrintSelf(os, indent);
|
||||
backend_->PrintSelf(os, indent);
|
||||
|
||||
os << indent << "Time step range: "
|
||||
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1] << "\n"
|
||||
@ -524,7 +558,7 @@ void vtkPVFoamReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
|
||||
int vtkPVFoamReader::GetTimeStep()
|
||||
{
|
||||
return foamData_ ? foamData_->timeIndex() : -1;
|
||||
return backend_ ? backend_->timeIndex() : -1;
|
||||
}
|
||||
|
||||
|
||||
@ -533,32 +567,24 @@ int vtkPVFoamReader::GetTimeStep()
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetPartSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartSelection");
|
||||
return PartSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfPartArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfPartArrays");
|
||||
return PartSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetPartArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartArrayName");
|
||||
return PartSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetPartArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPartArrayStatus");
|
||||
return PartSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetPartArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro("Set mesh part \"" << name << "\" status to: " << status);
|
||||
@ -579,35 +605,26 @@ void vtkPVFoamReader::SetPartArrayStatus(const char* name, int status)
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetVolFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldSelection");
|
||||
return VolFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfVolFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfVolFieldArrays");
|
||||
return VolFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetVolFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldArrayName");
|
||||
return VolFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetVolFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetVolFieldArrayStatus");
|
||||
return VolFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro(<<"SetVolFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
VolFieldSelection->EnableArray(name);
|
||||
@ -624,35 +641,26 @@ void vtkPVFoamReader::SetVolFieldArrayStatus(const char* name, int status)
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetPointFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldSelection");
|
||||
return PointFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfPointFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfPointFieldArrays");
|
||||
return PointFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetPointFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldArrayName");
|
||||
return PointFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetPointFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetPointFieldArrayStatus");
|
||||
return PointFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status)
|
||||
{
|
||||
vtkDebugMacro(<<"SetPointFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
PointFieldSelection->EnableArray(name);
|
||||
@ -669,39 +677,30 @@ void vtkPVFoamReader::SetPointFieldArrayStatus(const char* name, int status)
|
||||
|
||||
vtkDataArraySelection* vtkPVFoamReader::GetLagrangianFieldSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldSelection");
|
||||
return LagrangianFieldSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetNumberOfLagrangianFieldArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfLagrangianFieldArrays");
|
||||
return LagrangianFieldSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVFoamReader::GetLagrangianFieldArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldArrayName");
|
||||
return LagrangianFieldSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVFoamReader::GetLagrangianFieldArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
|
||||
return LagrangianFieldSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVFoamReader::SetLagrangianFieldArrayStatus
|
||||
(
|
||||
const char* name,
|
||||
int status
|
||||
)
|
||||
{
|
||||
vtkDebugMacro(<<"SetLagrangianFieldArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
LagrangianFieldSelection->EnableArray(name);
|
||||
|
||||
@ -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.
|
||||
@ -77,59 +77,63 @@ public:
|
||||
vtkSetStringMacro(FileName);
|
||||
vtkGetStringMacro(FileName);
|
||||
|
||||
// Description:
|
||||
// Print some case information
|
||||
virtual void PrintInfo();
|
||||
|
||||
// Description:
|
||||
// OpenFOAM mesh caching control
|
||||
vtkSetMacro(CacheMesh, int);
|
||||
vtkGetMacro(CacheMesh, int);
|
||||
vtkSetMacro(CacheMesh, bool);
|
||||
vtkGetMacro(CacheMesh, bool);
|
||||
|
||||
// Description:
|
||||
// OpenFOAM refresh times/fields
|
||||
virtual void SetRefresh(int);
|
||||
virtual void Refresh();
|
||||
|
||||
// Description:
|
||||
// OpenFOAM skip/include the 0/ time directory
|
||||
vtkSetMacro(SkipZeroTime, int);
|
||||
vtkGetMacro(SkipZeroTime, int);
|
||||
vtkSetMacro(SkipZeroTime, bool);
|
||||
vtkGetMacro(SkipZeroTime, bool);
|
||||
|
||||
// Description:
|
||||
// GUI update control
|
||||
vtkSetMacro(UpdateGUI, int);
|
||||
vtkGetMacro(UpdateGUI, int);
|
||||
vtkSetMacro(UpdateGUI, bool);
|
||||
vtkGetMacro(UpdateGUI, bool);
|
||||
|
||||
// Description:
|
||||
// OpenFOAM extrapolate internal values onto the patches
|
||||
vtkSetMacro(ExtrapolatePatches, int);
|
||||
vtkGetMacro(ExtrapolatePatches, int);
|
||||
vtkSetMacro(ExtrapolatePatches, bool);
|
||||
vtkGetMacro(ExtrapolatePatches, bool);
|
||||
|
||||
// Description:
|
||||
// OpenFOAM use vtkPolyhedron instead of decomposing polyhedra
|
||||
vtkSetMacro(UseVTKPolyhedron, int);
|
||||
vtkGetMacro(UseVTKPolyhedron, int);
|
||||
vtkSetMacro(UseVTKPolyhedron, bool);
|
||||
vtkGetMacro(UseVTKPolyhedron, bool);
|
||||
|
||||
// Description:
|
||||
// OpenFOAM read sets control
|
||||
virtual void SetIncludeSets(int);
|
||||
vtkGetMacro(IncludeSets, int);
|
||||
virtual void SetIncludeSets(bool);
|
||||
vtkGetMacro(IncludeSets, bool);
|
||||
|
||||
// Description:
|
||||
// OpenFOAM read zones control
|
||||
virtual void SetIncludeZones(int);
|
||||
vtkGetMacro(IncludeZones, int);
|
||||
virtual void SetIncludeZones(bool);
|
||||
vtkGetMacro(IncludeZones, bool);
|
||||
|
||||
// Description:
|
||||
// OpenFOAM display patch names control
|
||||
virtual void SetShowPatchNames(int);
|
||||
vtkGetMacro(ShowPatchNames, int);
|
||||
virtual void SetShowPatchNames(bool);
|
||||
vtkGetMacro(ShowPatchNames, bool);
|
||||
|
||||
// Description:
|
||||
// OpenFOAM display patchGroups
|
||||
virtual void SetShowGroupsOnly(int);
|
||||
vtkGetMacro(ShowGroupsOnly, int);
|
||||
virtual void SetShowGroupsOnly(bool);
|
||||
vtkGetMacro(ShowGroupsOnly, bool);
|
||||
|
||||
// Description:
|
||||
// OpenFOAM volField interpolation
|
||||
vtkSetMacro(InterpolateVolFields, int);
|
||||
vtkGetMacro(InterpolateVolFields, int);
|
||||
vtkSetMacro(InterpolateVolFields, bool);
|
||||
vtkGetMacro(InterpolateVolFields, bool);
|
||||
|
||||
// Description:
|
||||
// Get the current timestep
|
||||
@ -218,29 +222,28 @@ protected:
|
||||
private:
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkPVFoamReader(const vtkPVFoamReader&);
|
||||
vtkPVFoamReader(const vtkPVFoamReader&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPVFoamReader&);
|
||||
void operator=(const vtkPVFoamReader&) = delete;
|
||||
|
||||
//- Add/remove patch names to/from the view
|
||||
void updatePatchNamesView(const bool show);
|
||||
|
||||
int TimeStepRange[2];
|
||||
int Refresh;
|
||||
int CacheMesh;
|
||||
int SkipZeroTime;
|
||||
bool CacheMesh;
|
||||
bool SkipZeroTime;
|
||||
|
||||
int ExtrapolatePatches;
|
||||
int UseVTKPolyhedron;
|
||||
int IncludeSets;
|
||||
int IncludeZones;
|
||||
int ShowPatchNames;
|
||||
int ShowGroupsOnly;
|
||||
int InterpolateVolFields;
|
||||
bool ExtrapolatePatches;
|
||||
bool UseVTKPolyhedron;
|
||||
bool IncludeSets;
|
||||
bool IncludeZones;
|
||||
bool ShowPatchNames;
|
||||
bool ShowGroupsOnly;
|
||||
bool InterpolateVolFields;
|
||||
|
||||
//- Dummy variable/switch to invoke a reader update
|
||||
int UpdateGUI;
|
||||
bool UpdateGUI;
|
||||
|
||||
vtkDataArraySelection* PartSelection;
|
||||
vtkDataArraySelection* VolFieldSelection;
|
||||
@ -250,9 +253,8 @@ private:
|
||||
//- Cached data for output port0 (experimental!)
|
||||
vtkMultiBlockDataSet* output0_;
|
||||
|
||||
//BTX
|
||||
Foam::vtkPVFoam* foamData_;
|
||||
//ETX
|
||||
//- Backend portion of the reader
|
||||
Foam::vtkPVFoam* backend_;
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,10 +2,7 @@ vtkPVFoam.C
|
||||
vtkPVFoamFields.C
|
||||
vtkPVFoamMesh.C
|
||||
vtkPVFoamMeshLagrangian.C
|
||||
vtkPVFoamMeshSet.C
|
||||
vtkPVFoamMeshVolume.C
|
||||
vtkPVFoamMeshZone.C
|
||||
vtkPVFoamUpdateInfo.C
|
||||
vtkPVFoamUtils.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVFoam
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVFoam-pv${ParaView_MAJOR}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
sinclude $(GENERAL_RULES)/paraview
|
||||
|
||||
EXE_INC = \
|
||||
${c++LESSWARN} \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
@ -8,7 +10,7 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/conversion/lnInclude \
|
||||
-I$(ParaView_INCLUDE_DIR) \
|
||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
|
||||
-I../../vtkPVReaders/lnInclude \
|
||||
-I../../foamPv/lnInclude \
|
||||
-I../PVFoamReader
|
||||
|
||||
LIB_LIBS = \
|
||||
@ -16,5 +18,5 @@ LIB_LIBS = \
|
||||
-lconversion \
|
||||
-lgenericPatchFields \
|
||||
-llagrangian \
|
||||
-L$(FOAM_LIBBIN) -lvtkPVReaders \
|
||||
-L$(FOAM_LIBBIN) -lfoamPv-pv${ParaView_MAJOR} \
|
||||
$(GLIBS)
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkOpenFOAMPoints_H
|
||||
#define vtkOpenFOAMPoints_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPoints.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline void vtkInsertNextOpenFOAMPoint
|
||||
(
|
||||
vtkPoints *points,
|
||||
const Foam::point& p
|
||||
)
|
||||
{
|
||||
points->InsertNextPoint(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
#if 0
|
||||
// this should be faster, but didn't get it working ...
|
||||
inline void vtkSetOpenFOAMPoint
|
||||
(
|
||||
vtkPoints *points,
|
||||
const Foam::label id,
|
||||
const Foam::point& p
|
||||
)
|
||||
{
|
||||
points->SetPoint(id, p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
|
||||
// Convert OpenFOAM mesh vertices to VTK
|
||||
inline vtkPoints* vtkSetOpenFOAMPoints(const Foam::pointField& points)
|
||||
{
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->SetNumberOfPoints(points.size());
|
||||
forAll(points, i)
|
||||
{
|
||||
const Foam::point& p = points[i];
|
||||
vtkpoints->SetPoint(i, p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
return vtkpoints;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -42,15 +42,40 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(vtkPVFoam, 0);
|
||||
defineTypeNameAndDebug(vtkPVFoam, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
vtkTextActor* Foam::vtkPVFoam::createTextActor
|
||||
(
|
||||
const string& s,
|
||||
const point& pt
|
||||
)
|
||||
{
|
||||
vtkTextActor* txt = vtkTextActor::New();
|
||||
txt->SetInput(s.c_str());
|
||||
|
||||
// Set text properties
|
||||
vtkTextProperty* tprop = txt->GetTextProperty();
|
||||
tprop->SetFontFamilyToArial();
|
||||
tprop->BoldOn();
|
||||
tprop->ShadowOff();
|
||||
tprop->SetLineSpacing(1.0);
|
||||
tprop->SetFontSize(14);
|
||||
tprop->SetColor(1.0, 0.0, 1.0);
|
||||
tprop->SetJustificationToCentered();
|
||||
|
||||
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
|
||||
txt->GetPositionCoordinate()->SetValue(pt.x(), pt.y(), pt.z());
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPVFoamAddToSelection.H"
|
||||
#include "vtkPVFoamUpdateInfoFields.H"
|
||||
|
||||
void Foam::vtkPVFoam::resetCounters()
|
||||
{
|
||||
// Reset array range information (ids and sizes)
|
||||
@ -116,14 +141,10 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::setTime(";
|
||||
Info<< "<beg> setTime(";
|
||||
for (int requestI = 0; requestI < nRequest; ++requestI)
|
||||
{
|
||||
if (requestI)
|
||||
{
|
||||
Info<< ", ";
|
||||
}
|
||||
|
||||
if (requestI) Info<< ", ";
|
||||
Info<< requestTimes[requestI];
|
||||
}
|
||||
Info<< ") - previousIndex = " << timeIndex_
|
||||
@ -160,7 +181,7 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::setTime() - selectedTime="
|
||||
Info<< "<end> setTime() - selectedTime="
|
||||
<< Times[nearestIndex].name() << " index=" << timeIndex_
|
||||
<< "/" << Times.size()
|
||||
<< " meshChanged=" << Switch(meshChanged_)
|
||||
@ -175,7 +196,7 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateMeshPartsStatus" << endl;
|
||||
Info<< "<beg> updateMeshPartsStatus" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection* selection = reader_->GetPartSelection();
|
||||
@ -203,7 +224,7 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
|
||||
meshChanged_ = true;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
if (debug > 1)
|
||||
{
|
||||
Info<< " part[" << partId << "] = "
|
||||
<< partStatus_[partId]
|
||||
@ -212,11 +233,17 @@ void Foam::vtkPVFoam::updateMeshPartsStatus()
|
||||
}
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::updateMeshPartsStatus" << endl;
|
||||
Info<< "<end> updateMeshPartsStatus" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::vtkPVFoam::getPartName(const int partId)
|
||||
{
|
||||
return getFirstWord(reader_->GetPartArrayName(partId));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vtkPVFoam::vtkPVFoam
|
||||
@ -245,7 +272,7 @@ Foam::vtkPVFoam::vtkPVFoam
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Foam::vtkPVFoam::vtkPVFoam - " << FileName << endl;
|
||||
Info<< "vtkPVFoam - " << FileName << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -333,7 +360,7 @@ Foam::vtkPVFoam::~vtkPVFoam()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::~vtkPVFoam" << endl;
|
||||
Info<< "~vtkPVFoam" << endl;
|
||||
}
|
||||
|
||||
delete meshPtr_;
|
||||
@ -346,7 +373,7 @@ void Foam::vtkPVFoam::updateInfo()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfo"
|
||||
Info<< "<beg> updateInfo"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] timeIndex="
|
||||
<< timeIndex_ << endl;
|
||||
}
|
||||
@ -363,16 +390,15 @@ void Foam::vtkPVFoam::updateInfo()
|
||||
// time of the vtkDataArraySelection, but the qt/paraview proxy
|
||||
// layer doesn't care about that anyhow.
|
||||
|
||||
// enable 'internalMesh' on the first call
|
||||
// or preserve the enabled selections
|
||||
stringList enabledEntries;
|
||||
if (!partSelection->GetNumberOfArrays() && !meshPtr_)
|
||||
{
|
||||
enabledEntries.setSize(1);
|
||||
enabledEntries[0] = "internalMesh";
|
||||
// enable 'internalMesh' on the first call
|
||||
enabledEntries = { "internalMesh" };
|
||||
}
|
||||
else
|
||||
{
|
||||
// preserve the enabled selections
|
||||
enabledEntries = getSelectedArrayEntries(partSelection);
|
||||
}
|
||||
|
||||
@ -395,23 +421,12 @@ void Foam::vtkPVFoam::updateInfo()
|
||||
}
|
||||
|
||||
// Update volume, point and lagrangian fields
|
||||
updateInfoFields<fvPatchField, volMesh>
|
||||
(
|
||||
reader_->GetVolFieldSelection()
|
||||
);
|
||||
updateInfoFields<pointPatchField, pointMesh>
|
||||
(
|
||||
reader_->GetPointFieldSelection()
|
||||
);
|
||||
updateInfoLagrangianFields();
|
||||
updateInfoFields();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(partSelection);
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfo" << endl;
|
||||
Info<< "<end> updateInfo" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -419,7 +434,7 @@ void Foam::vtkPVFoam::updateFoamMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateFoamMesh" << endl;
|
||||
Info<< "<beg> updateFoamMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -463,7 +478,7 @@ void Foam::vtkPVFoam::updateFoamMesh()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::updateFoamMesh" << endl;
|
||||
Info<< "<end> updateFoamMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -532,7 +547,7 @@ void Foam::vtkPVFoam::Update
|
||||
convertLagrangianFields(lagrangianOutput);
|
||||
if (debug)
|
||||
{
|
||||
Info<< "done reader part" << endl;
|
||||
Info<< "done reader part" << nl << endl;
|
||||
}
|
||||
reader_->UpdateProgress(0.95);
|
||||
|
||||
@ -548,68 +563,58 @@ void Foam::vtkPVFoam::CleanUp()
|
||||
}
|
||||
|
||||
|
||||
double* Foam::vtkPVFoam::findTimes(int& nTimeSteps)
|
||||
std::vector<double> Foam::vtkPVFoam::findTimes(const bool skipZero) const
|
||||
{
|
||||
int nTimes = 0;
|
||||
double* tsteps = nullptr;
|
||||
std::vector<double> times;
|
||||
|
||||
if (dbPtr_.valid())
|
||||
{
|
||||
Time& runTime = dbPtr_();
|
||||
const Time& runTime = dbPtr_();
|
||||
instantList timeLst = runTime.times();
|
||||
|
||||
// find the first time for which this mesh appears to exist
|
||||
label timeI = 0;
|
||||
for (; timeI < timeLst.size(); ++timeI)
|
||||
label begIndex = timeLst.size();
|
||||
forAll(timeLst, timeI)
|
||||
{
|
||||
const word& timeName = timeLst[timeI].name();
|
||||
|
||||
if
|
||||
(
|
||||
isFile(runTime.path()/timeName/meshDir_/"points")
|
||||
&& IOobject
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
timeName,
|
||||
timeLst[timeI].name(),
|
||||
meshDir_,
|
||||
runTime
|
||||
).typeHeaderOk<pointIOField>(true)
|
||||
).typeHeaderOk<pointIOField>(false, false)
|
||||
)
|
||||
{
|
||||
begIndex = timeI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nTimes = timeLst.size() - timeI;
|
||||
label nTimes = timeLst.size() - begIndex;
|
||||
|
||||
// skip "constant" time whenever possible
|
||||
if (timeI == 0 && nTimes > 1)
|
||||
if (begIndex == 0 && nTimes > 1)
|
||||
{
|
||||
if (timeLst[timeI].name() == runTime.constant())
|
||||
if (timeLst[begIndex].name() == runTime.constant())
|
||||
{
|
||||
++timeI;
|
||||
++begIndex;
|
||||
--nTimes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// skip "0/" time if requested and possible
|
||||
if (nTimes > 1 && reader_->GetSkipZeroTime())
|
||||
if (skipZero && nTimes > 1 && timeLst[begIndex].name() == "0")
|
||||
{
|
||||
if (mag(timeLst[timeI].value()) < SMALL)
|
||||
{
|
||||
++timeI;
|
||||
--nTimes;
|
||||
}
|
||||
++begIndex;
|
||||
--nTimes;
|
||||
}
|
||||
|
||||
if (nTimes)
|
||||
times.reserve(nTimes);
|
||||
while (nTimes-- > 0)
|
||||
{
|
||||
tsteps = new double[nTimes];
|
||||
for (label stepI = 0; stepI < nTimes; ++stepI, ++timeI)
|
||||
{
|
||||
tsteps[stepI] = timeLst[timeI].value();
|
||||
}
|
||||
times.push_back(timeLst[begIndex++].value());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -620,10 +625,7 @@ double* Foam::vtkPVFoam::findTimes(int& nTimeSteps)
|
||||
}
|
||||
}
|
||||
|
||||
// vector length returned via the parameter
|
||||
nTimeSteps = nTimes;
|
||||
|
||||
return tsteps;
|
||||
return times;
|
||||
}
|
||||
|
||||
|
||||
@ -633,11 +635,6 @@ void Foam::vtkPVFoam::renderPatchNames
|
||||
const bool show
|
||||
)
|
||||
{
|
||||
if (!meshPtr_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// always remove old actors first
|
||||
|
||||
forAll(patchTextActorsPtrs_, patchi)
|
||||
@ -647,10 +644,10 @@ void Foam::vtkPVFoam::renderPatchNames
|
||||
}
|
||||
patchTextActorsPtrs_.clear();
|
||||
|
||||
if (show)
|
||||
if (show && meshPtr_)
|
||||
{
|
||||
// get the display patches, strip off any suffix
|
||||
wordHashSet selectedPatches = getSelected
|
||||
hashedWordList selectedPatches = getSelected
|
||||
(
|
||||
reader_->GetPartSelection(),
|
||||
arrayRangePatches_
|
||||
@ -764,17 +761,16 @@ void Foam::vtkPVFoam::renderPatchNames
|
||||
{
|
||||
const polyPatch& pp = pbMesh[patchi];
|
||||
|
||||
label globalZoneI = 0;
|
||||
|
||||
// Only selected patches will have a non-zero number of zones
|
||||
label nDisplayZones = min(MAXPATCHZONES, nZones[patchi]);
|
||||
const label nDisplayZones = min(MAXPATCHZONES, nZones[patchi]);
|
||||
label increment = 1;
|
||||
if (nZones[patchi] >= MAXPATCHZONES)
|
||||
{
|
||||
increment = nZones[patchi]/MAXPATCHZONES;
|
||||
}
|
||||
|
||||
for (label i = 0; i < nDisplayZones; i++)
|
||||
label globalZoneI = 0;
|
||||
for (label i = 0; i < nDisplayZones; ++i, globalZoneI += increment)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -783,45 +779,24 @@ void Foam::vtkPVFoam::renderPatchNames
|
||||
<< "globalZoneI = " << globalZoneI << endl;
|
||||
}
|
||||
|
||||
vtkTextActor* txt = vtkTextActor::New();
|
||||
|
||||
txt->SetInput(pp.name().c_str());
|
||||
|
||||
// Set text properties
|
||||
vtkTextProperty* tprop = txt->GetTextProperty();
|
||||
tprop->SetFontFamilyToArial();
|
||||
tprop->BoldOff();
|
||||
tprop->ShadowOff();
|
||||
tprop->SetLineSpacing(1.0);
|
||||
tprop->SetFontSize(12);
|
||||
tprop->SetColor(1.0, 0.0, 0.0);
|
||||
tprop->SetJustificationToCentered();
|
||||
|
||||
// Set text to use 3-D world co-ordinates
|
||||
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
|
||||
|
||||
txt->GetPositionCoordinate()->SetValue
|
||||
// Into a list for later removal
|
||||
patchTextActorsPtrs_[displayZoneI++] = createTextActor
|
||||
(
|
||||
zoneCentre[patchi][globalZoneI].x(),
|
||||
zoneCentre[patchi][globalZoneI].y(),
|
||||
zoneCentre[patchi][globalZoneI].z()
|
||||
pp.name(),
|
||||
zoneCentre[patchi][globalZoneI]
|
||||
);
|
||||
|
||||
// Add text to each renderer
|
||||
renderer->AddViewProp(txt);
|
||||
|
||||
// Maintain a list of text labels added so that they can be
|
||||
// removed later
|
||||
patchTextActorsPtrs_[displayZoneI] = txt;
|
||||
|
||||
globalZoneI += increment;
|
||||
displayZoneI++;
|
||||
}
|
||||
}
|
||||
|
||||
// Resize the patch names list to the actual number of patch names added
|
||||
patchTextActorsPtrs_.setSize(displayZoneI);
|
||||
}
|
||||
|
||||
// Add text to each renderer
|
||||
forAll(patchTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->AddViewProp(patchTextActorsPtrs_[actori]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -840,4 +815,24 @@ void Foam::vtkPVFoam::PrintSelf(ostream& os, vtkIndent indent) const
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::printInfo() const
|
||||
{
|
||||
std::cout
|
||||
<< "Region: " << meshRegion_ << "\n"
|
||||
<< "nPoints: " << (meshPtr_ ? meshPtr_->nPoints() : 0) << "\n"
|
||||
<< "nCells: " << (meshPtr_ ? meshPtr_->nCells() : 0) << "\n"
|
||||
<< "nTimes: "
|
||||
<< (dbPtr_.valid() ? dbPtr_().times().size() : 0) << "\n";
|
||||
|
||||
std::vector<double> times = this->findTimes(reader_->GetSkipZeroTime());
|
||||
|
||||
std::cout<<" " << times.size() << "(";
|
||||
for (const double& val : times)
|
||||
{
|
||||
std::cout<< ' ' << val;
|
||||
}
|
||||
std::cout << " )" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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.
|
||||
@ -29,24 +29,15 @@ Description
|
||||
|
||||
SourceFiles
|
||||
vtkPVFoam.C
|
||||
vtkPVFoam.H
|
||||
vtkPVFoamFields.C
|
||||
vtkPVFoamMesh.C
|
||||
vtkPVFoamMeshLagrangian.C
|
||||
vtkPVFoamTemplates.C
|
||||
vtkPVFoamMeshSet.C
|
||||
vtkPVFoamMeshVolume.C
|
||||
vtkPVFoamMeshZone.C
|
||||
vtkPVFoamFaceField.H
|
||||
vtkPVFoamLagrangianFields.H
|
||||
vtkPVFoamPatchField.H
|
||||
vtkPVFoamPointFields.H
|
||||
vtkPVFoamPoints.H
|
||||
vtkPVFoamTemplates.C
|
||||
vtkPVFoamUpdateInfo.C
|
||||
vtkPVFoamUpdateInfoFields.H
|
||||
vtkPVFoamUtils.C
|
||||
vtkPVFoamVolFields.H
|
||||
vtkPVFoamAddToSelection.H
|
||||
vtkPVFoamFieldTemplates.C
|
||||
vtkPVFoamUpdateTemplates.C
|
||||
|
||||
// Needed by VTK:
|
||||
vtkDataArrayTemplateImplicit.txx
|
||||
@ -56,11 +47,6 @@ SourceFiles
|
||||
#ifndef vtkPVFoam_H
|
||||
#define vtkPVFoam_H
|
||||
|
||||
// do not include legacy strstream headers
|
||||
#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
|
||||
# define VTK_EXCLUDE_STRSTREAM_HEADERS
|
||||
#endif
|
||||
|
||||
#include "className.H"
|
||||
#include "fileName.H"
|
||||
#include "stringList.H"
|
||||
@ -68,6 +54,7 @@ SourceFiles
|
||||
#include "primitivePatch.H"
|
||||
#include "PrimitivePatchInterpolation.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "foamPvCore.H"
|
||||
|
||||
#undef VTKPVFOAM_DUALPORT
|
||||
|
||||
@ -75,6 +62,7 @@ SourceFiles
|
||||
|
||||
class vtkDataArraySelection;
|
||||
class vtkDataSet;
|
||||
class vtkFloatArray;
|
||||
class vtkPoints;
|
||||
class vtkPVFoamReader;
|
||||
class vtkRenderer;
|
||||
@ -95,10 +83,9 @@ class Time;
|
||||
class fvMesh;
|
||||
class IOobjectList;
|
||||
class polyPatch;
|
||||
class faceSet;
|
||||
class pointSet;
|
||||
|
||||
template<class Type> class IOField;
|
||||
template<class Type> class Field;
|
||||
template<class Type> class List;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -106,84 +93,15 @@ template<class Type> class List;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkPVFoam
|
||||
:
|
||||
private foamPvCore
|
||||
{
|
||||
// Convenience typedefs
|
||||
typedef PrimitivePatchInterpolation<primitivePatch> patchInterpolator;
|
||||
|
||||
|
||||
// Private classes
|
||||
|
||||
//- Bookkeeping for GUI checklists and the multi-block organization
|
||||
class arrayRange
|
||||
{
|
||||
const char *name_;
|
||||
int block_;
|
||||
int start_;
|
||||
int size_;
|
||||
|
||||
public:
|
||||
|
||||
arrayRange(const char *name, const int blockNo=0)
|
||||
:
|
||||
name_(name),
|
||||
block_(blockNo),
|
||||
start_(0),
|
||||
size_(0)
|
||||
{}
|
||||
|
||||
//- Return the block holding these datasets
|
||||
int block() const
|
||||
{
|
||||
return block_;
|
||||
}
|
||||
|
||||
//- Assign block number, return previous value
|
||||
int block(int blockNo)
|
||||
{
|
||||
int prev = block_;
|
||||
block_ = blockNo;
|
||||
return prev;
|
||||
}
|
||||
|
||||
//- Return block name
|
||||
const char* name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return array start index
|
||||
int start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- Return array end index
|
||||
int end() const
|
||||
{
|
||||
return start_ + size_;
|
||||
}
|
||||
|
||||
//- Return sublist size
|
||||
int size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return !size_;
|
||||
}
|
||||
|
||||
//- Reset the size to zero and optionally assign a new start
|
||||
void reset(const int startAt = 0)
|
||||
{
|
||||
start_ = startAt;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
//- Increment the size
|
||||
void operator+=(const int n)
|
||||
{
|
||||
size_ += n;
|
||||
}
|
||||
};
|
||||
|
||||
//- Bookkeeping for polyhedral cell decomposition
|
||||
// hide in extra pointMap (cellSet/cellZone) for now
|
||||
class polyDecomp
|
||||
@ -302,372 +220,261 @@ class vtkPVFoam
|
||||
//- List of patch names for rendering to window
|
||||
List<vtkTextActor*> patchTextActorsPtrs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static void AddToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
);
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static vtkDataSet* GetDataSetFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static label GetNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&
|
||||
);
|
||||
//- Create a text actor
|
||||
static vtkTextActor* createTextActor(const string& s, const point& pt);
|
||||
|
||||
//- Reset data counters
|
||||
void resetCounters();
|
||||
|
||||
// Update information helper functions
|
||||
// Update information helper functions
|
||||
|
||||
//- Update the mesh parts selected in the GUI
|
||||
void updateMeshPartsStatus();
|
||||
//- Update the mesh parts selected in the GUI
|
||||
void updateMeshPartsStatus();
|
||||
|
||||
//- Internal mesh info
|
||||
void updateInfoInternalMesh(vtkDataArraySelection*);
|
||||
//- Internal mesh info
|
||||
void updateInfoInternalMesh(vtkDataArraySelection*);
|
||||
|
||||
//- Lagrangian info
|
||||
void updateInfoLagrangian(vtkDataArraySelection*);
|
||||
//- Lagrangian info
|
||||
void updateInfoLagrangian(vtkDataArraySelection*);
|
||||
|
||||
//- Patch info
|
||||
void updateInfoPatches(vtkDataArraySelection*, stringList&);
|
||||
//- Patch info
|
||||
void updateInfoPatches(vtkDataArraySelection*, stringList&);
|
||||
|
||||
//- Set info
|
||||
void updateInfoSets(vtkDataArraySelection*);
|
||||
//- Set info
|
||||
void updateInfoSets(vtkDataArraySelection*);
|
||||
|
||||
//- Zone info
|
||||
void updateInfoZones(vtkDataArraySelection*);
|
||||
//- Zone info
|
||||
void updateInfoZones(vtkDataArraySelection*);
|
||||
|
||||
//- Get non-empty zone names for zoneType from file
|
||||
wordList getZoneNames(const word& zoneType) const;
|
||||
//- Get non-empty zone names for zoneType from file
|
||||
wordList getZoneNames(const word& zoneType) const;
|
||||
|
||||
//- Get non-empty zone names from mesh info
|
||||
template<class ZoneType>
|
||||
wordList getZoneNames
|
||||
(
|
||||
const ZoneMesh<ZoneType, polyMesh>&
|
||||
) const;
|
||||
|
||||
//- Add objects of Type to paraview array selection
|
||||
template<class Type>
|
||||
label addToSelection
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const IOobjectList&,
|
||||
const string& suffix=string::null
|
||||
);
|
||||
|
||||
//- Field info
|
||||
template<template<class> class patchType, class meshType>
|
||||
void updateInfoFields(vtkDataArraySelection*);
|
||||
|
||||
//- Lagrangian field info
|
||||
void updateInfoLagrangianFields();
|
||||
|
||||
|
||||
// Update helper functions
|
||||
|
||||
//- OpenFOAM mesh
|
||||
void updateFoamMesh();
|
||||
|
||||
//- Reduce memory footprint after conversion
|
||||
void reduceMemory();
|
||||
|
||||
|
||||
// Mesh conversion functions
|
||||
|
||||
//- Volume mesh
|
||||
void convertMeshVolume(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Lagrangian mesh
|
||||
void convertMeshLagrangian(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Patch meshes
|
||||
void convertMeshPatches(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Cell zone meshes
|
||||
void convertMeshCellZones(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Face zone meshes
|
||||
void convertMeshFaceZones(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Point zone meshes
|
||||
void convertMeshPointZones(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Cell set meshes
|
||||
void convertMeshCellSets(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Face set meshes
|
||||
void convertMeshFaceSets(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Point set meshes
|
||||
void convertMeshPointSets(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
|
||||
// Add mesh functions
|
||||
|
||||
//- Add internal mesh/cell set meshes
|
||||
vtkUnstructuredGrid* volumeVTKMesh(const fvMesh&, polyDecomp&);
|
||||
|
||||
//- Add Lagrangian mesh
|
||||
vtkPolyData* lagrangianVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const word& cloudName
|
||||
);
|
||||
|
||||
//- Add patch mesh
|
||||
template<class PatchType>
|
||||
vtkPolyData* patchVTKMesh(const word& name, const PatchType&);
|
||||
|
||||
//- Add point zone
|
||||
vtkPolyData* pointZoneVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const labelList& pointLabels
|
||||
);
|
||||
|
||||
//- Add face set mesh
|
||||
vtkPolyData* faceSetVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const faceSet&
|
||||
);
|
||||
|
||||
//- Add point mesh
|
||||
vtkPolyData* pointSetVTKMesh
|
||||
(
|
||||
const fvMesh&,
|
||||
const pointSet&
|
||||
);
|
||||
|
||||
// Field conversion functions
|
||||
|
||||
//- Convert volume fields
|
||||
void convertVolFields(vtkMultiBlockDataSet*);
|
||||
|
||||
//- Convert point fields
|
||||
void convertPointFields(vtkMultiBlockDataSet*);
|
||||
|
||||
//- Convert Lagrangian fields
|
||||
void convertLagrangianFields(vtkMultiBlockDataSet*);
|
||||
|
||||
|
||||
//- Add the fields in the selected time directory to the selection
|
||||
// lists
|
||||
template<class GeoField>
|
||||
label addObjectsToSelection
|
||||
//- Get names of on non-empty zones from the mesh info
|
||||
template<class ZoneType>
|
||||
static wordList getZoneNames
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const IOobjectList&,
|
||||
const string& suffix=string::null
|
||||
const ZoneMesh<ZoneType, polyMesh>& zmesh
|
||||
);
|
||||
|
||||
//- Field (volume, point, lagrangian) info
|
||||
void updateInfoFields();
|
||||
|
||||
//- Field info
|
||||
template<template<class> class patchType, class meshType>
|
||||
void updateInfoFields
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
);
|
||||
|
||||
//- Lagrangian field info
|
||||
void updateInfoLagrangianFields(vtkDataArraySelection* select);
|
||||
|
||||
|
||||
// Update helper functions
|
||||
|
||||
//- OpenFOAM mesh
|
||||
void updateFoamMesh();
|
||||
|
||||
//- Reduce memory footprint after conversion
|
||||
void reduceMemory();
|
||||
|
||||
|
||||
// Mesh conversion functions
|
||||
|
||||
//- Convert volume mesh
|
||||
void convertMeshVolume(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
//- Convert Lagrangian points
|
||||
void convertMeshLagrangian(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
//- Convert mesh patches
|
||||
void convertMeshPatches(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
//- Convert cell zones
|
||||
void convertMeshCellZones(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
//- Convert face zones
|
||||
void convertMeshFaceZones(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
//- Convert point zones
|
||||
void convertMeshPointZones(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
//- Convert cell sets
|
||||
void convertMeshCellSets(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
//- Convert face sets
|
||||
void convertMeshFaceSets(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
//- Convert point sets
|
||||
void convertMeshPointSets(vtkMultiBlockDataSet* output, int& blockNo);
|
||||
|
||||
|
||||
// Add mesh functions
|
||||
|
||||
//- Volume meshes as vtkUnstructuredGrid
|
||||
vtkUnstructuredGrid* volumeVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
polyDecomp& decompInfo
|
||||
);
|
||||
|
||||
//- Lagrangian positions as vtkPolyData
|
||||
vtkPolyData* lagrangianVTKMesh
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& cloudName
|
||||
);
|
||||
|
||||
//- Patches (mesh or primitive) as vtkPolyData
|
||||
template<class PatchType>
|
||||
vtkPolyData* patchVTKMesh
|
||||
(
|
||||
const word& name,
|
||||
const PatchType& p
|
||||
);
|
||||
|
||||
|
||||
// Convert OpenFOAM fields
|
||||
// Field conversion functions
|
||||
|
||||
//- Volume field - all types
|
||||
template<class Type>
|
||||
void convertVolField
|
||||
(
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
//- Convert Field to VTK field
|
||||
template<class Type>
|
||||
vtkFloatArray* convertFieldToVTK
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& fld
|
||||
);
|
||||
|
||||
//- Volume fields - all types
|
||||
template<class Type>
|
||||
void convertVolFields
|
||||
(
|
||||
const fvMesh&,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&,
|
||||
const IOobjectList&,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
//- Face set/zone field
|
||||
template<class Type>
|
||||
vtkFloatArray* convertFaceFieldToVTK
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
const labelUList& faceLabels
|
||||
);
|
||||
|
||||
//- Volume internal fields (DimensionedField)- all types
|
||||
template<class Type>
|
||||
void convertDimFields
|
||||
(
|
||||
const fvMesh&,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>&,
|
||||
const IOobjectList&,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Volume field - all selected parts
|
||||
template<class Type>
|
||||
void convertVolFieldBlock
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const List<polyDecomp>& decompLst
|
||||
);
|
||||
|
||||
//- Volume field
|
||||
template<class Type>
|
||||
void convertVolField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const polyDecomp&
|
||||
);
|
||||
|
||||
//- Patch field
|
||||
template<class Type>
|
||||
void convertPatchField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Face set/zone field
|
||||
template<class Type>
|
||||
void convertFaceField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const fvMesh&,
|
||||
const labelList& faceLabels
|
||||
);
|
||||
|
||||
//- Lagrangian fields - all types
|
||||
template<class Type>
|
||||
void convertLagrangianFields
|
||||
(
|
||||
const IOobjectList&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Lagrangian field
|
||||
template<class Type>
|
||||
void convertLagrangianField
|
||||
(
|
||||
const IOField<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Point fields - all types
|
||||
template<class Type>
|
||||
void convertPointFields
|
||||
(
|
||||
const fvMesh&,
|
||||
const pointMesh&,
|
||||
const IOobjectList&,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Point field - all selected parts
|
||||
template<class Type>
|
||||
void convertPointFieldBlock
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const List<polyDecomp>&
|
||||
);
|
||||
|
||||
//- Point fields
|
||||
template<class Type>
|
||||
void convertPointField
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const polyDecomp&
|
||||
);
|
||||
|
||||
//- Patch point field
|
||||
template<class Type>
|
||||
void convertPatchPointField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>&,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
//- Volume field
|
||||
template<class Type>
|
||||
vtkFloatArray* convertVolFieldToVTK
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
const polyDecomp& decompInfo
|
||||
);
|
||||
|
||||
|
||||
// GUI selection helper functions
|
||||
//- Convert volume fields
|
||||
void convertVolFields(vtkMultiBlockDataSet* output);
|
||||
|
||||
//- Only keep what is listed in hashSet
|
||||
static void pruneObjectList
|
||||
(
|
||||
IOobjectList&,
|
||||
const wordHashSet&
|
||||
);
|
||||
//- Convert point fields
|
||||
void convertPointFields(vtkMultiBlockDataSet* output);
|
||||
|
||||
//- Retrieve the current selections
|
||||
static wordHashSet getSelected(vtkDataArraySelection*);
|
||||
//- Convert Lagrangian fields
|
||||
void convertLagrangianFields(vtkMultiBlockDataSet* output);
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
static wordHashSet getSelected
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const arrayRange&
|
||||
);
|
||||
|
||||
//- Retrieve the current selections
|
||||
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
|
||||
// Convert OpenFOAM fields
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
static stringList getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const arrayRange&
|
||||
);
|
||||
//- Volume field - all types
|
||||
template<class Type>
|
||||
void convertVolField
|
||||
(
|
||||
const PtrList<patchInterpolator>& patchInterpList,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Set selection(s)
|
||||
static void setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const stringList&
|
||||
);
|
||||
//- Volume fields - all types
|
||||
template<class Type>
|
||||
void convertVolFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const PtrList<patchInterpolator>& patchInterpList,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Get the first word from the mesh parts selection
|
||||
word getPartName(const int);
|
||||
//- Volume internal fields (DimensionedField)- all types
|
||||
template<class Type>
|
||||
void convertDimFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const PtrList<patchInterpolator>& patchInterpList,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Volume field - all selected parts
|
||||
template<class Type>
|
||||
void convertVolFieldBlock
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const List<polyDecomp>& decompLst
|
||||
);
|
||||
|
||||
//- Lagrangian fields - all types
|
||||
template<class Type>
|
||||
void convertLagrangianFields
|
||||
(
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Point fields - all types
|
||||
template<class Type>
|
||||
void convertPointFields
|
||||
(
|
||||
const pointMesh& pMesh,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
);
|
||||
|
||||
//- Point field - all selected parts
|
||||
template<class Type>
|
||||
void convertPointFieldBlock
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const List<polyDecomp>& decompLst
|
||||
);
|
||||
|
||||
//- Point field
|
||||
template<class Type>
|
||||
void convertPointField
|
||||
(
|
||||
vtkUnstructuredGrid* vtkmesh,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vfld,
|
||||
const polyDecomp& decomp
|
||||
);
|
||||
|
||||
|
||||
// GUI selection helper functions
|
||||
|
||||
//- Only retain specified fields
|
||||
static void pruneObjectList
|
||||
(
|
||||
IOobjectList& objects,
|
||||
const hashedWordList& retain
|
||||
);
|
||||
|
||||
//- Get the first word from the reader 'parts' selection
|
||||
word getPartName(const int partId);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkPVFoam(const vtkPVFoam&);
|
||||
vtkPVFoam(const vtkPVFoam&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPVFoam&);
|
||||
void operator=(const vtkPVFoam&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -705,9 +512,9 @@ public:
|
||||
//- Clean any storage
|
||||
void CleanUp();
|
||||
|
||||
//- Allocate and return a list of selected times
|
||||
// returns the count via the parameter
|
||||
double* findTimes(int& nTimeSteps);
|
||||
//- Return a list of selected times.
|
||||
// Use STL container since these values are used by the plugin
|
||||
std::vector<double> findTimes(const bool skipZero = false) const;
|
||||
|
||||
//- Add/remove patch names to/from the view
|
||||
void renderPatchNames(vtkRenderer*, const bool show);
|
||||
@ -730,9 +537,7 @@ public:
|
||||
//- Debug information
|
||||
void PrintSelf(ostream&, vtkIndent) const;
|
||||
|
||||
//- Simple memory used debugging information
|
||||
static void printMemory();
|
||||
|
||||
void printInfo() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,117 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamFaceField_H
|
||||
#define vtkPVFoamFaceField_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellData.h"
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkPolyData.h"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertFaceField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const label datasetNo,
|
||||
const fvMesh& mesh,
|
||||
const labelList& faceLabels
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
const label nInternalFaces = mesh.nInternalFaces();
|
||||
const labelList& faceOwner = mesh.faceOwner();
|
||||
const labelList& faceNeigh = mesh.faceNeighbour();
|
||||
|
||||
vtkFloatArray* cellData = vtkFloatArray::New();
|
||||
cellData->SetNumberOfTuples(faceLabels.size());
|
||||
cellData->SetNumberOfComponents(nComp);
|
||||
cellData->Allocate(nComp*faceLabels.size());
|
||||
cellData->SetName(tf.name().c_str());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert convertFaceField: "
|
||||
<< tf.name()
|
||||
<< " size = " << tf.size()
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << faceLabels.size() << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
// for interior faces: average owner/neighbour
|
||||
// for boundary faces: owner
|
||||
forAll(faceLabels, facei)
|
||||
{
|
||||
const label faceNo = faceLabels[facei];
|
||||
if (faceNo < nInternalFaces)
|
||||
{
|
||||
Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
|
||||
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const Type& t = tf[faceOwner[faceNo]];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
cellData->InsertTuple(facei, vec);
|
||||
}
|
||||
|
||||
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, range, datasetNo)
|
||||
) ->GetCellData()
|
||||
->AddArray(cellData);
|
||||
|
||||
cellData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,909 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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/>.
|
||||
|
||||
InClass
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamFieldTemplates_C
|
||||
#define vtkPVFoamFieldTemplates_C
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "emptyFvPatchField.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "faceSet.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "zeroGradientFvPatchField.H"
|
||||
#include "interpolatePointToCell.H"
|
||||
#include "foamPvFields.H"
|
||||
|
||||
// vtk includes
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkCellData.h"
|
||||
#include "vtkPointData.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
//
|
||||
// volume-fields
|
||||
//
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertVolField
|
||||
(
|
||||
const PtrList<patchInterpolator>& patchInterpList,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = fld.mesh();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
const bool interpField = !patchInterpList.empty();
|
||||
const bool extrapPatch = reader_->GetExtrapolatePatches();
|
||||
|
||||
// Interpolated field (demand driven)
|
||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>> ptfPtr;
|
||||
if (interpField)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convertVolField interpolating:" << fld.name() << endl;
|
||||
}
|
||||
|
||||
ptfPtr.reset
|
||||
(
|
||||
volPointInterpolation::New(mesh).interpolate(fld).ptr()
|
||||
);
|
||||
}
|
||||
|
||||
// Convert activated internalMesh regions
|
||||
convertVolFieldBlock
|
||||
(
|
||||
fld,
|
||||
ptfPtr,
|
||||
output,
|
||||
arrayRangeVolume_,
|
||||
regionPolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellZones
|
||||
convertVolFieldBlock
|
||||
(
|
||||
fld,
|
||||
ptfPtr,
|
||||
output,
|
||||
arrayRangeCellZones_,
|
||||
zonePolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellSets
|
||||
convertVolFieldBlock
|
||||
(
|
||||
fld,
|
||||
ptfPtr,
|
||||
output,
|
||||
arrayRangeCellSets_,
|
||||
csetPolyDecomp_
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Convert patches - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangePatches_.start();
|
||||
partId < arrayRangePatches_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word patchName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
const label patchId = patches.findPatchID(patchName);
|
||||
|
||||
if (!partStatus_[partId] || patchId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
|
||||
(
|
||||
output, arrayRangePatches_, datasetNo
|
||||
);
|
||||
|
||||
if (!vtkmesh)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const fvPatchField<Type>& ptf = fld.boundaryField()[patchId];
|
||||
|
||||
if
|
||||
(
|
||||
isType<emptyFvPatchField<Type>>(ptf)
|
||||
||
|
||||
(
|
||||
extrapPatch
|
||||
&& !polyPatch::constraintType(patches[patchId].type())
|
||||
)
|
||||
)
|
||||
{
|
||||
fvPatch p(ptf.patch().patch(), mesh.boundary());
|
||||
|
||||
tmp<Field<Type>> tpptf
|
||||
(
|
||||
fvPatchField<Type>(p, fld).patchInternalField()
|
||||
);
|
||||
|
||||
vtkFloatArray* cdata = convertFieldToVTK(fld.name(), tpptf());
|
||||
vtkmesh->GetCellData()->AddArray(cdata);
|
||||
cdata->Delete();
|
||||
|
||||
if (patchId < patchInterpList.size())
|
||||
{
|
||||
vtkFloatArray* pdata = convertFieldToVTK
|
||||
(
|
||||
fld.name(),
|
||||
patchInterpList[patchId].faceToPointInterpolate(tpptf)()
|
||||
);
|
||||
|
||||
vtkmesh->GetPointData()->AddArray(pdata);
|
||||
pdata->Delete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkFloatArray* cdata = convertFieldToVTK(fld.name(), ptf);
|
||||
vtkmesh->GetCellData()->AddArray(cdata);
|
||||
cdata->Delete();
|
||||
|
||||
if (patchId < patchInterpList.size())
|
||||
{
|
||||
vtkFloatArray* pdata = convertFieldToVTK
|
||||
(
|
||||
fld.name(),
|
||||
patchInterpList[patchId].faceToPointInterpolate(ptf)()
|
||||
);
|
||||
|
||||
vtkmesh->GetPointData()->AddArray(pdata);
|
||||
pdata->Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Convert face zones - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangeFaceZones_.start();
|
||||
partId < arrayRangeFaceZones_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word zoneName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const faceZoneMesh& zMesh = mesh.faceZones();
|
||||
const label zoneId = zMesh.findZoneID(zoneName);
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
|
||||
(
|
||||
output, arrayRangeFaceZones_, datasetNo
|
||||
);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
vtkFloatArray* cdata = convertFaceFieldToVTK
|
||||
(
|
||||
fld,
|
||||
zMesh[zoneId]
|
||||
);
|
||||
|
||||
vtkmesh->GetCellData()->AddArray(cdata);
|
||||
cdata->Delete();
|
||||
}
|
||||
|
||||
// TODO: points
|
||||
}
|
||||
|
||||
//
|
||||
// Convert face sets - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangeFaceSets_.start();
|
||||
partId < arrayRangeFaceSets_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word selectName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
|
||||
(
|
||||
output, arrayRangeFaceSets_, datasetNo
|
||||
);
|
||||
|
||||
if (!vtkmesh)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const faceSet fSet(mesh, selectName);
|
||||
|
||||
vtkFloatArray* cdata = convertFaceFieldToVTK
|
||||
(
|
||||
fld,
|
||||
fSet.sortedToc()
|
||||
);
|
||||
|
||||
vtkmesh->GetCellData()->AddArray(cdata);
|
||||
cdata->Delete();
|
||||
|
||||
// TODO: points
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertVolFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const PtrList<patchInterpolator>& patchInterpList,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
// restrict to GeometricField<Type, ...>
|
||||
if
|
||||
(
|
||||
iter()->headerClassName()
|
||||
!= GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Load field
|
||||
GeometricField<Type, fvPatchField, volMesh> fld
|
||||
(
|
||||
*iter(),
|
||||
mesh
|
||||
);
|
||||
|
||||
// Convert
|
||||
convertVolField(patchInterpList, fld, output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertDimFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const PtrList<patchInterpolator>& patchInterpList,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
// restrict to DimensionedField<Type, ...>
|
||||
if
|
||||
(
|
||||
iter()->headerClassName()
|
||||
!= DimensionedField<Type, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Load field
|
||||
DimensionedField<Type, volMesh> dimFld(*iter(), mesh);
|
||||
|
||||
// Construct volField with zero-gradient patch fields
|
||||
|
||||
IOobject io(dimFld);
|
||||
io.readOpt() = IOobject::NO_READ;
|
||||
|
||||
PtrList<fvPatchField<Type>> patchFields(mesh.boundary().size());
|
||||
forAll(patchFields, patchI)
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchI,
|
||||
fvPatchField<Type>::New
|
||||
(
|
||||
zeroGradientFvPatchField<Type>::typeName,
|
||||
mesh.boundary()[patchI],
|
||||
dimFld
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
VolFieldType volFld
|
||||
(
|
||||
io,
|
||||
dimFld.mesh(),
|
||||
dimFld.dimensions(),
|
||||
dimFld,
|
||||
patchFields
|
||||
);
|
||||
volFld.correctBoundaryConditions();
|
||||
|
||||
convertVolField(patchInterpList, volFld, output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertVolFieldBlock
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const List<polyDecomp>& decompLst
|
||||
)
|
||||
{
|
||||
for (int partId = range.start(); partId < range.end(); ++partId)
|
||||
{
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh =
|
||||
getDataFromBlock<vtkUnstructuredGrid>(output, range, datasetNo);
|
||||
|
||||
if (!vtkmesh)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkFloatArray* cdata = convertVolFieldToVTK
|
||||
(
|
||||
fld,
|
||||
decompLst[datasetNo]
|
||||
);
|
||||
|
||||
vtkmesh->GetCellData()->AddArray(cdata);
|
||||
cdata->Delete();
|
||||
|
||||
if (ptfPtr.valid())
|
||||
{
|
||||
convertPointField(vtkmesh, ptfPtr(), fld, decompLst[datasetNo]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
//
|
||||
// point-fields
|
||||
//
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertPointFields
|
||||
(
|
||||
const pointMesh& pMesh,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
const polyMesh& mesh = pMesh.mesh();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
const word& fieldName = iter()->name();
|
||||
// restrict to this GeometricField<Type, ...>
|
||||
if
|
||||
(
|
||||
iter()->headerClassName()
|
||||
!= GeometricField<Type, pointPatchField, pointMesh>::typeName
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convertPointFields : " << fieldName << endl;
|
||||
}
|
||||
|
||||
GeometricField<Type, pointPatchField, pointMesh> pfld(*iter(), pMesh);
|
||||
|
||||
|
||||
// Convert activated internalMesh regions
|
||||
convertPointFieldBlock
|
||||
(
|
||||
pfld,
|
||||
output,
|
||||
arrayRangeVolume_,
|
||||
regionPolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellZones
|
||||
convertPointFieldBlock
|
||||
(
|
||||
pfld,
|
||||
output,
|
||||
arrayRangeCellZones_,
|
||||
zonePolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellSets
|
||||
convertPointFieldBlock
|
||||
(
|
||||
pfld,
|
||||
output,
|
||||
arrayRangeCellSets_,
|
||||
csetPolyDecomp_
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Convert patches - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangePatches_.start();
|
||||
partId < arrayRangePatches_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word patchName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
const label patchId = patches.findPatchID(patchName);
|
||||
|
||||
if (!partStatus_[partId] || patchId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
|
||||
(
|
||||
output, arrayRangePatches_, datasetNo
|
||||
);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
vtkFloatArray* pdata = convertFieldToVTK
|
||||
(
|
||||
fieldName,
|
||||
pfld.boundaryField()[patchId].patchInternalField()()
|
||||
);
|
||||
|
||||
vtkmesh->GetPointData()->AddArray(pdata);
|
||||
pdata->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Convert faceZones - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangeFaceZones_.start();
|
||||
partId < arrayRangeFaceZones_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word zoneName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
const label zoneId = mesh.faceZones().findZoneID(zoneName);
|
||||
|
||||
if (!partStatus_[partId] || zoneId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
|
||||
(
|
||||
output, arrayRangeFaceZones_, datasetNo
|
||||
);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
// Extract the field on the zone
|
||||
Field<Type> znfld
|
||||
(
|
||||
pfld.primitiveField(),
|
||||
mesh.faceZones()[zoneId]().meshPoints()
|
||||
);
|
||||
|
||||
vtkFloatArray* pdata = convertFieldToVTK(fieldName, znfld);
|
||||
|
||||
vtkmesh->GetPointData()->AddArray(pdata);
|
||||
pdata->Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertPointFieldBlock
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const List<polyDecomp>& decompLst
|
||||
)
|
||||
{
|
||||
for (int partId = range.start(); partId < range.end(); ++partId)
|
||||
{
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = getDataFromBlock<vtkUnstructuredGrid>
|
||||
(
|
||||
output, range, datasetNo
|
||||
);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
convertPointField
|
||||
(
|
||||
vtkmesh,
|
||||
pfld,
|
||||
GeometricField<Type, fvPatchField, volMesh>::null(),
|
||||
decompLst[datasetNo]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertPointField
|
||||
(
|
||||
vtkUnstructuredGrid* vtkmesh,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vfld,
|
||||
const polyDecomp& decomp
|
||||
)
|
||||
{
|
||||
if (!vtkmesh)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
const labelUList& addPointCellLabels = decomp.addPointCellLabels();
|
||||
const labelUList& pointMap = decomp.pointMap();
|
||||
|
||||
// use a pointMap or address directly into mesh
|
||||
const label nPoints = (pointMap.size() ? pointMap.size() : pfld.size());
|
||||
|
||||
vtkFloatArray* fldData = vtkFloatArray::New();
|
||||
fldData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
|
||||
fldData->SetNumberOfComponents(nComp);
|
||||
fldData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
|
||||
|
||||
// Note: using the name of the original volField
|
||||
// not the name generated by the interpolation "volPointInterpolate(<name>)"
|
||||
|
||||
if (&vfld != &GeometricField<Type, fvPatchField, volMesh>::null())
|
||||
{
|
||||
fldData->SetName(vfld.name().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
fldData->SetName(pfld.name().c_str());
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert Point field: "
|
||||
<< pfld.name()
|
||||
<< " size=" << (nPoints + addPointCellLabels.size())
|
||||
<< " (" << nPoints << " + " << addPointCellLabels.size()
|
||||
<< ") nComp=" << nComp << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
if (pointMap.size())
|
||||
{
|
||||
forAll(pointMap, i)
|
||||
{
|
||||
const Type& t = pfld[pointMap[i]];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
foamPvFields::remapTuple<Type>(vec);
|
||||
|
||||
fldData->InsertTuple(i, vec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(pfld, i)
|
||||
{
|
||||
const Type& t = pfld[i];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
foamPvFields::remapTuple<Type>(vec);
|
||||
|
||||
fldData->InsertTuple(i, vec);
|
||||
}
|
||||
}
|
||||
|
||||
// continue insertion from here
|
||||
label i = nPoints;
|
||||
|
||||
if (&vfld != &GeometricField<Type, fvPatchField, volMesh>::null())
|
||||
{
|
||||
forAll(addPointCellLabels, apI)
|
||||
{
|
||||
const Type& t = vfld[addPointCellLabels[apI]];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
foamPvFields::remapTuple<Type>(vec);
|
||||
|
||||
fldData->InsertTuple(i++, vec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(addPointCellLabels, apI)
|
||||
{
|
||||
Type t = interpolatePointToCell(pfld, addPointCellLabels[apI]);
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
foamPvFields::remapTuple<Type>(vec);
|
||||
|
||||
fldData->InsertTuple(i++, vec);
|
||||
}
|
||||
}
|
||||
|
||||
vtkmesh->GetPointData()->AddArray(fldData);
|
||||
fldData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
//
|
||||
// lagrangian-fields
|
||||
//
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertLagrangianFields
|
||||
(
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const arrayRange& range = arrayRangeLagrangian_;
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
// restrict to this IOField<Type>
|
||||
if (iter()->headerClassName() == IOField<Type>::typeName)
|
||||
{
|
||||
vtkPolyData* vtkmesh =
|
||||
getDataFromBlock<vtkPolyData>(output, range, datasetNo);
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
IOField<Type> fld(*iter());
|
||||
|
||||
vtkFloatArray* fldData = convertFieldToVTK(fld.name(), fld);
|
||||
vtkmesh->GetPointData()->AddArray(fldData);
|
||||
fldData->Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
//
|
||||
// low-level conversions
|
||||
//
|
||||
|
||||
template<class Type>
|
||||
vtkFloatArray* Foam::vtkPVFoam::convertFieldToVTK
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& fld
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert Field<" << pTraits<Type>::typeName << "> "
|
||||
<< name
|
||||
<< " size=" << fld.size()
|
||||
<< " nComp=" << label(pTraits<Type>::nComponents) << endl;
|
||||
}
|
||||
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkFloatArray* fldData = vtkFloatArray::New();
|
||||
fldData->SetNumberOfTuples(fld.size());
|
||||
fldData->SetNumberOfComponents(nComp);
|
||||
fldData->Allocate(nComp*fld.size());
|
||||
fldData->SetName(name.c_str());
|
||||
|
||||
float vec[nComp];
|
||||
forAll(fld, i)
|
||||
{
|
||||
const Type& t = fld[i];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
foamPvFields::remapTuple<Type>(vec);
|
||||
|
||||
fldData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
return fldData;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
vtkFloatArray* Foam::vtkPVFoam::convertFaceFieldToVTK
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
const labelUList& faceLabels
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert face field: "
|
||||
<< fld.name()
|
||||
<< " size=" << faceLabels.size()
|
||||
<< " nComp=" << label(pTraits<Type>::nComponents) << endl;
|
||||
}
|
||||
|
||||
const fvMesh& mesh = fld.mesh();
|
||||
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
const label nInternalFaces = mesh.nInternalFaces();
|
||||
const labelList& faceOwner = mesh.faceOwner();
|
||||
const labelList& faceNeigh = mesh.faceNeighbour();
|
||||
|
||||
vtkFloatArray* fldData = vtkFloatArray::New();
|
||||
fldData->SetNumberOfTuples(faceLabels.size());
|
||||
fldData->SetNumberOfComponents(nComp);
|
||||
fldData->Allocate(nComp*faceLabels.size());
|
||||
fldData->SetName(fld.name().c_str());
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
// for interior faces: average owner/neighbour
|
||||
// for boundary faces: owner
|
||||
forAll(faceLabels, facei)
|
||||
{
|
||||
const label faceNo = faceLabels[facei];
|
||||
if (faceNo < nInternalFaces)
|
||||
{
|
||||
Type t = 0.5*(fld[faceOwner[faceNo]] + fld[faceNeigh[faceNo]]);
|
||||
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const Type& t = fld[faceOwner[faceNo]];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
}
|
||||
foamPvFields::remapTuple<Type>(vec);
|
||||
|
||||
fldData->InsertTuple(facei, vec);
|
||||
}
|
||||
|
||||
return fldData;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
vtkFloatArray* Foam::vtkPVFoam::convertVolFieldToVTK
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||
const polyDecomp& decompInfo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
const labelList& superCells = decompInfo.superCells();
|
||||
|
||||
vtkFloatArray* fldData = vtkFloatArray::New();
|
||||
fldData->SetNumberOfTuples(superCells.size());
|
||||
fldData->SetNumberOfComponents(nComp);
|
||||
fldData->Allocate(nComp*superCells.size());
|
||||
fldData->SetName(fld.name().c_str());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert volField: "
|
||||
<< fld.name()
|
||||
<< " size=" << superCells.size()
|
||||
<< " (" << fld.size() << " + "
|
||||
<< (superCells.size() - fld.size())
|
||||
<< ") nComp=" << nComp << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
forAll(superCells, i)
|
||||
{
|
||||
const Type& t = fld[superCells[i]];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
foamPvFields::remapTuple<Type>(vec);
|
||||
|
||||
fldData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
return fldData;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "vtkPVFoam.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "Cloud.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "vtkPVFoamReader.h"
|
||||
|
||||
@ -34,29 +35,26 @@ License
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
// Templates (only needed here)
|
||||
#include "vtkPVFoamFieldTemplates.C"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
#include "vtkPVFoamVolFields.H"
|
||||
#include "vtkPVFoamPointFields.H"
|
||||
#include "vtkPVFoamLagrangianFields.H"
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::pruneObjectList
|
||||
(
|
||||
IOobjectList& objects,
|
||||
const wordHashSet& selected
|
||||
const hashedWordList& retain
|
||||
)
|
||||
{
|
||||
// hash all the selected field names
|
||||
if (selected.empty())
|
||||
if (retain.empty())
|
||||
{
|
||||
objects.clear();
|
||||
}
|
||||
|
||||
// only keep selected fields
|
||||
// only retain specified fields
|
||||
forAllIter(IOobjectList, objects, iter)
|
||||
{
|
||||
if (!selected.found(iter()->name()))
|
||||
if (!retain.found(iter()->name()))
|
||||
{
|
||||
objects.erase(iter);
|
||||
}
|
||||
@ -71,7 +69,8 @@ void Foam::vtkPVFoam::convertVolFields
|
||||
{
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
wordHashSet selectedFields = getSelected
|
||||
const bool interpFields = reader_->GetInterpolateVolFields();
|
||||
hashedWordList selectedFields = getSelected
|
||||
(
|
||||
reader_->GetVolFieldSelection()
|
||||
);
|
||||
@ -93,80 +92,50 @@ void Foam::vtkPVFoam::convertVolFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertVolFields" << nl
|
||||
<< "converting OpenFOAM volume fields" << endl;
|
||||
Info<< "<beg> convert volume fields" << endl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
<< " == " << iter()->objectPath() << endl;
|
||||
}
|
||||
printMemory();
|
||||
}
|
||||
|
||||
|
||||
PtrList<PrimitivePatchInterpolation<primitivePatch>>
|
||||
ppInterpList(mesh.boundaryMesh().size());
|
||||
PtrList<patchInterpolator> interpLst;
|
||||
|
||||
forAll(ppInterpList, i)
|
||||
if (interpFields)
|
||||
{
|
||||
ppInterpList.set
|
||||
(
|
||||
i,
|
||||
new PrimitivePatchInterpolation<primitivePatch>
|
||||
interpLst.setSize(mesh.boundaryMesh().size());
|
||||
|
||||
forAll(interpLst, i)
|
||||
{
|
||||
interpLst.set
|
||||
(
|
||||
mesh.boundaryMesh()[i]
|
||||
)
|
||||
);
|
||||
i,
|
||||
new PrimitivePatchInterpolation<primitivePatch>
|
||||
(
|
||||
mesh.boundaryMesh()[i]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
convertVolFields<scalar>(mesh, interpLst, objects, output);
|
||||
convertVolFields<vector>(mesh, interpLst, objects, output);
|
||||
convertVolFields<sphericalTensor>(mesh, interpLst, objects, output);
|
||||
convertVolFields<symmTensor>(mesh, interpLst, objects, output);
|
||||
convertVolFields<tensor>(mesh, interpLst, objects, output);
|
||||
|
||||
bool interpFields = reader_->GetInterpolateVolFields();
|
||||
|
||||
convertVolFields<scalar>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertVolFields<vector>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertVolFields<sphericalTensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertVolFields<symmTensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertVolFields<tensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
|
||||
convertDimFields<scalar>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertDimFields<vector>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertDimFields<sphericalTensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertDimFields<symmTensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertDimFields<tensor>
|
||||
(
|
||||
mesh, ppInterpList, objects, interpFields, output
|
||||
);
|
||||
convertDimFields<scalar>(mesh, interpLst, objects, output);
|
||||
convertDimFields<vector>(mesh, interpLst, objects, output);
|
||||
convertDimFields<sphericalTensor>(mesh, interpLst, objects, output);
|
||||
convertDimFields<symmTensor>(mesh, interpLst, objects, output);
|
||||
convertDimFields<tensor>(mesh, interpLst, objects, output);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertVolFields" << endl;
|
||||
Info<< "<end> convert volume fields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -179,7 +148,7 @@ void Foam::vtkPVFoam::convertPointFields
|
||||
{
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
wordHashSet selectedFields = getSelected
|
||||
hashedWordList selectedFields = getSelected
|
||||
(
|
||||
reader_->GetPointFieldSelection()
|
||||
);
|
||||
@ -205,12 +174,11 @@ void Foam::vtkPVFoam::convertPointFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertPointFields" << nl
|
||||
<< "converting OpenFOAM volume fields -> point fields" << endl;
|
||||
Info<< "<beg> convert volume -> point fields" << endl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
<< " == " << iter()->objectPath() << endl;
|
||||
}
|
||||
printMemory();
|
||||
}
|
||||
@ -218,31 +186,15 @@ void Foam::vtkPVFoam::convertPointFields
|
||||
// Construct interpolation on the raw mesh
|
||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||
|
||||
|
||||
convertPointFields<scalar>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<vector>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<sphericalTensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<symmTensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<tensor>
|
||||
(
|
||||
mesh, pMesh, objects, output
|
||||
);
|
||||
convertPointFields<scalar>(pMesh, objects, output);
|
||||
convertPointFields<vector>(pMesh, objects, output);
|
||||
convertPointFields<sphericalTensor>(pMesh, objects, output);
|
||||
convertPointFields<symmTensor>(pMesh, objects, output);
|
||||
convertPointFields<tensor>(pMesh, objects, output);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertPointFields" << endl;
|
||||
Info<< "<end> convert volume -> point fields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -256,7 +208,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
||||
arrayRange& range = arrayRangeLagrangian_;
|
||||
const fvMesh& mesh = *meshPtr_;
|
||||
|
||||
wordHashSet selectedFields = getSelected
|
||||
hashedWordList selectedFields = getSelected
|
||||
(
|
||||
reader_->GetLagrangianFieldSelection()
|
||||
);
|
||||
@ -268,7 +220,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertLagrangianFields" << endl;
|
||||
Info<< "<beg> convert Lagrangian fields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -282,7 +234,6 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Get the Lagrangian fields for this time and this cloud
|
||||
// but only keep selected fields
|
||||
// the region name is already in the mesh db
|
||||
@ -301,43 +252,25 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "converting OpenFOAM lagrangian fields" << nl;
|
||||
Info<< "converting OpenFOAM lagrangian fields" << endl;
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
Info<< " " << iter()->name()
|
||||
<< " == " << iter()->objectPath() << nl;
|
||||
<< " == " << iter()->objectPath() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
convertLagrangianFields<label>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<scalar>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<vector>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<sphericalTensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<symmTensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<tensor>
|
||||
(
|
||||
objects, output, datasetNo
|
||||
);
|
||||
convertLagrangianFields<label>(objects, output, datasetNo);
|
||||
convertLagrangianFields<scalar>(objects, output, datasetNo);
|
||||
convertLagrangianFields<vector>(objects, output, datasetNo);
|
||||
convertLagrangianFields<sphericalTensor>(objects, output, datasetNo);
|
||||
convertLagrangianFields<symmTensor>(objects, output, datasetNo);
|
||||
convertLagrangianFields<tensor>(objects, output, datasetNo);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertLagrangianFields" << endl;
|
||||
Info<< "<end> convert Lagrangian fields" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,113 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamLagrangianFields_H
|
||||
#define vtkPVFoamLagrangianFields_H
|
||||
|
||||
#include "Cloud.H"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertLagrangianFields
|
||||
(
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const arrayRange& range = arrayRangeLagrangian_;
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
// restrict to this IOField<Type>
|
||||
if (iter()->headerClassName() == IOField<Type>::typeName)
|
||||
{
|
||||
IOField<Type> tf(*iter());
|
||||
convertLagrangianField(tf, output, range, datasetNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertLagrangianField
|
||||
(
|
||||
const IOField<Type>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkFloatArray* pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples(tf.size());
|
||||
pointData->SetNumberOfComponents(nComp);
|
||||
pointData->Allocate(nComp*tf.size());
|
||||
pointData->SetName(tf.name().c_str());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert LagrangianField: "
|
||||
<< tf.name()
|
||||
<< " size = " << tf.size()
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << tf.size() << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
forAll(tf, i)
|
||||
{
|
||||
const Type& t = tf[i];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, range, datasetNo)
|
||||
) ->GetPointData()
|
||||
->AddArray(pointData);
|
||||
|
||||
pointData->Delete();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -57,7 +57,7 @@ void Foam::vtkPVFoam::convertMeshVolume
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshVolume" << endl;
|
||||
Info<< "<beg> convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ void Foam::vtkPVFoam::convertMeshVolume
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -95,7 +95,7 @@ void Foam::vtkPVFoam::convertMeshVolume
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshVolume" << endl;
|
||||
Info<< "<end> convertMeshVolume" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -114,7 +114,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshLagrangian" << endl;
|
||||
Info<< "<beg> convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, cloudName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, cloudName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -146,7 +146,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshLagrangian" << endl;
|
||||
Info<< "<end> convertMeshLagrangian" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ void Foam::vtkPVFoam::convertMeshPatches
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshPatches" << endl;
|
||||
Info<< "<beg> convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -201,26 +201,33 @@ void Foam::vtkPVFoam::convertMeshPatches
|
||||
{
|
||||
sz += patches[iter.key()].size();
|
||||
}
|
||||
labelList meshFaceLabels(sz);
|
||||
labelList faceLabels(sz);
|
||||
sz = 0;
|
||||
forAllConstIter(labelHashSet, patchIds, iter)
|
||||
{
|
||||
const polyPatch& pp = patches[iter.key()];
|
||||
forAll(pp, i)
|
||||
{
|
||||
meshFaceLabels[sz++] = pp.start()+i;
|
||||
faceLabels[sz++] = pp.start()+i;
|
||||
}
|
||||
}
|
||||
UIndirectList<face> fcs(mesh.faces(), meshFaceLabels);
|
||||
uindirectPrimitivePatch pp(fcs, mesh.points());
|
||||
|
||||
uindirectPrimitivePatch pp
|
||||
(
|
||||
UIndirectList<face>
|
||||
(
|
||||
mesh.faces(),
|
||||
faceLabels
|
||||
),
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
vtkmesh = patchVTKMesh(patchName, pp);
|
||||
}
|
||||
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, patchName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, patchName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -235,7 +242,7 @@ void Foam::vtkPVFoam::convertMeshPatches
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshPatches" << endl;
|
||||
Info<< "<end> convertMeshPatches" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -262,7 +269,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshCellZones" << endl;
|
||||
Info<< "<beg> convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -309,7 +316,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
||||
// copy pointMap as well, otherwise pointFields fail
|
||||
zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
|
||||
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -324,7 +331,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshCellZones" << endl;
|
||||
Info<< "<end> convertMeshCellZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -346,7 +353,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshCellSets" << endl;
|
||||
Info<< "<beg> convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -391,7 +398,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
||||
// copy pointMap as well, otherwise pointFields fail
|
||||
csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
|
||||
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -406,7 +413,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshCellSets" << endl;
|
||||
Info<< "<end> convertMeshCellSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -430,7 +437,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshFaceZones" << endl;
|
||||
Info<< "<beg> convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -455,7 +462,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -470,7 +477,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshFaceZones" << endl;
|
||||
Info<< "<end> convertMeshFaceZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -489,7 +496,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshFaceSets" << endl;
|
||||
Info<< "<beg> convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -507,12 +514,26 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
||||
Info<< "Creating VTK mesh for faceSet=" << partName << endl;
|
||||
}
|
||||
|
||||
const faceSet fSet(mesh, partName);
|
||||
// faces in sorted order for more reliability
|
||||
uindirectPrimitivePatch p
|
||||
(
|
||||
UIndirectList<face>
|
||||
(
|
||||
mesh.faces(),
|
||||
faceSet(mesh, partName).sortedToc()
|
||||
),
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
vtkPolyData* vtkmesh = faceSetVTKMesh(mesh, fSet);
|
||||
if (p.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = patchVTKMesh("faceSet:" + partName, p);
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -527,7 +548,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshFaceSets" << endl;
|
||||
Info<< "<end> convertMeshFaceSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -546,7 +567,7 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshPointZones" << endl;
|
||||
Info<< "<beg> convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -563,10 +584,24 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = pointZoneVTKMesh(mesh, zMesh[zoneId]);
|
||||
const labelUList& pointLabels = zMesh[zoneId];
|
||||
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(pointLabels.size());
|
||||
|
||||
const pointField& meshPoints = mesh.points();
|
||||
forAll(pointLabels, pointi)
|
||||
{
|
||||
vtkpoints->InsertNextPoint(meshPoints[pointLabels[pointi]].v_);
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -582,7 +617,7 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshPointZones" << endl;
|
||||
Info<< "<end> convertMeshPointZones" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
@ -602,7 +637,7 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::convertMeshPointSets" << endl;
|
||||
Info<< "<beg> convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -622,10 +657,22 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
||||
|
||||
const pointSet pSet(mesh, partName);
|
||||
|
||||
vtkPolyData* vtkmesh = pointSetVTKMesh(mesh, pSet);
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(pSet.size());
|
||||
|
||||
const pointField& meshPoints = mesh.points();
|
||||
forAllConstIter(pointSet, pSet, iter)
|
||||
{
|
||||
vtkpoints->InsertNextPoint(meshPoints[iter.key()].v_);
|
||||
}
|
||||
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
if (vtkmesh)
|
||||
{
|
||||
AddToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||
vtkmesh->Delete();
|
||||
|
||||
partDataset_[partId] = datasetNo++;
|
||||
@ -640,7 +687,7 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::convertMeshPointSets" << endl;
|
||||
Info<< "<end> convertMeshPointSets" << endl;
|
||||
printMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -30,7 +30,6 @@ License
|
||||
#include "fvMesh.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
@ -41,7 +40,7 @@ License
|
||||
|
||||
vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const polyMesh& mesh,
|
||||
const word& cloudName
|
||||
)
|
||||
{
|
||||
@ -49,7 +48,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::lagrangianVTKMesh - timePath "
|
||||
Info<< "<beg> lagrangianVTKMesh - timePath "
|
||||
<< mesh.time().timePath()/cloud::prefix/cloudName << endl;
|
||||
printMemory();
|
||||
}
|
||||
@ -83,7 +82,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
||||
vtkIdType particleId = 0;
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, iter)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position());
|
||||
vtkpoints->InsertNextPoint(iter().position().v_);
|
||||
|
||||
vtkcells->InsertNextCell(1, &particleId);
|
||||
particleId++;
|
||||
@ -98,7 +97,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::lagrangianVTKMesh" << endl;
|
||||
Info<< "<end> lagrangianVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
|
||||
@ -1,148 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPVFoam.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPoints.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkCellArray.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
vtkPolyData* Foam::vtkPVFoam::faceSetVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const faceSet& fSet
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::faceSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
// Construct primitivePatch of faces in fSet.
|
||||
|
||||
const faceList& meshFaces = mesh.faces();
|
||||
faceList patchFaces(fSet.size());
|
||||
label facei = 0;
|
||||
forAllConstIter(faceSet, fSet, iter)
|
||||
{
|
||||
patchFaces[facei++] = meshFaces[iter.key()];
|
||||
}
|
||||
primitiveFacePatch p(patchFaces, mesh.points());
|
||||
|
||||
|
||||
// The balance of this routine should be identical to patchVTKMesh
|
||||
|
||||
// Convert OpenFOAM mesh vertices to VTK
|
||||
const pointField& points = p.localPoints();
|
||||
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(points.size());
|
||||
forAll(points, i)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
||||
}
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
// Add faces as polygons
|
||||
const faceList& faces = p.localFaces();
|
||||
|
||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
||||
vtkcells->Allocate(faces.size());
|
||||
|
||||
forAll(faces, facei)
|
||||
{
|
||||
const face& f = faces[facei];
|
||||
vtkIdType nodeIds[f.size()];
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
nodeIds[fp] = f[fp];
|
||||
}
|
||||
vtkcells->InsertNextCell(f.size(), nodeIds);
|
||||
}
|
||||
|
||||
vtkmesh->SetPolys(vtkcells);
|
||||
vtkcells->Delete();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::faceSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
vtkPolyData* Foam::vtkPVFoam::pointSetVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const pointSet& pSet
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::pointSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const pointField& meshPoints = mesh.points();
|
||||
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(pSet.size());
|
||||
|
||||
forAllConstIter(pointSet, pSet, iter)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, meshPoints[iter.key()]);
|
||||
}
|
||||
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::pointSetVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,8 +29,6 @@ License
|
||||
// OpenFOAM includes
|
||||
#include "fvMesh.H"
|
||||
#include "cellModeller.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
#include "Swap.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
@ -56,7 +54,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::volumeVTKMesh" << endl;
|
||||
Info<< "<beg> volumeVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -78,11 +76,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
// and cells
|
||||
if (!reader_->GetUseVTKPolyhedron())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "... scanning for polyhedra" << endl;
|
||||
}
|
||||
|
||||
forAll(cellShapes, celli)
|
||||
{
|
||||
const cellModel& model = cellShapes[celli].model();
|
||||
@ -123,21 +116,8 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
// Set size of additional cells mapping array
|
||||
// (from added cell to original cell)
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<<" mesh nCells = " << mesh.nCells() << nl
|
||||
<<" nPoints = " << mesh.nPoints() << nl
|
||||
<<" nAddCells = " << nAddCells << nl
|
||||
<<" nAddPoints = " << nAddPoints << endl;
|
||||
}
|
||||
|
||||
superCells.setSize(mesh.nCells() + nAddCells);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "... converting points" << endl;
|
||||
}
|
||||
|
||||
// Convert OpenFOAM mesh vertices to VTK
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
|
||||
@ -146,13 +126,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
|
||||
forAll(points, i)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
||||
}
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "... converting cells" << endl;
|
||||
vtkpoints->InsertNextPoint(points[i].v_);
|
||||
}
|
||||
|
||||
vtkmesh->Allocate(mesh.nCells() + nAddCells);
|
||||
@ -329,7 +303,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
|
||||
// The new vertex from the cell-centre
|
||||
const label newVertexLabel = mesh.nPoints() + addPointi;
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, mesh.C()[celli]);
|
||||
vtkpoints->InsertNextPoint(mesh.C()[celli].v_);
|
||||
|
||||
// Whether to insert cell in place of original or not.
|
||||
bool substituteCell = true;
|
||||
@ -441,7 +415,10 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::volumeVTKMesh" << endl;
|
||||
Info<<"nCells=" << mesh.nCells() <<" nPoints=" << mesh.nPoints()
|
||||
<<" nAddCells=" << nAddCells <<" nAddPoints=" << nAddPoints
|
||||
<< nl
|
||||
<< "<end> volumeVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPVFoam.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPoints.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkCellArray.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
vtkPolyData* Foam::vtkPVFoam::pointZoneVTKMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const labelList& pointLabels
|
||||
)
|
||||
{
|
||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::pointZoneVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
const pointField& meshPoints = mesh.points();
|
||||
|
||||
vtkPoints* vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate(pointLabels.size());
|
||||
|
||||
forAll(pointLabels, pointi)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, meshPoints[pointLabels[pointi]]);
|
||||
}
|
||||
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::pointZoneVTKMesh" << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
return vtkmesh;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,129 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamPatchField_H
|
||||
#define vtkPVFoamPatchField_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellData.h"
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkPointData.h"
|
||||
#include "vtkPolyData.h"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertPatchField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& ptf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkFloatArray* cellData = vtkFloatArray::New();
|
||||
cellData->SetNumberOfTuples(ptf.size());
|
||||
cellData->SetNumberOfComponents(nComp);
|
||||
cellData->Allocate(nComp*ptf.size());
|
||||
cellData->SetName(name.c_str());
|
||||
|
||||
float vec[nComp];
|
||||
forAll(ptf, i)
|
||||
{
|
||||
const Type& t = ptf[i];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
cellData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, range, datasetNo)
|
||||
) ->GetCellData()
|
||||
->AddArray(cellData);
|
||||
|
||||
cellData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// as above, but with PointData()
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertPatchPointField
|
||||
(
|
||||
const word& name,
|
||||
const Field<Type>& pptf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
vtkFloatArray* pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples(pptf.size());
|
||||
pointData->SetNumberOfComponents(nComp);
|
||||
pointData->Allocate(nComp*pptf.size());
|
||||
pointData->SetName(name.c_str());
|
||||
|
||||
float vec[nComp];
|
||||
forAll(pptf, i)
|
||||
{
|
||||
const Type& t = pptf[i];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
vtkPolyData::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, range, datasetNo)
|
||||
) ->GetPointData()
|
||||
->AddArray(pointData);
|
||||
|
||||
pointData->Delete();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,331 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamPointFields_H
|
||||
#define vtkPVFoamPointFields_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "interpolatePointToCell.H"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertPointFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const pointMesh& pMesh,
|
||||
const IOobjectList& objects,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
const word& fieldName = iter()->name();
|
||||
// restrict to this GeometricField<Type, ...>
|
||||
if
|
||||
(
|
||||
iter()->headerClassName()
|
||||
!= GeometricField<Type, pointPatchField, pointMesh>::typeName
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Foam::vtkPVFoam::convertPointFields : "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
|
||||
GeometricField<Type, pointPatchField, pointMesh> ptf
|
||||
(
|
||||
*iter(),
|
||||
pMesh
|
||||
);
|
||||
|
||||
|
||||
// Convert activated internalMesh regions
|
||||
convertPointFieldBlock
|
||||
(
|
||||
ptf,
|
||||
output,
|
||||
arrayRangeVolume_,
|
||||
regionPolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellZones
|
||||
convertPointFieldBlock
|
||||
(
|
||||
ptf,
|
||||
output,
|
||||
arrayRangeCellZones_,
|
||||
zonePolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellSets
|
||||
convertPointFieldBlock
|
||||
(
|
||||
ptf,
|
||||
output,
|
||||
arrayRangeCellSets_,
|
||||
csetPolyDecomp_
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Convert patches - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangePatches_.start();
|
||||
partId < arrayRangePatches_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word patchName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
const label patchId = patches.findPatchID(patchName);
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
convertPatchPointField
|
||||
(
|
||||
fieldName,
|
||||
ptf.boundaryField()[patchId].patchInternalField()(),
|
||||
output,
|
||||
arrayRangePatches_,
|
||||
datasetNo
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert faceZones - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangeFaceZones_.start();
|
||||
partId < arrayRangeFaceZones_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word zoneName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
const label zoneId = mesh.faceZones().findZoneID(zoneName);
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0 || zoneId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Extract the field on the zone
|
||||
Field<Type> fld
|
||||
(
|
||||
ptf.primitiveField(),
|
||||
mesh.faceZones()[zoneId]().meshPoints()
|
||||
);
|
||||
|
||||
convertPatchPointField
|
||||
(
|
||||
fieldName,
|
||||
fld,
|
||||
output,
|
||||
arrayRangeFaceZones_,
|
||||
datasetNo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertPointFieldBlock
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const List<polyDecomp>& decompLst
|
||||
)
|
||||
{
|
||||
for (int partId = range.start(); partId < range.end(); ++partId)
|
||||
{
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (datasetNo >= 0 && partStatus_[partId])
|
||||
{
|
||||
convertPointField
|
||||
(
|
||||
ptf,
|
||||
GeometricField<Type, fvPatchField, volMesh>::null(),
|
||||
output,
|
||||
range,
|
||||
datasetNo,
|
||||
decompLst[datasetNo]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertPointField
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& ptf,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const label datasetNo,
|
||||
const polyDecomp& decomp
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
const labelList& addPointCellLabels = decomp.addPointCellLabels();
|
||||
const labelList& pointMap = decomp.pointMap();
|
||||
|
||||
// use a pointMap or address directly into mesh
|
||||
label nPoints;
|
||||
if (pointMap.size())
|
||||
{
|
||||
nPoints = pointMap.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
nPoints = ptf.size();
|
||||
}
|
||||
|
||||
vtkFloatArray* pointData = vtkFloatArray::New();
|
||||
pointData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
|
||||
pointData->SetNumberOfComponents(nComp);
|
||||
pointData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
|
||||
|
||||
// Note: using the name of the original volField
|
||||
// not the name generated by the interpolation "volPointInterpolate(<name>)"
|
||||
|
||||
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
|
||||
{
|
||||
pointData->SetName(tf.name().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
pointData->SetName(ptf.name().c_str());
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert convertPointField: "
|
||||
<< ptf.name()
|
||||
<< " size = " << nPoints
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << (nPoints + addPointCellLabels.size())
|
||||
<< endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
|
||||
if (pointMap.size())
|
||||
{
|
||||
forAll(pointMap, i)
|
||||
{
|
||||
const Type& t = ptf[pointMap[i]];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(ptf, i)
|
||||
{
|
||||
const Type& t = ptf[i];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
pointData->InsertTuple(i, vec);
|
||||
}
|
||||
}
|
||||
|
||||
// continue insertion from here
|
||||
label i = nPoints;
|
||||
|
||||
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
|
||||
{
|
||||
forAll(addPointCellLabels, apI)
|
||||
{
|
||||
const Type& t = tf[addPointCellLabels[apI]];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
pointData->InsertTuple(i++, vec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(addPointCellLabels, apI)
|
||||
{
|
||||
Type t = interpolatePointToCell(ptf, addPointCellLabels[apI]);
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
pointData->InsertTuple(i++, vec);
|
||||
}
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, range, datasetNo)
|
||||
) ->GetPointData()
|
||||
->AddArray(pointData);
|
||||
|
||||
pointData->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -28,7 +28,6 @@ License
|
||||
// OpenFOAM includes
|
||||
#include "polyPatch.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
@ -48,7 +47,7 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::patchVTKMesh - " << name << endl;
|
||||
Info<< "<beg> patchVTKMesh - " << name << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
@ -59,13 +58,12 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
||||
vtkpoints->Allocate(points.size());
|
||||
forAll(points, i)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint(vtkpoints, points[i]);
|
||||
vtkpoints->InsertNextPoint(points[i].v_);
|
||||
}
|
||||
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
|
||||
// Add faces as polygons
|
||||
const faceList& faces = p.localFaces();
|
||||
|
||||
@ -88,7 +86,7 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::patchVTKMesh - " << name << endl;
|
||||
Info<< "<end> patchVTKMesh - " << name << endl;
|
||||
printMemory();
|
||||
}
|
||||
|
||||
|
||||
@ -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,13 +36,12 @@ License
|
||||
#include "Cloud.H"
|
||||
#include "vtkPVFoamReader.h"
|
||||
|
||||
// local headers
|
||||
#include "vtkPVFoamAddToSelection.H"
|
||||
#include "vtkPVFoamUpdateInfoFields.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
|
||||
// Templates (only needed here)
|
||||
#include "vtkPVFoamUpdateTemplates.C"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Private Classes * * * * * * * * * * * * * * //
|
||||
|
||||
@ -85,14 +84,14 @@ template<class ZoneType>
|
||||
Foam::wordList Foam::vtkPVFoam::getZoneNames
|
||||
(
|
||||
const ZoneMesh<ZoneType, polyMesh>& zmesh
|
||||
) const
|
||||
)
|
||||
{
|
||||
wordList names(zmesh.size());
|
||||
label nZone = 0;
|
||||
|
||||
forAll(zmesh, zoneI)
|
||||
{
|
||||
if (zmesh[zoneI].size())
|
||||
if (!zmesh[zoneI].empty())
|
||||
{
|
||||
names[nZone++] = zmesh[zoneI].name();
|
||||
}
|
||||
@ -124,7 +123,7 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
|
||||
false
|
||||
);
|
||||
|
||||
if (ioObj.typeHeaderOk<cellZoneMesh>(false))
|
||||
if (ioObj.typeHeaderOk<cellZoneMesh>(false, false))
|
||||
{
|
||||
zonesEntries zones(ioObj);
|
||||
|
||||
@ -146,7 +145,7 @@ void Foam::vtkPVFoam::updateInfoInternalMesh
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoInternalMesh" << endl;
|
||||
Info<< "<beg> updateInfoInternalMesh" << endl;
|
||||
}
|
||||
|
||||
// Determine mesh parts (internalMesh, patches...)
|
||||
@ -160,10 +159,7 @@ void Foam::vtkPVFoam::updateInfoInternalMesh
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoInternalMesh" << endl;
|
||||
Info<< "<end> updateInfoInternalMesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +171,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoLagrangian" << nl
|
||||
Info<< "<beg> updateInfoLagrangian" << nl
|
||||
<< " " << dbPtr_->timePath()/cloud::prefix << endl;
|
||||
}
|
||||
|
||||
@ -211,10 +207,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoLagrangian" << endl;
|
||||
Info<< "<end> updateInfoLagrangian" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,8 +220,8 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoPatches"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
|
||||
Info<< "<beg> updateInfoPatches"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -333,7 +326,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
);
|
||||
|
||||
// this should only ever fail if the mesh region doesn't exist
|
||||
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true))
|
||||
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true, false))
|
||||
{
|
||||
polyBoundaryMeshEntries patchEntries(ioObj);
|
||||
|
||||
@ -377,7 +370,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
}
|
||||
else
|
||||
{
|
||||
groups.insert(groupNames[groupI], labelList(1, patchi));
|
||||
groups.insert(groupNames[groupI], labelList{patchi});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -455,10 +448,7 @@ void Foam::vtkPVFoam::updateInfoPatches
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoPatches" << endl;
|
||||
Info<< "<end> updateInfoPatches" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -475,8 +465,8 @@ void Foam::vtkPVFoam::updateInfoZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoZones"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
|
||||
Info<< "<beg> updateInfoZones"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
wordList namesLst;
|
||||
@ -551,10 +541,7 @@ void Foam::vtkPVFoam::updateInfoZones
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoZones" << endl;
|
||||
Info<< "<end> updateInfoZones" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -571,7 +558,7 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoSets" << endl;
|
||||
Info<< "<beg> updateInfoSets" << endl;
|
||||
}
|
||||
|
||||
// Add names of sets. Search for last time directory with a sets
|
||||
@ -596,7 +583,7 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< " Foam::vtkPVFoam::updateInfoSets read "
|
||||
Info<< " updateInfoSets read "
|
||||
<< objects.names() << " from " << setsInstance << endl;
|
||||
}
|
||||
|
||||
@ -627,28 +614,41 @@ void Foam::vtkPVFoam::updateInfoSets
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoSets" << endl;
|
||||
Info<< "<end> updateInfoSets" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateInfoLagrangianFields()
|
||||
void Foam::vtkPVFoam::updateInfoFields()
|
||||
{
|
||||
updateInfoFields<fvPatchField, volMesh>
|
||||
(
|
||||
reader_->GetVolFieldSelection()
|
||||
);
|
||||
updateInfoFields<pointPatchField, pointMesh>
|
||||
(
|
||||
reader_->GetPointFieldSelection()
|
||||
);
|
||||
updateInfoLagrangianFields
|
||||
(
|
||||
reader_->GetLagrangianFieldSelection()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::updateInfoLagrangianFields
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoLagrangianFields"
|
||||
<< endl;
|
||||
Info<< "<beg> updateInfoLagrangianFields" << endl;
|
||||
}
|
||||
|
||||
vtkDataArraySelection* fieldSelection =
|
||||
reader_->GetLagrangianFieldSelection();
|
||||
|
||||
// preserve the enabled selections
|
||||
stringList enabledEntries = getSelectedArrayEntries(fieldSelection);
|
||||
fieldSelection->RemoveAllArrays();
|
||||
stringList enabledEntries = getSelectedArrayEntries(select);
|
||||
select->RemoveAllArrays();
|
||||
|
||||
// TODO - currently only get fields from ONE cloud
|
||||
// have to decide if the second set of fields get mixed in
|
||||
@ -678,44 +678,37 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields()
|
||||
lagrangianPrefix/cloudName
|
||||
);
|
||||
|
||||
addToSelection<IOField<label>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<scalar>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<vector>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<sphericalTensor>>
|
||||
(
|
||||
fieldSelection,
|
||||
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<symmTensor>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<tensor>>
|
||||
(
|
||||
fieldSelection,
|
||||
objects
|
||||
);
|
||||
addToSelection<IOField<label>>(select, objects);
|
||||
addToSelection<IOField<scalar>>(select, objects);
|
||||
addToSelection<IOField<vector>>(select, objects);
|
||||
addToSelection<IOField<sphericalTensor>>(select, objects);
|
||||
addToSelection<IOField<symmTensor>>(select, objects);
|
||||
addToSelection<IOField<tensor>>(select, objects);
|
||||
|
||||
// restore the enabled selections
|
||||
setSelectedArrayEntries(fieldSelection, enabledEntries);
|
||||
setSelectedArrayEntries(select, enabledEntries);
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
boolList status;
|
||||
const label nElem = getSelected(status, select);
|
||||
|
||||
forAll(status, i)
|
||||
{
|
||||
Info<< " lagrangian[" << i << "] = "
|
||||
<< status[i]
|
||||
<< " : " << select->GetArrayName(i) << nl;
|
||||
}
|
||||
|
||||
if (!nElem)
|
||||
{
|
||||
Info<< " lagrangian[none]" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoLagrangianFields - "
|
||||
Info<< "<end> updateInfoLagrangianFields - "
|
||||
<< "lagrangian objects.size() = " << objects.size() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,8 +26,8 @@ InClass
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamUpdateInfoFields_H
|
||||
#define vtkPVFoamUpdateInfoFields_H
|
||||
#ifndef vtkPVFoamUpdateTemplates_C
|
||||
#define vtkPVFoamUpdateTemplates_C
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -39,19 +39,17 @@ void Foam::vtkPVFoam::updateInfoFields
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVFoam::updateInfoFields <"
|
||||
Info<< "<beg> updateInfoFields <"
|
||||
<< meshType::Mesh::typeName
|
||||
<< "> [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]"
|
||||
<< "> [meshPtr=" << (meshPtr_ ? "set" : "null") << "]"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
stringList enabledEntries;
|
||||
// enable 'p' and 'U' on the first call
|
||||
if (select->GetNumberOfArrays() == 0 && !meshPtr_)
|
||||
if (!select->GetNumberOfArrays() && !meshPtr_)
|
||||
{
|
||||
enabledEntries.setSize(2);
|
||||
enabledEntries[0] = "p";
|
||||
enabledEntries[1] = "U";
|
||||
// enable 'p' and 'U' only on the first call
|
||||
enabledEntries = { "p", "U" };
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -72,7 +70,7 @@ void Foam::vtkPVFoam::updateInfoFields
|
||||
// Search for list of objects for this time and mesh region
|
||||
IOobjectList objects(dbPtr_(), dbPtr_().timeName(), regionPrefix);
|
||||
|
||||
//- Add volume fields to GUI
|
||||
// Add volume fields to GUI
|
||||
addToSelection<GeometricField<scalar, patchType, meshType>>
|
||||
(
|
||||
select,
|
||||
@ -93,13 +91,14 @@ void Foam::vtkPVFoam::updateInfoFields
|
||||
select,
|
||||
objects
|
||||
);
|
||||
|
||||
addToSelection<GeometricField<tensor, patchType, meshType>>
|
||||
(
|
||||
select,
|
||||
objects
|
||||
);
|
||||
|
||||
//- Add dimensioned fields to GUI
|
||||
// Add dimensioned fields to GUI
|
||||
addToSelection<DimensionedField<scalar, meshType>>
|
||||
(
|
||||
select,
|
||||
@ -132,7 +131,7 @@ void Foam::vtkPVFoam::updateInfoFields
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVFoam::updateInfoFields" << endl;
|
||||
Info<< "<end> updateInfoFields" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,340 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
Misc helper methods and utilities
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPVFoam.H"
|
||||
#include "vtkPVFoamReader.h"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "fvMesh.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
#include "memInfo.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkDataSet.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkInformation.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
//! \cond fileScope
|
||||
// Extract up to the first non-word characters
|
||||
inline word getFirstWord(const char* str)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
label n = 0;
|
||||
while (str[n] && word::valid(str[n]))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
return word(str, n, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return word::null;
|
||||
}
|
||||
|
||||
}
|
||||
//! \endcond
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVFoam::AddToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const arrayRange& range,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
)
|
||||
{
|
||||
const int blockNo = range.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
|
||||
if (!block)
|
||||
{
|
||||
if (blockDO)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Block already has a vtkDataSet assigned to it"
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
|
||||
block = vtkMultiBlockDataSet::New();
|
||||
output->SetBlock(blockNo, block);
|
||||
block->Delete();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "block[" << blockNo << "] has "
|
||||
<< block->GetNumberOfBlocks()
|
||||
<< " datasets prior to adding set " << datasetNo
|
||||
<< " with name: " << datasetName << endl;
|
||||
}
|
||||
|
||||
block->SetBlock(datasetNo, dataset);
|
||||
|
||||
// name the block when assigning dataset 0
|
||||
if (datasetNo == 0)
|
||||
{
|
||||
output->GetMetaData(blockNo)->Set
|
||||
(
|
||||
vtkCompositeDataSet::NAME(),
|
||||
range.name()
|
||||
);
|
||||
}
|
||||
|
||||
if (datasetName.size())
|
||||
{
|
||||
block->GetMetaData(datasetNo)->Set
|
||||
(
|
||||
vtkCompositeDataSet::NAME(),
|
||||
datasetName.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vtkDataSet* Foam::vtkPVFoam::GetDataSetFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const int blockNo = range.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
|
||||
if (block)
|
||||
{
|
||||
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ununsed at the moment
|
||||
Foam::label Foam::vtkPVFoam::GetNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range
|
||||
)
|
||||
{
|
||||
const int blockNo = range.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
if (block)
|
||||
{
|
||||
return block->GetNumberOfBlocks();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::vtkPVFoam::getPartName(const int partId)
|
||||
{
|
||||
return getFirstWord(reader_->GetPartArrayName(partId));
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPVFoam::getSelected
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
|
||||
for (int elemI=0; elemI < nElem; ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections.insert(getFirstWord(select->GetArrayName(elemI)));
|
||||
}
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPVFoam::getSelected
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const arrayRange& range
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
|
||||
for (int elemI = range.start(); elemI < range.end(); ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections.insert(getFirstWord(select->GetArrayName(elemI)));
|
||||
}
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPVFoam::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
stringList selections(select->GetNumberOfArrays());
|
||||
label nElem = 0;
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections[nElem++] = select->GetArrayName(elemI);
|
||||
}
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
label nElem = select->GetNumberOfArrays();
|
||||
Info<< "available(";
|
||||
for (int elemI = 0; elemI < nElem; ++elemI)
|
||||
{
|
||||
Info<< " \"" << select->GetArrayName(elemI) << "\"";
|
||||
}
|
||||
Info<< " )\nselected(";
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
Info<< " " << selections[elemI];
|
||||
}
|
||||
Info<< " )\n";
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPVFoam::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const arrayRange& range
|
||||
)
|
||||
{
|
||||
stringList selections(range.size());
|
||||
label nElem = 0;
|
||||
|
||||
for (int elemI = range.start(); elemI < range.end(); ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections[nElem++] = select->GetArrayName(elemI);
|
||||
}
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "available(";
|
||||
for (int elemI = range.start(); elemI < range.end(); ++elemI)
|
||||
{
|
||||
Info<< " \"" << select->GetArrayName(elemI) << "\"";
|
||||
}
|
||||
Info<< " )\nselected(";
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
Info<< " " << selections[elemI];
|
||||
}
|
||||
Info<< " )\n";
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVFoam::setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const stringList& selections
|
||||
)
|
||||
{
|
||||
const int nElem = select->GetNumberOfArrays();
|
||||
select->DisableAllArrays();
|
||||
|
||||
// Loop through entries, setting values from selectedEntries
|
||||
for (int elemI=0; elemI < nElem; ++elemI)
|
||||
{
|
||||
string arrayName(select->GetArrayName(elemI));
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
if (selections[elemI] == arrayName)
|
||||
{
|
||||
select->EnableArray(arrayName.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVFoam::printMemory()
|
||||
{
|
||||
memInfo mem;
|
||||
|
||||
if (mem.valid())
|
||||
{
|
||||
Info<< "mem peak/size/rss: " << mem << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,456 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
vtkPVFoam
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamVolFields_H
|
||||
#define vtkPVFoamVolFields_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "emptyFvPatchField.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "faceSet.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "zeroGradientFvPatchField.H"
|
||||
|
||||
#include "vtkPVFoamFaceField.H"
|
||||
#include "vtkPVFoamPatchField.H"
|
||||
|
||||
#include "vtkOpenFOAMTupleRemap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertVolField
|
||||
(
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>& ppInterpList,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = tf.mesh();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
// Interpolated field (demand driven)
|
||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>> ptfPtr;
|
||||
if (interpFields)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convertVolFieldBlock interpolating:" << tf.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
ptfPtr.reset
|
||||
(
|
||||
volPointInterpolation::New(mesh).interpolate(tf).ptr()
|
||||
);
|
||||
}
|
||||
|
||||
// Convert activated internalMesh regions
|
||||
convertVolFieldBlock
|
||||
(
|
||||
tf,
|
||||
ptfPtr,
|
||||
output,
|
||||
arrayRangeVolume_,
|
||||
regionPolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellZones
|
||||
convertVolFieldBlock
|
||||
(
|
||||
tf,
|
||||
ptfPtr,
|
||||
output,
|
||||
arrayRangeCellZones_,
|
||||
zonePolyDecomp_
|
||||
);
|
||||
|
||||
// Convert activated cellSets
|
||||
convertVolFieldBlock
|
||||
(
|
||||
tf,
|
||||
ptfPtr,
|
||||
output,
|
||||
arrayRangeCellSets_,
|
||||
csetPolyDecomp_
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Convert patches - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangePatches_.start();
|
||||
partId < arrayRangePatches_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word patchName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
const label patchId = patches.findPatchID(patchName);
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const fvPatchField<Type>& ptf = tf.boundaryField()[patchId];
|
||||
|
||||
if
|
||||
(
|
||||
isType<emptyFvPatchField<Type>>(ptf)
|
||||
||
|
||||
(
|
||||
reader_->GetExtrapolatePatches()
|
||||
&& !polyPatch::constraintType(patches[patchId].type())
|
||||
)
|
||||
)
|
||||
{
|
||||
fvPatch p(ptf.patch().patch(), mesh.boundary());
|
||||
|
||||
tmp<Field<Type>> tpptf
|
||||
(
|
||||
fvPatchField<Type>(p, tf).patchInternalField()
|
||||
);
|
||||
|
||||
convertPatchField
|
||||
(
|
||||
tf.name(),
|
||||
tpptf(),
|
||||
output,
|
||||
arrayRangePatches_,
|
||||
datasetNo
|
||||
);
|
||||
|
||||
if (interpFields)
|
||||
{
|
||||
convertPatchPointField
|
||||
(
|
||||
tf.name(),
|
||||
ppInterpList[patchId].faceToPointInterpolate(tpptf)(),
|
||||
output,
|
||||
arrayRangePatches_,
|
||||
datasetNo
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
convertPatchField
|
||||
(
|
||||
tf.name(),
|
||||
ptf,
|
||||
output,
|
||||
arrayRangePatches_,
|
||||
datasetNo
|
||||
);
|
||||
|
||||
if (interpFields)
|
||||
{
|
||||
convertPatchPointField
|
||||
(
|
||||
tf.name(),
|
||||
ppInterpList[patchId].faceToPointInterpolate(ptf)(),
|
||||
output,
|
||||
arrayRangePatches_,
|
||||
datasetNo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Convert face zones - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangeFaceZones_.start();
|
||||
partId < arrayRangeFaceZones_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word zoneName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const faceZoneMesh& zMesh = mesh.faceZones();
|
||||
const label zoneId = zMesh.findZoneID(zoneName);
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
convertFaceField
|
||||
(
|
||||
tf,
|
||||
output,
|
||||
arrayRangeFaceZones_,
|
||||
datasetNo,
|
||||
mesh,
|
||||
zMesh[zoneId]
|
||||
);
|
||||
|
||||
// TODO: points
|
||||
}
|
||||
|
||||
//
|
||||
// Convert face sets - if activated
|
||||
//
|
||||
for
|
||||
(
|
||||
int partId = arrayRangeFaceSets_.start();
|
||||
partId < arrayRangeFaceSets_.end();
|
||||
++partId
|
||||
)
|
||||
{
|
||||
const word selectName = getPartName(partId);
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (!partStatus_[partId] || datasetNo < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const faceSet fSet(mesh, selectName);
|
||||
|
||||
convertFaceField
|
||||
(
|
||||
tf,
|
||||
output,
|
||||
arrayRangeFaceSets_,
|
||||
datasetNo,
|
||||
mesh,
|
||||
fSet.toc()
|
||||
);
|
||||
|
||||
// TODO: points
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertVolFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>& ppInterpList,
|
||||
const IOobjectList& objects,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
// restrict to GeometricField<Type, ...>
|
||||
if
|
||||
(
|
||||
iter()->headerClassName()
|
||||
!= GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Load field
|
||||
GeometricField<Type, fvPatchField, volMesh> tf
|
||||
(
|
||||
*iter(),
|
||||
mesh
|
||||
);
|
||||
|
||||
// Convert
|
||||
convertVolField(ppInterpList, tf, interpFields, output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertDimFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const PtrList<PrimitivePatchInterpolation<primitivePatch>>& ppInterpList,
|
||||
const IOobjectList& objects,
|
||||
const bool interpFields,
|
||||
vtkMultiBlockDataSet* output
|
||||
)
|
||||
{
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
// restrict to DimensionedField<Type, ...>
|
||||
if
|
||||
(
|
||||
iter()->headerClassName()
|
||||
!= DimensionedField<Type, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Load field
|
||||
DimensionedField<Type, volMesh> dimFld(*iter(), mesh);
|
||||
|
||||
|
||||
// Construct volField with zero-gradient patch fields
|
||||
|
||||
IOobject io(dimFld);
|
||||
io.readOpt() = IOobject::NO_READ;
|
||||
|
||||
PtrList<fvPatchField<Type>> patchFields(mesh.boundary().size());
|
||||
forAll(patchFields, patchI)
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchI,
|
||||
fvPatchField<Type>::New
|
||||
(
|
||||
zeroGradientFvPatchField<scalar>::typeName,
|
||||
mesh.boundary()[patchI],
|
||||
dimFld
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
GeometricField<Type, fvPatchField, volMesh> volFld
|
||||
(
|
||||
io,
|
||||
dimFld.mesh(),
|
||||
dimFld.dimensions(),
|
||||
dimFld,
|
||||
patchFields
|
||||
);
|
||||
volFld.correctBoundaryConditions();
|
||||
|
||||
convertVolField(ppInterpList, volFld, interpFields, output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertVolFieldBlock
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const List<polyDecomp>& decompLst
|
||||
)
|
||||
{
|
||||
for (int partId = range.start(); partId < range.end(); ++partId)
|
||||
{
|
||||
const label datasetNo = partDataset_[partId];
|
||||
|
||||
if (datasetNo >= 0 && partStatus_[partId])
|
||||
{
|
||||
convertVolField
|
||||
(
|
||||
tf,
|
||||
output,
|
||||
range,
|
||||
datasetNo,
|
||||
decompLst[datasetNo]
|
||||
);
|
||||
|
||||
if (ptfPtr.valid())
|
||||
{
|
||||
convertPointField
|
||||
(
|
||||
ptfPtr(),
|
||||
tf,
|
||||
output,
|
||||
range,
|
||||
datasetNo,
|
||||
decompLst[datasetNo]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkPVFoam::convertVolField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& tf,
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const label datasetNo,
|
||||
const polyDecomp& decompInfo
|
||||
)
|
||||
{
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
const labelList& superCells = decompInfo.superCells();
|
||||
|
||||
vtkFloatArray* celldata = vtkFloatArray::New();
|
||||
celldata->SetNumberOfTuples(superCells.size());
|
||||
celldata->SetNumberOfComponents(nComp);
|
||||
celldata->Allocate(nComp*superCells.size());
|
||||
celldata->SetName(tf.name().c_str());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "convert volField: "
|
||||
<< tf.name()
|
||||
<< " size = " << tf.size()
|
||||
<< " nComp=" << nComp
|
||||
<< " nTuples = " << superCells.size() << endl;
|
||||
}
|
||||
|
||||
float vec[nComp];
|
||||
forAll(superCells, i)
|
||||
{
|
||||
const Type& t = tf[superCells[i]];
|
||||
for (direction d=0; d<nComp; ++d)
|
||||
{
|
||||
vec[d] = component(t, d);
|
||||
}
|
||||
vtkOpenFOAMTupleRemap<Type>(vec);
|
||||
|
||||
celldata->InsertTuple(i, vec);
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid::SafeDownCast
|
||||
(
|
||||
GetDataSetFromBlock(output, range, datasetNo)
|
||||
) ->GetCellData()
|
||||
->AddArray(celldata);
|
||||
|
||||
celldata->Delete();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,17 +2,15 @@
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Source the wmake functions
|
||||
. $WM_DIR/scripts/wmakeFunctions
|
||||
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
|
||||
|
||||
#set -x
|
||||
|
||||
# deal with client/server vs combined plugins
|
||||
# Cleanup client-server and/or combined plugins
|
||||
rm -f $FOAM_LIBBIN/libPVblockMeshReader* 2>/dev/null
|
||||
|
||||
rm -rf PVblockMeshReader/Make # safety: old build location
|
||||
wclean libso vtkPVblockMesh
|
||||
|
||||
# Where are the generated files stored?
|
||||
# Cleanup generated files
|
||||
findObjectDir $PWD # remove entire top-level
|
||||
rm -rf "$objectsDir" > /dev/null 2>&1
|
||||
|
||||
|
||||
@ -4,49 +4,18 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
# Source the wmake functions
|
||||
. $WM_DIR/scripts/wmakeFunctions
|
||||
|
||||
# Ensure CMake gets the correct C/C++ compilers
|
||||
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
||||
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
||||
|
||||
|
||||
# CMake into objectsDir,
|
||||
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
|
||||
doCmake()
|
||||
{
|
||||
local sourceDir="$1"
|
||||
|
||||
findObjectDir $sourceDir # Where are generated files stored?
|
||||
test -f "$objectsDir/CMakeCache.txt"
|
||||
retry=$? # CMakeCache.txt exists, but sources may have moved
|
||||
|
||||
mkdir -p $objectsDir && \
|
||||
(
|
||||
cd $objectsDir || exit 1
|
||||
|
||||
cmake $sourceDir || {
|
||||
if [ $retry -eq 0 ]
|
||||
then
|
||||
echo "Removing CMakeCache.txt and attempt again"
|
||||
rm -f CMakeCache.txt
|
||||
cmake $sourceDir
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
} && make
|
||||
)
|
||||
}
|
||||
# Source CMake functions
|
||||
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
if [ -d "$ParaView_DIR" ]
|
||||
then
|
||||
wmake $targetType vtkPVblockMesh
|
||||
wmakeLibPv vtkPVblockMesh
|
||||
|
||||
if [ "$targetType" != objects ]
|
||||
then
|
||||
doCmake $PWD/PVblockMeshReader || {
|
||||
cmakePv $PWD/PVblockMeshReader || {
|
||||
echo
|
||||
echo " WARNING: incomplete build of ParaView BlockMesh plugin"
|
||||
echo
|
||||
|
||||
@ -1,85 +1,70 @@
|
||||
# create a plugin that adds a reader to the ParaView GUI
|
||||
# it is added in the file dialog when doing opens/saves.
|
||||
# Create a plugin to add a reader to the ParaView GUI
|
||||
|
||||
# The qrc file is processed by Qt's resource compiler (rcc)
|
||||
# the qrc file must have a resource prefix of "/ParaViewResources"
|
||||
# and ParaView will read anything contained under that prefix
|
||||
# the pqReader.xml file contains xml defining readers with their
|
||||
# file extensions and descriptions.
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
find_package(ParaView REQUIRED)
|
||||
include(${PARAVIEW_USE_FILE})
|
||||
|
||||
FIND_PACKAGE(ParaView REQUIRED)
|
||||
INCLUDE(${PARAVIEW_USE_FILE})
|
||||
|
||||
LINK_DIRECTORIES(
|
||||
link_directories(
|
||||
$ENV{FOAM_LIBBIN}
|
||||
$ENV{FOAM_EXT_LIBBIN}
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
include_directories(
|
||||
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/meshing/blockMesh/lnInclude
|
||||
${PROJECT_SOURCE_DIR}/../vtkPVblockMesh
|
||||
${PROJECT_SOURCE_DIR}/../../foamPv/lnInclude
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-std=c++0x
|
||||
add_definitions(
|
||||
-std=c++11
|
||||
-DWM_$ENV{WM_PRECISION_OPTION}
|
||||
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
|
||||
)
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
SET(
|
||||
set(
|
||||
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
|
||||
CACHE INTERNAL
|
||||
"Single output directory for building all libraries."
|
||||
)
|
||||
|
||||
#
|
||||
# Define combined plugin
|
||||
#
|
||||
|
||||
# Extend the auto-generated panel
|
||||
QT4_WRAP_CPP(MOC_SRCS pqPVblockMeshReaderPanel.h)
|
||||
if (PARAVIEW_QT_VERSION VERSION_GREATER "4")
|
||||
qt5_wrap_cpp(MOC_SRCS
|
||||
pqFoamBlockMeshControls.h
|
||||
)
|
||||
else()
|
||||
qt4_wrap_cpp(MOC_SRCS
|
||||
pqFoamBlockMeshControls.h
|
||||
)
|
||||
endif()
|
||||
|
||||
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
|
||||
CLASS_NAME pqPVblockMeshReaderPanel
|
||||
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
|
||||
XML_GROUP sources
|
||||
add_paraview_property_group_widget(IFACES0 IFACES0_SRCS
|
||||
TYPE "openfoam_blockMesh_general_controls"
|
||||
CLASS_NAME pqFoamBlockMeshControls
|
||||
)
|
||||
|
||||
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
|
||||
# so check if version < 4.4
|
||||
add_paraview_plugin(
|
||||
PVblockMeshReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
|
||||
GUI_INTERFACES
|
||||
${IFACES0}
|
||||
SOURCES
|
||||
${IFACES0_SRCS}
|
||||
${MOC_SRCS}
|
||||
pqFoamBlockMeshControls.cxx
|
||||
)
|
||||
|
||||
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVblockMeshReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
|
||||
GUI_INTERFACES ${IFACES}
|
||||
GUI_SOURCES pqPVblockMeshReaderPanel.cxx
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
GUI_RESOURCE_FILES PVblockMeshReader.xml
|
||||
)
|
||||
ELSE()
|
||||
ADD_PARAVIEW_PLUGIN(
|
||||
PVblockMeshReader_SM "1.0"
|
||||
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
|
||||
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
|
||||
GUI_INTERFACES ${IFACES}
|
||||
GUI_SOURCES pqPVblockMeshReaderPanel.cxx
|
||||
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# Build the client-side plugin
|
||||
|
||||
TARGET_LINK_LIBRARIES(
|
||||
target_link_libraries(
|
||||
PVblockMeshReader_SM
|
||||
LINK_PUBLIC
|
||||
vtkPVblockMesh
|
||||
vtkPVblockMesh-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
|
||||
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
|
||||
blockMesh
|
||||
OpenFOAM
|
||||
)
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/ParaViewResources" >
|
||||
<file>PVblockMeshReader.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@ -1,7 +0,0 @@
|
||||
<ParaViewReaders>
|
||||
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
|
||||
<Reader name="PVblockMeshReader"
|
||||
extensions="blockMesh"
|
||||
file_description="OpenFOAM blockMesh reader">
|
||||
</Reader>
|
||||
</ParaViewReaders>
|
||||
@ -5,49 +5,58 @@
|
||||
class="vtkPVblockMeshReader">
|
||||
|
||||
<!-- File name - compulsory -->
|
||||
<StringVectorProperty
|
||||
<StringVectorProperty animateable="0"
|
||||
name="FileName"
|
||||
command="SetFileName"
|
||||
number_of_elements="1"
|
||||
animateable="0">
|
||||
panel_visibility="never">
|
||||
<FileListDomain name="files"/>
|
||||
<Documentation>
|
||||
Specifies the filename for the OpenFOAM blockMesh Reader.
|
||||
</Documentation>
|
||||
<Documentation>The filename for the OpenFOAM blockMesh reader.</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- Show Point Numbers check-box -->
|
||||
<IntVectorProperty
|
||||
name="UiShowPointNumbers"
|
||||
command="SetShowPointNumbers"
|
||||
number_of_elements="1"
|
||||
default_values="1"
|
||||
is_internal="1"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Show point numbers in render window.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
<!-- Refresh (push button) -->
|
||||
<Property
|
||||
name="Refresh"
|
||||
command="Refresh"
|
||||
panel_visibility="default">
|
||||
<Documentation>Rescan for updated blockMeshDict.</Documentation>
|
||||
</Property>
|
||||
|
||||
<!-- Refresh button -->
|
||||
<IntVectorProperty
|
||||
name="UiRefresh"
|
||||
command="SetRefresh"
|
||||
number_of_elements="1"
|
||||
is_internal="0"
|
||||
<!-- General Controls -->
|
||||
|
||||
<!-- Show Patch Names (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="ShowPatchNames"
|
||||
label="Patch Names"
|
||||
command="SetShowPatchNames"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
Rescan for updated blockMeshDict.
|
||||
</Documentation>
|
||||
<Documentation>Show patch names in render window.</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Show Point Numbers (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="ShowPointNumbers"
|
||||
label="Point Numbers"
|
||||
command="SetShowPointNumbers"
|
||||
default_values="1"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>Show point numbers in render window.</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!--
|
||||
| Selections
|
||||
-->
|
||||
<PropertyGroup
|
||||
label="General Controls"
|
||||
panel_widget="openfoam_blockMesh_general_controls">
|
||||
<Property name="Refresh"/>
|
||||
<Property name="ShowPatchNames"/>
|
||||
<Property name="ShowPointNumbers"/>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Selections -->
|
||||
|
||||
<!-- Available Blocks array -->
|
||||
<StringVectorProperty
|
||||
@ -55,7 +64,7 @@
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="Block"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
<StringVectorProperty animateable="0"
|
||||
name="BlockStatus"
|
||||
label="Blocks"
|
||||
command="SetBlockArrayStatus"
|
||||
@ -63,16 +72,13 @@
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="BlockArrayStatus"
|
||||
animateable="0">
|
||||
information_property="BlockArrayStatus">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="BlockArrayStatus" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
<Documentation>
|
||||
This property contains a list of the blocks
|
||||
</Documentation>
|
||||
<Documentation>The list of blocks</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- Available CurvedEdges array -->
|
||||
@ -81,7 +87,7 @@
|
||||
information_only="1">
|
||||
<ArraySelectionInformationHelper attribute_name="CurvedEdges"/>
|
||||
</StringVectorProperty>
|
||||
<StringVectorProperty
|
||||
<StringVectorProperty animateable="0"
|
||||
name="CurvedEdgesStatus"
|
||||
label="Curved Edges"
|
||||
command="SetCurvedEdgesArrayStatus"
|
||||
@ -89,24 +95,26 @@
|
||||
repeat_command="1"
|
||||
number_of_elements_per_command="2"
|
||||
element_types="2 0"
|
||||
information_property="CurvedEdgesArrayStatus"
|
||||
animateable="0">
|
||||
information_property="CurvedEdgesArrayStatus">
|
||||
<ArraySelectionDomain name="array_list">
|
||||
<RequiredProperties>
|
||||
<Property name="CurvedEdgesArrayStatus" function="ArrayList"/>
|
||||
</RequiredProperties>
|
||||
</ArraySelectionDomain>
|
||||
<Documentation>
|
||||
This property contains a list of the curved edges
|
||||
</Documentation>
|
||||
<Documentation>The list of curved edges</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<PropertyGroup label="Selections">
|
||||
<Property name="BlockArrayStatus"/>
|
||||
<Property name="BlockStatus"/>
|
||||
<Property name="CurvedEdgesArrayStatus"/>
|
||||
<Property name="CurvedEdgesStatus"/>
|
||||
</PropertyGroup>
|
||||
|
||||
<Hints>
|
||||
<Property name="FileName" show="0"/>
|
||||
<Property name="UiRefresh" show="0"/>
|
||||
<Property name="UiShowPointNumbers" show="0"/>
|
||||
<ReaderFactory extensions="blockMesh"
|
||||
file_description="OpenFOAM blockMesh"/>
|
||||
<ReaderFactory
|
||||
extensions="blockMesh"
|
||||
file_description="OpenFOAM blockMesh"/>
|
||||
</Hints>
|
||||
|
||||
</SourceProxy>
|
||||
|
||||
@ -0,0 +1,232 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pqFoamBlockMeshControls.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "pqPVApplicationCore.h"
|
||||
#include "pqView.h"
|
||||
#include "vtkSMDocumentation.h"
|
||||
#include "vtkSMIntVectorProperty.h"
|
||||
#include "vtkSMPropertyGroup.h"
|
||||
#include "vtkSMSourceProxy.h"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// file-scope
|
||||
static QAbstractButton* setButtonProperties
|
||||
(
|
||||
QAbstractButton* b,
|
||||
vtkSMProperty* prop
|
||||
)
|
||||
{
|
||||
QString tip;
|
||||
|
||||
vtkSMDocumentation* doc = prop->GetDocumentation();
|
||||
if (doc)
|
||||
{
|
||||
const char* txt = doc->GetDescription();
|
||||
if (txt)
|
||||
{
|
||||
tip = QString(txt).simplified();
|
||||
}
|
||||
}
|
||||
|
||||
b->setText(prop->GetXMLLabel());
|
||||
if (tip.size())
|
||||
{
|
||||
b->setToolTip(tip);
|
||||
}
|
||||
b->setFocusPolicy(Qt::NoFocus); // avoid dotted border
|
||||
|
||||
|
||||
vtkSMIntVectorProperty* intProp =
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop);
|
||||
|
||||
// initial checked state for integer (bool) properties
|
||||
if (intProp)
|
||||
{
|
||||
b->setChecked(intProp->GetElement(0));
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
static vtkSMIntVectorProperty* lookupIntProp
|
||||
(
|
||||
vtkSMPropertyGroup* group,
|
||||
const char* name
|
||||
)
|
||||
{
|
||||
vtkSMProperty* prop = group->GetProperty(name);
|
||||
|
||||
if (prop)
|
||||
{
|
||||
return vtkSMIntVectorProperty::SafeDownCast(prop);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void pqFoamBlockMeshControls::fireCommand(vtkSMProperty* prop)
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
// Fire off command
|
||||
prop->Modified();
|
||||
pxy->UpdateProperty(pxy->GetPropertyName(prop));
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::fireCommand
|
||||
(
|
||||
vtkSMIntVectorProperty* prop,
|
||||
bool checked
|
||||
)
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
prop->SetElement(0, checked); // Toogle bool
|
||||
|
||||
// Fire off command
|
||||
prop->Modified();
|
||||
pxy->UpdateProperty(pxy->GetPropertyName(prop));
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::updateParts()
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
pxy->UpdatePropertyInformation(pxy->GetProperty("BlockArrayStatus"));
|
||||
pxy->UpdatePropertyInformation(pxy->GetProperty("CurvedEdgesArrayStatus"));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void pqFoamBlockMeshControls::refreshPressed()
|
||||
{
|
||||
fireCommand(refresh_);
|
||||
|
||||
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
|
||||
|
||||
// Trigger a rendering (all views)
|
||||
pqPVApplicationCore::instance()->render();
|
||||
|
||||
updateParts();
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::showPatchNames(bool checked)
|
||||
{
|
||||
fireCommand(showPatchNames_, checked);
|
||||
|
||||
// Update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
}
|
||||
|
||||
// OR: update all views
|
||||
// pqPVApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::showPointNumbers(bool checked)
|
||||
{
|
||||
fireCommand(showPointNumbers_, checked);
|
||||
|
||||
// Update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
}
|
||||
|
||||
// OR: update all views
|
||||
// pqPVApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
pqFoamBlockMeshControls::pqFoamBlockMeshControls
|
||||
(
|
||||
vtkSMProxy* proxy,
|
||||
vtkSMPropertyGroup* group,
|
||||
QWidget* parent
|
||||
)
|
||||
:
|
||||
Superclass(proxy, parent),
|
||||
refresh_(group->GetProperty("Refresh")),
|
||||
showPatchNames_(lookupIntProp(group, "ShowPatchNames")),
|
||||
showPointNumbers_(lookupIntProp(group, "ShowPointNumbers"))
|
||||
{
|
||||
QGridLayout* form = new QGridLayout(this);
|
||||
|
||||
if (refresh_)
|
||||
{
|
||||
QPushButton* b = new QPushButton(this);
|
||||
setButtonProperties(b, refresh_);
|
||||
form->addWidget(b, 0, 0, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed()));
|
||||
}
|
||||
|
||||
if (showPatchNames_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, showPatchNames_);
|
||||
form->addWidget(b, 0, 1, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool)));
|
||||
}
|
||||
|
||||
if (showPointNumbers_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, showPointNumbers_);
|
||||
form->addWidget(b, 0, 2, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPointNumbers(bool)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
pqFoamBlockMeshControls::~pqFoamBlockMeshControls()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,123 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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/>.
|
||||
|
||||
Class
|
||||
pqFoamBlockMeshControls
|
||||
|
||||
Description
|
||||
Customized property controls for the ParaView blockMesh reader.
|
||||
|
||||
Refresh, ShowPatchNames, ShowPointNumbers.
|
||||
|
||||
SourceFiles
|
||||
pqFoamBlockMeshControls.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef pqFoamBlockMeshControls_h
|
||||
#define pqFoamBlockMeshControls_h
|
||||
|
||||
#include "pqPropertyWidget.h"
|
||||
|
||||
// Forward declarations (ParaView)
|
||||
class vtkSMProperty;
|
||||
class vtkSMIntVectorProperty;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pqFoamBlockMeshControls Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pqFoamBlockMeshControls
|
||||
:
|
||||
public pqPropertyWidget
|
||||
{
|
||||
Q_OBJECT;
|
||||
typedef pqPropertyWidget Superclass;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Refresh (push button)
|
||||
vtkSMProperty* refresh_;
|
||||
|
||||
//- Show Patch Names (bool property)
|
||||
vtkSMIntVectorProperty* showPatchNames_;
|
||||
|
||||
//- Show Point Numbers (bool property)
|
||||
vtkSMIntVectorProperty* showPointNumbers_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update property
|
||||
void fireCommand(vtkSMProperty* prop);
|
||||
|
||||
//- Toggle and update bool property
|
||||
void fireCommand(vtkSMIntVectorProperty* prop, bool checked);
|
||||
|
||||
//- Update "BlockArrayStatus", "CurvedEdgesArrayStatus" information
|
||||
void updateParts();
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pqFoamBlockMeshControls(const pqFoamBlockMeshControls&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const pqFoamBlockMeshControls&) = delete;
|
||||
|
||||
|
||||
protected slots:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Trigger refresh
|
||||
void refreshPressed();
|
||||
|
||||
//- Sync property with changed checkbox state, update rendered view(s)
|
||||
void showPatchNames(bool checked);
|
||||
|
||||
//- Sync property with changed checkbox state, update rendered view(s)
|
||||
void showPointNumbers(bool checked);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Construct from components
|
||||
pqFoamBlockMeshControls
|
||||
(
|
||||
vtkSMProxy* proxy,
|
||||
vtkSMPropertyGroup* group,
|
||||
QWidget* parent = nullptr
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pqFoamBlockMeshControls();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,143 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pqPVblockMeshReaderPanel.h"
|
||||
|
||||
// QT
|
||||
#include <QGridLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QString>
|
||||
#include <QPushButton>
|
||||
#include <QtDebug>
|
||||
|
||||
// Paraview <-> QT UI
|
||||
#include "pqAnimationScene.h"
|
||||
#include "pqApplicationCore.h"
|
||||
#include "pqPipelineRepresentation.h"
|
||||
#include "pqServerManagerModel.h"
|
||||
#include "pqView.h"
|
||||
|
||||
// Paraview Server Manager
|
||||
#include "vtkSMDoubleVectorProperty.h"
|
||||
#include "vtkSMIntVectorProperty.h"
|
||||
#include "vtkSMProperty.h"
|
||||
#include "vtkSMSourceProxy.h"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
pqPVblockMeshReaderPanel::pqPVblockMeshReaderPanel
|
||||
(
|
||||
pqProxy *proxy,
|
||||
QWidget *p
|
||||
)
|
||||
:
|
||||
pqAutoGeneratedObjectPanel(proxy, p)
|
||||
{
|
||||
// Create first sublayout (at top of the panel)
|
||||
QGridLayout *form = new QGridLayout();
|
||||
this->PanelLayout->addLayout(form, 0, 0, 1, -1);
|
||||
|
||||
vtkSMProperty* prop = 0;
|
||||
|
||||
// Refresh button for updating blocks
|
||||
if ((prop = this->proxy()->GetProperty("UiRefresh")) != 0)
|
||||
{
|
||||
prop->SetImmediateUpdate(1);
|
||||
QPushButton* refresh = new QPushButton("Refresh");
|
||||
refresh->setToolTip("Rescan for updated blockMeshDict.");
|
||||
|
||||
form->addWidget(refresh, 0, 0, Qt::AlignLeft);
|
||||
QObject::connect
|
||||
(
|
||||
refresh,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(RefreshPressed())
|
||||
);
|
||||
}
|
||||
|
||||
// Checkbox for showing point numbers
|
||||
if ((prop = this->proxy()->GetProperty("UiShowPointNumbers")) != 0)
|
||||
{
|
||||
prop->SetImmediateUpdate(true);
|
||||
|
||||
ShowPointNumbers_ = new QCheckBox("Show Point Numbers");
|
||||
ShowPointNumbers_->setToolTip("Show point numbers in render window.");
|
||||
ShowPointNumbers_->setChecked
|
||||
(
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0)
|
||||
);
|
||||
|
||||
form->addWidget(ShowPointNumbers_);
|
||||
|
||||
connect
|
||||
(
|
||||
ShowPointNumbers_,
|
||||
SIGNAL(stateChanged(int)),
|
||||
this,
|
||||
SLOT(ShowPointNumbersToggled())
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void pqPVblockMeshReaderPanel::ShowPointNumbersToggled()
|
||||
{
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiShowPointNumbers")
|
||||
)->SetElement(0, ShowPointNumbers_->isChecked());
|
||||
|
||||
// Update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
}
|
||||
// OR: update all views
|
||||
// pqApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
void pqPVblockMeshReaderPanel::RefreshPressed()
|
||||
{
|
||||
// Update everything
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiRefresh")
|
||||
)->Modified();
|
||||
|
||||
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
|
||||
|
||||
// Render all views
|
||||
pqApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,86 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Class
|
||||
pqPVblockMeshReaderPanel
|
||||
|
||||
Description
|
||||
GUI modifications for the ParaView reader panel
|
||||
|
||||
A custom panel for the PVblockMeshReader.
|
||||
|
||||
SourceFiles
|
||||
pqPVblockMeshReaderPanel.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef pqPVblockMeshReaderPanel_h
|
||||
#define pqPVblockMeshReaderPanel_h
|
||||
|
||||
#include "pqAutoGeneratedObjectPanel.h"
|
||||
|
||||
// Forward declaration of QT classes
|
||||
|
||||
class QCheckBox;
|
||||
class QLineEdit;
|
||||
class QTimer;
|
||||
class QToolButton;
|
||||
|
||||
// Forward declaration of ParaView classes
|
||||
class vtkSMSourceProxy;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pqPVblockMeshReaderPanel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pqPVblockMeshReaderPanel
|
||||
:
|
||||
public pqAutoGeneratedObjectPanel
|
||||
{
|
||||
// Private data
|
||||
Q_OBJECT;
|
||||
typedef pqAutoGeneratedObjectPanel Superclass;
|
||||
|
||||
//- Show Point Numbers checkbox
|
||||
QCheckBox* ShowPointNumbers_;
|
||||
|
||||
protected slots:
|
||||
|
||||
void ShowPointNumbersToggled();
|
||||
void RefreshPressed();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
pqPVblockMeshReaderPanel(pqProxy*, QWidget*);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -56,10 +56,11 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
|
||||
|
||||
SetNumberOfInputPorts(0);
|
||||
|
||||
FileName = nullptr;
|
||||
foamData_ = nullptr;
|
||||
FileName = nullptr;
|
||||
backend_ = nullptr;
|
||||
|
||||
ShowPointNumbers = 1;
|
||||
ShowPatchNames = false;
|
||||
ShowPointNumbers = true;
|
||||
|
||||
BlockSelection = vtkDataArraySelection::New();
|
||||
CurvedEdgesSelection = vtkDataArraySelection::New();
|
||||
@ -73,7 +74,6 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
|
||||
);
|
||||
SelectionObserver->SetClientData(this);
|
||||
|
||||
|
||||
BlockSelection->AddObserver
|
||||
(
|
||||
vtkCommand::ModifiedEvent,
|
||||
@ -92,13 +92,16 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
|
||||
|
||||
vtkPVblockMeshReader::~vtkPVblockMeshReader()
|
||||
{
|
||||
vtkDebugMacro(<<"Deconstructor");
|
||||
vtkDebugMacro(<<"Destructor");
|
||||
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
// Remove point numbers
|
||||
// Remove text actors
|
||||
updatePatchNamesView(false);
|
||||
updatePointNumbersView(false);
|
||||
delete foamData_;
|
||||
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
}
|
||||
|
||||
if (FileName)
|
||||
@ -106,11 +109,12 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
|
||||
delete [] FileName;
|
||||
}
|
||||
|
||||
BlockSelection->RemoveObserver(this->SelectionObserver);
|
||||
CurvedEdgesSelection->RemoveObserver(this->SelectionObserver);
|
||||
BlockSelection->RemoveAllObservers();
|
||||
CurvedEdgesSelection->RemoveAllObservers();
|
||||
|
||||
SelectionObserver->Delete();
|
||||
BlockSelection->Delete();
|
||||
CurvedEdgesSelection->Delete();
|
||||
}
|
||||
|
||||
|
||||
@ -125,35 +129,25 @@ int vtkPVblockMeshReader::RequestInformation
|
||||
{
|
||||
vtkDebugMacro(<<"RequestInformation");
|
||||
|
||||
if (Foam::vtkPVblockMesh::debug)
|
||||
{
|
||||
cout<<"REQUEST_INFORMATION\n";
|
||||
}
|
||||
|
||||
if (!FileName)
|
||||
{
|
||||
vtkErrorMacro("FileName has to be specified!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPVblockMesh::debug)
|
||||
{
|
||||
cout<<"RequestInformation with " << nInfo << " item(s)\n";
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Print(cout);
|
||||
}
|
||||
cout<<"REQUEST_INFORMATION\n";
|
||||
outputVector->GetInformationObject(0)->Print(cout);
|
||||
}
|
||||
|
||||
if (!foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
foamData_ = new Foam::vtkPVblockMesh(FileName, this);
|
||||
backend_->updateInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
foamData_->updateInfo();
|
||||
backend_ = new Foam::vtkPVblockMesh(FileName, this);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -176,21 +170,16 @@ int vtkPVblockMeshReader::RequestData
|
||||
}
|
||||
|
||||
// Catch previous error
|
||||
if (!foamData_)
|
||||
if (!backend_)
|
||||
{
|
||||
vtkErrorMacro("Reader failed - perhaps no mesh?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPVblockMesh::debug)
|
||||
{
|
||||
cout<<"RequestData with " << nInfo << " item(s)\n";
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Print(cout);
|
||||
}
|
||||
cout<<"REQUEST_DATA:\n";
|
||||
outputVector->GetInformationObject(0)->Print(cout);
|
||||
}
|
||||
|
||||
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
|
||||
@ -207,32 +196,46 @@ int vtkPVblockMeshReader::RequestData
|
||||
<< output->GetNumberOfBlocks() << " blocks\n";
|
||||
}
|
||||
|
||||
backend_->Update(output);
|
||||
|
||||
foamData_->Update(output);
|
||||
updatePatchNamesView(ShowPatchNames);
|
||||
updatePointNumbersView(ShowPointNumbers);
|
||||
|
||||
// Do any cleanup on the OpenFOAM side
|
||||
foamData_->CleanUp();
|
||||
backend_->CleanUp();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetRefresh(int val)
|
||||
void vtkPVblockMeshReader::Refresh()
|
||||
{
|
||||
// Delete the current blockMesh to force re-read and update
|
||||
if (foamData_)
|
||||
if (backend_)
|
||||
{
|
||||
// Remove text actors
|
||||
updatePatchNamesView(false);
|
||||
updatePointNumbersView(false);
|
||||
delete foamData_;
|
||||
foamData_ = 0;
|
||||
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
}
|
||||
|
||||
Modified();
|
||||
this->Modified();
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetShowPointNumbers(const int val)
|
||||
void vtkPVblockMeshReader::SetShowPatchNames(bool val)
|
||||
{
|
||||
if (ShowPatchNames != val)
|
||||
{
|
||||
ShowPatchNames = val;
|
||||
updatePatchNamesView(ShowPatchNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetShowPointNumbers(bool val)
|
||||
{
|
||||
if (ShowPointNumbers != val)
|
||||
{
|
||||
@ -242,6 +245,38 @@ void vtkPVblockMeshReader::SetShowPointNumbers(const int val)
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::updatePatchNamesView(const bool show)
|
||||
{
|
||||
pqApplicationCore* appCore = pqApplicationCore::instance();
|
||||
|
||||
// Need to check this, since our destructor calls this
|
||||
if (!appCore)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Server manager model for querying items in the server manager
|
||||
pqServerManagerModel* smModel = appCore->getServerManagerModel();
|
||||
if (!smModel || !backend_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all the pqRenderView instances
|
||||
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
|
||||
for (int viewI=0; viewI<renderViews.size(); ++viewI)
|
||||
{
|
||||
backend_->renderPatchNames
|
||||
(
|
||||
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
|
||||
show
|
||||
);
|
||||
}
|
||||
|
||||
// Use refresh here?
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
|
||||
{
|
||||
pqApplicationCore* appCore = pqApplicationCore::instance();
|
||||
@ -254,17 +289,16 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
|
||||
|
||||
// Server manager model for querying items in the server manager
|
||||
pqServerManagerModel* smModel = appCore->getServerManagerModel();
|
||||
if (!smModel || !foamData_)
|
||||
if (!smModel || !backend_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get all the pqRenderView instances
|
||||
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
|
||||
for (int viewI=0; viewI<renderViews.size(); ++viewI)
|
||||
{
|
||||
foamData_->renderPointNumbers
|
||||
backend_->renderPointNumbers
|
||||
(
|
||||
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
|
||||
show
|
||||
@ -283,7 +317,7 @@ void vtkPVblockMeshReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
os << indent << "File name: "
|
||||
<< (this->FileName ? this->FileName : "(none)") << "\n";
|
||||
|
||||
foamData_->PrintSelf(os, indent);
|
||||
backend_->PrintSelf(os, indent);
|
||||
}
|
||||
|
||||
|
||||
@ -292,39 +326,30 @@ void vtkPVblockMeshReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
|
||||
vtkDataArraySelection* vtkPVblockMeshReader::GetBlockSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetBlockSelection");
|
||||
return BlockSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVblockMeshReader::GetNumberOfBlockArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfBlockArrays");
|
||||
return BlockSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVblockMeshReader::GetBlockArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetBlockArrayName");
|
||||
return BlockSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVblockMeshReader::GetBlockArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetBlockArrayStatus");
|
||||
return BlockSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetBlockArrayStatus
|
||||
(
|
||||
const char* name,
|
||||
int status
|
||||
)
|
||||
{
|
||||
vtkDebugMacro(<<"SetBlockArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
BlockSelection->EnableArray(name);
|
||||
@ -341,39 +366,30 @@ void vtkPVblockMeshReader::SetBlockArrayStatus
|
||||
|
||||
vtkDataArraySelection* vtkPVblockMeshReader::GetCurvedEdgesSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetCurvedEdgesSelection");
|
||||
return CurvedEdgesSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVblockMeshReader::GetNumberOfCurvedEdgesArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfCurvedEdgesArrays");
|
||||
return CurvedEdgesSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVblockMeshReader::GetCurvedEdgesArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetCurvedEdgesArrayName");
|
||||
return CurvedEdgesSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVblockMeshReader::GetCurvedEdgesArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetCurvedEdgesArrayStatus");
|
||||
return CurvedEdgesSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetCurvedEdgesArrayStatus
|
||||
(
|
||||
const char* name,
|
||||
int status
|
||||
)
|
||||
{
|
||||
vtkDebugMacro(<<"SetCurvedEdgesArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
CurvedEdgesSelection->EnableArray(name);
|
||||
|
||||
@ -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.
|
||||
@ -71,29 +71,34 @@ public:
|
||||
vtkSetStringMacro(FileName);
|
||||
vtkGetStringMacro(FileName);
|
||||
|
||||
// Description:
|
||||
// Display patch names
|
||||
virtual void SetShowPatchNames(bool);
|
||||
vtkGetMacro(ShowPatchNames, bool);
|
||||
|
||||
// Description:
|
||||
// Display corner point labels
|
||||
virtual void SetShowPointNumbers(int);
|
||||
vtkGetMacro(ShowPointNumbers, int);
|
||||
virtual void SetShowPointNumbers(bool);
|
||||
vtkGetMacro(ShowPointNumbers, bool);
|
||||
|
||||
// Description:
|
||||
// Refresh blockMesh from changes to blockMeshDict
|
||||
virtual void SetRefresh(int);
|
||||
virtual void Refresh();
|
||||
|
||||
// Description:
|
||||
// Blocks selection list control
|
||||
vtkDataArraySelection* GetBlockSelection();
|
||||
int GetNumberOfBlockArrays();
|
||||
int GetBlockArrayStatus(const char*);
|
||||
void SetBlockArrayStatus(const char*, int status);
|
||||
int GetBlockArrayStatus(const char* name);
|
||||
void SetBlockArrayStatus(const char* name, int status);
|
||||
const char* GetBlockArrayName(int index);
|
||||
|
||||
// Description:
|
||||
// CurvedEdges selection list control
|
||||
vtkDataArraySelection* GetCurvedEdgesSelection();
|
||||
int GetNumberOfCurvedEdgesArrays();
|
||||
int GetCurvedEdgesArrayStatus(const char*);
|
||||
void SetCurvedEdgesArrayStatus(const char*, int status);
|
||||
int GetCurvedEdgesArrayStatus(const char* name);
|
||||
void SetCurvedEdgesArrayStatus(const char* name, int status);
|
||||
const char* GetCurvedEdgesArrayName(int index);
|
||||
|
||||
// Description:
|
||||
@ -114,22 +119,22 @@ protected:
|
||||
vtkPVblockMeshReader();
|
||||
|
||||
//- Destructor
|
||||
~vtkPVblockMeshReader();
|
||||
virtual ~vtkPVblockMeshReader();
|
||||
|
||||
//- Return information about mesh, times, etc without loading anything
|
||||
virtual int RequestInformation
|
||||
(
|
||||
vtkInformation*,
|
||||
vtkInformationVector**,
|
||||
vtkInformationVector*
|
||||
vtkInformation* unusedRequest,
|
||||
vtkInformationVector** unusedInputVector,
|
||||
vtkInformationVector* outputVector
|
||||
);
|
||||
|
||||
//- Get the mesh/fields for a particular time
|
||||
//- Get the mesh for a particular time
|
||||
virtual int RequestData
|
||||
(
|
||||
vtkInformation*,
|
||||
vtkInformationVector**,
|
||||
vtkInformationVector*
|
||||
vtkInformation* unusedRequest,
|
||||
vtkInformationVector** unusedInputVector,
|
||||
vtkInformationVector* outputVector
|
||||
);
|
||||
|
||||
//- Fill in additional port information
|
||||
@ -144,25 +149,29 @@ protected:
|
||||
private:
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkPVblockMeshReader(const vtkPVblockMeshReader&);
|
||||
vtkPVblockMeshReader(const vtkPVblockMeshReader&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPVblockMeshReader&);
|
||||
void operator=(const vtkPVblockMeshReader&) = delete;
|
||||
|
||||
//- Add/remove patch names to/from the view
|
||||
void updatePatchNamesView(const bool show);
|
||||
|
||||
//- Add/remove point numbers to/from the view
|
||||
void updatePointNumbersView(const bool show);
|
||||
|
||||
|
||||
//- Show Patch Names
|
||||
bool ShowPatchNames;
|
||||
|
||||
//- Show Point Numbers
|
||||
int ShowPointNumbers;
|
||||
bool ShowPointNumbers;
|
||||
|
||||
vtkDataArraySelection* BlockSelection;
|
||||
|
||||
vtkDataArraySelection* CurvedEdgesSelection;
|
||||
|
||||
//BTX
|
||||
Foam::vtkPVblockMesh* foamData_;
|
||||
//ETX
|
||||
//- Backend portion of the reader
|
||||
Foam::vtkPVblockMesh* backend_;
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
vtkPVblockMesh.C
|
||||
vtkPVblockMeshConvert.C
|
||||
vtkPVblockMeshUtils.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVblockMesh
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVblockMesh-pv${ParaView_MAJOR}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
sinclude $(GENERAL_RULES)/paraview
|
||||
|
||||
EXE_INC = \
|
||||
${c++LESSWARN} \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
@ -5,12 +7,12 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/blockMesh/lnInclude \
|
||||
-I$(ParaView_INCLUDE_DIR) \
|
||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
|
||||
-I../../vtkPVReaders/lnInclude \
|
||||
-I../../foamPv/lnInclude \
|
||||
-I../PVblockMeshReader
|
||||
|
||||
LIB_LIBS = \
|
||||
-lmeshTools \
|
||||
-lfileFormats \
|
||||
-lblockMesh \
|
||||
-L$(FOAM_LIBBIN) -lvtkPVReaders \
|
||||
-L$(FOAM_LIBBIN) -lfoamPv-pv${ParaView_MAJOR} \
|
||||
$(GLIBS)
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
vtkPVblockMesh
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkOpenFOAMPoints_H
|
||||
#define vtkOpenFOAMPoints_H
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPoints.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline void vtkInsertNextOpenFOAMPoint
|
||||
(
|
||||
vtkPoints *points,
|
||||
const Foam::point& p
|
||||
)
|
||||
{
|
||||
points->InsertNextPoint(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
inline void vtkInsertNextOpenFOAMPoint
|
||||
(
|
||||
vtkPoints *points,
|
||||
const Foam::point& p,
|
||||
const Foam::scalar scaleFactor
|
||||
)
|
||||
{
|
||||
points->InsertNextPoint
|
||||
(
|
||||
p.x()*scaleFactor,
|
||||
p.y()*scaleFactor,
|
||||
p.z()*scaleFactor
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -28,6 +28,7 @@ License
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "blockMesh.H"
|
||||
#include "blockMeshTools.H"
|
||||
#include "Time.H"
|
||||
#include "patchZones.H"
|
||||
#include "OStringStream.H"
|
||||
@ -47,6 +48,34 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
vtkTextActor* Foam::vtkPVblockMesh::createTextActor
|
||||
(
|
||||
const string& s,
|
||||
const point& pt
|
||||
)
|
||||
{
|
||||
vtkTextActor* txt = vtkTextActor::New();
|
||||
txt->SetInput(s.c_str());
|
||||
|
||||
// Set text properties
|
||||
vtkTextProperty* tprop = txt->GetTextProperty();
|
||||
tprop->SetFontFamilyToArial();
|
||||
tprop->BoldOn();
|
||||
tprop->ShadowOff();
|
||||
tprop->SetLineSpacing(1.0);
|
||||
tprop->SetFontSize(14);
|
||||
tprop->SetColor(1.0, 0.0, 1.0);
|
||||
tprop->SetJustificationToCentered();
|
||||
|
||||
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
|
||||
txt->GetPositionCoordinate()->SetValue(pt.x(), pt.y(), pt.z());
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVblockMesh::resetCounters()
|
||||
@ -60,16 +89,18 @@ void Foam::vtkPVblockMesh::resetCounters()
|
||||
|
||||
void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
(
|
||||
vtkDataArraySelection* arraySelection
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
arrayRange& range = arrayRangeBlocks_;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateInfoBlocks"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
|
||||
Info<< "<beg> updateInfoBlocks"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() );
|
||||
range.reset(select->GetNumberOfArrays());
|
||||
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
|
||||
@ -80,49 +111,46 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
|
||||
// Display either blockI as a number or with its name
|
||||
// (looked up from blockMeshDict)
|
||||
OStringStream os;
|
||||
blockDescriptor::write(os, blockI, blkMesh.meshDict());
|
||||
word partName(os.str());
|
||||
OStringStream ostr;
|
||||
blockDescriptor::write(ostr, blockI, blkMesh.meshDict());
|
||||
|
||||
// append the (optional) zone name
|
||||
if (!blockDef.zoneName().empty())
|
||||
{
|
||||
partName += " - " + blockDef.zoneName();
|
||||
ostr << " - " << blockDef.zoneName();
|
||||
}
|
||||
|
||||
// Add blockId and zoneName to GUI list
|
||||
arraySelection->AddArray(partName.c_str());
|
||||
// Add "blockId" or "blockId - zoneName" to GUI list
|
||||
select->AddArray(ostr.str().c_str());
|
||||
}
|
||||
|
||||
arrayRangeBlocks_ += nBlocks;
|
||||
range += nBlocks;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateInfoBlocks" << endl;
|
||||
Info<< "<end> updateInfoBlocks" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::updateInfoEdges
|
||||
(
|
||||
vtkDataArraySelection* arraySelection
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
arrayRange& range = arrayRangeEdges_;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateInfoEdges"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]" << endl;
|
||||
Info<< "<beg> updateInfoEdges"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
|
||||
range.reset(select->GetNumberOfArrays());
|
||||
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
const blockEdgeList& edges = blkMesh.edges();
|
||||
|
||||
const int nEdges = edges.size();
|
||||
forAll(edges, edgeI)
|
||||
{
|
||||
OStringStream ostr;
|
||||
@ -132,17 +160,14 @@ void Foam::vtkPVblockMesh::updateInfoEdges
|
||||
ostr << " - " << edges[edgeI].type();
|
||||
|
||||
// Add "beg:end - type" to GUI list
|
||||
arraySelection->AddArray(ostr.str().c_str());
|
||||
select->AddArray(ostr.str().c_str());
|
||||
}
|
||||
|
||||
arrayRangeEdges_ += nEdges;
|
||||
range += edges.size();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// just for debug info
|
||||
getSelectedArrayEntries(arraySelection);
|
||||
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateInfoEdges" << endl;
|
||||
Info<< "<end> updateInfoEdges" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,8 +191,7 @@ Foam::vtkPVblockMesh::vtkPVblockMesh
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Foam::vtkPVblockMesh::vtkPVblockMesh - "
|
||||
<< FileName << endl;
|
||||
Info<< "vtkPVblockMesh - " << FileName << endl;
|
||||
}
|
||||
|
||||
// avoid argList and get rootPath/caseName directly from the file
|
||||
@ -253,17 +277,9 @@ Foam::vtkPVblockMesh::~vtkPVblockMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::~vtkPVblockMesh" << endl;
|
||||
Info<< "~vtkPVblockMesh" << endl;
|
||||
}
|
||||
|
||||
// Hmm. pointNumberTextActors are not getting removed
|
||||
//
|
||||
forAll(pointNumberTextActorsPtrs_, pointi)
|
||||
{
|
||||
pointNumberTextActorsPtrs_[pointi]->Delete();
|
||||
}
|
||||
pointNumberTextActorsPtrs_.clear();
|
||||
|
||||
delete meshPtr_;
|
||||
}
|
||||
|
||||
@ -274,25 +290,20 @@ void Foam::vtkPVblockMesh::updateInfo()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateInfo"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "] " << endl;
|
||||
Info<< "<beg> updateInfo"
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "] " << endl;
|
||||
}
|
||||
|
||||
resetCounters();
|
||||
|
||||
vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
|
||||
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
|
||||
vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
|
||||
|
||||
// enable 'internalMesh' on the first call
|
||||
// or preserve the enabled selections
|
||||
// preserve the enabled selections if possible
|
||||
stringList enabledParts;
|
||||
stringList enabledEdges;
|
||||
bool firstTime = false;
|
||||
if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
|
||||
{
|
||||
firstTime = true;
|
||||
}
|
||||
else
|
||||
const bool firstTime = (!blockSelection->GetNumberOfArrays() && !meshPtr_);
|
||||
if (!firstTime)
|
||||
{
|
||||
enabledParts = getSelectedArrayEntries(blockSelection);
|
||||
enabledEdges = getSelectedArrayEntries(edgeSelection);
|
||||
@ -306,21 +317,21 @@ void Foam::vtkPVblockMesh::updateInfo()
|
||||
updateFoamMesh();
|
||||
|
||||
// Update mesh parts list
|
||||
updateInfoBlocks( blockSelection );
|
||||
updateInfoBlocks(blockSelection);
|
||||
|
||||
// Update curved edges list
|
||||
updateInfoEdges( edgeSelection );
|
||||
updateInfoEdges(edgeSelection);
|
||||
|
||||
// restore the enabled selections
|
||||
if (!firstTime)
|
||||
{
|
||||
setSelectedArrayEntries(blockSelection, enabledParts);
|
||||
setSelectedArrayEntries(edgeSelection, enabledEdges);
|
||||
setSelectedArrayEntries(edgeSelection, enabledEdges);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateInfo" << endl;
|
||||
Info<< "<end> updateInfo" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,7 +340,7 @@ void Foam::vtkPVblockMesh::updateFoamMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateFoamMesh" << endl;
|
||||
Info<< "<beg> updateFoamMesh" << endl;
|
||||
}
|
||||
|
||||
// Check to see if the OpenFOAM mesh has been created
|
||||
@ -379,7 +390,7 @@ void Foam::vtkPVblockMesh::updateFoamMesh()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateFoamMesh" << endl;
|
||||
Info<< "<end> updateFoamMesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,10 +403,10 @@ void Foam::vtkPVblockMesh::Update
|
||||
reader_->UpdateProgress(0.1);
|
||||
|
||||
// Set up mesh parts selection(s)
|
||||
updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
|
||||
getSelected(blockStatus_, reader_->GetBlockSelection());
|
||||
|
||||
// Set up curved edges selection(s)
|
||||
updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
|
||||
getSelected(edgeStatus_, reader_->GetCurvedEdgesSelection());
|
||||
|
||||
reader_->UpdateProgress(0.2);
|
||||
|
||||
@ -421,6 +432,103 @@ void Foam::vtkPVblockMesh::CleanUp()
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::renderPatchNames
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
const bool show
|
||||
)
|
||||
{
|
||||
// always remove old actors first
|
||||
forAll(patchTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->RemoveViewProp(patchTextActorsPtrs_[actori]);
|
||||
patchTextActorsPtrs_[actori]->Delete();
|
||||
}
|
||||
patchTextActorsPtrs_.clear();
|
||||
|
||||
// the number of text actors
|
||||
label nActors = 0;
|
||||
|
||||
if (show && meshPtr_)
|
||||
{
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
const dictionary& meshDescription = blkMesh.meshDict();
|
||||
const pointField& cornerPts = blkMesh.vertices();
|
||||
const scalar scaleFactor = blkMesh.scaleFactor();
|
||||
|
||||
if (!meshDescription.found("boundary"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 8 sides per block is plenty
|
||||
patchTextActorsPtrs_.setSize(8*blkMesh.size());
|
||||
|
||||
// Collect all variables
|
||||
dictionary varDict(meshDescription.subOrEmptyDict("namedVertices"));
|
||||
varDict.merge(meshDescription.subOrEmptyDict("namedBlocks"));
|
||||
|
||||
// Read like boundary file
|
||||
const PtrList<entry> patchesInfo(meshDescription.lookup("boundary"));
|
||||
|
||||
forAll(patchesInfo, patchi)
|
||||
{
|
||||
const entry& patchInfo = patchesInfo[patchi];
|
||||
|
||||
if (!patchInfo.isDict())
|
||||
{
|
||||
IOWarningInFunction(meshDescription)
|
||||
<< "Entry " << patchInfo << " in boundary section is not a"
|
||||
<< " valid dictionary."
|
||||
<< endl;
|
||||
break;
|
||||
}
|
||||
|
||||
const word& patchName = patchInfo.keyword();
|
||||
|
||||
// Read block faces
|
||||
faceList patchFaces = blockMeshTools::read<face>
|
||||
(
|
||||
patchInfo.dict().lookup("faces"),
|
||||
varDict
|
||||
);
|
||||
|
||||
forAll(patchFaces, facei)
|
||||
{
|
||||
const face& f = patchFaces[facei];
|
||||
|
||||
// Into a list for later removal
|
||||
patchTextActorsPtrs_[nActors++] = createTextActor
|
||||
(
|
||||
patchName,
|
||||
f.centre(cornerPts) * scaleFactor
|
||||
);
|
||||
|
||||
if (nActors == patchTextActorsPtrs_.size())
|
||||
{
|
||||
// hit max allocated space - bail out
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nActors == patchTextActorsPtrs_.size())
|
||||
{
|
||||
// hit max allocated space - bail out
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
patchTextActorsPtrs_.setSize(nActors);
|
||||
}
|
||||
|
||||
// Add text to each renderer
|
||||
forAll(patchTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->AddViewProp(patchTextActorsPtrs_[actori]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::renderPointNumbers
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
@ -429,12 +537,12 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
||||
{
|
||||
// always remove old actors first
|
||||
|
||||
forAll(pointNumberTextActorsPtrs_, pointi)
|
||||
forAll(pointTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]);
|
||||
pointNumberTextActorsPtrs_[pointi]->Delete();
|
||||
renderer->RemoveViewProp(pointTextActorsPtrs_[actori]);
|
||||
pointTextActorsPtrs_[actori]->Delete();
|
||||
}
|
||||
pointNumberTextActorsPtrs_.clear();
|
||||
pointTextActorsPtrs_.clear();
|
||||
|
||||
if (show && meshPtr_)
|
||||
{
|
||||
@ -442,49 +550,29 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
||||
const pointField& cornerPts = blkMesh.vertices();
|
||||
const scalar scaleFactor = blkMesh.scaleFactor();
|
||||
|
||||
pointNumberTextActorsPtrs_.setSize(cornerPts.size());
|
||||
pointTextActorsPtrs_.setSize(cornerPts.size());
|
||||
forAll(cornerPts, pointi)
|
||||
{
|
||||
vtkTextActor* txt = vtkTextActor::New();
|
||||
|
||||
// Display either pointi as a number or with its name
|
||||
// (looked up from blockMeshDict)
|
||||
{
|
||||
OStringStream os;
|
||||
blockVertex::write(os, pointi, blkMesh.meshDict());
|
||||
txt->SetInput(os.str().c_str());
|
||||
}
|
||||
OStringStream os;
|
||||
blockVertex::write(os, pointi, blkMesh.meshDict());
|
||||
|
||||
// Set text properties
|
||||
vtkTextProperty* tprop = txt->GetTextProperty();
|
||||
tprop->SetFontFamilyToArial();
|
||||
tprop->BoldOn();
|
||||
tprop->ShadowOff();
|
||||
tprop->SetLineSpacing(1.0);
|
||||
tprop->SetFontSize(14);
|
||||
tprop->SetColor(1.0, 0.0, 1.0);
|
||||
tprop->SetJustificationToCentered();
|
||||
|
||||
// Set text to use 3-D world co-ordinates
|
||||
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
|
||||
|
||||
txt->GetPositionCoordinate()->SetValue
|
||||
// Into a list for later removal
|
||||
pointTextActorsPtrs_[pointi] = createTextActor
|
||||
(
|
||||
cornerPts[pointi].x()*scaleFactor,
|
||||
cornerPts[pointi].y()*scaleFactor,
|
||||
cornerPts[pointi].z()*scaleFactor
|
||||
os.str(),
|
||||
cornerPts[pointi]*scaleFactor
|
||||
);
|
||||
|
||||
// Add text to each renderer
|
||||
renderer->AddViewProp(txt);
|
||||
|
||||
// Maintain a list of text labels added so that they can be
|
||||
// removed later
|
||||
pointNumberTextActorsPtrs_[pointi] = txt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add text to each renderer
|
||||
forAll(pointTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->AddViewProp(pointTextActorsPtrs_[actori]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::PrintSelf(ostream& os, vtkIndent indent) const
|
||||
|
||||
@ -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.
|
||||
@ -41,17 +41,7 @@ SourceFiles
|
||||
#ifndef vtkPVblockMesh_H
|
||||
#define vtkPVblockMesh_H
|
||||
|
||||
// do not include legacy strstream headers
|
||||
#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
|
||||
# define VTK_EXCLUDE_STRSTREAM_HEADERS
|
||||
#endif
|
||||
|
||||
#include "className.H"
|
||||
#include "fileName.H"
|
||||
#include "stringList.H"
|
||||
#include "wordList.H"
|
||||
|
||||
#include "primitivePatch.H"
|
||||
#include "foamPvCore.H"
|
||||
|
||||
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
|
||||
|
||||
@ -83,85 +73,9 @@ template<class Type> class List;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkPVblockMesh
|
||||
:
|
||||
private foamPvCore
|
||||
{
|
||||
// Private classes
|
||||
|
||||
//- Bookkeeping for GUI checklists and the multi-block organization
|
||||
class arrayRange
|
||||
{
|
||||
const char *name_;
|
||||
int block_;
|
||||
int start_;
|
||||
int size_;
|
||||
|
||||
public:
|
||||
|
||||
arrayRange(const char *name, const int blockNo=0)
|
||||
:
|
||||
name_(name),
|
||||
block_(blockNo),
|
||||
start_(0),
|
||||
size_(0)
|
||||
{}
|
||||
|
||||
//- Return the block holding these datasets
|
||||
int block() const
|
||||
{
|
||||
return block_;
|
||||
}
|
||||
|
||||
//- Assign block number, return previous value
|
||||
int block(int blockNo)
|
||||
{
|
||||
int prev = block_;
|
||||
block_ = blockNo;
|
||||
return prev;
|
||||
}
|
||||
|
||||
//- Return block name
|
||||
const char* name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return array start index
|
||||
int start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- Return array end index
|
||||
int end() const
|
||||
{
|
||||
return start_ + size_;
|
||||
}
|
||||
|
||||
//- Return sublist size
|
||||
int size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return !size_;
|
||||
}
|
||||
|
||||
//- Reset the size to zero and optionally assign a new start
|
||||
void reset(const int startAt = 0)
|
||||
{
|
||||
start_ = startAt;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
//- Increment the size
|
||||
void operator+=(const int n)
|
||||
{
|
||||
size_ += n;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Access to the controlling vtkPVblockMeshReader
|
||||
@ -195,109 +109,45 @@ class vtkPVblockMesh
|
||||
//- First instance and size of block corners (only partially used)
|
||||
arrayRange arrayRangeCorners_;
|
||||
|
||||
//- List of patch names for rendering to window
|
||||
List<vtkTextActor*> patchTextActorsPtrs_;
|
||||
|
||||
//- List of point numbers for rendering to window
|
||||
List<vtkTextActor*> pointNumberTextActorsPtrs_;
|
||||
List<vtkTextActor*> pointTextActorsPtrs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static void AddToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const arrayRange&,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
);
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static vtkDataSet* GetDataSetFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
// Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
static label GetNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange&
|
||||
);
|
||||
|
||||
//- Update boolList from GUI selection
|
||||
static void updateBoolListStatus
|
||||
(
|
||||
boolList&,
|
||||
vtkDataArraySelection*
|
||||
);
|
||||
//- Create a text actor
|
||||
static vtkTextActor* createTextActor(const string& s, const point& pt);
|
||||
|
||||
//- Reset data counters
|
||||
void resetCounters();
|
||||
|
||||
// Update information helper functions
|
||||
//- OpenFOAM mesh
|
||||
void updateFoamMesh();
|
||||
|
||||
//- Internal block info
|
||||
void updateInfoBlocks(vtkDataArraySelection*);
|
||||
//- Internal block info
|
||||
void updateInfoBlocks(vtkDataArraySelection* select);
|
||||
|
||||
//- Block curved edges info
|
||||
void updateInfoEdges(vtkDataArraySelection*);
|
||||
//- Block curved edges info
|
||||
void updateInfoEdges(vtkDataArraySelection* select);
|
||||
|
||||
// Update helper functions
|
||||
//- Mesh blocks
|
||||
void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- OpenFOAM mesh
|
||||
void updateFoamMesh();
|
||||
//- Mesh curved edges
|
||||
void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
// Mesh conversion functions
|
||||
|
||||
//- Mesh blocks
|
||||
void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Mesh curved edges
|
||||
void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Mesh corners
|
||||
void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
|
||||
// GUI selection helper functions
|
||||
|
||||
//- Retrieve the current selections
|
||||
static wordHashSet getSelected(vtkDataArraySelection*);
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
static wordHashSet getSelected
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const arrayRange&
|
||||
);
|
||||
|
||||
//- Retrieve the current selections
|
||||
static stringList getSelectedArrayEntries(vtkDataArraySelection*);
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
static stringList getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const arrayRange&
|
||||
);
|
||||
|
||||
//- Set selection(s)
|
||||
static void setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const stringList&
|
||||
);
|
||||
//- Mesh corners
|
||||
void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkPVblockMesh(const vtkPVblockMesh&);
|
||||
vtkPVblockMesh(const vtkPVblockMesh&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPVblockMesh&);
|
||||
void operator=(const vtkPVblockMesh&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -331,6 +181,9 @@ public:
|
||||
//- Clean any storage
|
||||
void CleanUp();
|
||||
|
||||
//- Add/remove patch names to/from the view
|
||||
void renderPatchNames(vtkRenderer*, const bool show);
|
||||
|
||||
//- Add/remove point numbers to/from the view
|
||||
void renderPointNumbers(vtkRenderer*, const bool show);
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -30,8 +30,6 @@ License
|
||||
#include "blockMesh.H"
|
||||
#include "Time.H"
|
||||
|
||||
#include "vtkOpenFOAMPoints.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCellArray.h"
|
||||
#include "vtkDataArraySelection.h"
|
||||
@ -41,6 +39,26 @@ License
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
//! \cond fileScope
|
||||
inline static void insertNextPoint
|
||||
(
|
||||
vtkPoints *points,
|
||||
const Foam::point& p,
|
||||
const Foam::scalar scaleFactor
|
||||
)
|
||||
{
|
||||
points->InsertNextPoint
|
||||
(
|
||||
p.x()*scaleFactor,
|
||||
p.y()*scaleFactor,
|
||||
p.z()*scaleFactor
|
||||
);
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
@ -52,14 +70,14 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
vtkDataArraySelection* selection = reader_->GetBlockSelection();
|
||||
arrayRange& range = arrayRangeBlocks_;
|
||||
range.block(blockNo); // set output block
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
label datasetNo = 0; // restart at dataset 0
|
||||
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
const Foam::pointField& blockPoints = blkMesh.vertices();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::convertMeshBlocks" << endl;
|
||||
Info<< "<beg> convertMeshBlocks" << endl;
|
||||
}
|
||||
|
||||
int blockI = 0;
|
||||
@ -79,19 +97,16 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
|
||||
const blockDescriptor& blockDef = blkMesh[blockI];
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
||||
|
||||
// Convert OpenFOAM mesh vertices to VTK
|
||||
vtkPoints *vtkpoints = vtkPoints::New();
|
||||
vtkpoints->Allocate( blockDef.nPoints() );
|
||||
vtkpoints->Allocate(blockDef.nPoints());
|
||||
const labelList& blockLabels = blockDef.blockShape();
|
||||
|
||||
vtkmesh->Allocate(1);
|
||||
vtkIdType nodeIds[8];
|
||||
|
||||
forAll(blockLabels, ptI)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint
|
||||
insertNextPoint
|
||||
(
|
||||
vtkpoints,
|
||||
blockPoints[blockLabels[ptI]],
|
||||
@ -101,6 +116,8 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
nodeIds[ptI] = ptI;
|
||||
}
|
||||
|
||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
||||
vtkmesh->Allocate(1);
|
||||
vtkmesh->InsertNextCell
|
||||
(
|
||||
VTK_HEXAHEDRON,
|
||||
@ -111,7 +128,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
AddToBlock
|
||||
addToBlock
|
||||
(
|
||||
output, vtkmesh, range, datasetNo,
|
||||
selection->GetArrayName(partId)
|
||||
@ -130,7 +147,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::convertMeshBlocks" << endl;
|
||||
Info<< "<end> convertMeshBlocks" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +218,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
||||
vtkIdType pointIds[edgePoints.size()];
|
||||
forAll(edgePoints, ptI)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint
|
||||
insertNextPoint
|
||||
(
|
||||
vtkpoints,
|
||||
edgePoints[ptI],
|
||||
@ -220,7 +237,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
||||
vtkmesh->SetPoints(vtkpoints);
|
||||
vtkpoints->Delete();
|
||||
|
||||
AddToBlock
|
||||
addToBlock
|
||||
(
|
||||
output, vtkmesh, range, datasetNo,
|
||||
selection->GetArrayName(partId)
|
||||
@ -234,7 +251,6 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// anything added?
|
||||
if (datasetNo)
|
||||
{
|
||||
@ -243,7 +259,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::convertMeshEdges" << endl;
|
||||
Info<< "<end> convertMeshEdges" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -264,7 +280,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::convertMeshCorners" << endl;
|
||||
Info<< "<beg> convertMeshCorners" << endl;
|
||||
}
|
||||
|
||||
if (true) // or some flag or other condition
|
||||
@ -279,14 +295,14 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
||||
vtkIdType pointId = 0;
|
||||
forAll(blockPoints, ptI)
|
||||
{
|
||||
vtkInsertNextOpenFOAMPoint
|
||||
insertNextPoint
|
||||
(
|
||||
vtkpoints,
|
||||
blockPoints[ptI],
|
||||
scaleFactor
|
||||
);
|
||||
|
||||
vtkcells->InsertNextCell(1, &pointId);
|
||||
vtkcells->InsertNextCell(1, &pointId); // VTK_VERTEX
|
||||
pointId++;
|
||||
}
|
||||
|
||||
@ -296,11 +312,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
||||
vtkmesh->SetVerts(vtkcells);
|
||||
vtkcells->Delete();
|
||||
|
||||
AddToBlock
|
||||
(
|
||||
output, vtkmesh, range, datasetNo,
|
||||
arrayRangeCorners_.name()
|
||||
);
|
||||
addToBlock(output, vtkmesh, range, datasetNo, range.name());
|
||||
vtkmesh->Delete();
|
||||
|
||||
datasetNo++;
|
||||
@ -314,7 +326,7 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::convertMeshCorners" << endl;
|
||||
Info<< "<end> convertMeshCorners" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,357 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
Misc helper methods and utilities
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPVblockMesh.H"
|
||||
#include "vtkPVblockMeshReader.h"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkDataSet.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
#include "vtkInformation.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
//! \cond fileScope
|
||||
// Extract up to the first non-word characters
|
||||
inline word getFirstWord(const char* str)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
label n = 0;
|
||||
while (str[n] && word::valid(str[n]))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
return word(str, n, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return word::null;
|
||||
}
|
||||
|
||||
}
|
||||
//! \endcond
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVblockMesh::AddToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const arrayRange& range,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
)
|
||||
{
|
||||
const int blockNo = range.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
|
||||
if (!block)
|
||||
{
|
||||
if (blockDO)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Block already has a vtkDataSet assigned to it"
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
|
||||
block = vtkMultiBlockDataSet::New();
|
||||
output->SetBlock(blockNo, block);
|
||||
block->Delete();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "block[" << blockNo << "] has "
|
||||
<< block->GetNumberOfBlocks()
|
||||
<< " datasets prior to adding set " << datasetNo
|
||||
<< " with name: " << datasetName << endl;
|
||||
}
|
||||
|
||||
block->SetBlock(datasetNo, dataset);
|
||||
|
||||
// name the block when assigning dataset 0
|
||||
if (datasetNo == 0)
|
||||
{
|
||||
output->GetMetaData(blockNo)->Set
|
||||
(
|
||||
vtkCompositeDataSet::NAME(),
|
||||
range.name()
|
||||
);
|
||||
}
|
||||
|
||||
if (datasetName.size())
|
||||
{
|
||||
block->GetMetaData(datasetNo)->Set
|
||||
(
|
||||
vtkCompositeDataSet::NAME(),
|
||||
datasetName.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vtkDataSet* Foam::vtkPVblockMesh::GetDataSetFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const int blockNo = range.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
|
||||
if (block)
|
||||
{
|
||||
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ununsed at the moment
|
||||
Foam::label Foam::vtkPVblockMesh::GetNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& range
|
||||
)
|
||||
{
|
||||
const int blockNo = range.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
if (block)
|
||||
{
|
||||
return block->GetNumberOfBlocks();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPVblockMesh::getSelected
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
|
||||
for (int elemI=0; elemI < nElem; ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections.insert(getFirstWord(select->GetArrayName(elemI)));
|
||||
}
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPVblockMesh::getSelected
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const arrayRange& range
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
|
||||
for (int elemI = range.start(); elemI < range.end(); ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections.insert(getFirstWord(select->GetArrayName(elemI)));
|
||||
}
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPVblockMesh::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
stringList selections(select->GetNumberOfArrays());
|
||||
label nElem = 0;
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections[nElem++] = select->GetArrayName(elemI);
|
||||
}
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
label nElem = select->GetNumberOfArrays();
|
||||
Info<< "available(";
|
||||
for (int elemI = 0; elemI < nElem; ++elemI)
|
||||
{
|
||||
Info<< " \"" << select->GetArrayName(elemI) << "\"";
|
||||
}
|
||||
Info<< " )\nselected(";
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
Info<< " " << selections[elemI];
|
||||
}
|
||||
Info<< " )\n";
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPVblockMesh::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const arrayRange& range
|
||||
)
|
||||
{
|
||||
stringList selections(range.size());
|
||||
label nElem = 0;
|
||||
|
||||
for (int elemI = range.start(); elemI < range.end(); ++elemI)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
{
|
||||
selections[nElem++] = select->GetArrayName(elemI);
|
||||
}
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "available(";
|
||||
for (int elemI = range.start(); elemI < range.end(); ++elemI)
|
||||
{
|
||||
Info<< " \"" << select->GetArrayName(elemI) << "\"";
|
||||
}
|
||||
Info<< " )\nselected(";
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
Info<< " " << selections[elemI];
|
||||
}
|
||||
Info<< " )\n";
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const stringList& selections
|
||||
)
|
||||
{
|
||||
const int nElem = select->GetNumberOfArrays();
|
||||
select->DisableAllArrays();
|
||||
|
||||
// Loop through entries, setting values from selectedEntries
|
||||
for (int elemI=0; elemI < nElem; ++elemI)
|
||||
{
|
||||
string arrayName(select->GetArrayName(elemI));
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
if (selections[elemI] == arrayName)
|
||||
{
|
||||
select->EnableArray(arrayName.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::updateBoolListStatus
|
||||
(
|
||||
boolList& status,
|
||||
vtkDataArraySelection* selection
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<beg> Foam::vtkPVblockMesh::updateBoolListStatus" << endl;
|
||||
}
|
||||
|
||||
const label nElem = selection->GetNumberOfArrays();
|
||||
if (status.size() != nElem)
|
||||
{
|
||||
status.setSize(nElem);
|
||||
status = false;
|
||||
}
|
||||
|
||||
forAll(status, elemI)
|
||||
{
|
||||
const int setting = selection->GetArraySetting(elemI);
|
||||
|
||||
status[elemI] = setting;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< " part[" << elemI << "] = "
|
||||
<< status[elemI]
|
||||
<< " : " << selection->GetArrayName(elemI) << endl;
|
||||
}
|
||||
}
|
||||
if (debug)
|
||||
{
|
||||
Info<< "<end> Foam::vtkPVblockMesh::updateBoolListStatus" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,3 @@
|
||||
foamPvCore.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfoamPv-pv${ParaView_MAJOR}
|
||||
@ -1,5 +1,8 @@
|
||||
sinclude $(GENERAL_RULES)/paraview
|
||||
|
||||
EXE_INC = \
|
||||
${c++LESSWARN} \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(ParaView_INCLUDE_DIR) \
|
||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml
|
||||
|
||||
@ -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.
|
||||
@ -21,17 +21,13 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Misc helper methods and utilities
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkPVReaders.H"
|
||||
#include "foamPvCore.H"
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "IFstream.H"
|
||||
#include "memInfo.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkDataSet.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
@ -41,57 +37,28 @@ Description
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(vtkPVReaders, 0);
|
||||
defineTypeNameAndDebug(foamPvCore, 0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
//! \cond fileScope
|
||||
// Extract up to the first non-word characters
|
||||
inline word getFirstWord(const char* str)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
label n = 0;
|
||||
while (str[n] && word::valid(str[n]))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
return word(str, n, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return word::null;
|
||||
}
|
||||
|
||||
}
|
||||
//! \endcond
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVReaders::AddToBlock
|
||||
void Foam::foamPvCore::addToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const partInfo& selector,
|
||||
const arrayRange& selector,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
vtkDataObject* dataObj = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(dataObj);
|
||||
|
||||
if (!block)
|
||||
{
|
||||
if (blockDO)
|
||||
if (dataObj)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Block already has a vtkDataSet assigned to it"
|
||||
@ -114,7 +81,7 @@ void Foam::vtkPVReaders::AddToBlock
|
||||
|
||||
block->SetBlock(datasetNo, dataset);
|
||||
|
||||
// name the block when assigning dataset 0
|
||||
// name the output block when assigning dataset 0
|
||||
if (datasetNo == 0)
|
||||
{
|
||||
output->GetMetaData(blockNo)->Set
|
||||
@ -135,38 +102,19 @@ void Foam::vtkPVReaders::AddToBlock
|
||||
}
|
||||
|
||||
|
||||
vtkDataSet* Foam::vtkPVReaders::GetDataSetFromBlock
|
||||
int Foam::foamPvCore::getNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const label datasetNo
|
||||
const arrayRange& selector
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast
|
||||
(
|
||||
output->GetBlock(blockNo)
|
||||
);
|
||||
|
||||
if (block)
|
||||
{
|
||||
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ununsed at the moment
|
||||
Foam::label Foam::vtkPVReaders::GetNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkDataObject* blockDO = output->GetBlock(blockNo);
|
||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
|
||||
if (block)
|
||||
{
|
||||
return block->GetNumberOfBlocks();
|
||||
@ -176,54 +124,76 @@ Foam::label Foam::vtkPVReaders::GetNumberOfDataSets
|
||||
}
|
||||
|
||||
|
||||
// Foam::word Foam::vtkPVReaders::getPartName(int partId)
|
||||
// {
|
||||
// return getFirstWord(reader_->GetPartArrayName(partId));
|
||||
// }
|
||||
int Foam::foamPvCore::getSelected
|
||||
(
|
||||
boolList& status,
|
||||
vtkDataArraySelection* selection
|
||||
)
|
||||
{
|
||||
const int n = selection->GetNumberOfArrays();
|
||||
if (status.size() != n)
|
||||
{
|
||||
status.setSize(n);
|
||||
status = false;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
forAll(status, i)
|
||||
{
|
||||
const bool setting = selection->GetArraySetting(i);
|
||||
if (setting)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
status[i] = setting;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPVReaders::getSelected
|
||||
Foam::hashedWordList Foam::foamPvCore::getSelected
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
const int n = select->GetNumberOfArrays();
|
||||
DynamicList<word> selected(n);
|
||||
|
||||
for (int elemI=0; elemI < nElem; ++elemI)
|
||||
for (int i=0; i < n; ++i)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
if (select->GetArraySetting(i))
|
||||
{
|
||||
selections.insert(getFirstWord(select->GetArrayName(elemI)));
|
||||
selected.append(getFirstWord(select->GetArrayName(i)));
|
||||
}
|
||||
}
|
||||
|
||||
return selections;
|
||||
return hashedWordList(selected, true);
|
||||
}
|
||||
|
||||
|
||||
Foam::wordHashSet Foam::vtkPVReaders::getSelected
|
||||
Foam::hashedWordList Foam::foamPvCore::getSelected
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const partInfo& selector
|
||||
const arrayRange& selector
|
||||
)
|
||||
{
|
||||
int nElem = select->GetNumberOfArrays();
|
||||
wordHashSet selections(2*nElem);
|
||||
const int n = select->GetNumberOfArrays();
|
||||
DynamicList<word> selected(n);
|
||||
|
||||
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
|
||||
for (int i = selector.start(); i < selector.end(); ++i)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
if (select->GetArraySetting(i))
|
||||
{
|
||||
selections.insert(getFirstWord(select->GetArrayName(elemI)));
|
||||
selected.append(getFirstWord(select->GetArrayName(i)));
|
||||
}
|
||||
}
|
||||
|
||||
return selections;
|
||||
return hashedWordList(selected, true);
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
@ -240,14 +210,13 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
if (debug > 1)
|
||||
{
|
||||
label nElem = select->GetNumberOfArrays();
|
||||
const int n = select->GetNumberOfArrays();
|
||||
Info<< "available(";
|
||||
for (int elemI = 0; elemI < nElem; ++elemI)
|
||||
for (int i=0; i < n; ++i)
|
||||
{
|
||||
Info<< " \"" << select->GetArrayName(elemI) << "\"";
|
||||
Info<< " \"" << select->GetArrayName(i) << "\"";
|
||||
}
|
||||
Info<< " )\nselected(";
|
||||
|
||||
@ -262,31 +231,30 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
}
|
||||
|
||||
|
||||
Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
Foam::stringList Foam::foamPvCore::getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const partInfo& selector
|
||||
const arrayRange& selector
|
||||
)
|
||||
{
|
||||
stringList selections(selector.size());
|
||||
label nElem = 0;
|
||||
|
||||
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
|
||||
for (int i = selector.start(); i < selector.end(); ++i)
|
||||
{
|
||||
if (select->GetArraySetting(elemI))
|
||||
if (select->GetArraySetting(i))
|
||||
{
|
||||
selections[nElem++] = select->GetArrayName(elemI);
|
||||
selections[nElem++] = select->GetArrayName(i);
|
||||
}
|
||||
}
|
||||
selections.setSize(nElem);
|
||||
|
||||
|
||||
if (debug)
|
||||
if (debug > 1)
|
||||
{
|
||||
Info<< "available(";
|
||||
for (int elemI = selector.start(); elemI < selector.end(); ++elemI)
|
||||
for (int i = selector.start(); i < selector.end(); ++i)
|
||||
{
|
||||
Info<< " \"" << select->GetArrayName(elemI) << "\"";
|
||||
Info<< " \"" << select->GetArrayName(i) << "\"";
|
||||
}
|
||||
Info<< " )\nselected(";
|
||||
|
||||
@ -301,19 +269,19 @@ Foam::stringList Foam::vtkPVReaders::getSelectedArrayEntries
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVReaders::setSelectedArrayEntries
|
||||
void Foam::foamPvCore::setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const stringList& selections
|
||||
)
|
||||
{
|
||||
const int nElem = select->GetNumberOfArrays();
|
||||
const int n = select->GetNumberOfArrays();
|
||||
select->DisableAllArrays();
|
||||
|
||||
// Loop through entries, setting values from selectedEntries
|
||||
for (int elemI=0; elemI < nElem; ++elemI)
|
||||
for (int i=0; i < n; ++i)
|
||||
{
|
||||
string arrayName(select->GetArrayName(elemI));
|
||||
const string arrayName(select->GetArrayName(i));
|
||||
|
||||
forAll(selections, elemI)
|
||||
{
|
||||
@ -327,7 +295,33 @@ void Foam::vtkPVReaders::setSelectedArrayEntries
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
Foam::word Foam::foamPvCore::getFirstWord(const char* str)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
label n = 0;
|
||||
while (str[n] && word::valid(str[n]))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
// don't need to re-check for invalid chars
|
||||
return word(str, n, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return word::null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamPvCore::printMemory()
|
||||
{
|
||||
memInfo mem;
|
||||
|
||||
if (mem.valid())
|
||||
{
|
||||
Info<< "mem peak/size/rss: " << mem << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -21,44 +21,33 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Namespace
|
||||
Foam::vtkPVReaders
|
||||
|
||||
Description
|
||||
A collection of helper functions when building a reader interface in
|
||||
ParaView3.
|
||||
Helpers for OpenFOAM reader interfaces in ParaView.
|
||||
|
||||
SourceFiles
|
||||
vtkPVReaders.C
|
||||
foamPvCore.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVReaders_H
|
||||
#define vtkPVReaders_H
|
||||
|
||||
// do not include legacy strstream headers
|
||||
#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
|
||||
# define VTK_EXCLUDE_STRSTREAM_HEADERS
|
||||
#endif
|
||||
#ifndef foamPvCore_H
|
||||
#define foamPvCore_H
|
||||
|
||||
#include "className.H"
|
||||
#include "fileName.H"
|
||||
#include "stringList.H"
|
||||
#include "boolList.H"
|
||||
#include "pointList.H"
|
||||
#include "wordList.H"
|
||||
#include "HashSet.H"
|
||||
#include "Hash.H"
|
||||
#include "hashedWordList.H"
|
||||
|
||||
#include "vtkPoints.h"
|
||||
|
||||
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
|
||||
|
||||
class vtkDataArraySelection;
|
||||
class vtkDataSet;
|
||||
class vtkPoints;
|
||||
class vtkPVFoamReader;
|
||||
class vtkRenderer;
|
||||
class vtkTextActor;
|
||||
class vtkMultiBlockDataSet;
|
||||
class vtkPolyData;
|
||||
class vtkUnstructuredGrid;
|
||||
class vtkIndent;
|
||||
|
||||
|
||||
@ -66,13 +55,20 @@ class vtkIndent;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace vtkPVReaders
|
||||
{
|
||||
//- Declare name of the class and its debug switch
|
||||
NamespaceName("vtkPVReaders");
|
||||
|
||||
//- Bookkeeping for GUI checklists and the multi-block organization
|
||||
class partInfo
|
||||
class IOobjectList;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamPvCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamPvCore
|
||||
{
|
||||
public:
|
||||
|
||||
//- Bookkeeping for GUI checklists and multi-block organization
|
||||
// Works like a SubList selection.
|
||||
class arrayRange
|
||||
{
|
||||
const char *name_;
|
||||
int block_;
|
||||
@ -81,11 +77,12 @@ namespace vtkPVReaders
|
||||
|
||||
public:
|
||||
|
||||
partInfo(const char *name, const int blockNo=0)
|
||||
//- Construct with given name for the specified block
|
||||
arrayRange(const char *name, const int blockNo=0)
|
||||
:
|
||||
name_(name),
|
||||
block_(blockNo),
|
||||
start_(-1),
|
||||
start_(0),
|
||||
size_(0)
|
||||
{}
|
||||
|
||||
@ -103,42 +100,47 @@ namespace vtkPVReaders
|
||||
return prev;
|
||||
}
|
||||
|
||||
//- Return the name
|
||||
const char* name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- The array start index
|
||||
int start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- The array end index
|
||||
int end() const
|
||||
{
|
||||
return start_ + size_;
|
||||
}
|
||||
|
||||
//- The sub-list size
|
||||
int size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
//- True if the sub-list is empty
|
||||
bool empty() const
|
||||
{
|
||||
return !size_;
|
||||
}
|
||||
|
||||
void reset()
|
||||
//- Reset the size to zero and optionally assign a new start
|
||||
void reset(const int startAt = 0)
|
||||
{
|
||||
start_ = -1;
|
||||
size_ = 0;
|
||||
start_ = startAt;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
//- Assign new start and reset the size
|
||||
void operator=(const int i)
|
||||
{
|
||||
start_ = i;
|
||||
size_ = 0;
|
||||
reset(i);
|
||||
}
|
||||
|
||||
//- Increment the size
|
||||
@ -146,81 +148,132 @@ namespace vtkPVReaders
|
||||
{
|
||||
size_ += n;
|
||||
}
|
||||
};
|
||||
|
||||
}; // End class arrayRange
|
||||
|
||||
|
||||
//- Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
void AddToBlock
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamPvCore(const foamPvCore&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamPvCore&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
//- Static data members
|
||||
ClassName("foamPvCore");
|
||||
|
||||
|
||||
//- Construct null
|
||||
foamPvCore()
|
||||
{}
|
||||
|
||||
|
||||
//- Convenience method for the VTK multiblock API
|
||||
static void addToBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
vtkDataSet* dataset,
|
||||
const partInfo& selector,
|
||||
const arrayRange& selector,
|
||||
const label datasetNo,
|
||||
const std::string& datasetName
|
||||
);
|
||||
|
||||
|
||||
//- Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
vtkDataSet* GetDataSetFromBlock
|
||||
//- Convenience method for the VTK multiblock API
|
||||
// Always returns a nullptr if datasetNo is negative
|
||||
template<class Type=vtkDataSet>
|
||||
static Type* getDataFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector,
|
||||
const arrayRange& selector,
|
||||
const label datasetNo
|
||||
);
|
||||
|
||||
//- Convenience method use to convert the readers from VTK 5
|
||||
// multiblock API to the current composite data infrastructure
|
||||
// ununsed at the moment
|
||||
label GetNumberOfDataSets
|
||||
//- Convenience method for the VTK multiblock API
|
||||
static int getNumberOfDataSets
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const partInfo& selector
|
||||
const arrayRange& selector
|
||||
);
|
||||
|
||||
//- Add objects of Type to array selection
|
||||
template<class Type>
|
||||
static label addToSelection
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const IOobjectList& objects,
|
||||
const string& suffix = string::null
|
||||
);
|
||||
|
||||
|
||||
//- Retrieve the current selections into a boolList
|
||||
static int getSelected
|
||||
(
|
||||
boolList& lst,
|
||||
vtkDataArraySelection* select
|
||||
);
|
||||
|
||||
//- Retrieve the current selections as a wordHashSet
|
||||
wordHashSet getSelected
|
||||
static hashedWordList getSelected
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
);
|
||||
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
wordHashSet getSelected
|
||||
static hashedWordList getSelected
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const partInfo&
|
||||
vtkDataArraySelection* select,
|
||||
const arrayRange& selector
|
||||
);
|
||||
|
||||
|
||||
//- Retrieve the current selections
|
||||
stringList getSelectedArrayEntries(vtkDataArraySelection*);
|
||||
static stringList getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select
|
||||
);
|
||||
|
||||
//- Retrieve a sub-list of the current selections
|
||||
stringList getSelectedArrayEntries
|
||||
static stringList getSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection* select,
|
||||
const partInfo& selector
|
||||
const arrayRange& selector
|
||||
);
|
||||
|
||||
|
||||
//- Set selection(s)
|
||||
void setSelectedArrayEntries
|
||||
static void setSelectedArrayEntries
|
||||
(
|
||||
vtkDataArraySelection*,
|
||||
const stringList&
|
||||
vtkDataArraySelection* select,
|
||||
const stringList& selections
|
||||
);
|
||||
|
||||
|
||||
//- Extract up to the first non-word characters
|
||||
static word getFirstWord(const char* str);
|
||||
|
||||
//- Simple memory used debugging information
|
||||
static void printMemory();
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtkPV
|
||||
}; // End class foamPvCore
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "foamPvCoreTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,43 +23,57 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkPVFoamAddToSelection_H
|
||||
#define vtkPVFoamAddToSelection_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "IOobjectList.H"
|
||||
#include "SortableList.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkDataArraySelection.h"
|
||||
#include "vtkMultiBlockDataSet.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::vtkPVFoam::addToSelection
|
||||
Type* Foam::foamPvCore::getDataFromBlock
|
||||
(
|
||||
vtkMultiBlockDataSet* output,
|
||||
const arrayRange& selector,
|
||||
const label datasetNo
|
||||
)
|
||||
{
|
||||
const int blockNo = selector.block();
|
||||
|
||||
vtkMultiBlockDataSet* block =
|
||||
(
|
||||
datasetNo < 0
|
||||
? nullptr
|
||||
: vtkMultiBlockDataSet::SafeDownCast(output->GetBlock(blockNo))
|
||||
);
|
||||
|
||||
if (block)
|
||||
{
|
||||
return Type::SafeDownCast(block->GetBlock(datasetNo));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::foamPvCore::addToSelection
|
||||
(
|
||||
vtkDataArraySelection *select,
|
||||
const IOobjectList& objectLst,
|
||||
const IOobjectList& objects,
|
||||
const string& suffix
|
||||
)
|
||||
{
|
||||
SortableList<word> names(objectLst.names(Type::typeName));
|
||||
const wordList names = objects.sortedNames(Type::typeName);
|
||||
|
||||
forAll(names, nameI)
|
||||
forAll(names, i)
|
||||
{
|
||||
if (suffix.size())
|
||||
if (suffix.empty())
|
||||
{
|
||||
select->AddArray
|
||||
(
|
||||
(names[nameI] + suffix).c_str()
|
||||
);
|
||||
select->AddArray(names[i].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
select->AddArray
|
||||
(
|
||||
(names[nameI]).c_str()
|
||||
);
|
||||
select->AddArray((names[i] + suffix).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,8 +81,4 @@ Foam::label Foam::vtkPVFoam::addToSelection
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,36 +21,57 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InClass
|
||||
vtkPVFoam
|
||||
Description
|
||||
Helpers for OpenFOAM reader interfaces in ParaView.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkOpenFOAMTupleRemap_H
|
||||
#define vtkOpenFOAMTupleRemap_H
|
||||
#ifndef foamPvFields_H
|
||||
#define foamPvFields_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "Swap.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline void vtkOpenFOAMTupleRemap(float vec[]);
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamPvFields Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamPvFields
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamPvFields(const foamPvFields&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamPvFields&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
//- Remapping for some data types
|
||||
template<class Type>
|
||||
inline static void remapTuple(float vec[])
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
}; // End class foamPvFields
|
||||
|
||||
|
||||
// Template specialization for symmTensor
|
||||
template<>
|
||||
inline void vtkOpenFOAMTupleRemap<Foam::symmTensor>(float vec[])
|
||||
inline void Foam::foamPvFields::remapTuple<Foam::symmTensor>(float vec[])
|
||||
{
|
||||
Foam::Swap(vec[1], vec[3]); // swap XY <-> YY
|
||||
Foam::Swap(vec[2], vec[5]); // swap XZ <-> ZZ
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline void vtkOpenFOAMTupleRemap(float vec[])
|
||||
{}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
vtkPVReaders.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libvtkPVReaders
|
||||
@ -148,8 +148,9 @@ runParallel()
|
||||
|
||||
# Store any parsed additional arguments e.g. decomposeParDict
|
||||
APP_PARARGS=
|
||||
# Check the default decomposeParDict if available
|
||||
nProcs=$(getNumberOfProcessors system/decomposeParDict)
|
||||
|
||||
# Initialise number of procs to unset value
|
||||
nProcs=-1
|
||||
|
||||
# Parse options and executable
|
||||
while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
|
||||
@ -185,6 +186,8 @@ runParallel()
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$nProcs" -eq -1 ] && nProcs=$(getNumberOfProcessors system/decomposeParDict)
|
||||
|
||||
if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ]
|
||||
then
|
||||
echo "$APP_NAME already run on $PWD:" \
|
||||
@ -213,7 +216,7 @@ cloneCase()
|
||||
else
|
||||
echo "Cloning $2 case from $1"
|
||||
mkdir $2
|
||||
cpfiles="0 system constant"
|
||||
cpfiles="0.orig 0 system constant"
|
||||
for f in $cpfiles
|
||||
do
|
||||
\cp -r $1/$f $2
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
[ -d "$WM_PROJECT_DIR" ] || {
|
||||
echo " Error: WM_PROJECT_DIR directory does not exist"
|
||||
echo " Check the OpenFOAM entries in your dot-files and source them."
|
||||
echo " WM_PROJECT_DIR=$WM_PROJECT_DIR"
|
||||
echo "Error (${0##*/}) : no \$WM_PROJECT_DIR found"
|
||||
echo " Check your OpenFOAM environment and installation"
|
||||
echo " WM_PROJECT_DIR=$WM_PROJECT_DIR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@ -15,29 +14,29 @@ usage() {
|
||||
|
||||
usage: ${0##*/} [OPTION]
|
||||
options:
|
||||
-online use the links to the Github repositories instead of the local source code
|
||||
-online use links to the Github repositories instead of the local source code
|
||||
-help
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
defineURL() {
|
||||
WEB_PATH="https://develop.openfoam.com"
|
||||
FOAM_REPO_VERSION="$WM_PROJECT-plus"
|
||||
|
||||
WEB_PATH="https://develop.openfoam.com"
|
||||
FOAM_REPO_VERSION="$WM_PROJECT-plus"
|
||||
case "$WM_PROJECT_VERSION" in
|
||||
v[1-9][.0-9]*)
|
||||
FOAM_REPO_TAG="$WM_PROJECT-$WM_PROJECT_VERSION"
|
||||
;;
|
||||
*)
|
||||
FOAM_REPO_TAG="master"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$WM_PROJECT_VERSION" in
|
||||
v[0-9].[0-9]+)
|
||||
FOAM_REPO_TAG="$WM_PROJECT-$WM_PROJECT_VERSION"
|
||||
;;
|
||||
*)
|
||||
FOAM_REPO_TAG="master"
|
||||
;;
|
||||
esac
|
||||
|
||||
export FOAM_BASE_REPO="$WEB_PATH/Development/$FOAM_REPO_VERSION"
|
||||
export FOAM_ONLINE_REPO="$FOAM_BASE_REPO/blob/${FOAM_REPO_TAG}"
|
||||
export FOAM_BASE_REPO="$WEB_PATH/Development/$FOAM_REPO_VERSION"
|
||||
export FOAM_ONLINE_REPO="$FOAM_BASE_REPO/blob/${FOAM_REPO_TAG}"
|
||||
}
|
||||
|
||||
# parse options
|
||||
@ -49,12 +48,12 @@ do
|
||||
;;
|
||||
-online)
|
||||
defineURL
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage "unknown option/argument: '$*'"
|
||||
usage "unknown option/argument: '$1'"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
25
src/Allwmake
25
src/Allwmake
@ -1,21 +1,20 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
# Run from OPENFOAM src/ directory only
|
||||
cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR/src" 2>/dev/null || {
|
||||
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR/src"
|
||||
echo " Check your OpenFOAM environment and installation"
|
||||
exit 1
|
||||
}
|
||||
[ -n "$FOAM_EXT_LIBBIN" ] || {
|
||||
echo "Error (${0##*/}) : FOAM_EXT_LIBBIN not set"
|
||||
echo " Check your OpenFOAM environment and installation"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
wmakeCheckPwd "$WM_PROJECT_DIR/src" || {
|
||||
echo "Allwmake error: Current directory is not \$WM_PROJECT_DIR/src"
|
||||
echo " The environment variables are inconsistent with the installation."
|
||||
echo " Check the OpenFOAM entries in your dot-files and source them."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -n "$FOAM_EXT_LIBBIN" ] || {
|
||||
echo "Allwmake error: FOAM_EXT_LIBBIN not set"
|
||||
echo " Check the OpenFOAM entries in your dot-files and source them."
|
||||
exit 1
|
||||
}
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Update OpenFOAM version strings if required
|
||||
wmakePrintBuild -check || wrmo OpenFOAM/global/global.o 2>/dev/null
|
||||
|
||||
@ -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.
|
||||
@ -45,7 +45,15 @@ Foam::HashPtrTable<T, Key, Hash>::HashPtrTable
|
||||
{
|
||||
for (const_iterator iter = ht.begin(); iter != ht.end(); ++iter)
|
||||
{
|
||||
this->insert(iter.key(), new T(**iter));
|
||||
const T* ptr = *iter;
|
||||
if (ptr)
|
||||
{
|
||||
this->insert(iter.key(), new T(*ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->insert(iter.key(), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,24 +70,24 @@ Foam::HashPtrTable<T, Key, Hash>::~HashPtrTable()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
T* Foam::HashPtrTable<T, Key, Hash>::remove(iterator& it)
|
||||
T* Foam::HashPtrTable<T, Key, Hash>::remove(iterator& iter)
|
||||
{
|
||||
T* elemPtr = *it;
|
||||
HashTable<T*, Key, Hash>::erase(it);
|
||||
return elemPtr;
|
||||
T* ptr = *iter;
|
||||
HashTable<T*, Key, Hash>::erase(iter);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
bool Foam::HashPtrTable<T, Key, Hash>::erase(iterator& it)
|
||||
bool Foam::HashPtrTable<T, Key, Hash>::erase(iterator& iter)
|
||||
{
|
||||
T* elemPtr = *it;
|
||||
T* ptr = *iter;
|
||||
|
||||
if (HashTable<T*, Key, Hash>::erase(it))
|
||||
if (HashTable<T*, Key, Hash>::erase(iter))
|
||||
{
|
||||
if (elemPtr)
|
||||
if (ptr)
|
||||
{
|
||||
delete elemPtr;
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -128,7 +136,15 @@ void Foam::HashPtrTable<T, Key, Hash>::operator=
|
||||
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
{
|
||||
this->insert(iter.key(), new T(**iter));
|
||||
const T* ptr = *iter;
|
||||
if (ptr)
|
||||
{
|
||||
this->insert(iter.key(), new T(*ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->insert(iter.key(), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -70,7 +70,7 @@ class HashPtrTable
|
||||
|
||||
//- Read from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
void read(Istream&, const INew& inewt);
|
||||
void read(Istream& is, const INew& inewt);
|
||||
|
||||
//- Read from dictionary using given dictionary constructor class
|
||||
template<class INew>
|
||||
@ -91,17 +91,17 @@ public:
|
||||
|
||||
//- Construct from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
HashPtrTable(Istream&, const INew&);
|
||||
HashPtrTable(Istream& is, const INew& inewt);
|
||||
|
||||
//- Construct from Istream using default Istream constructor class
|
||||
HashPtrTable(Istream&);
|
||||
HashPtrTable(Istream& is);
|
||||
|
||||
//- Construct from dictionary using default dictionary constructor
|
||||
// class
|
||||
HashPtrTable(const dictionary&);
|
||||
HashPtrTable(const dictionary& dict);
|
||||
|
||||
//- Construct as copy
|
||||
HashPtrTable(const HashPtrTable<T, Key, Hash>&);
|
||||
HashPtrTable(const HashPtrTable<T, Key, Hash>& ht);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -113,10 +113,10 @@ public:
|
||||
// Edit
|
||||
|
||||
//- Remove and return the pointer specified by given iterator
|
||||
T* remove(iterator&);
|
||||
T* remove(iterator& iter);
|
||||
|
||||
//- Erase an hashedEntry specified by given iterator
|
||||
bool erase(iterator&);
|
||||
bool erase(iterator& iter);
|
||||
|
||||
//- Clear all entries from table
|
||||
void clear();
|
||||
@ -127,7 +127,8 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const HashPtrTable<T, Key, Hash>&);
|
||||
//- Copy assignment
|
||||
void operator=(const HashPtrTable<T, Key, Hash>& rhs);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -61,7 +61,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
|
||||
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
Key key;
|
||||
is >> key;
|
||||
@ -166,8 +166,11 @@ void Foam::HashPtrTable<T, Key, Hash>::write(Ostream& os) const
|
||||
++iter
|
||||
)
|
||||
{
|
||||
const T* ptr = iter();
|
||||
ptr->write(os);
|
||||
const T* ptr = *iter;
|
||||
if (ptr)
|
||||
{
|
||||
ptr->write(os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +229,14 @@ Foam::Ostream& Foam::operator<<
|
||||
++iter
|
||||
)
|
||||
{
|
||||
os << iter.key() << token::SPACE << *iter() << nl;
|
||||
const T* ptr = *iter;
|
||||
|
||||
os << iter.key();
|
||||
if (ptr)
|
||||
{
|
||||
os << token::SPACE << *ptr;
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
|
||||
// Write end delimiter
|
||||
|
||||
@ -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.
|
||||
@ -144,10 +144,10 @@ class HashTable
|
||||
|
||||
private:
|
||||
//- Disallow default bitwise copy construct
|
||||
hashedEntry(const hashedEntry&);
|
||||
hashedEntry(const hashedEntry&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const hashedEntry&);
|
||||
void operator=(const hashedEntry&) = delete;
|
||||
};
|
||||
|
||||
|
||||
@ -400,10 +400,6 @@ public:
|
||||
//- Return non-const access to referenced object
|
||||
inline T& object();
|
||||
|
||||
//- Return const access to referenced object
|
||||
inline const T& cobject() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Member operators
|
||||
@ -413,6 +409,9 @@ public:
|
||||
//- Return the Key corresponding to the iterator
|
||||
inline const Key& key() const;
|
||||
|
||||
//- Return const access to referenced object
|
||||
inline const T& cobject() const;
|
||||
|
||||
//- Compare hashedEntry element pointers
|
||||
inline bool operator==(const iteratorBase&) const;
|
||||
inline bool operator!=(const iteratorBase&) const;
|
||||
@ -460,11 +459,14 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Return referenced hash value
|
||||
//- Return non-const access to referenced object
|
||||
using iteratorBase::object;
|
||||
|
||||
//- Return non-const access to referenced object
|
||||
inline T& operator*();
|
||||
inline T& operator()();
|
||||
|
||||
//- Return referenced hash value
|
||||
//- Return const access to referenced object
|
||||
inline const T& operator*() const;
|
||||
inline const T& operator()() const;
|
||||
|
||||
@ -518,13 +520,12 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Return referenced hash value
|
||||
//- Return const access to referenced object
|
||||
inline const T& operator*() const;
|
||||
inline const T& operator()() const;
|
||||
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
||||
}
|
||||
else if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
L.setSize(s);
|
||||
|
||||
@ -183,7 +183,7 @@ bool Foam::UList<T>::operator<(const UList<T>& a) const
|
||||
(
|
||||
const_iterator vi = begin(), ai = a.begin();
|
||||
vi < end() && ai < a.end();
|
||||
vi++, ai++
|
||||
++vi, ++ai
|
||||
)
|
||||
{
|
||||
if (*vi < *ai)
|
||||
|
||||
@ -427,7 +427,7 @@ inline void reverse(UList<T>&);
|
||||
// \endcode
|
||||
// \sa forAllReverse
|
||||
#define forAll(list, i) \
|
||||
for (Foam::label i=0; i<(list).size(); i++)
|
||||
for (Foam::label i=0; i<(list).size(); ++i)
|
||||
|
||||
//- Reverse loop across all elements in \a list
|
||||
// \par Usage
|
||||
@ -439,7 +439,7 @@ inline void reverse(UList<T>&);
|
||||
// \endcode
|
||||
// \sa forAll
|
||||
#define forAllReverse(list, i) \
|
||||
for (Foam::label i=(list).size()-1; i>=0; i--)
|
||||
for (Foam::label i=(list).size()-1; i>=0; --i)
|
||||
|
||||
//- Iterate across all elements in the \a container object of type
|
||||
// \a Container.
|
||||
@ -472,8 +472,8 @@ inline void reverse(UList<T>&);
|
||||
#define forAllConstIter(Container,container,iter) \
|
||||
for \
|
||||
( \
|
||||
Container::const_iterator iter = (container).begin(); \
|
||||
iter != (container).end(); \
|
||||
Container::const_iterator iter = (container).cbegin(); \
|
||||
iter != (container).cend(); \
|
||||
++iter \
|
||||
)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -33,7 +33,7 @@ template<class T>
|
||||
inline Foam::UList<T>::UList()
|
||||
:
|
||||
size_(0),
|
||||
v_(0)
|
||||
v_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
@ -321,7 +321,7 @@ inline bool Foam::UList<T>::empty() const
|
||||
template<class T>
|
||||
inline void Foam::reverse(UList<T>& ul, const label n)
|
||||
{
|
||||
for (int i=0; i<n/2; i++)
|
||||
for (int i=0; i<n/2; ++i)
|
||||
{
|
||||
Swap(ul[i], ul[n-1-i]);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -165,7 +165,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
)
|
||||
);
|
||||
// Check list length
|
||||
label s = elems.size();
|
||||
const label s = elems.size();
|
||||
|
||||
if (s != L.size())
|
||||
{
|
||||
@ -174,14 +174,14 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
<< " expected " << L.size()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
L[i] = elems[i];
|
||||
}
|
||||
}
|
||||
else if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
if (s != L.size())
|
||||
@ -203,7 +203,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
{
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
is >> L[i];
|
||||
|
||||
@ -226,7 +226,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
"reading the single entry"
|
||||
);
|
||||
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
L[i] = element;
|
||||
}
|
||||
@ -281,7 +281,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
(
|
||||
typename SLList<T>::const_iterator iter = sll.begin();
|
||||
iter != sll.end();
|
||||
++iter
|
||||
++iter, ++i
|
||||
)
|
||||
{
|
||||
L[i] = iter();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -43,27 +43,35 @@ static const unsigned char base64Chars[64] =
|
||||
//! \endcond
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
std::size_t Foam::base64Layer::encodedLength(std::size_t n)
|
||||
{
|
||||
return 4 * ((n / 3) + (n % 3 ? 1 : 0));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode0()
|
||||
inline unsigned char Foam::base64Layer::encode0() const
|
||||
{
|
||||
// Top 6 bits of char0
|
||||
return base64Chars[((group_[0] & 0xFC) >> 2)];
|
||||
}
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode1()
|
||||
inline unsigned char Foam::base64Layer::encode1() const
|
||||
{
|
||||
// Bottom 2 bits of char0, Top 4 bits of char1
|
||||
return base64Chars[((group_[0] & 0x03) << 4) | ((group_[1] & 0xF0) >> 4)];
|
||||
}
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode2()
|
||||
inline unsigned char Foam::base64Layer::encode2() const
|
||||
{
|
||||
// Bottom 4 bits of char1, Top 2 bits of char2
|
||||
return base64Chars[((group_[1] & 0x0F) << 2) | ((group_[2] & 0xC0) >> 6)];
|
||||
}
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode3()
|
||||
inline unsigned char Foam::base64Layer::encode3() const
|
||||
{
|
||||
// Bottom 6 bits of char2
|
||||
return base64Chars[(group_[2] & 0x3F)];
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -30,7 +30,7 @@ Description
|
||||
Base64 encoding accoding to RFC 4648 specification
|
||||
(https://tools.ietf.org/html/rfc4648#page-5).
|
||||
It is the obligation of the caller to avoid using normal output
|
||||
while the base-64 encoding layer is actively being used.
|
||||
while the base-64 encoding layer is actively used.
|
||||
|
||||
SourceFiles
|
||||
base64Layer.C
|
||||
@ -70,10 +70,10 @@ class base64Layer
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
inline unsigned char encode0();
|
||||
inline unsigned char encode1();
|
||||
inline unsigned char encode2();
|
||||
inline unsigned char encode3();
|
||||
inline unsigned char encode0() const;
|
||||
inline unsigned char encode1() const;
|
||||
inline unsigned char encode2() const;
|
||||
inline unsigned char encode3() const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
base64Layer(const base64Layer&) = delete;
|
||||
@ -95,7 +95,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
base64Layer(std::ostream&);
|
||||
base64Layer(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -104,6 +104,10 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The encoded length has 4 bytes out for every 3 bytes in.
|
||||
static std::size_t encodedLength(std::size_t n);
|
||||
|
||||
|
||||
//- Encode the character sequence, writing when possible.
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
@ -111,7 +115,7 @@ public:
|
||||
void reset();
|
||||
|
||||
//- End the encoding sequence, padding the final characters with '='.
|
||||
// Return false if no encoding layer was actually used.
|
||||
// Return false if no encoding was actually performed.
|
||||
bool close();
|
||||
|
||||
};
|
||||
|
||||
@ -129,7 +129,7 @@ Foam::PtrList<Foam::OFstream>& Foam::functionObjects::logFiles::files()
|
||||
}
|
||||
|
||||
|
||||
Foam::OFstream& Foam::functionObjects::logFiles::file(const label i)
|
||||
Foam::OFstream& Foam::functionObjects::logFiles::files(const label i)
|
||||
{
|
||||
if (!Pstream::master())
|
||||
{
|
||||
|
||||
@ -128,7 +128,7 @@ public:
|
||||
PtrList<OFstream>& files();
|
||||
|
||||
//- Return file 'i'
|
||||
OFstream& file(const label i);
|
||||
OFstream& files(const label i);
|
||||
|
||||
//- Write function
|
||||
virtual bool write();
|
||||
|
||||
@ -32,7 +32,7 @@ Description
|
||||
Note: cannot access the state dictionary until after construction of the
|
||||
function objects, since the owner container functionObjectList is owned
|
||||
by time, and time owns the state dictionary. I.e. need to wait for time
|
||||
to be fully consttucted.
|
||||
to be fully constructed.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
|
||||
@ -51,7 +51,7 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjectFile Declaration
|
||||
Class writeFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeFile
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,105 +24,62 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "boundBox.H"
|
||||
#include "ListOps.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
#include "tmp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::scalar Foam::boundBox::great(VGREAT);
|
||||
|
||||
const Foam::boundBox Foam::boundBox::greatBox
|
||||
(
|
||||
point(-VGREAT, -VGREAT, -VGREAT),
|
||||
point(VGREAT, VGREAT, VGREAT)
|
||||
point::uniform(-ROOTVGREAT),
|
||||
point::uniform(ROOTVGREAT)
|
||||
);
|
||||
|
||||
|
||||
const Foam::boundBox Foam::boundBox::invertedBox
|
||||
(
|
||||
point(VGREAT, VGREAT, VGREAT),
|
||||
point(-VGREAT, -VGREAT, -VGREAT)
|
||||
point::uniform(ROOTVGREAT),
|
||||
point::uniform(-ROOTVGREAT)
|
||||
);
|
||||
|
||||
|
||||
//! \cond ignoreDocumentation
|
||||
//- Skip documentation : local scope only
|
||||
const Foam::label facesArray[6][4] =
|
||||
{
|
||||
// point and face order as per hex cellmodel
|
||||
{0, 4, 7, 3}, // x-min
|
||||
{1, 2, 6, 5}, // x-max
|
||||
{0, 1, 5, 4}, // y-min
|
||||
{3, 7, 6, 2}, // y-max
|
||||
{0, 3, 2, 1}, // z-min
|
||||
{4, 5, 6, 7} // z-max
|
||||
};
|
||||
//! \endcond
|
||||
|
||||
|
||||
const Foam::faceList Foam::boundBox::faces
|
||||
(
|
||||
initListList<face, label, 6, 4>(facesArray)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::boundBox::calculate(const UList<point>& points, const bool doReduce)
|
||||
{
|
||||
if (points.empty())
|
||||
{
|
||||
min_ = Zero;
|
||||
max_ = Zero;
|
||||
|
||||
if (doReduce && Pstream::parRun())
|
||||
{
|
||||
// Use values that get overwritten by reduce minOp, maxOp below
|
||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
||||
max_ = point(-VGREAT, -VGREAT, -VGREAT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
min_ = points[0];
|
||||
max_ = points[0];
|
||||
|
||||
|
||||
for (label i = 1; i < points.size(); i++)
|
||||
{
|
||||
min_ = ::Foam::min(min_, points[i]);
|
||||
max_ = ::Foam::max(max_, points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce parallel information
|
||||
if (doReduce)
|
||||
{
|
||||
reduce(min_, minOp<point>());
|
||||
reduce(max_, maxOp<point>());
|
||||
}
|
||||
}
|
||||
({
|
||||
// Point and face order as per hex cellmodel
|
||||
face{0, 4, 7, 3}, // x-min
|
||||
face{1, 2, 6, 5}, // x-max
|
||||
face{0, 1, 5, 4}, // y-min
|
||||
face{3, 7, 6, 2}, // y-max
|
||||
face{0, 3, 2, 1}, // z-min
|
||||
face{4, 5, 6, 7} // z-max
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::boundBox::boundBox(const UList<point>& points, const bool doReduce)
|
||||
Foam::boundBox::boundBox(const UList<point>& points, bool doReduce)
|
||||
:
|
||||
min_(Zero),
|
||||
max_(Zero)
|
||||
min_(invertedBox.min()),
|
||||
max_(invertedBox.max())
|
||||
{
|
||||
calculate(points, doReduce);
|
||||
add(points);
|
||||
|
||||
if (doReduce)
|
||||
{
|
||||
reduce();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::boundBox::boundBox(const tmp<pointField>& points, const bool doReduce)
|
||||
Foam::boundBox::boundBox(const tmp<pointField>& tpoints, bool doReduce)
|
||||
:
|
||||
min_(Zero),
|
||||
max_(Zero)
|
||||
min_(invertedBox.min()),
|
||||
max_(invertedBox.max())
|
||||
{
|
||||
calculate(points(), doReduce);
|
||||
points.clear();
|
||||
add(tpoints);
|
||||
|
||||
if (doReduce)
|
||||
{
|
||||
reduce();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -130,38 +87,17 @@ Foam::boundBox::boundBox
|
||||
(
|
||||
const UList<point>& points,
|
||||
const labelUList& indices,
|
||||
const bool doReduce
|
||||
bool doReduce
|
||||
)
|
||||
:
|
||||
min_(Zero),
|
||||
max_(Zero)
|
||||
min_(invertedBox.min()),
|
||||
max_(invertedBox.max())
|
||||
{
|
||||
if (points.empty() || indices.empty())
|
||||
{
|
||||
if (doReduce && Pstream::parRun())
|
||||
{
|
||||
// Use values that get overwritten by reduce minOp, maxOp below
|
||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
||||
max_ = point(-VGREAT, -VGREAT, -VGREAT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
min_ = points[indices[0]];
|
||||
max_ = points[indices[0]];
|
||||
add(points, indices);
|
||||
|
||||
for (label i=1; i < indices.size(); ++i)
|
||||
{
|
||||
min_ = ::Foam::min(min_, points[indices[i]]);
|
||||
max_ = ::Foam::max(max_, points[indices[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce parallel information
|
||||
if (doReduce)
|
||||
{
|
||||
reduce(min_, minOp<point>());
|
||||
reduce(max_, maxOp<point>());
|
||||
reduce();
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,8 +106,8 @@ Foam::boundBox::boundBox
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::boundBox::points() const
|
||||
{
|
||||
tmp<pointField> tPts = tmp<pointField>(new pointField(8));
|
||||
pointField& pt = tPts.ref();
|
||||
tmp<pointField> tpoints = tmp<pointField>(new pointField(8));
|
||||
pointField& pt = tpoints.ref();
|
||||
|
||||
pt[0] = min_; // min-x, min-y, min-z
|
||||
pt[1] = point(max_.x(), min_.y(), min_.z()); // max-x, min-y, min-z
|
||||
@ -182,19 +118,35 @@ Foam::tmp<Foam::pointField> Foam::boundBox::points() const
|
||||
pt[6] = max_; // max-x, max-y, max-z
|
||||
pt[7] = point(min_.x(), max_.y(), max_.z()); // min-x, max-y, max-z
|
||||
|
||||
return tPts;
|
||||
return tpoints;
|
||||
}
|
||||
|
||||
|
||||
void Foam::boundBox::inflate(const scalar s)
|
||||
{
|
||||
vector ext = vector::one*s*mag();
|
||||
const vector ext = vector::one*s*mag();
|
||||
|
||||
min_ -= ext;
|
||||
max_ += ext;
|
||||
}
|
||||
|
||||
|
||||
void Foam::boundBox::reduce()
|
||||
{
|
||||
Foam::reduce(min_, minOp<point>());
|
||||
Foam::reduce(max_, maxOp<point>());
|
||||
}
|
||||
|
||||
|
||||
bool Foam::boundBox::intersect(const boundBox& bb)
|
||||
{
|
||||
min_ = ::Foam::max(min_, bb.min_);
|
||||
max_ = ::Foam::min(max_, bb.max_);
|
||||
|
||||
return !empty();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::boundBox::contains(const UList<point>& points) const
|
||||
{
|
||||
if (points.empty())
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,6 +27,11 @@ Class
|
||||
Description
|
||||
A bounding box defined in terms of the points at its extremities.
|
||||
|
||||
Note
|
||||
When a bounding box is created without any points, it creates an inverted
|
||||
bounding box. Points can be added later and the bounding box will grow to
|
||||
include them.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef boundBox_H
|
||||
@ -60,26 +65,17 @@ class boundBox
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Minimum and maximum describing the bounding box
|
||||
//- Minimum and maximum points describing the bounding box
|
||||
point min_, max_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the bounding box from the given points.
|
||||
// Does parallel communication (doReduce = true)
|
||||
void calculate(const UList<point>&, const bool doReduce = true);
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- The great value used for greatBox and invertedBox
|
||||
static const scalar great;
|
||||
|
||||
//- A very large boundBox: min/max == -/+ VGREAT
|
||||
//- A large boundBox: min/max == -/+ ROOTVGREAT
|
||||
static const boundBox greatBox;
|
||||
|
||||
//- A very large inverted boundBox: min/max == +/- VGREAT
|
||||
//- A large inverted boundBox: min/max == +/- ROOTVGREAT
|
||||
static const boundBox invertedBox;
|
||||
|
||||
//- Faces to point addressing, as per a 'hex' cell
|
||||
@ -88,49 +84,58 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null, setting points to zero
|
||||
//- Construct without any points - an inverted bounding box
|
||||
inline boundBox();
|
||||
|
||||
//- Construct a bounding box containing a single initial point
|
||||
explicit inline boundBox(const point& pt);
|
||||
|
||||
//- Construct from components
|
||||
inline boundBox(const point& min, const point& max);
|
||||
|
||||
//- Construct as the bounding box of the given points
|
||||
// Does parallel communication (doReduce = true)
|
||||
boundBox(const UList<point>&, const bool doReduce = true);
|
||||
explicit boundBox(const UList<point>& points, bool doReduce = true);
|
||||
|
||||
//- Construct as the bounding box of the given temporary pointField.
|
||||
// Does parallel communication (doReduce = true)
|
||||
boundBox(const tmp<pointField>&, const bool doReduce = true);
|
||||
explicit boundBox(const tmp<pointField>& tpoints, bool doReduce = true);
|
||||
|
||||
//- Construct bounding box as subset of the pointField.
|
||||
//- Construct bounding box as an indirect subset of the points.
|
||||
// The indices could be from cell/face etc.
|
||||
// Does parallel communication (doReduce = true)
|
||||
boundBox
|
||||
(
|
||||
const UList<point>&,
|
||||
const UList<point>& points,
|
||||
const labelUList& indices,
|
||||
const bool doReduce = true
|
||||
bool doReduce = true
|
||||
);
|
||||
|
||||
//- Construct bounding box as subset of the pointField.
|
||||
//- Construct bounding box as an indirect subset of the points.
|
||||
// The indices could be from edge/triFace etc.
|
||||
// Does parallel communication (doReduce = true)
|
||||
template<unsigned Size>
|
||||
boundBox
|
||||
(
|
||||
const UList<point>&,
|
||||
const UList<point>& points,
|
||||
const FixedList<label, Size>& indices,
|
||||
const bool doReduce = true
|
||||
bool doReduce = true
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
inline boundBox(Istream&);
|
||||
inline boundBox(Istream& is);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Bounding box is inverted, contains no points.
|
||||
inline bool empty() const;
|
||||
|
||||
//- Clear bounding box of all points - make it an inverted box
|
||||
inline void clear();
|
||||
|
||||
//- Minimum describing the bounding box
|
||||
inline const point& min() const;
|
||||
|
||||
@ -170,80 +175,130 @@ public:
|
||||
|
||||
// Manipulate
|
||||
|
||||
//- Extend to include the second box.
|
||||
inline void add(const boundBox& bb);
|
||||
|
||||
//- Extend to include the point.
|
||||
inline void add(const point& pt);
|
||||
|
||||
//- Extend to include the points.
|
||||
inline void add(const UList<point>& points);
|
||||
|
||||
//- Extend to include the points from the temporary point field.
|
||||
inline void add(const tmp<pointField>& tpoints);
|
||||
|
||||
//- Extend to include the subset of the point field.
|
||||
// The indices could be from cell/face etc.
|
||||
inline void add
|
||||
(
|
||||
const UList<point>& points,
|
||||
const labelUList& indices
|
||||
);
|
||||
|
||||
//- Extend to include the points.
|
||||
template<unsigned Size>
|
||||
void add(const FixedList<point, Size>& points);
|
||||
|
||||
//- Extend to include the subset of the point field.
|
||||
// The indices could be from edge/triFace etc.
|
||||
template<unsigned Size>
|
||||
void add
|
||||
(
|
||||
const UList<point>& points,
|
||||
const FixedList<label, Size>& indices
|
||||
);
|
||||
|
||||
//- Inflate box by factor*mag(span) in all dimensions
|
||||
void inflate(const scalar s);
|
||||
|
||||
//- Parallel reduction of min/max values
|
||||
void reduce();
|
||||
|
||||
//- Intersection (union) with the second box.
|
||||
// The return value is true if the intersection is non-empty.
|
||||
bool intersect(const boundBox& bb);
|
||||
|
||||
|
||||
// Query
|
||||
|
||||
//- Overlaps/touches boundingBox?
|
||||
inline bool overlaps(const boundBox&) const;
|
||||
inline bool overlaps(const boundBox& bb) const;
|
||||
|
||||
//- Overlaps boundingSphere (centre + sqr(radius))?
|
||||
inline bool overlaps(const point&, const scalar radiusSqr) const;
|
||||
inline bool overlaps
|
||||
(
|
||||
const point& centre,
|
||||
const scalar radiusSqr
|
||||
) const;
|
||||
|
||||
//- Contains point? (inside or on edge)
|
||||
inline bool contains(const point&) const;
|
||||
inline bool contains(const point& pt) const;
|
||||
|
||||
//- Fully contains other boundingBox?
|
||||
inline bool contains(const boundBox&) const;
|
||||
inline bool contains(const boundBox& bb) const;
|
||||
|
||||
//- Contains point? (inside only)
|
||||
inline bool containsInside(const point&) const;
|
||||
inline bool containsInside(const point& pt) const;
|
||||
|
||||
//- Contains all of the points? (inside or on edge)
|
||||
bool contains(const UList<point>&) const;
|
||||
bool contains(const UList<point>& points) const;
|
||||
|
||||
//- Contains all of the points? (inside or on edge)
|
||||
//- Contains all of the subset of points? (inside or on edge)
|
||||
bool contains
|
||||
(
|
||||
const UList<point>&,
|
||||
const UList<point>& points,
|
||||
const labelUList& indices
|
||||
) const;
|
||||
|
||||
//- Contains all of the points? (inside or on edge)
|
||||
//- Contains all of the subset of points? (inside or on edge)
|
||||
template<unsigned Size>
|
||||
bool contains
|
||||
(
|
||||
const UList<point>&,
|
||||
const UList<point>& points,
|
||||
const FixedList<label, Size>& indices
|
||||
) const;
|
||||
|
||||
|
||||
//- Contains any of the points? (inside or on edge)
|
||||
bool containsAny(const UList<point>&) const;
|
||||
bool containsAny(const UList<point>& points) const;
|
||||
|
||||
//- Contains any of the points? (inside or on edge)
|
||||
//- Contains any of the subset of points? (inside or on edge)
|
||||
bool containsAny
|
||||
(
|
||||
const UList<point>&,
|
||||
const UList<point>& points,
|
||||
const labelUList& indices
|
||||
) const;
|
||||
|
||||
//- Contains any of the points? (inside or on edge)
|
||||
//- Contains any of the subset of points? (inside or on edge)
|
||||
template<unsigned Size>
|
||||
bool containsAny
|
||||
(
|
||||
const UList<point>&,
|
||||
const UList<point>& points,
|
||||
const FixedList<label, Size>& indices
|
||||
) const;
|
||||
|
||||
//- Return the nearest point on the boundBox to the supplied point.
|
||||
// If point is inside the boundBox then the point is returned
|
||||
// unchanged.
|
||||
point nearest(const point&) const;
|
||||
point nearest(const point& pt) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Extend box to include the second box, as per the add() method.
|
||||
inline void operator+=(const boundBox& bb);
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
inline friend bool operator==(const boundBox&, const boundBox&);
|
||||
inline friend bool operator!=(const boundBox&, const boundBox&);
|
||||
inline friend bool operator==(const boundBox& a, const boundBox& b);
|
||||
inline friend bool operator!=(const boundBox& a, const boundBox& b);
|
||||
|
||||
|
||||
// IOstream operator
|
||||
|
||||
friend Istream& operator>>(Istream&, boundBox&);
|
||||
friend Ostream& operator<<(Ostream&, const boundBox&);
|
||||
friend Istream& operator>>(Istream& is, boundBox& bb);
|
||||
friend Ostream& operator<<(Ostream& os, const boundBox& bb);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,15 +24,21 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "boundBox.H"
|
||||
#include "pointField.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::boundBox::boundBox()
|
||||
:
|
||||
min_(Zero),
|
||||
max_(Zero)
|
||||
min_(invertedBox.min()),
|
||||
max_(invertedBox.max())
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::boundBox::boundBox(const point& pt)
|
||||
:
|
||||
min_(pt),
|
||||
max_(pt)
|
||||
{}
|
||||
|
||||
|
||||
@ -51,6 +57,19 @@ inline Foam::boundBox::boundBox(Istream& is)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::boundBox::empty() const
|
||||
{
|
||||
return (min_ > max_);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::boundBox::clear()
|
||||
{
|
||||
min_ = invertedBox.min();
|
||||
max_ = invertedBox.max();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::point& Foam::boundBox::min() const
|
||||
{
|
||||
return min_;
|
||||
@ -117,6 +136,52 @@ inline Foam::scalar Foam::boundBox::avgDim() const
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::boundBox::add(const boundBox& bb)
|
||||
{
|
||||
min_ = ::Foam::min(min_, bb.min_);
|
||||
max_ = ::Foam::max(max_, bb.max_);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::boundBox::add(const point& pt)
|
||||
{
|
||||
min_ = ::Foam::min(min_, pt);
|
||||
max_ = ::Foam::max(max_, pt);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::boundBox::add(const UList<point>& points)
|
||||
{
|
||||
forAll(points, i)
|
||||
{
|
||||
add(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::boundBox::add(const tmp<pointField>& tpoints)
|
||||
{
|
||||
add(tpoints());
|
||||
tpoints.clear();
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::boundBox::add
|
||||
(
|
||||
const UList<point>& points,
|
||||
const labelUList& indices
|
||||
)
|
||||
{
|
||||
if (!points.empty())
|
||||
{
|
||||
forAll(indices, i)
|
||||
{
|
||||
add(points[indices[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::boundBox::overlaps(const boundBox& bb) const
|
||||
{
|
||||
return
|
||||
@ -138,7 +203,7 @@ inline bool Foam::boundBox::overlaps
|
||||
// Find nearest point on bb.
|
||||
scalar distSqr = 0;
|
||||
|
||||
for (direction dir = 0; dir < vector::nComponents; dir++)
|
||||
for (direction dir = 0; dir < vector::nComponents; ++dir)
|
||||
{
|
||||
scalar d0 = min_[dir] - centre[dir];
|
||||
scalar d1 = max_[dir] - centre[dir];
|
||||
@ -178,7 +243,6 @@ inline bool Foam::boundBox::contains(const point& pt) const
|
||||
}
|
||||
|
||||
|
||||
// this.bb fully contains bb
|
||||
inline bool Foam::boundBox::contains(const boundBox& bb) const
|
||||
{
|
||||
return contains(bb.min()) && contains(bb.max());
|
||||
@ -196,6 +260,14 @@ inline bool Foam::boundBox::containsInside(const point& pt) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::boundBox::operator+=(const boundBox& bb)
|
||||
{
|
||||
add(bb);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::operator==(const boundBox& a, const boundBox& b)
|
||||
|
||||
@ -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) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,8 +25,6 @@ License
|
||||
|
||||
#include "boundBox.H"
|
||||
#include "FixedList.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -35,45 +33,55 @@ Foam::boundBox::boundBox
|
||||
(
|
||||
const UList<point>& points,
|
||||
const FixedList<label, Size>& indices,
|
||||
const bool doReduce
|
||||
bool doReduce
|
||||
)
|
||||
:
|
||||
min_(Zero),
|
||||
max_(Zero)
|
||||
min_(invertedBox.min()),
|
||||
max_(invertedBox.max())
|
||||
{
|
||||
// a FixedList is never empty
|
||||
if (points.empty())
|
||||
{
|
||||
if (doReduce && Pstream::parRun())
|
||||
{
|
||||
// Use values that get overwritten by reduce minOp, maxOp below
|
||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
||||
max_ = point(-VGREAT, -VGREAT, -VGREAT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
min_ = points[indices[0]];
|
||||
max_ = points[indices[0]];
|
||||
add(points, indices);
|
||||
|
||||
for (unsigned i=1; i < Size; ++i)
|
||||
{
|
||||
min_ = ::Foam::min(min_, points[indices[i]]);
|
||||
max_ = ::Foam::max(max_, points[indices[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce parallel information
|
||||
if (doReduce)
|
||||
{
|
||||
reduce(min_, minOp<point>());
|
||||
reduce(max_, maxOp<point>());
|
||||
reduce();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<unsigned Size>
|
||||
void Foam::boundBox::add
|
||||
(
|
||||
const FixedList<point, Size>& points
|
||||
)
|
||||
{
|
||||
// a FixedList is never empty
|
||||
for (unsigned i=0; i < Size; ++i)
|
||||
{
|
||||
add(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned Size>
|
||||
void Foam::boundBox::add
|
||||
(
|
||||
const UList<point>& points,
|
||||
const FixedList<label, Size>& indices
|
||||
)
|
||||
{
|
||||
// points may be empty, but a FixedList is never empty
|
||||
if (!points.empty())
|
||||
{
|
||||
for (unsigned i=0; i < Size; ++i)
|
||||
{
|
||||
add(points[indices[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned Size>
|
||||
bool Foam::boundBox::contains
|
||||
(
|
||||
@ -81,7 +89,7 @@ bool Foam::boundBox::contains
|
||||
const FixedList<label, Size>& indices
|
||||
) const
|
||||
{
|
||||
// a FixedList is never empty
|
||||
// points may be empty, but a FixedList is never empty
|
||||
if (points.empty())
|
||||
{
|
||||
return false;
|
||||
@ -106,7 +114,7 @@ bool Foam::boundBox::containsAny
|
||||
const FixedList<label, Size>& indices
|
||||
) const
|
||||
{
|
||||
// a FixedList is never empty
|
||||
// points may be empty, but a FixedList is never empty
|
||||
if (points.empty())
|
||||
{
|
||||
return false;
|
||||
|
||||
@ -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.
|
||||
@ -236,9 +236,8 @@ void Foam::PatchTools::calcBounds
|
||||
label pointi = f[fp];
|
||||
if (pointIsUsed.set(pointi, 1u))
|
||||
{
|
||||
bb.min() = ::Foam::min(bb.min(), points[pointi]);
|
||||
bb.max() = ::Foam::max(bb.max(), points[pointi]);
|
||||
nPoints++;
|
||||
bb.add(points[pointi]);
|
||||
++nPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,8 +48,7 @@ bool Foam::primitiveMesh::pointInCellBB
|
||||
|
||||
if (inflationFraction > SMALL)
|
||||
{
|
||||
vector inflation = inflationFraction*vector::one*mag(bb.span());
|
||||
bb = boundBox(bb.min() - inflation, bb.max() + inflation);
|
||||
bb.inflate(inflationFraction);
|
||||
}
|
||||
|
||||
return bb.contains(p);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -92,11 +92,10 @@ public:
|
||||
//- Calculate the bounding box
|
||||
inline treeBoundBox bounds() const
|
||||
{
|
||||
treeBoundBox bb(operator[](0), operator[](0));
|
||||
for (label i = 1; i < size(); i++)
|
||||
treeBoundBox bb(operator[](0));
|
||||
for (label i = 1; i < size(); ++i)
|
||||
{
|
||||
bb.min() = min(bb.min(), operator[](i));
|
||||
bb.max() = max(bb.max(), operator[](i));
|
||||
bb.add(operator[](i));
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,11 +78,10 @@ public:
|
||||
//- Calculate the bounding box
|
||||
inline treeBoundBox bounds() const
|
||||
{
|
||||
treeBoundBox bb(operator[](0), operator[](0));
|
||||
for (label i = 1; i < size(); i++)
|
||||
treeBoundBox bb(operator[](0));
|
||||
for (label i = 1; i < size(); ++i)
|
||||
{
|
||||
bb.min() = min(bb.min(), operator[](i));
|
||||
bb.max() = max(bb.max(), operator[](i));
|
||||
bb.add(operator[](i));
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user