|
[Sponsors] |
make custom functionObject available with postProcess |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 15, 2021, 08:57 |
make custom functionObject available with postProcess
|
#1 |
Member
Join Date: Feb 2020
Posts: 90
Rep Power: 6 |
Hello to all,
I would like to know how to make a custom functionObject available via the postProcess utility in OpenFOAM from ESI (v2012). As an example, I have duplicated the writeCellCentres functionObject and renamed it as myWriteCellCentres. Did the same inside the .H and .C files. Prepared a Make folder with (copied from OpenFOAM-v2012/src/functionObjects/field): files Code:
myWriteCellCentres.C LIB = $(FOAM_USER_LIBBIN)/libmyFunctionObjects Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/fvAgglomerationMethods/pairPatchAgglomeration/lnInclude LIB_LIBS = \ -lfiniteVolume \ -lfileFormats \ -lsurfMesh \ -lmeshTools \ -lsampling \ -llagrangian \ -ldistributionModels \ -lfluidThermophysicalModels \ -lsolidThermo \ -lincompressibleTransportModels \ -lturbulenceModels \ -lcompressibleTransportModels \ -lincompressibleTurbulenceModels \ -lcompressibleTurbulenceModels \ -lchemistryModel \ -lreactionThermophysicalModels \ -lpairPatchAgglomeration Code:
functions { writeBoundaryCells1 { // Mandatory entries (unmodifiable) type myWriteCellCentres; libs (libmyFunctionObjects.so); } } When I try to execute it with the postProcess utility with: Code:
postProcess -func myWriteCellCentres -lib myFunctionObjects Code:
--> FOAM Warning : From static bool Foam::functionObjectList::readFunctionObject(const Foam::string&, Foam::dictionary&, Foam::HashSet<Foam::wordRe>&, const Foam::word&) in file db/functionObjects/functionObjectList/functionObjectList.C at line 336 Cannot find functionObject file myWriteCellCentres What is the correct way of calling a custom functionObject with postProcess? |
|
July 17, 2021, 15:44 |
|
#2 |
Member
Join Date: Feb 2020
Posts: 90
Rep Power: 6 |
Anyone can give a hand with this issue?
|
|
July 19, 2021, 01:14 |
|
#3 |
Senior Member
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16 |
You can try by including your compiled library in libs entry in controlDict file. This will load your library while running the case and your functionObject should be then available for postProcess utility.
-Yogesh |
|
July 19, 2021, 04:21 |
|
#4 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Try calling postprocces with your function "writeBoundaryCells1" instead. Probably don't need the - lib argument since it is already mentioned in the dictionary.
The function execution is by your function name, not by the type of functionObject. |
|
July 19, 2021, 05:51 |
|
#5 | |
Member
Join Date: Mar 2021
Posts: 39
Rep Power: 5 |
Quote:
Hello Mr. Olesen, I had no luck with that. I know you have a very busy schedule but I will attach the case with the functionObject in case your are interested in having a look. test.zip |
||
October 4, 2023, 03:55 |
Same issue here
|
#6 |
Member
Join Date: Jun 2019
Posts: 41
Rep Power: 7 |
Hi there. I'm facing the same issue. I use the primer openfoam.
I've compilated my custom function object with Code:
LIB = $(FOAM_USER_LIBBIN)/libcalcul_surface_faceFunctionObject Code:
functions { calc_SF { type calcul_surface_face; libs ("libcalcul_surface_faceFunctionObject.so"); executeControl writeTime; writeControl writeTime; } } Code:
--> FOAM Warning : From static bool Foam::functionObjectList::readFunctionObject(const Foam::string&, Foam::dictionary&, Foam::HashSet<Foam::wordRe>&, const Foam::word&) in file db/functionObjects/functionObjectList/functionObjectList.C at line 290 Cannot find functionObject file calcul_surface_face
__________________
« Debugging is what CFD is about. 5 minutes to modify your code, 5 months to find why it does not work anymore. » |
|
October 5, 2023, 19:40 |
|
#7 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
try with the foamLibrary utility if your library can even load properly. If it does load then did you also remember to register the function in your code as well?
|
|
October 5, 2023, 23:56 |
|
#8 |
Member
Join Date: Jun 2019
Posts: 41
Rep Power: 7 |
Hello Olesen. Thanks for your message. I'm sad because it seems that I'm not enough skilled to fully understand it.
Yes foamHasLibrary -detail libcalcul_surface_faceFunctionObject.so do returns me the lib. What do you mean by register the function ? I put TypeName("calcul_surface_face"); inside the header of my class declaraction if this is what you means. Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | \*---------------------------------------------------------------------------*/ #ifndef functionObjects_calcul_surface_face_H #define functionObjects_calcul_surface_face_H #include "fvMeshFunctionObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { /*---------------------------------------------------------------------------*\ Class calcul_surface_face Declaration \*---------------------------------------------------------------------------*/ class calcul_surface_face : public fvMeshFunctionObject { public: //- Runtime type information TypeName("calcul_surface_face"); // Constructors //- Construct from Time and dictionary calcul_surface_face ( const word& name, const Time& runTime, const dictionary& dict ); //- No copy construct calcul_surface_face(const calcul_surface_face&) = delete; //- No copy assignment void operator=(const calcul_surface_face&) = delete; //- Destructor virtual ~calcul_surface_face() = default; // Member Functions //- Read the cell-volume data virtual bool read(const dictionary&); //- Do nothing virtual bool execute(); //- Write the cell-volume fields virtual bool write(); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //
__________________
« Debugging is what CFD is about. 5 minutes to modify your code, 5 months to find why it does not work anymore. » Last edited by Voulet; October 6, 2023 at 05:52. |
|
October 6, 2023, 05:36 |
|
#9 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Quote:
Code:
#include "addToRunTimeSelectionTable.H" namespace Foam { namespace functionObjects { defineTypeNameAndDebug(grad, 0); addToRunTimeSelectionTable(functionObject, grad, dictionary); } } |
||
October 6, 2023, 05:50 |
|
#10 |
Member
Join Date: Jun 2019
Posts: 41
Rep Power: 7 |
Yes I have it :
Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation Copyright (C) 2016-2020 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 <http://www.gnu.org/licenses/>. \*---------------------------------------------------------------------------*/ #include "calcul_surface_face.H" #include "surfaceFields.H" #include "fvMesh.H" #include "Time.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { defineTypeNameAndDebug(calcul_surface_face, 0); addToRunTimeSelectionTable(functionObject, calcul_surface_face, dictionary); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::calcul_surface_face::calcul_surface_face ( const word& name, const Time& runTime, const dictionary& dict ) : fvMeshFunctionObject(name, runTime, dict) { read(dict); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::functionObjects::calcul_surface_face::read(const dictionary& dict) { return fvMeshFunctionObject::read(dict); } bool Foam::functionObjects::calcul_surface_face::execute() { return true; } bool Foam::functionObjects::calcul_surface_face::write() { surfaceVectorField Sf ( IOobject ( mesh_.Sf().name(), time_.timeName(), mesh_, IOobject::NO_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER ), mesh_, Zero ); Sf.ref() = mesh_.Sf(); // Without correctBoundaryConditions() - boundary faces have zero volume Log << type() << " " << name() << " write:" << nl << " writing cell-face area field Sf" << " to " << time_.timeName() << endl; Sf.write(); return true; } // ************************************************************************* //
__________________
« Debugging is what CFD is about. 5 minutes to modify your code, 5 months to find why it does not work anymore. » |
|
October 6, 2023, 06:05 |
|
#11 |
Member
Join Date: Jun 2019
Posts: 41
Rep Power: 7 |
In fact when I run it on a tutorial case with one of the following comand :
postProcess -func calcul_surface_face or postProcess it does works ! But the openfoam case I wanted to treat was an old case which was run with openfoam8. With this case : (using ofv23 and the objectFunction compiled with ofv23) postProcess -func calcul_surface_face doesn't find the function or postProcess works This is quite strange but I suppose my issue is solved. Thanks Olesen
__________________
« Debugging is what CFD is about. 5 minutes to modify your code, 5 months to find why it does not work anymore. » |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
postProcess functionality in openFOAM 4 | bullmut | OpenFOAM Post-Processing | 23 | July 21, 2017 10:11 |
OF-4.x: Multiple Inheritance of a functionObject | A_Pete | OpenFOAM Programming & Development | 1 | September 21, 2016 11:01 |
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch | gschaider | OpenFOAM Installation | 225 | August 25, 2015 20:43 |
Create registered object at runtime using a functionObject | CedricVH | OpenFOAM Programming & Development | 21 | November 28, 2012 06:04 |
a way to make lots of money quick and easy no lies | Dob | Main CFD Forum | 0 | October 10, 2006 17:45 |