TLCFEM / suanPan

🧮 An Open Source, Parallel and Heterogeneous Finite Element Analysis Framework
https://tlcfem.github.io/suanPan-manual/latest/
GNU General Public License v3.0
56 stars 9 forks source link

[BUG] While running the evolutionary structural optimization example I get the error "Cannot open the input file "node.supan"." #209

Closed lokitkhemka closed 1 month ago

lokitkhemka commented 1 month ago

Describe the bug I tried running the example provided in the page https://tlcfem.github.io/suanPan-manual/latest/Example/Structural/Optimization/evolutionary-structural-optimization/. I run the program using command ./suanPan -f ./evolutionary-structural-optimization.supan, I get the error [ERROR] command.cpp:1589 ~> Cannot open the input file "node.supan". I have the node.supan in the same folder as the main .supan file. Most examples are working fine, so I am unable to figure out why this is happening with this particular example.

Is it possible this is happening with the debug build of the program, because I am running the program in debug mode? I am running Ubuntu 22.04, if that helps. The options that I used for building the library are as below. CmakeOptions

TLCFEM commented 1 month ago

I ran this example, and it appeared to be fine at my end. I cannot reproduce this unfortunately.

https://github.com/TLCFEM/suanPan/blob/25cb0ae6f22bc7ace7f4b795a6215579c5d4616b/Toolbox/command.cpp#L1589

Checking the code around this line, what it does is simply try to ifstream.open files with different file names.

This could fail due to many reasons, can you please check the permissions first, ls node.supan && cat node.supan.

lokitkhemka commented 1 month ago

I figured it out. Basically, it was looking for the file node.supan at the current working directory, not at the location of the main .supan file. Because the current working directory was not the same as the location the main input file, it couldn't find it.

TLCFEM commented 1 month ago

I figured it out. Basically, it was looking for the file node.supan at the current working directory, not at the location of the main .supan file. Because the current working directory was not the same as the location the main input file, it couldn't find it.

Yes, if the files are relocated, the corresponding paths shall be updated. The folder where the executable is invoked is the default CWD, it is also possible to change CWD using the pwd command.