|
[Sponsors] |
October 7, 2021, 06:26 |
‘argc’ was not declared in this scope
|
#1 |
New Member
Philipp Conen
Join Date: Jul 2021
Location: Germany, NRW
Posts: 22
Rep Power: 5 |
Dear Foamers,
for the first time, I am trying to compile an application in OpenFOAM. Regarding my needs, I would like to build the code mentioned in this thread: https://www.cfd-online.com/Forums/op...ary-patch.html Code:
#include "setRootCase.H" #include "createTime.H" #include "createMesh.H" label PatchID = mesh.boundaryMesh().findPatchID("tuyau"); const polyPatch& patchFound = mesh.boundaryMesh()[PatchID]; labelList labelPatchFound( patchFound.meshPoints() ); pointField meshPoints(mesh.points()); long nombre = 0; forAll(labelPatchFound , label) { vector coord = meshPoints[labelPatchFound[label]]; Info << coord[0] << " " << coord[1] << " " << coord[2] << endl; nombre++; } Info << nombre << endl; After trying to merge a simple code from the tutorial with the above-mentioned code I am getting the following output (errors). Code:
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/apps/patchPointsOrder$ wmake Making dependency list for source file patchPointsOrder.C g++-5 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/meshTools/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include -IlnInclude -I. -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude -fPIC -c patchPointsOrder.C -o Make/linux64GccDPInt64Opt/patchPointsOrder.o In file included from patchPointsOrder.C:17:0: /home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include/setRootCase.H: In function ‘int main()’: /home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include/setRootCase.H:5:24: error: ‘argc’ was not declared in this scope Foam::argList args(argc, argv); ^ /home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include/setRootCase.H:5:30: error: ‘argv’ was not declared in this scope Foam::argList args(argc, argv); ^ /home/philipp/OpenFOAM/OpenFOAM-3.0.1/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt64Opt/patchPointsOrder.o' failed make: *** [Make/linux64GccDPInt64Opt/patchPointsOrder.o] Error 1 /Make/files: Code:
patchPointsOrder.C EXE = $(FOAM_USER_APPBIN)/patchPointsOrder Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/OpenFOAM/include EXE_LIBS = \ -lfiniteVolume Code:
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/apps/patchPointsOrder$ tree . ├── Make │** ├── files │** ├── linux64GccDPInt64Opt │** │** ├── options │** │** ├── patchPointsOrder.C.dep │** │** ├── sourceFiles │** │** └── variables │** └── options └── patchPointsOrder.C I would be very happy about any help. My OpenFOAM is version 3.0.1. Greetings! |
|
October 7, 2021, 11:53 |
|
#2 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 727
Rep Power: 14 |
Ok - a quick question - was the code that you quoted at the top your whole code? If not, then it would be best to include the whole code.
If it WAS, then you need to just brush up on your basic C++, since the implementation file needs to be of the form: Code:
#include "something.H" int main(int argc, char *argv[]) { #include "somethingElse.H" insert your coding here return(0); } |
|
October 7, 2021, 12:08 |
|
#3 |
New Member
Philipp Conen
Join Date: Jul 2021
Location: Germany, NRW
Posts: 22
Rep Power: 5 |
Dear Tobermory,
many many thanks for the fast reply! So my first try was: Code:
#include "vector.H" #include "IOstreams.H" #include "scalar.H" #include "fvCFD.H" #include "OFstream.H" #define FIELDSIZE 4 using namespace Foam; typedef Field<scalar> binningField; typedef Field<vector> binningVField; int main() { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" label PatchID = mesh.boundaryMesh().findPatchID("tuyau"); const polyPatch& patchFound = mesh.boundaryMesh()[PatchID]; labelList labelPatchFound( patchFound.meshPoints() ); pointField meshPoints(mesh.points()); long nombre = 0; forAll(labelPatchFound , label) { vector coord = meshPoints[labelPatchFound[label]]; Info << coord[0] << " " << coord[1] << " " << coord[2] << endl; nombre++; } Info << nombre << endl; return 0; } After your answer I changed it to: Code:
#include "vector.H" #include "IOstreams.H" #include "scalar.H" #include "fvCFD.H" #include "OFstream.H" #define FIELDSIZE 4 using namespace Foam; typedef Field<scalar> binningField; typedef Field<vector> binningVField; int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" label PatchID = mesh.boundaryMesh().findPatchID("tuyau"); const polyPatch& patchFound = mesh.boundaryMesh()[PatchID]; labelList labelPatchFound( patchFound.meshPoints() ); pointField meshPoints(mesh.points()); long nombre = 0; forAll(labelPatchFound , label) { vector coord = meshPoints[labelPatchFound[label]]; Info << coord[0] << " " << coord[1] << " " << coord[2] << endl; nombre++; } Info << nombre << endl; return 0; } Code:
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/apps/patchPointsOrder$ wclean philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/apps/patchPointsOrder$ wmake Making dependency list for source file patchPointsOrder.C g++-5 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/meshTools/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include -IlnInclude -I. -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude -fPIC -c patchPointsOrder.C -o Make/linux64GccDPInt64Opt/patchPointsOrder.o g++-5 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/meshTools/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include -IlnInclude -I. -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPInt64Opt/patchPointsOrder.o -L/home/philipp/OpenFOAM/OpenFOAM-3.0.1/platforms/linux64GccDPInt64Opt/lib \ -lfiniteVolume -lOpenFOAM -ldl \ -lm -o /home/philipp/OpenFOAM/philipp-3.0.1/platforms/linux64GccDPInt64Opt/bin/patchPointsOrder Code:
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/run/DLR/Working/airfoil2D_dynMesh_rotateProfile$ patchPointsOrder /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 3.0.1 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : 3.0.1-d8a290b55d28 Exec : patchPointsOrder Date : Oct 07 2021 Time : 18:01:23 Host : "philipp-MS-7A38" PID : 16476 Case : /home/philipp/OpenFOAM/philipp-3.0.1/run/DLR/Working/airfoil2D_dynMesh_rotateProfile nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 ? in "/lib/x86_64-linux-gnu/libc.so.6" #3 ? in "/home/philipp/OpenFOAM/philipp-3.0.1/platforms/linux64GccDPInt64Opt/bin/patchPointsOrder" #4 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #5 ? in "/home/philipp/OpenFOAM/philipp-3.0.1/platforms/linux64GccDPInt64Opt/bin/patchPointsOrder" Speicherzugriffsfehler (Speicherabzug geschrieben) Tomorrow I will go on and try to check what could be wrong in the code. Again many thanks! Greetings! |
|
October 7, 2021, 12:13 |
|
#4 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 727
Rep Power: 14 |
Excellent - yes, it looks like it has got past the creatTime.H and createMesh.H lines, and is into the main coding. My advice is to pepper the code with
Code:
Info << variable T |
|
Tags |
application, argv, code, compilation error, linking |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compile calcMassFlowC | aurore | OpenFOAM Programming & Development | 13 | March 23, 2018 07:43 |
error compiling modified applications | yvyan | OpenFOAM Programming & Development | 21 | March 1, 2016 04:53 |
Compile problem | ivanyao | OpenFOAM Running, Solving & CFD | 1 | October 12, 2012 09:31 |
checking the system setup and Qt version | vivek070176 | OpenFOAM Installation | 22 | June 1, 2010 12:34 |
How to get the max value of the whole field | waynezw0618 | OpenFOAM Running, Solving & CFD | 4 | June 17, 2008 05:07 |