|
[Sponsors] |
April 16, 2021, 08:55 |
Issue with mesh().C()
|
#1 | ||
New Member
Claudio Contarini
Join Date: Apr 2021
Posts: 2
Rep Power: 0 |
Hello Foamers!
I'm currently trying to implement a few lines of code to be inserted in fvOptions to generate a non uniform heat source. The geometry i'm working with is a tube along z direction that is running the chtMultiRegionFoam solver on 4 parallel processors. I'm currently stuck due to the implementation of the following lines of code: Quote:
I would expect cellx and celly to have different values, but any selected point posses the same coordinates in x and y. In addition, I would expect mesh().C() to possess only 3 components (the x,y and z coordinates of the cell centers) but I'm obtaining the same results for any component selected (in the results below the component(10) is shown) Quote:
Any ideas on what I could do to solve this? |
|||
April 17, 2021, 07:26 |
|
#2 | |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14 |
Instead of the components method, just use the index, eg:
Code:
func1 { libs ( "libutilityFunctionObjects.so" ); type coded; name test; writeControl timeStep; writeInterval 1; codeWrite #{ float value(-0.4); int intValue(value); bool boolValue(value); bool boolIntValue(intValue); Info << "Cell[100] C = " << mesh().C()[100] << " Cell[100] Cx = " << mesh().C()[100][0] << " Cell[100] Cy = " << mesh().C()[100][1] << endl; #}; } Quote:
|
||
April 17, 2021, 07:30 |
|
#3 | |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14 |
... as does:
Code:
func1 { libs ( "libutilityFunctionObjects.so" ); type coded; name test; writeControl timeStep; writeInterval 1; codeWrite #{ float value(-0.4); int intValue(value); bool boolValue(value); bool boolIntValue(intValue); Info << "Cell[100] C = " << mesh().C()[100] << ", Cell[100] Cx = " << mesh().C()[100][0] << ", Cell[100] Cy = " << mesh().C()[100][1] << endl; Info << "Cell[100] C = " << mesh().C()[100] << ", Cell[100] Cx = " << mesh().C()[100].component(0) << ", Cell[100] Cy = " << mesh().C()[100].component(1) << endl; #}; } Quote:
|
||
April 18, 2021, 03:57 |
|
#4 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40 |
Quote:
|
||
April 18, 2021, 04:14 |
|
#5 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40 |
Quote:
People should also be aware that the components method on the volume field will return a tmp scalarField. So binding to a const-reference is dubious. And unless you need these as an entire field, also wasteful of memory and slower than directly accessing the components of individual elements. Slightly reworked: Code:
func1 { name test; type coded; libs ( "libutilityFunctionObjects.so" ); codeWrite #{ const auto& cc = mesh().C(); Info << "Cell[100] C = " << cc[100] << ", Cell[100] Cx = " << cc[100].x() << ", Cell[100] Cy = " << cc[100].y() << nl; #}; } |
||
April 18, 2021, 12:17 |
|
#6 | |
New Member
Claudio Contarini
Join Date: Apr 2021
Posts: 2
Rep Power: 0 |
Thank you very much Tobermory. I was actually thinking to employ the components as entire fields, as Olesen suggested, but i managed to rewrite my code so that i can employ a single
Quote:
Thank you all guys |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issue on zeroGradient BC for system rotation | magnushaese | OpenFOAM Running, Solving & CFD | 2 | January 28, 2022 13:43 |
rhoCentralFoam inviscid airfoil issue (Foam::error::printStack(Foam::Ostream&) at ??) | kmkb21 | OpenFOAM Running, Solving & CFD | 1 | March 1, 2018 01:07 |
Prism Layer - Core Mesh Boundary Issue | InfernoxCJC | STAR-CCM+ | 7 | November 21, 2017 15:46 |
foamToTecplot360 issue with multiregion solvers | manuc | OpenFOAM Post-Processing | 2 | November 21, 2016 13:51 |
Pressure boundary condition issue | Vijay | FLUENT | 0 | April 6, 2012 13:35 |