|
[Sponsors] |
fvOptions - sign for sources in scalarCodedSource |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 17, 2021, 16:22 |
fvOptions - sign of sources in scalarCodedSource
|
#1 |
New Member
Join Date: Apr 2009
Posts: 13
Rep Power: 17 |
Hello foamers,
I'm struggling with adding a heat source via scalarCodedSource because it seems that negative values are needed to have a positive source. For further investigations I made a simple test case with rhoPimpleFoam where I used a scalarSemiImplicitSource in a cellZone to define a positive heat source in a closed system: Code:
heatSource1 { type scalarSemiImplicitSource; active true; scalarSemiImplicitSourceCoeffs { selectionMode cellZone; // all, cellSet, cellZone, points cellZone sourceZone; volumeMode absolute; injectionRateSuSp { h (0.1 0); } } } Code:
heatSource2 { type scalarCodedSource; active true; name heatSource2; scalarCodedSourceCoeffs { selectionMode cellZone; cellZone sourceZone; fields (h); codeInclude #{ #}; codeCorrect #{ #}; codeAddSup #{ scalarField& hSource = eqn.source(); const scalarField& V = mesh_.V(); double hSourceTot = 0; forAll(V, i) { hSourceTot += hSource[i]; } Pout << " hSourceTot = " << hSourceTot << " with dimension " << eqn.dimensions() << endl; #}; codeConstrain #{ #}; code #{ $codeInclude $codeCorrect $codeAddSup $codeSetValue #}; } } I tested it with OpenFOAM-v2006 and v2012 and have attached the test case. Just unpack and run "./runMesh" and after that rhoPimpleFoam Thanks in advance Ulf Last edited by user; March 23, 2021 at 11:47. |
|
March 20, 2021, 09:29 |
|
#2 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
If I'm not mistaken, the function below gives you a reference to the source of the whole equation (the term on the right hand side the equation . If you are solving the temperature equation there is not only coded source in it but a lot more staff. Think about the laplacian discretization on non ortognonal grids. There you get also explicit source term.
Code:
eqn.source(); |
|
March 22, 2021, 15:39 |
|
#3 |
New Member
Join Date: Apr 2009
Posts: 13
Rep Power: 17 |
Yes, thanks for your reply - your are absolutely right and I also thought about this. That's why I tested it without the scalarSemiImplicitSource and then the reported sources from scalarCodedSource is zero.
Any ideas? I also looked at the code and couldn't find any difference (regarding the sign) between scalarCoded and scalarSemiImplicit. Maybe some C/C++ expert could analyse this ;-) |
|
August 30, 2021, 13:01 |
|
#4 |
New Member
Zhen WANG
Join Date: Jul 2021
Posts: 4
Rep Power: 5 |
Hello, everyone
I'm stuck with the same problem. Can someone please explain? 1. why sources in scalarCodedSources must be negative? 2. why sources in scalarCodedSources always multiply by voluMe V[i] ? |
|
September 3, 2021, 09:24 |
|
#5 |
Senior Member
René Thibault
Join Date: Dec 2019
Location: Canada
Posts: 114
Rep Power: 7 |
Hi,
This maybe could answer your question #2 (see picture in attachment). I don't have the answer for your 1st question though. I encounter the same question and don't have the answer yet. If someone can answer this one, it would be appreciated. Best Regards, |
|
September 3, 2021, 09:59 |
|
#6 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
the answer to queston 2 is that if you discretize a source term in a fine volume framework you integrate it over the cell volume. For a source term which is constant in the volume (this is the usual assumption made) you have to multiply it by the cell volume
|
|
September 3, 2021, 10:53 |
|
#7 |
New Member
Zhen WANG
Join Date: Jul 2021
Posts: 4
Rep Power: 5 |
I got it! Great thanks for your reply @Tibo99, @mAlletto
Could somebody explain the queston 2: why sources in scalarCodedSources must be negative? |
|
September 3, 2021, 11:02 |
|
#8 |
Senior Member
René Thibault
Join Date: Dec 2019
Location: Canada
Posts: 114
Rep Power: 7 |
You mean question 1?
|
|
September 3, 2021, 20:28 |
|
#9 |
New Member
Zhen WANG
Join Date: Jul 2021
Posts: 4
Rep Power: 5 |
Yes, I mean question 1. Sorry for the type error.
|
|
September 4, 2021, 04:44 |
|
#10 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Can you formulate your question a bit more clearly?
|
|
March 10, 2023, 07:06 |
|
#11 |
Senior Member
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 849
Rep Power: 18 |
I run into this problem today. I did some research. I think its because of the following:
Code:
code.template<class Type> Foam::tmp<Foam::fvMatrix<Type>> Foam::operator== ( const fvMatrix<Type>& A, const fvMatrix<Type>& B ) { checkMethod(A, B, "=="); return (A - B); }
__________________
My OpenFOAM algorithm website: http://dyfluid.com By far the largest Chinese CFD-based forum: http://www.cfd-china.com/category/6/openfoam We provide lots of clusters to Chinese customers, and we are considering to do business overseas: http://dyfluid.com/DMCmodel.html |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Howto use scalarCodedSource in fvOptions | hanness | OpenFOAM Running, Solving & CFD | 61 | November 18, 2022 13:11 |
scalarCodedSource fvOptions example moving heat source | superkelle | OpenFOAM Running, Solving & CFD | 1 | March 4, 2021 16:59 |
Configuration of boundary conditions and fvOptions file | Raza Javed | OpenFOAM Running, Solving & CFD | 16 | May 3, 2019 17:35 |
[ICEM] ICEM wind tunnel sign panel mesh | tigerdroppings | ANSYS Meshing & Geometry | 5 | July 30, 2018 14:28 |
reading in a field into fvOptions with type: scalarCodedSource | Ali Blues | OpenFOAM Programming & Development | 4 | June 7, 2018 11:25 |