CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How should new class constructors be compiled and linked? (https://www.cfd-online.com/Forums/openfoam-programming-development/139160-how-should-new-class-constructors-compiled-linked.html)

kasper1301 July 18, 2014 04:56

How should new class constructors be compiled and linked?
 
Hi,

I am currently working on extending twoPhaseEulerFoam to include mutlicomponent mixtures in each phase :). So far I have switched from the thermodynamic model rhoThermo to rhoReactionThermo and created the necessary fields in createFields.H.

The problem is that the mixture model (basicMulticomponentMixture) doesn't have a constructor that includes the phase names. I was therefore wondering on how to include a new constructor that includes phase names (similar to what is done in basicThermo). The implementation in itself looks quite straightforward, but I am unsure on how to extend the existing model with the new constructor. :confused:

The only solution that I can think of is to copy the whole reactionThermo folder, apply the changes and compile it to the user library. However, this will create a lot of duplicate code and I'm guessing there is a better way to do it. Does anyone know how to do it with less duplications?

I could compile the changes directly in the src folder, but I would rather not do any changes to the original source code.

Kasper

osha July 18, 2014 14:56

I would have done the modification in following manner.

  1. Goto $WM_PROJECT_USER_DIR directory and create the following folders --> /src/thermophysicalModels/reactionThermo
  2. Modify the required code on basis of code available in OpenFOAM, like adding the required constructor, as you mentions or anything else.
  3. Edit 'files' and 'options' files in the 'Make' folder to include new code. Refer Make folder in reactionThermo folder to see how it has been written and modify the name of your *.C file and the lib file. for e.g libreactionThermophysicalModels as newlibreactionThermophysicalModels.
  4. Final step will involve wmake.
I believe this method will keep the the original source intact and you will be aware of your own library built on OpenFOAM.

I hope this helps.

Kalli

kasper1301 July 18, 2014 15:10

Thanks for the reply!

I will try that once I get back from vacation ;)

Another possibility that has arisen is to copy only the files that will be altered from the source folder, and link to the other original files. Since I am adding a constructor (without deleting the old ones), I believe that it is safe to create a user library that precedes the original library while all the other functionality is maintained (please correct me if I'm wrong).


All times are GMT -4. The time now is 14:55.