/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 .
\*---------------------------------------------------------------------------*/
#include "codedFunctionObject.H"
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
#include "dynamicCode.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(codedFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
codedFunctionObject,
dictionary
);
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::functionObjects::codedFunctionObject::prepare
(
dynamicCode& dynCode,
const dynamicCodeContext& context
) const
{
// Set additional rewrite rules
dynCode.setFilterVariable("typeName", name_);
dynCode.setFilterVariable("codeData", codeData_);
dynCode.setFilterVariable("codeRead", codeRead_);
dynCode.setFilterVariable("codeExecute", codeExecute_);
dynCode.setFilterVariable("codeWrite", codeWrite_);
dynCode.setFilterVariable("codeEnd", codeEnd_);
// Compile filtered C template
dynCode.addCompileFile(codeTemplateC);
// Copy filtered H template
dynCode.addCopyFile(codeTemplateH);
// Debugging: make verbose
// dynCode.setFilterVariable("verbose", "true");
// DetailInfo
// <<"compile " << name_ << " sha1: "
// << context.sha1() << endl;
// Define Make/options
dynCode.setMakeOptions
(
"EXE_INC = -g \\\n"
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
"-I$(LIB_SRC)/meshTools/lnInclude \\\n"
+ context.options()
+ "\n\nLIB_LIBS = \\\n"
" -lOpenFOAM \\\n"
" -lfiniteVolume \\\n"
" -lmeshTools \\\n"
+ context.libs()
);
}
Foam::dlLibraryTable& Foam::functionObjects::codedFunctionObject::libs() const
{
return const_cast