coded energysource in fvModels
In OF8, I used "scalarCodedSource" in fvOptions to add a source to the field e. The source term is a function of coordinate and resides in a field, sourceTerm.
In OF9, I had to rephrase a bit to "coded" in fvModels to get it running. It does however not seem to add any source in the energy equation - the temperatures are unaffected by it. Would you have an idea why (or alternatives how to add a constant heat source which is a function of coordinate)? Code:
energySource |
Not sure.
Possibly it helps to first replace "V = mesh().V()" by "V = mesh_().V()" (adding underscore) as given by the example here https://www.openfoam.com/documentati...ces-coded.html and run a test with replacing "heSource = -1*ST*V" by "heSource = -1*V" (thus leaving leaving ST out). I am very curious to see whether that would work. In a second step I would reconsider the ST factor. I currently fail to understand how the value of ST is set. I wonder whether the use of the object registry is recommended here. Good luck. |
Thanks for your reply!
I did try the underscore already with OF8 "mesh_.V()" and it gives Code:
‘const Mesh& Foam::DimensionedField<double, Foam::volMesh>::mesh_’ is private within this context https://cpp.openfoam.org/v9/classFoa...edFvModel.html The ST field should be fetched from a file named sourceTerm located in /0/. I tried both a codeStream version of that file (which seems to work as there are lists created in the processor0/0 directories), as well as a uniform version (though that is not sufficient for the purpose - to have it nonuniform). The ST field does however not seem to be the problem. There does e.g. not seem to be any impact on the temperature even if I replace Code:
heSource = -1*ST*V; Code:
forAll(V, i) Is there another way to set a test field into eqn.source(), e.g. a uniform constant? Alternatively, is there a way to inspect what is actually set, e.g. save it in a file? Is the problem "V"? Can I confirm that it is actually referring to the volumes of the model mesh in the code previously shown? |
No clue.
Are you (maybe?) adding to h and solving for e (or vice versa)? |
I do not think so.
I solve for sensibleInternalEnergy (e) as specified in thermoType of thermoPhysicalProperties and the coded energySource is also acting on the field specified as e. It worked like that in OF8 too. |
Three questions:
1/ Do you see the result of the Pout statement when running the code? 2/ What happens in case you toss mesh().V and merely set heSource = - 1e8? 3/ What happens in case you place the Pout statement inside of the loop over cell? |
Thanks for the suggestions!
1. No, a grep does not show any output of "codeAddSup". The line does occur, as repeated input, in dynamicCode/energySource/codedFvModelTemplate.C. The output also shows evidence of using the code: Code:
Selecting finite volume model type coded Is that valid though, as 1e8 is a scalar but heSource is a field (unless it is indexed)? 3. Pout inside the loop gives no difference, no output. (That loop relies on V though.) All this is on sensibleInternalEnergy. Along with your previous suggestion that it might be related to e/h, I did another test. I copied the heatedDuct tutorial. Then I copied exactly the example of https://cpp.openfoam.org/v9/classFoa...edFvModel.html into constant/fluid/fvModels and changed heSource to 1e8. It runs and shows evidence as above, but no impact on temperature. |
Do you need to add
codeInclude #{ #include "fvCFD.H" #include <cmath> #include <iostream> #}; codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; or similar? |
I did not think that either, because if a reference to a library function or similar was missing the compiler should complain, right?
Neither were there any such references in the example at cpp.openfoam.org/v9. I did try to add the ones you suggest anyway though, before codeAddSup. (Maybe it could be other libraries but that would be pure guessing from my side.) These made no difference. |
I could have found the answer by investigating why the Pout string does not occur in the output. :o
The solver is compressible, so the source term should be added by codeAddRhoSup instead of codeAddSup. Then it seems to work. :-) |
Well done! Congrats! Happy that this is resolved.
Question: is my (always very limited) understanding correct that this construction allows not only to add source terms, but replace implemented source terms altogether? What I meant is to proceed in two steps by 1/ first subtract in the codedSource the negative of what is in the source code; 2/ add a user defined contribution? Tak, Domenico. |
Hello Per,
I have the same problem, could you elaborate how you fixed the issue? How did you choose codeAddRhoSup instead of codeAddSup? Which solver did you use? Thank you very much! |
As you can see in the code included at the top of this thread, the code is written under the keyword codeAddSup. For this solver (chtMultiRegionFoam) it should be under codeAddRhoSup.
|
I think "source term" can be defined in different ways, so I am not sure what is meant by a replacement or addition. As I see it here, this is the only external or user defined source term in the energy equation. If there would be another source term, e.g. from viscous heating, I strongly doubt it can be replaced in this relatively simple manner.
|
Quick Question!!!
Quote:
Can you write ST field each writeTime Interval?? |
Hello
I am having a similar problem where I am applying a energy source. However, I need to apply this source term to a particular volume of geometry. I tried it by doing select cellZone; cellZone c0; In log file, it is showing that the source term is being applied to zone c0, but in actual it is being applied to whole volume (from the results it is being visualized). So, just want to know, where I am going wrong. Is there any other way to do? Thanks Shubham |
Quote:
Where it is being created? in the blockMeshDict or in the topoSetDict? |
1. I have checked the c0 cellzone number of times. It is modelled and assigned properly. Even I am able to visualise that zone in ParaFoam. Also, the log file indicates that a source term is being applied to cellZone c0.
2. I have created the model using gmsh and assigned the names there only. |
Quote:
It is a codedFvModel or a heatSource?? |
I am using coded fvModel for this.
|
All times are GMT -4. The time now is 18:32. |