/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2020 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 . \*---------------------------------------------------------------------------*/ #include "CodedFunction1.H" #include "dynamicCode.H" #include "dynamicCodeContext.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeName(Foam::Function1s::coded); template<> const Foam::wordList Foam::CodedBase::codeKeys_ = { "code", "codeInclude" }; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template void Foam::Function1s::Coded::prepare ( dynamicCode& dynCode, const dynamicCodeContext& context ) const { dynCode.setFilterVariable("typeName", codeName()); // Set TemplateType filter variables dynCode.setFilterVariable("TemplateType", pTraits::typeName); // Compile filtered C template dynCode.addCompileFile(codeTemplateC); // Copy filtered H template dynCode.addCopyFile(codeTemplateH); // Debugging: make verbose if (debug) { dynCode.setFilterVariable("verbose", "true"); Info<<"compile " << codeName() << " sha1: " << context.sha1() << endl; } // Define Make/options dynCode.setMakeOptions ( "EXE_INC = -g \\\n" + context.options() + "\n\nLIB_LIBS = \\\n" + " -lOpenFOAM \\\n" + context.libs() ); } template void Foam::Function1s::Coded::clearRedirect() const { // Remove instantiation of Function1 provided by library redirectFunction1Ptr_.clear(); } template Foam::autoPtr> Foam::Function1s::Coded::compileNew() { this->updateLibrary(codeName()); dictionary redirectDict(codeDict()); redirectDict.set(codeName(), codeName()); return Function1::New(codeName(), redirectDict); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::Function1s::Coded::Coded ( const word& entryName, const dictionary& dict ) : Function1(entryName), CodedBase(dict) { redirectFunction1Ptr_ = compileNew(); } template Foam::Function1s::Coded::Coded(const Coded& cf1) : Function1(cf1), CodedBase(cf1) { redirectFunction1Ptr_ = compileNew(); } template Foam::tmp> Foam::Function1s::Coded::clone() const { return tmp>(new Coded(*this)); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template Foam::Function1s::Coded::~Coded() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template Foam::tmp> Foam::Function1s::Coded::value ( const scalarField& x ) const { return redirectFunction1Ptr_->value(x); } template inline Type Foam::Function1s::Coded::integrate ( const scalar x1, const scalar x2 ) const { NotImplemented; return pTraits::zero; } template Foam::tmp> Foam::Function1s::Coded::integrate ( const scalarField& x1, const scalarField& x2 ) const { NotImplemented; return tmp>(); } template void Foam::Function1s::Coded::writeData(Ostream& os) const { Function1::writeData(os); os << token::END_STATEMENT << nl; writeCode(os); } // ************************************************************************* //