Commit d1caaa05 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: build dummy runTimePostProcessing if VTK/ParaView are not available

- this allows more use of the runTimePostProcessing functionObject
  that will fail more gracefully if the proper version could not be
  built.

  The dummy functionObject simply emits a message that it is not available.
parent dd2c7c48
......@@ -40,6 +40,7 @@ bool Foam::functionObject::postProcess(false);
Foam::word Foam::functionObject::outputPrefix("postProcessing");
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::word Foam::functionObject::scopedName(const word& name) const
......@@ -68,10 +69,9 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
{
const word functionType(dict.get<word>("type"));
if (debug)
{
Info<< "Selecting function " << functionType << endl;
}
DebugInfo
<< "Selecting function " << functionType << endl;
// Load any additional libraries
{
......@@ -122,12 +122,6 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObject::~functionObject()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::functionObject::name() const
......@@ -179,4 +173,45 @@ void Foam::functionObject::movePoints(const polyMesh&)
{}
// * * * * * * * * * * * * unavailableFunctionObject * * * * * * * * * * * * //
Foam::functionObject::unavailableFunctionObject::unavailableFunctionObject
(
const word& name
)
:
functionObject(name)
{}
void Foam::functionObject::unavailableFunctionObject::carp(std::string message)
{
FatalError
<< "####" << nl
<< " " << type() << " not available" << nl
<< "####" << nl;
if (message.size())
{
FatalError
<< message.c_str() << nl;
}
FatalError
<< exit(FatalError);
}
bool Foam::functionObject::unavailableFunctionObject::execute()
{
return true;
}
bool Foam::functionObject::unavailableFunctionObject::write()
{
return true;
}
// ************************************************************************* //
......@@ -127,7 +127,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward declarations
class Time;
class polyMesh;
class mapPolyMesh;
......@@ -144,15 +144,6 @@ class functionObject
const word name_;
// Private Member Functions
//- No copy construct
functionObject(const functionObject&) = delete;
//- No copy assignment
void operator=(const functionObject&) = delete;
protected:
// Protected Member Functions
......@@ -163,6 +154,9 @@ protected:
public:
// Forward declarations
class unavailableFunctionObject;
//- Runtime type information
virtual const word& type() const = 0;
......@@ -209,13 +203,13 @@ public:
static autoPtr<functionObject> New
(
const word& name,
const Time&,
const dictionary&
const Time& runTime,
const dictionary& dict
);
//- Destructor
virtual ~functionObject();
virtual ~functionObject() = default;
// Member Functions
......@@ -243,7 +237,7 @@ public:
virtual bool write() = 0;
//- Called when Time::run() determines that the time-loop exits.
// By default it simply calls execute().
// The base implementation is a no-op.
virtual bool end();
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
......@@ -262,6 +256,37 @@ public:
};
/*---------------------------------------------------------------------------*\
Class functionObject::unavailableFunctionObject Declaration
\*---------------------------------------------------------------------------*/
//- Abstract functionObject to report when a real version is unavailable.
class functionObject::unavailableFunctionObject
:
public functionObject
{
protected:
//- Construct with name
unavailableFunctionObject(const word& name);
//- Report it is unavailable, emitting a FatalError for try/catch
//- in the caller
void carp(std::string message = "");
public:
// Member Functions
//- No nothing
virtual bool execute();
//- No nothing
virtual bool write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
......@@ -2,10 +2,12 @@
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Source wmake functions
# Cleanup library
# This cleanup handles both cmake runTimePostProcessing and the dummy version
# Cleanup library files with .so version endings
rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null
# Cleanup generated files - remove entire top-level
removeObjectDir $PWD
removeObjectDir "$PWD"
#------------------------------------------------------------------------------
......@@ -6,9 +6,9 @@ cd ${0%/*} || exit 1 # Run from this directory
echo "======================================================================"
echo "${PWD##*/} : $PWD"
echo
unset depend
if [ -d "$VTK_DIR" ]
then
depend="VTK_DIR=$VTK_DIR"
......@@ -17,25 +17,36 @@ then
depend="ParaView_DIR=$ParaView_DIR"
fi
if [ -n "$depend" ]
# Or force use of dummy only
# unset depend
if [ "$targetType" = objects ]
then
depend=ignore
elif [ -n "$depend" ]
then
if [ "$targetType" != objects ]
if command -v cmake > /dev/null 2>&1
then
if command -v cmake > /dev/null 2>&1
then
cmakeVersioned "$depend" $PWD || {
echo
echo " WARNING: incomplete build of VTK-based post-processing"
echo
}
else
echo "WARNING: skipped - needs cmake"
fi
cmakeVersioned "$depend" $PWD || {
echo
echo " WARNING: incomplete build of VTK-based post-processing"
echo
depend="dummy"
}
else
echo "==> skip runTimePostProcessing (needs cmake)"
depend="dummy"
fi
else
echo "WARNING: skipped - needs a VTK or a ParaView installation"
echo " - For ParaView : export the 'ParaView_DIR' variable"
echo " - For VTK : export the 'VTK_DIR' variable"
echo "WARNING: skip runTimePostProcessing (no VTK or ParaView)"
echo " - ParaView : export the 'ParaView_DIR' variable"
echo " - VTK : export the 'VTK_DIR' variable"
fi
if [ "${depend:-dummy}" = dummy ]
then
echo "==> dummy runTimePostProcessing"
wmakeVersioned "vtk=dummy" $PWD dummy
fi
echo "======================================================================"
......
runTimePostProcessingDummy.C
LIB = $(FOAM_LIBBIN)/librunTimePostProcessing
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "runTimePostProcessingDummy.H"
#include "dictionary.H"
#include "Time.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(runTimePostProcessingDummy, 0);
addToRunTimeSelectionTable
(
functionObject,
runTimePostProcessingDummy,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostProcessingDummy::runTimePostProcessingDummy
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
functionObject::unavailableFunctionObject(name)
{
carp
(
"VTK libraries were not available at compilation time"
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::runTimePostPro::runTimePostProcessingDummy
Group
grpGraphicsFunctionObjects
Description
Dummy implementation of runTimePostProcessing to report when
the real version is unavailable.
SourceFiles
runTimePostProcessingDummy.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_runTimePostProcessingDummy_H
#define functionObjects_runTimePostProcessingDummy_H
#include "functionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class runTimePostProcessingDummy Declaration
\*---------------------------------------------------------------------------*/
class runTimePostProcessingDummy
:
public functionObject::unavailableFunctionObject
{
public:
//- Runtime type information
TypeName("runTimePostProcessing");
// Constructors
//- Construct from dictionary
runTimePostProcessingDummy
(
const word& name,
const Time& runTime,
const dictionary& dict
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -80,12 +80,6 @@ Foam::functionObjects::runTimePostProcessing::runTimePostProcessing
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostProcessing::~runTimePostProcessing()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -119,15 +119,11 @@ private:
PtrList<runTimePostPro::text> text_;
// Private Member Functions
// Private Member Functions
//- Helper function to read scene objects
template<class Type>
void readObjects
(
const dictionary& dict,
PtrList<Type>& objects
) const;
//- Helper function to read scene objects
template<class Type>
void readObjects(const dictionary& dict, PtrList<Type>& objects) const;
public:
......@@ -143,12 +139,12 @@ public:
(
const word& name,
const Time& runTime,
const dictionary&dict
const dictionary& dict
);
//- Destructor
virtual ~runTimePostProcessing();
virtual ~runTimePostProcessing() = default;
// Member Functions
......@@ -158,8 +154,8 @@ public:
return mesh_;
}
//- Read the field min/max data
virtual bool read(const dictionary&);
//- Read the post-processing controls
virtual bool read(const dictionary& dict);
//- Execute, currently does nothing
virtual bool execute();
......
......@@ -52,8 +52,8 @@ maxCo 0.2;
functions
{
// #include "sampling"
// #include "runTimePostProcessing"
#include "sampling"
#include "runTimePostProcessing"
}
// ************************************************************************* //
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment