|
[Sponsors] |
October 28, 2019, 23:49 |
Face Normal Vector Function Help
|
#1 |
Member
Join Date: Nov 2015
Posts: 38
Rep Power: 11 |
Hello,
I'm trying to write the face normal vectors for all face cells on a patch (ideally in the same order as the cell centers output from "postProcess -func wallCellCentres". I've scavenged code from old posts but I am stuck on getting the results to output. I'm running the functions from within the controlDict. I think at a minimum the "write" part of the fucntion isn't correct but I'm unsure how to fix. Any help would be greatly appreciated! (I'm using v1906) Try 1 (From Post #17 (Faces of a cell) Code:
testFunc1 { functionObjectLibs ("libutilityFunctionObjects.so"); enabled true; type coded; name testFunc1; writeControl outputTime; codeExecute #{ forAll(fluidRegions[0].cells(), cellI) { const cell& faces = fluidRegions[0].cells()[cellI]; forAll( faces, i ) // loop over all faces in cellID { int k=faces[i]; vector faceINormal = fluidRegions[0].Sf()[k] / fluidRegions[0].magSf()[k] ; vector faceICenter = fluidRegions[0].Cf()[k]; Info << " k = " << k << " i = " << i << ", faceINormal = " << faceINormal << ", faceICenter = " << faceICenter << endl ; } } #}; } Code:
functions { computeNormals2 { functionObjectLibs ("libutilityFunctionObjects.so"); enabled true; type coded; name computeNormals2; writeControl outputTime; code #{ const surfaceVectorField& Sf = mesh.Sf(); // Face area normal vectors const surfaceScalarField& magSf = mesh.magSf(); // Face areas const surfaceVectorField& N = Sf/magSf; // Face normal vectors Info << "maxN = " << max(N) <<endl; // Write N.write(); N.boundaryField().write(); #}; } } Code:
Using dynamicCode for functionObject testFunc1 at line -1 in "/p/work2/ps/profileTest/system/controlDict.functions.testFunc1" Creating new library in "dynamicCode/testFunc1/platforms/linux64GccDPInt32Opt/lib/libtestFunc1_d54450d20b2d4857cb3f069b8ae4af60967656b2.so" Invoking wmake libso /p/work2/ps/profileTest/dynamicCode/testFunc1 wmake libso /p/work2/ps/profileTest/dynamicCode/testFunc1 dep: functionObjectTemplate.C Ctoo: functionObjectTemplate.C ld: /p/work2/ps/profileTest/dynamicCode/testFunc1/../platforms/linux64GccDPInt32Opt/lib/libtestFunc1_d54450d20b2d4857cb3f069b8ae4af60967656b2.so --> FOAM Warning : From function virtual bool Foam::functionObjects::codedFunctionObject::read(const Foam::dictionary&) in file codedFunctionObject/codedFunctionObject.C at line 287 Reading "/p/work2/ps/profileTest/system/controlDict.functions.computeNormals2" No critical "code" prefixed keywords found. Please check the code documentation for more details. Using dynamicCode for functionObject computeNormals2 at line -1 in "/p/work2/ps/profileTest/system/controlDict.functions.computeNormals2" Creating new library in "dynamicCode/computeNormals2/platforms/linux64GccDPInt32Opt/lib/libcomputeNormals2_854fbc54de3816ba2f2d0fa40318ecadd3dad4cc.so" Invoking wmake libso /p/work2/ps/profileTest/dynamicCode/computeNormals2 wmake libso /p/work2/ps/profileTest/dynamicCode/computeNormals2 dep: functionObjectTemplate.C Ctoo: functionObjectTemplate.C ld: /p/work2/ps/profileTest/dynamicCode/computeNormals2/../platforms/linux64GccDPInt32Opt/lib/libcomputeNormals2_854fbc54de3816ba2f2d0fa40318ecadd3dad4cc.so --> FOAM Warning : From function void Foam::timeControl::read(const Foam::dictionary&) in file db/functionObjects/timeControl/timeControl.C at line 94 Try 2 Error Log (doesn't crash simulation but doesn't write anything): Code:
--> FOAM IOWarning : Found [v1612] 'functionObjectLibs' entry instead of 'libs' in dictionary "/p/work2/ps/profileTest/system/controlDict.functions.computeNormals2" This keyword is deemed to be 30 months old. ln: ./lnInclude --> FOAM IOWarning : Found [v1612] 'functionObjectLibs' entry instead of 'libs' in dictionary "/p/work2/ps/profileTest/system/controlDict.functions.computeNormals2" This keyword is deemed to be 30 months old. Note: When I use "code #{ }#" a warning shows that it should be "codeExecute #{ }#". If I use "codeExecute #{ }#" the simulation failes and gets an error: Code:
Using dynamicCode for functionObject testFunc1 at line -1 in "/p/work2/ps/profileTest/system/controlDict.functions.testFunc1" Creating new library in "dynamicCode/testFunc1/platforms/linux64GccDPInt32Opt/lib/libtestFunc1_4e17b8c92ceee51ad09c0fa0f3b83d285367fb7d.so" Invoking wmake libso /p/work2/ps/profileTest/dynamicCode/testFunc1 wmake libso /p/work2/ps/profileTest/dynamicCode/testFunc1 dep: functionObjectTemplate.C Ctoo: functionObjectTemplate.C /p/home/openfoam/v1906/OpenFOAM-v1906/wmake/rules/General/transform:34: recipe for target 'Make/linux64GccDPInt32Opt/functionObjectTemplate.o' failed --> FOAM FATAL IO ERROR: Failed wmake "dynamicCode/testFunc1/platforms/linux64GccDPInt32Opt/lib/libtestFunc1_4e17b8c92ceee51ad09c0fa0f3b83d285367fb7d.so" file: /p/work2/ps/profileTest/system/controlDict.functions.testFunc1 From function void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const in file db/dynamicLibrary/codedBase/codedBase.C at line 231. |
|
October 29, 2019, 17:34 |
|
#2 |
Member
Join Date: Nov 2015
Posts: 38
Rep Power: 11 |
I've also tried compiling it in the ~/src/functionObjects directory instead of within the controlDict, but I still have a wire crossed somewhere. To troubleshoot further, I've tried recreating a simple tutorial build (Ch. 3 - http://www.tfd.chalmers.se/~hani/kur...CFD_Report.pdf) which also fails.
From the error message, it appears to be looking for the #include "fieldExpression.H" file. That same header is in other functionObjects (i.e. vorticity) that appears to work without issue. I've included the full error message, .H, .C, Make/files, Make/options below. Any help/hints would be greatly appreciated! Error when running "wmake", executed in directory "~/openfoam/v1906/OpenFOAM-v1906/src/functionObjects/field/helicity": Code:
~/openfoam/v1906/OpenFOAM-v1906/src/functionObjects/field/helicity> wmake ln: ./lnInclude g++ -std=c++11 -m64 -DOPENFOAM=1906 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3 -DNoRepository -ftemplate-depth=1024 -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/fieldExpression/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/finiteVolume/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/fileFormats/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/surfMesh/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/meshTools/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/sampling/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/lagrangian/basic/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/lagrangian/distributionModels/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/thermophysicalModels/basic/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/transportModels -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/transportModels/compressible/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/TurbulenceModels/turbulenceModels/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/TurbulenceModels/incompressible/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/TurbulenceModels/compressible/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/transportModels/compressible/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/thermophysicalModels/basic/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/thermophysicalModels/solidThermo/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/thermophysicalModels/chemistryModel/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/thermophysicalModels/reactionThermo/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/thermophysicalModels/specie/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/fvAgglomerationMethods/pairPatchAgglomeration/lnInclude -IlnInclude -I. -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/OpenFOAM/lnInclude -I/p/home/openfoam/v1906/OpenFOAM-v1906/src/OSspecific/POSIX/lnInclude -fPIC -c helicity.C -o /p/home/openfoam/v1906/OpenFOAM-v1906/build/linux64GccDPInt32Opt/src/functionObjects/field/helicity/helicity.o In file included from helicity.C:28:0: helicity.H:71:10: fatal error: fieldExpression.H: No such file or directory #include "fieldExpression.H" ^~~~~~~~~~~~~~~~~~~ compilation terminated. /p/home/openfoam/v1906/OpenFOAM-v1906/wmake/rules/General/transform:34: recipe for target '/p/home/openfoam/v1906/OpenFOAM-v1906/build/linux64GccDPInt32Opt/src/functionObjects/field/helicity/helicity.o' failed make: *** [/p/home/openfoam/v1906/OpenFOAM-v1906/build/linux64GccDPInt32Opt/src/functionObjects/field/helicity/helicity.o] Error 1 helicity.H Code:
\*---------------------------------------------------------------------------*/ #ifndef functionObjects_helicity_H #define functionObjects_helicity_H #include "fieldExpression.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { /*---------------------------------------------------------------------------*\ Class vorticity Declaration \*---------------------------------------------------------------------------*/ class helicity : public fieldExpression { // Private Member Functions //- Calculate the vorticity field and return true if successful virtual bool calc(); public: //- Runtime type information TypeName("helicity"); // Constructors //- Construct from Time and dictionary helicity ( const word& name, const Time& runTime, const dictionary& dict ); //- Destructor virtual ~helicity(); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* // helicity.C Code:
\*---------------------------------------------------------------------------*/ #include "helicity.H" #include "fvcCurl.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { defineTypeNameAndDebug(helicity, 0); addToRunTimeSelectionTable ( functionObject, helicity, dictionary ); } } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // bool Foam::functionObjects::helicity::calc() { if (foundObject<volVectorField>(fieldName_)) { return store ( resultName_, fvc::curl(lookupObject<volVectorField>(fieldName_)) & lookupObject<volVectorField>(fieldName_) ); } else { return false; } return true; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::helicity::helicity ( const word& name, const Time& runTime, const dictionary& dict ) : fieldExpression(name, runTime, dict, "U") { setResultName(typeName, fieldName_); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::functionObjects::helicity::~helicity() {} // ************************************************************************* // ~/openfoam/v1906/OpenFOAM-v1906/src/functionObjects/field/helicity/Make/files: Code:
helicity.C LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects Code:
EXE_INC = \ -I$(LIB_SRC)/fieldExpression/lnInclude \ -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 = \ -lfieldExpression \ -lfiniteVolume \ -lfileFormats \ -lsurfMesh \ -lmeshTools \ -lsampling \ -llagrangian \ -ldistributionModels \ -lfluidThermophysicalModels \ -lsolidThermo \ -lincompressibleTransportModels \ -lturbulenceModels \ -lcompressibleTransportModels \ -lincompressibleTurbulenceModels \ -lcompressibleTurbulenceModels \ -lchemistryModel \ -lreactionThermophysicalModels \ -lpairPatchAgglomeration |
|
Tags |
functions, programming, surface normals |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] mesh airfoil NACA0012 | anand_30 | OpenFOAM Meshing & Mesh Conversion | 13 | March 7, 2022 18:22 |
[ICEM] Error in mesh writing | helios | ANSYS Meshing & Geometry | 21 | August 19, 2021 15:18 |
Need help setting up chtMultiRegion | OskarT | OpenFOAM Pre-Processing | 1 | September 25, 2019 16:51 |
[DesignModeler] Internal face normal direction | Aidan.CFD | ANSYS Meshing & Geometry | 3 | February 14, 2018 15:35 |
fluent add additional zones for the mesh file | SSL | FLUENT | 2 | January 26, 2008 12:55 |