/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2016-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "CodedSource.H" #include "fvMesh.H" #include "fvMatrices.H" #include "dynamicCode.H" #include "dynamicCodeContext.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template void Foam::fv::CodedSource::prepare ( dynamicCode& dynCode, const dynamicCodeContext& context ) const { const word sourceType(pTraits::typeName); // Set additional rewrite rules dynCode.setFilterVariable("typeName", name_); dynCode.setFilterVariable("TemplateType", sourceType); dynCode.setFilterVariable("SourceType", sourceType + "Source"); //dynCode.removeFilterVariable("code"); dynCode.setFilterVariable("codeCorrect", codeCorrect_); dynCode.setFilterVariable("codeAddSup", codeAddSup_); dynCode.setFilterVariable("codeConstrain", codeConstrain_); // compile filtered C template dynCode.addCompileFile("codedFvOptionTemplate.C"); // copy filtered H template dynCode.addCopyFile("codedFvOptionTemplate.H"); // 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)/fvOptions/lnInclude \\\n" "-I$(LIB_SRC)/meshTools/lnInclude \\\n" "-I$(LIB_SRC)/sampling/lnInclude \\\n" + context.options() + "\n\nLIB_LIBS = \\\n" " -lfvOptions \\\n" " -lmeshTools \\\n" " -lsampling \\\n" " -lfiniteVolume \\\n" + context.libs() ); } template Foam::dlLibraryTable& Foam::fv::CodedSource::libs() const { return mesh_.time().libs(); } template Foam::string Foam::fv::CodedSource::description() const { return "fvOption::" + name_; } template void Foam::fv::CodedSource::clearRedirect() const { redirectFvOptionPtr_.clear(); } template const Foam::dictionary& Foam::fv::CodedSource::codeDict() const { return coeffs_; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::fv::CodedSource::CodedSource ( const word& name, const word& modelType, const dictionary& dict, const fvMesh& mesh ) : cellSetOption(name, modelType, dict, mesh) { read(dict); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template Foam::fv::option& Foam::fv::CodedSource::redirectFvOption() const { if (!redirectFvOptionPtr_.valid()) { dictionary constructDict(dict_); constructDict.set("type", name_); constructDict.changeKeyword(modelType_ & "Coeffs", name_ & "Coeffs"); redirectFvOptionPtr_ = option::New ( name_, constructDict, mesh_ ); } return *redirectFvOptionPtr_; } template void Foam::fv::CodedSource::correct ( GeometricField& field ) { DebugInfo << "CodedSource<" << pTraits::typeName << ">::correct for source " << name_ << endl; updateLibrary(name_); redirectFvOption().correct(field); } template void Foam::fv::CodedSource::addSup ( fvMatrix& eqn, const label fieldi ) { DebugInfo << "CodedSource<" << pTraits::typeName << ">::addSup for source " << name_ << endl; updateLibrary(name_); redirectFvOption().addSup(eqn, fieldi); } template void Foam::fv::CodedSource::addSup ( const volScalarField& rho, fvMatrix& eqn, const label fieldi ) { DebugInfo << "CodedSource<" << pTraits::typeName << ">::addSup for source " << name_ << endl; updateLibrary(name_); redirectFvOption().addSup(rho, eqn, fieldi); } template void Foam::fv::CodedSource::constrain ( fvMatrix& eqn, const label fieldi ) { DebugInfo << "CodedSource<" << pTraits::typeName << ">::constrain for source " << name_ << endl; updateLibrary(name_); redirectFvOption().constrain(eqn, fieldi); } // ************************************************************************* //