...
 
Commits (8)
......@@ -7,6 +7,6 @@ rm -f $FOAM_SITE_LIBBIN/libcatalystFoam* 2>/dev/null # ... extra safety
rm -f $FOAM_USER_LIBBIN/libcatalystFoam* 2>/dev/null # ... extra safety
# Cleanup generated files - remove entire top-level
removeObjectDir $PWD
removeObjectDir "$PWD"
#------------------------------------------------------------------------------
......@@ -3,14 +3,21 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # The cmake functions
# CMake into objectsDir with external dependency
# - Can this function can be removed with OpenFOAM-1812 ?
#
# 1 - depend
# 2 - sourceDir
# 3... optional cmake defines
#
# Available directly in OpenFOAM-1812 but left here for a while
# to ensure we can build with slightly older versions too (2018-11-29)
#
unset -f cmakeVersionedInstall 2>/dev/null
cmakeVersionedInstall()
{
local depend="$1"
local sourceDir="$2"
local objectsDir
shift 2
local objectsDir sentinel
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
......@@ -19,8 +26,8 @@ cmakeVersionedInstall()
sentinel=$(sameDependency "$depend" "$sourceDir") || \
rm -rf "$objectsDir" > /dev/null 2>&1
mkdir -p $objectsDir \
&& (cd $objectsDir && _cmake "$@" $sourceDir && make install) \
mkdir -p "$objectsDir" \
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make install) \
&& echo "$depend" >| "${sentinel:-/dev/null}"
}
......@@ -52,7 +59,7 @@ then
then
if command -v cmake > /dev/null 2>&1
then
cmakeVersionedInstall "$depend" $PWD "$cmakeOpts" || {
cmakeVersionedInstall "$depend" "$PWD" "$cmakeOpts" || {
echo
echo " WARNING: incomplete build of ParaView Catalyst"
echo
......
#------------------------------------------------------------------------------
project(catalyst)
include(${PARAVIEW_USE_FILE})
......@@ -28,6 +29,7 @@ endif()
# ----------------------------------------------------------------------
include_directories(
${LIB_SRC}/OpenFOAM/include
${LIB_SRC}/OpenFOAM/lnInclude
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
${LIB_SRC}/finiteArea/lnInclude
......@@ -95,6 +97,13 @@ add_library(
${SOURCE_FILES}
)
set_target_properties(
catalystFoam
PROPERTIES
VERSION ${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}.${PARAVIEW_VERSION_PATCH}
SOVERSION ${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
)
target_link_libraries(
catalystFoam
${LINK_LIBRARIES}
......
#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0002 NEW) # Policy CMP0002 required for for cmake >= 3
# Fail immediately if not using an out-of-source build
# Fail if not building out-of-source
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
message(FATAL_ERROR
"In-source builds are not supported. Please create a build directory "
"separate from the source directory")
"In-source builds disallowed. Use a separate build directory")
endif()
project(catalyst)
# Set policy for CMP0002 needed for cmake > 3
cmake_policy(SET CMP0002 OLD)
include(CMakeLists-OpenFOAM.txt)
#------------------------------------------------------------------------------
......@@ -41,6 +35,6 @@ message("================")
#-----------------------------------------------------------------------------
include(CMakeLists-Catalyst.txt)
include(CMakeLists-Project.txt)
#-----------------------------------------------------------------------------
......@@ -143,7 +143,7 @@ bool Foam::catalyst::faMeshInput::read(const dictionary& dict)
// Restrict to specified meshes
meshes_.filterKeys(selectAreas_);
dict.read("fields", selectFields_);
dict.readEntry("fields", selectFields_);
return true;
}
......
......@@ -43,16 +43,15 @@ void Foam::vtk::faMeshAdaptor::convertAreaFields
const wordRes& selectFields
)
{
typedef GeometricField<Type, faPatchField, areaMesh> FieldType;
const auto& obr = mesh_.mesh();
// Restrict to GeometricField<Type, ...>
const wordList names(mesh_.mesh().sortedNames<FieldType>(selectFields));
typedef GeometricField<Type, faPatchField, areaMesh> fieldType;
for (const word& fieldName : names)
for (const word& fieldName : obr.sortedNames<fieldType>(selectFields))
{
convertAreaField
(
mesh_.mesh().lookupObject<FieldType>(fieldName)
obr.lookupObject<fieldType>(fieldName)
);
}
}
......@@ -97,37 +96,8 @@ Foam::vtk::faMeshAdaptor::convertAreaFieldToVTK
const foamVtpData& vtpData
) const
{
const int nComp(pTraits<Type>::nComponents);
auto data = vtkSmartPointer<vtkFloatArray>::New();
data->SetName(fld.name().c_str());
data->SetNumberOfComponents(nComp);
data->SetNumberOfTuples(fld.size());
const label len = fld.size();
if (debug)
{
Info<< "convert areaField: "
<< fld.name()
<< " size=" << len
<< " nComp=" << nComp << endl;
}
float scratch[nComp];
for (label i=0; i < len; ++i)
{
const Type& t = fld[i];
for (direction d=0; d<nComp; ++d)
{
scratch[d] = component(t, d);
}
remapTuple<Type>(scratch);
data->SetTuple(i, scratch);
}
return data;
// The vtpData is not used for anything
return vtk::Tools::convertFieldToVTK(fld.name(), fld);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -34,28 +34,6 @@ License
// Templates (only needed here)
#include "foamVtkFaMeshAdaptorFieldTemplates.C"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
static wordHashSet supportedTypes()
{
// typedef DimensionedField<Type, areaMesh> DimFieldType;
typedef GeometricField<Type, faPatchField, areaMesh> AreaFieldType;
wordHashSet types;
// TODO: types.insert(DimFieldType::typeName);
types.insert(AreaFieldType::typeName);
return types;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::wordHashSet Foam::vtk::faMeshAdaptor::knownFields
......@@ -63,30 +41,20 @@ Foam::wordHashSet Foam::vtk::faMeshAdaptor::knownFields
const wordRes& selectFields
) const
{
wordHashSet allFields;
// Quick exit if no volume fields can be converted.
// This could be refined
HashTable<wordHashSet> objects = mesh_.mesh().classes(selectFields);
if (objects.empty())
{
return allFields;
}
wordHashSet types;
types += supportedTypes<scalar>();
types += supportedTypes<vector>();
types += supportedTypes<sphericalTensor>();
types += supportedTypes<symmTensor>();
types += supportedTypes<tensor>();
objects.retain(types);
wordHashSet allFields(2*objects.size());
forAllConstIters(objects, iter)
{
allFields += iter.object();
const word& clsName = iter.key();
if (fieldTypes::area.found(clsName))
{
allFields += iter.object();
}
}
return allFields;
......
......@@ -40,19 +40,16 @@ void Foam::vtk::faMeshAdaptor::convertGeometryInternal()
if (meshState_ == polyMesh::UNCHANGED)
{
// Without movement is easy.
if (debug)
{
Info<< "reuse " << longName << nl;
}
DebugInfo
<< "reuse " << longName << nl;
vtpData.reuse();
return;
}
else if (meshState_ == polyMesh::POINTS_MOVED)
{
if (debug)
{
Info<< "move points " << longName << nl;
}
DebugInfo
<< "move points " << longName << nl;
vtkgeom = vtpData.getCopy();
vtkgeom->SetPoints
......@@ -64,10 +61,8 @@ void Foam::vtk::faMeshAdaptor::convertGeometryInternal()
if (!vtkgeom)
{
if (debug)
{
Info<< "Nothing usable from cache - create new geometry" << nl;
}
DebugInfo
<< "Nothing usable from cache - create new geometry" << nl;
vtkgeom = vtk::Tools::Patch::mesh(mesh_.patch());
}
......
......@@ -192,8 +192,8 @@ bool Foam::functionObjects::catalystFunctionObject::read(const dictionary& dict)
Foam::mkDir(outputDir_);
}
dict.read("scripts", scripts_); // Python scripts
expand(scripts_, dict); // Expand and check availability
dict.readEntry("scripts", scripts_); // Python scripts
expand(scripts_, dict); // Expand and check availability
// Any changes detected
......
......@@ -28,6 +28,7 @@ License
#include <vtkCPDataDescription.h>
#include <vtkCPInputDataDescription.h>
#include <vtkCPProcessor.h>
#include <vtkDataObject.h>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -175,10 +176,16 @@ Foam::label Foam::catalyst::dataQuery::query(vtkCPProcessor* coproc)
descrip->AddInput(channel.c_str());
auto* input = descrip->GetInputDescriptionByName(channel.c_str());
for (const word& fieldName : dataq.fields(channel))
for (const word& fldName : dataq.fields(channel))
{
input->AddPointField(fieldName.c_str());
input->AddCellField(fieldName.c_str());
#if (PARAVIEW_VERSION_MAJOR == 5) && \
(PARAVIEW_VERSION_MINOR < 6)
input->AddPointField(fldName.c_str());
input->AddCellField(fldName.c_str());
#else
input->AddField(fldName.c_str(), vtkDataObject::CELL);
input->AddField(fldName.c_str(), vtkDataObject::POINT);
#endif
}
}
......@@ -200,12 +207,24 @@ Foam::label Foam::catalyst::dataQuery::query(vtkCPProcessor* coproc)
{
wordHashSet requestedFields;
for (const word& fieldName : dataq.fields(channel))
for (const word& fldName : dataq.fields(channel))
{
if (input->IsFieldNeeded(fieldName.c_str()))
#if (PARAVIEW_VERSION_MAJOR == 5) && \
(PARAVIEW_VERSION_MINOR < 6)
if (input->IsFieldNeeded(fldName.c_str()))
{
requestedFields.insert(fieldName);
requestedFields.insert(fldName);
}
#else
if
(
input->IsFieldNeeded(fldName.c_str(), vtkDataObject::CELL)
|| input->IsFieldNeeded(fldName.c_str(), vtkDataObject::POINT)
)
{
requestedFields.insert(fldName);
}
#endif
}
dataq.set(channel, requestedFields);
......
......@@ -37,25 +37,28 @@ Foam::label Foam::vtk::cloudAdaptor::convertLagrangianFields
const objectRegistry& obr
)
{
const wordList fieldNames(obr.sortedNames<IOField<Type>>());
typedef IOField<Type> fieldType;
for (const word& fieldName : fieldNames)
label nFields = 0;
for (const word& fieldName : obr.sortedNames<fieldType>())
{
const auto& fld = obr.lookupObject<IOField<Type>>(fieldName);
const auto& fld = obr.lookupObject<fieldType>(fieldName);
vtkSmartPointer<vtkFloatArray> data =
vtk::Tools::convertFieldToVTK
(
fieldName,
fld
);
vtkSmartPointer<vtkFloatArray> data = vtk::Tools::convertFieldToVTK
(
fld.name(),
fld
);
// Provide identical data as cell and as point data
vtkmesh->GetCellData()->AddArray(data);
vtkmesh->GetPointData()->AddArray(data);
++nFields;
}
return fieldNames.size();
return nFields;
}
......
......@@ -156,7 +156,7 @@ bool Foam::catalyst::fvMeshInput::read(const dictionary& dict)
// Restrict to specified meshes
meshes_.filterKeys(selectRegions_);
dict.read("fields", selectFields_);
dict.readEntry("fields", selectFields_);
return true;
}
......
......@@ -141,7 +141,6 @@ private:
public vtk::Caching<vtkUnstructuredGrid>,
public foamVtkMeshMaps
{
//- The vtk points for the mesh (and decomposition)
vtkSmartPointer<vtkPoints> points
(
......
......@@ -173,17 +173,20 @@ void Foam::vtk::fvMeshAdaptor::convertVolFields
const wordRes& selectFields
)
{
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
// Restrict to GeometricField<Type, ...>
const wordList names(mesh_.sortedNames<FieldType>(selectFields));
for (const word& fieldName : names)
for
(
const word& fieldName
: mesh_.sortedNames<fieldType>(selectFields)
)
{
convertVolField
(
patchInterpList,
mesh_.lookupObject<FieldType>(fieldName)
mesh_.lookupObject<fieldType>(fieldName)
);
}
}
......@@ -274,75 +277,50 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField
data->SetName(pfld.name().c_str());
}
if (debug)
{
Info<< "convert Point field: "
<< pfld.name()
<< " size=" << (nPoints + addPointCellLabels.size())
<< " (" << nPoints << " + " << addPointCellLabels.size()
<< ") nComp=" << nComp << endl;
}
DebugInfo
<< "convert Point field: " << pfld.name()
<< " size=" << (nPoints + addPointCellLabels.size())
<< " (" << nPoints << " + " << addPointCellLabels.size()
<< ") nComp=" << nComp << endl;
float vec[pTraits<Type>::nComponents];
label pointi = 0;
float scratch[pTraits<Type>::nComponents];
vtkIdType pointi = 0;
if (pointMap.size())
{
forAll(pointMap, i)
for (const label meshPointi : pointMap)
{
const Type& t = pfld[pointMap[i]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
remapTuple<Type>(vec);
data->SetTuple(pointi++, vec);
foamToVtkTuple(scratch, pfld[meshPointi]);
data->SetTuple(pointi++, scratch);
}
}
else
{
forAll(pfld, i)
for (const Type& val : pfld)
{
const Type& t = pfld[i];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
remapTuple<Type>(vec);
data->SetTuple(pointi++, vec);
foamToVtkTuple(scratch, val);
data->SetTuple(pointi++, scratch);
}
}
// Continue with additional points
// - correspond to cell centres
if (notNull(vfld))
{
forAll(addPointCellLabels, apI)
for (const label meshCelli : addPointCellLabels)
{
const Type& t = vfld[addPointCellLabels[apI]];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
remapTuple<Type>(vec);
data->SetTuple(pointi++, vec);
foamToVtkTuple(scratch, vfld[meshCelli]);
data->SetTuple(pointi++, scratch);
}
}
else
{
forAll(addPointCellLabels, apI)
for (const label meshCelli : addPointCellLabels)
{
Type t = interpolatePointToCell(pfld, addPointCellLabels[apI]);
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
}
remapTuple<Type>(vec);
data->SetTuple(pointi++, vec);
foamToVtkTuple(scratch, interpolatePointToCell(pfld, meshCelli));
data->SetTuple(pointi++, scratch);
}
}
......@@ -371,27 +349,21 @@ Foam::vtk::fvMeshAdaptor::convertVolFieldToVTK
data->SetNumberOfComponents(nComp);
data->SetNumberOfTuples(cellMap.size());
if (debug)
{
Info<< "convert volField: "
<< fld.name()
<< " size=" << cellMap.size()
<< " (" << fld.size() << " + "
<< (cellMap.size() - fld.size())
<< ") nComp=" << nComp << endl;
}
DebugInfo
<< "convert volField: " << fld.name()
<< " size=" << cellMap.size()
<< " (" << fld.size() << " + "
<< (cellMap.size() - fld.size())
<< ") nComp=" << nComp << endl;
float scratch[nComp];
forAll(cellMap, i)
{
const Type& t = fld[cellMap[i]];
for (direction d=0; d<nComp; ++d)
{
scratch[d] = component(t, d);
}
remapTuple<Type>(scratch);
data->SetTuple(i, scratch);
float scratch[pTraits<Type>::nComponents];
vtkIdType celli = 0;
for (const label meshCelli : cellMap)
{
foamToVtkTuple(scratch, fld[meshCelli]);
data->SetTuple(celli++, scratch);
}
return data;
......
......@@ -34,55 +34,30 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
static wordHashSet supportedTypes()
{
// typedef DimensionedField<Type, volMesh> DimFieldType;
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
wordHashSet types;
// TODO: types.insert(DimFieldType::typeName);
types.insert(VolFieldType::typeName);
return types;
}
} // End namespace Foam
Foam::wordHashSet Foam::vtk::fvMeshAdaptor::knownFields
(
const wordRes& selectFields
) const
{
wordHashSet allFields;
// Quick exit if no volume fields can be converted.
// This could be refined
HashTable<wordHashSet> objects = mesh_.classes(selectFields);
if (objects.empty())
{
return allFields;
}
wordHashSet types;
types += supportedTypes<scalar>();
types += supportedTypes<vector>();
types += supportedTypes<sphericalTensor>();
types += supportedTypes<symmTensor>();
types += supportedTypes<tensor>();
objects.retain(types);
wordHashSet allFields(2*objects.size());
forAllConstIters(objects, iter)
{
allFields += iter.object();
const word& clsName = iter.key();
if
(
fieldTypes::volume.found(clsName)
// TODO
// || fieldTypes::internal.found(clsName)
)
{
allFields += iter.object();
}
}
return allFields;
......
......@@ -52,19 +52,17 @@ void Foam::vtk::fvMeshAdaptor::convertGeometryInternal()
{
if (meshState_ == polyMesh::UNCHANGED)
{
if (debug)
{
Info<< "reuse " << longName << nl;
}
DebugInfo
<< "reuse " << longName << nl;
vtuData.reuse(); // No movement - simply reuse
return;
}
else if (meshState_ == polyMesh::POINTS_MOVED)
{
if (debug)
{
Info<< "move points " << longName << nl;
}
DebugInfo
<< "move points " << longName << nl;
vtkgeom = vtuData.getCopy();
vtkgeom->SetPoints(vtuData.points(mesh_));
}
......@@ -72,10 +70,8 @@ void Foam::vtk::fvMeshAdaptor::convertGeometryInternal()
if (!vtkgeom)
{
if (debug)
{
Info<< "Nothing usable from cache - create new geometry" << nl;
}
DebugInfo
<< "Nothing usable from cache - create new geometry" << nl;
// Nothing usable from cache - create new geometry
vtkgeom = vtuData.internal(mesh_, decomposePoly_);
......@@ -103,20 +99,18 @@ void Foam::vtk::fvMeshAdaptor::convertGeometryBoundary()
{
if (meshState_ == polyMesh::UNCHANGED)
{
if (debug)
{
Info<< "reuse " << longName << nl;
}
DebugInfo
<< "reuse " << longName << nl;
vtpData.reuse(); // No movement - simply reuse
continue;
}
else if (meshState_ == polyMesh::POINTS_MOVED)
{
// Point movement on single patch
if (debug)
{
Info<< "move points " << longName << nl;
}
DebugInfo
<< "move points " << longName << nl;
vtkgeom = vtpData.getCopy();
vtkgeom->SetPoints(vtk::Tools::Patch::points(pp));
}
......@@ -124,11 +118,9 @@ void Foam::vtk::fvMeshAdaptor::convertGeometryBoundary()
vtpData.clear(); // Remove any old mappings
if (debug)
{
Info<< "Creating VTK mesh for patch [" << patchId <<"] "
<< longName << endl;
}
DebugInfo
<< "Creating VTK mesh for patch [" << patchId <<"] "
<< longName << endl;
// Unused information
vtpData.additionalIds().clear();
......
......@@ -48,23 +48,21 @@ Foam::vtk::fvMeshAdaptor::foamVtuData::points
const pointField& pts = mesh.points();
// Additional cell centres
const labelList& addPoints = this->additionalIds();
const labelUList& addPoints = this->additionalIds();
vtkpoints->SetNumberOfPoints(pts.size() + addPoints.size());
// Normal points
label pointId = 0;
vtkIdType pointId = 0;
for (const point& p : pts)
{
vtkpoints->SetPoint(pointId, p.v_);
++pointId;
vtkpoints->SetPoint(pointId++, p.v_);
}
// Cell centres
for (const label ptId : addPoints)
for (const label meshCelli : addPoints)
{
vtkpoints->SetPoint(pointId, mesh.C()[ptId].v_);
++pointId;
vtkpoints->SetPoint(pointId++, mesh.cellCentres()[meshCelli].v_);
}
return vtkpoints;
......@@ -85,23 +83,21 @@ Foam::vtk::fvMeshAdaptor::foamVtuData::points
const pointField& pts = mesh.points();
// Additional cell centres
const labelList& addPoints = this->additionalIds();
const labelUList& addPoints = this->additionalIds();
vtkpoints->SetNumberOfPoints(pointMap.size() + addPoints.size());
// Normal points
label pointId = 0;
for (const label ptId : pointMap)
vtkIdType pointId = 0;
for (const label meshPointi : pointMap)
{
vtkpoints->SetPoint(pointId, pts[ptId].v_);
++pointId;
vtkpoints->SetPoint(pointId++, pts[meshPointi].v_);
}
// Cell centres
for (const label ptId : addPoints)
for (const label meshCelli : addPoints)
{
vtkpoints->SetPoint(pointId, mesh.C()[ptId].v_);
++pointId;
vtkpoints->SetPoint(pointId++, mesh.cellCentres()[meshCelli].v_);
}
return vtkpoints;
......