Integrating compiler to compile C++ code and running it in Abaqus - python

Recently, I learned that C++ codes runs faster than Python. We have post-processing Python script which takes huge time to run. So, I'm thinking of replacing them with C++ code. I know that C++ code can only be used for Post-processing, and that is fine for me.
I am not sure how to run the C++ code in Abaqus. I know that I need a compiler to compile the C++ code, like Visual Studio. But I don't know about integrating it with Abaqus and overall flow to compile and run the script.
Any help will be much appreciated!

Recently, I have the same problem with you,if you want to use C++ you must use the script in command: abaqus make job=filename.cpp.Then abaqus will give you a file:filename.exe,I think that C++ is same as fortran,I couldn't link it to abaqus ,so I couldn't run the .exe file,if you can solve my problem I would appreciate that you could answer me.

Related

How can I embed python in c ++ without exposing the my source code

I would like to embedding python program from my c++ program. I looking for Boost python, pypind, C/Python API
But I has problems for this:
I don't want to exposing my python scripts on end-user computer, so my visualization is make python script to *.dll, *.exe, *.lib or something similar,
which can be called in C++ project
I refer to Py2exe, but I don't know how can I get return result.
Thanks.

I recently changed my compiler path to run c++ code, but now I can't run any python code. How do I fix this?

How can I set my path so that I can easily switch between several coding languages? I am new to stuff like this so I appreciate any help.
You shouldn't have to set anything. Whatever reads your python code is a completely separate entity from what compiles/understands your C++ code. Your operating system's PATH variable contains a list of places for the system to look for programs.
Your python and C++ tools can co-exist in your PATH without butting heads or causing any issues. I have C++, python, and C# stuff all installed and they get along fine.

How to debug Cython in an IDE

I am trying to debug Cython code that wraps a c++ class, and the error I am hunting is somewhere in the C++ code.
It would be awfully convenient if I could somehow debug as if it were written in one language, i.e. if there's an error in the C++ part, it would show me the source code line there, and if the error is in the Python part it would do the same.
Right now I always have to try and replicate the Python code using the class in C++, and right now I have an error that only occurs when running through Python ... I hope somebody can help me out :)
It's been a while for me and I forgot how I exactly did it, but when I was writing my own C/C++ library and interfaced it with swig into python, I was able to debug the C code with DDD. It was important to compile with debug options. It wasn't great, but it worked for me. I think you had to run ddd python and within the python terminal run my faulty C code. You would have to make sure all linked libraries including yours is loaded with the source code so that you could set breakpoints.

How to profile a python extension module from Visual Studio 2015

I have a C++ static library .lib that I wrap with cython to create a python extension module. I have been able to build the library and extension module with debug information and attach the Visual Studio Community 2015 debugger to the python process and debug the C++ code.
Now I would like to profile the C++ code using instrumentation. If I chose the VS2015 performance wizard option for instrumentation I can only select projects that are either executables or dlls, I can't select the static library project where my code is. I guess that if I could direct VS to use the python .pyd extension module that may work as it's a dll. However, I don't know how to do that.
I have also tried to find some way of starting the profiler while having the debugger attached to the python process, the same way I do for debugging the C++ code, but I haven't found a way. I can see the PerfTips while stepping through the code, but that's not enough.
Does anybody know how could I profile the C++ code in this static library?
Ultimately, if I can't find a way, I could create another VS2015 executable project and call my lib code from there, then profile the executable project. The only inconvenience with this approach is that I'm passing a few multidimensional arrays from python to the extension module and I would have to first save them from python and then load them in the C++ executable project. I'm not sure how will I do it, but it's doable. It would just be a lot more convenient for me if I was able to profile the C++ lib code when being called from python as I'm going to be doing that multiple times in the future and having to save the python data and then loading it from C++ each time it's a bit of a hassle.

Embedding Python with basic IDE

My company has a C/C++ application developed using Visual Studio. Currently we have a Visual Basic plugin which lets you open a built-in text editor and run VB code. This built-in text editor gives the user all the basic debugging tools (break, watch, step...). I was wondering how could I do that using Python. The tricky part is that the python interpreter has to be launched from inside the main application, so that they have access to the same memory space.
I already have a swig interface for the application API and did a proof of concept VB script in which I loaded Python as a DLL and executed a script as described here. This works perfectly when I am sure the script has no bugs, but it would be much easier if I could have some sort of interface which I can debug the script being executed.
I had a look into the pdb module, but it dosent look like the way to go. If someone could just point me into the right direction it would be much appreciated.
I've had some luck embedding Spyder in a C/C++ program that I had created wrappers for (using PySide). Since the wrappers included the main application logic, I turned the program into a python application and then embedded Spyder using one of their examples.
However, it uses pdb or winpdb under the hood, so complete functionality is still not there IMHO.

Categories