|
[Sponsors] |
September 16, 2018, 13:33 |
Efficient way of programming for fvc::grad()
|
#1 |
Senior Member
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10 |
Hello All
I am new to OpenFoam. I have this small portion of code in my solver. I think right now it is working in a very efficient. Can anyone suggest me any more efficient way of doing the same thing. CODE forAll(solidRegions[0].cells(), cellI) { vector r=solidRegions[0].C()[cellI]-fluidRegions[0].C()[celladd_to_src[cellI]]; Us[cellI]=Uf[celladd_to_src[cellI]]; Us[cellI].component(0)=Us[cellI].component(0)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(0)*r.component(0); Us[cellI].component(1)=Us[cellI].component(1)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(1)*r.component(0); Us[cellI].component(2)=Us[cellI].component(2)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(2)*r.component(0); Us[cellI].component(0)=Us[cellI].component(0)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(3)*r.component(1); Us[cellI].component(1)=Us[cellI].component(1)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(4)*r.component(1); Us[cellI].component(2)=Us[cellI].component(2)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(5)*r.component(1); Us[cellI].component(0)=Us[cellI].component(0)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(6)*r.component(2); Us[cellI].component(1)=Us[cellI].component(1)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(7)*r.component(2); Us[cellI].component(2)=Us[cellI].component(2)+fvc::grad(Uf)()[celladd_to_src[cellI]].component(8)*r.component(2); Tf[celladd_to_src[cellI]]=0; } |
|
September 18, 2018, 04:57 |
|
#2 |
Senior Member
|
Possibly it helps to look into Chapter 9 of Moukalled, Manga and Darwish, The finite volume method in computational fluid dynamics, Springer 2015 , http://www.springer.com/gp/book/9783319168739
|
|
September 20, 2018, 11:01 |
|
#3 |
Member
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14 |
If I am right you need to update Us as:
Code:
Us += fvc::grad(Uf).T() & r |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM programming training, 19./20. Feb. 2018 | thg | OpenFOAM Announcements from Other Sources | 0 | February 8, 2018 07:04 |
Additional Programming Course November 2016 | thg | OpenFOAM Announcements from Other Sources | 0 | October 20, 2016 17:23 |
How can i make a parallel programming in OpenFOAM? | jignesh_thaker2007 | OpenFOAM Running, Solving & CFD | 3 | July 2, 2014 10:37 |
A book for a beginner wanting to learn programming | frank | Main CFD Forum | 9 | May 13, 2014 00:15 |
Rheolef 6.3: a free and efficient C++ finite element library | saramito | Main CFD Forum | 0 | October 23, 2012 03:42 |