|
[Sponsors] |
January 30, 2020, 07:53 |
how to add varying sourceTerm?
|
#1 |
New Member
Divyesh Variya
Join Date: May 2018
Location: INDIA
Posts: 16
Rep Power: 7 |
Hello Foamers,
I want to add a source Term in laplacianFoam. exp(time)*(Sqr(valueOfMesh(X))-2) Anyone have idea how to do that? Can I use funkySetFields? But still, I have to define something in solver... |
|
January 30, 2020, 07:58 |
|
#2 |
Senior Member
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14 |
Hi!
I think you are looking for this: https://www.openfoam.com/documentati...dedSource.html EDIT: I did not compiled it but I hope it'll work. I wrote it for you with loop so you can see some general way to set the source. You can do it without loop but maybe you will need it in the future so you can do it like this. I hope it helps. Code:
codeAddSup #{ const Time& time = mesh().time(); const vectorField& C = mesh().C(); const scalarField& V = mesh_.V(); scalarField& Source = eqn.source(); forAll(C, i) { Source[i] -= exp(time)*(sqr(C[i].x())-2.0)*V[i]; } #}; |
|
January 30, 2020, 22:54 |
|
#3 |
New Member
Divyesh Variya
Join Date: May 2018
Location: INDIA
Posts: 16
Rep Power: 7 |
Code:
source { type scalarCodedSource; scalarCodedSourceCoeffs { selectionMode all; fields (T); //name internalField; codeInclude #{ #}; codeCorrect #{ Pout<< "**codeCorrect**" << endl; #}; codeAddSup #{ const Time& time = mesh().time(); const vectorField& C = mesh().C(); const scalarField& V = mesh_.V(); scalarField& source = eqn.source(); forAll(C, i) { source[i] -= exp(time)*(sqr(C[i].x())-2.0)*V[i]; } #}; codeConstrain #{ Pout<< "**codeConstrain**"<< endl; #}; } } Code:
Creating finite volume options from "system/fvOptions" Selecting finite volume options model type scalarCodedSource Source: source - selecting all cells - selected 50 cell(s) with volume 0.01 --> FOAM FATAL IO ERROR: keyword name is undefined in dictionary "/system/fvOptions.source" Last edited by divyesh; February 3, 2020 at 03:54. |
|
February 11, 2020, 16:25 |
|
#4 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12 |
the error message is quite clear? comment out 'name' entry?
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
February 12, 2020, 02:44 |
|
#5 |
Senior Member
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14 |
Hi!
Sorry for the late answer. HPE is correct, it should be clear from the error. But there is an another problem which is the missing '}' after the scalarCodedSourceCoeffs. |
|
February 12, 2020, 03:24 |
|
#6 |
New Member
Divyesh Variya
Join Date: May 2018
Location: INDIA
Posts: 16
Rep Power: 7 |
thanks. problem solved.
another thing i add is time.value() instead of just time.
__________________
Divyesh Variya |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[PyFoam] and paraview | eelcovv | OpenFOAM Community Contributions | 28 | May 30, 2016 09:23 |
How to add Exner equation in settlingFoam | jimbean | OpenFOAM Running, Solving & CFD | 1 | October 6, 2013 09:59 |
.setSet problems | Grimoli | OpenFOAM | 9 | July 31, 2013 13:24 |
How to add source for UDS on a virtual surface? | SimulatingFlow | Fluent UDF and Scheme Programming | 1 | May 22, 2013 08:11 |
How to add fire source in STAR-CD?? | raymond | Siemens | 2 | February 22, 2002 13:49 |