CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Changing viewfactor Model and use the changed my model by calling "mySolver"

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By FabianF

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 13, 2014, 08:20
Default Changing viewfactor Model and use the changed my model by calling "mySolver"
  #1
New Member
 
Fabian
Join Date: Jan 2014
Posts: 4
Rep Power: 12
FabianF is on a distinguished road
Hello,


here is what I am trying to do:
  • I want to manipulate the viewFactor Model, especially the viewFactor.C file
  • I want to keep every part of my programming strictly seperated from the original source code
  • before I start a simulation I would like to be able to decide in a simple manner if the changed code or the original code is used
  • right now the approach I have chosen is explained below
Approach:
  • copied the content of radiationModels to the user directory myRadiationModels
  • changed the viewFactor.C file, in such a way that it will just show some recognizable output on the terminal
  • changed the Make-files, files and options
Files:
Code:
/* Radiation model */
radiationModel/radiationModel/radiationModel.C
radiationModel/radiationModel/radiationModelNew.C
radiationModel/noRadiation/noRadiation.C
radiationModel/P1/P1.C
radiationModel/fvDOM/fvDOM/fvDOM.C
radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C
radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C
radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C
radiationModel/viewFactor/viewFactor.C
radiationModel/opaqueSolid/opaqueSolid.C
/* Scatter model */
submodels/scatterModel/scatterModel/scatterModel.C
submodels/scatterModel/scatterModel/scatterModelNew.C
submodels/scatterModel/noScatter/noScatter.C
submodels/scatterModel/constantScatter/constantScatter.C
 
/* Absorption/Emission model */
submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.C
submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModelNew.C
submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.C
submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C
submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.C
submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C
submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C
submodels/absorptionEmissionModel/greyMeanSolidAbsorptionEmission/greyMeanSolidAbsorptionEmission.C
 
/* Boundary conditions */
derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C
derivedFvPatchFields/MarshakRadiationFixedTemperature/MarshakRadiationFixedTemperatureFvPatchScalarField.C
derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C
derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C
derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C
derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C
LIB = $(FOAM_USER_LIBBIN)/libmyRadiationModels
Options:
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
 
LIB_LIBS = \
    -lfiniteVolume \
    -lfluidThermophysicalModels \
    -lspecie \
    -lsolidThermo \
    -lmeshTools \
    -lSLGThermo \
    -lsolidMixtureProperties \
    -lliquidMixtureProperties \
    -lsolidProperties \
    -lliquidProperties
  • compiled it into a new library using wmake libso
  • copied the contents of the buoyantSimpleFoam solver to myBuoyantSimpleFoam solver
  • changed the Make-files to the ones below
files
Code:
buoyantSimpleFoam.C
EXE = $(FOAM_USER_APPBIN)/myBuoyantSimpleFoam
options
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/fvOptions/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(WM_PROJECT_USER_DIR)/src/myRadiationModels/lnInclude \
    -I$(LIB_SRC)/turbulenceModels \
    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/RAS \
EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lfiniteVolume \
    -lfvOptions \
    -lsampling \
    -lmeshTools \
    -lfluidThermophysicalModels \
    -lspecie \
    -lmyRadiationModels \
    -lcompressibleTurbulenceModel \
    -lcompressibleRASModels \
    -lmeshTools
  • compiled with wmake
Result:
  • actually this approach does work, calling buoyantSimpleFoam uses the original source code, myBuoyantSimpleFoam the changed one of libmyRadiationModels
  • but a lot of warnings are generated, which are all of the same structure, therefore I only put a few of them in here:
Code:
Duplicate entry MarshakRadiation in runtime selection table fvPatchField
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xc7139) [0x7f05ef54a139]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry MarshakRadiation in runtime selection table fvPatchField
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xc7091) [0x7f05ef54a091]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry MarshakRadiation in runtime selection table fvPatchField
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xc71d4) [0x7f05ef54a1d4]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry greyMeanSolidAbsorptionEmission in runtime selection table absorptionEmissionModel
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xc25dc) [0x7f05ef5455dc]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry wideBandAbsorptionEmission in runtime selection table absorptionEmissionModel
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xbe4ec) [0x7f05ef5414ec]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry greyMeanAbsorptionEmission in runtime selection table absorptionEmissionModel
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xb447c) [0x7f05ef53747c]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry binaryAbsorptionEmission in runtime selection table absorptionEmissionModel
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xb03ac) [0x7f05ef5333ac]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry constantAbsorptionEmission in runtime selection table absorptionEmissionModel
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xae40e) [0x7f05ef53140e]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry none in runtime selection table absorptionEmissionModel
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xab7c8) [0x7f05ef52e7c8]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]
Duplicate entry constantScatter in runtime selection table scatterModel
#0  /opt/OpenFOAM-2.2.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam5error14safePrintStackERSo+0x28) [0x7f05ee9fc8c8]
#1  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xa705e) [0x7f05ef52a05e]
#2  /home/ff/OpenFOAM/ff-2.2.1/platforms/linux64GccDPOpt/lib/libmyRadiationModels.so(+0xe38a6) [0x7f05ef5668a6]

=> I would like to understand what these warnings are telling me and how to get rid of them. Who can help? A suggestion of a totally different approach would be fine as well.


Please consider in your answer, that my OF and C++ knowledge is just on a beginners level. So I am thankful for any explanation that goes a little beyond the actual problem and extends my general knowledge about OF and compiling with wmake. I read the openFoam userguide and googled about wmake and make in c++, but so far I just have some sort of idea what the problem could be, but can not find a solution.

Thanks in advance for your efforts,
Regards

Fabian
FabianF is offline   Reply With Quote

Old   January 13, 2014, 14:48
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Hello there.

What appears to be happening is that the original library (or parts of it) are being linked in the solver as well as your new library. There are two entries in the runTime selection table that have the same name (in the case of the error you posted, its the absorptionEmission model).

Try changing the options file for your new solver either by:

1. Remove
Code:
 -L$(FOAM_USER_LIBBIN) \
- OR -

2. Specify the full path for your custom library, ie
Code:
-/$(FOAM_USER_LIBBIN)/libmyRadiationModels.so \
You may even have to do both. What I suspect is that the first line is adding all the libraries in $(FOAM_USER_LIBBIN), and then you are specifying the same library again with the second. Just a guess at this point
mturcios777 is offline   Reply With Quote

Old   January 14, 2014, 12:25
Default
  #3
New Member
 
Fabian
Join Date: Jan 2014
Posts: 4
Rep Power: 12
FabianF is on a distinguished road
Hi Marco,

Thank you for dealing with my problem.
I tried your solution suggestions, but they would not do the trick.

But I guess you are hinting in the right direction. One of the included lnIncludes of the solver already seems to include the unchanged radiation model. That is why the type definitions ("TypeName") appear twice if my model is added as well.

I have solved the problem now with a different approach, analogue to this one:

http://www.tfd.chalmers.se/~hani/kur...lenceModel.pdf

This approach is already mentioned in the Forum, from the guys who deal with turbulence modelling.

So I only compiled a "myViewfactor" folder into a "myLibrary", after I had changed TypeName viewFactor and every appearance of viewFactor into myViewfactor in the files.
Now I can include the "myLibrary" in the controlDict, and by using "myViewFactor" in the viewFactorControlDict I can switch to my model.

So I can't switch by choosing a different solver, but by editing two lines in a dictionary, which is a sufficient solution for me.

Thanks again to you
wenxu likes this.
FabianF is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:46.