|
[Sponsors] | |||||
|
|
|
#1 |
|
New Member
David
Join Date: May 2013
Posts: 2
Rep Power: 0 ![]() |
Hey,
I am writing a boundary condition and I need to access (not modify) the values of Phi over all the faces in a patch in updateCoeffs() I went along with something like const surfaceScalarField& phi = this->db().objectRegistry::lookupObject<surfaceScalarFi eld>("phi"); I thought this might grab the phi field from the openfoam database and i'd be able to just find the faces on my patch....and just sum over the corresponding face entries in the phi list. I thought this might be good...however this would be for the values of phi everywhere not just in my patch right? so i'd be storing a lot of values I do not need. Also when I check my phi list it doesn't match the Phi files that are created in each timestep directory. There must be an easy and nice way of just finding the sum(phi) over the faces of my patch. Thanks in advance. I'm brand new to programming so sometimes this stuff makes me weep. I'll be combing doxygen and google in the mean time. David |
|
|
|
|
|
|
|
|
#2 |
|
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Posts: 1,118
Rep Power: 19 ![]() |
Hi David,
Welcome to the Forum. You are actually on the right track here, and before I suggest a solution, then please allow me to bring your attention to the "&" in Code:
const surfaceScalarField & phi = this->db().objectRegistry().lookupObject<surfaceScalarField>("phi");
I hope this helped a bit, and then on to your problem at hand: Code:
// This line gather the index of the patch
label patchIndex = this->patch().index();
// This is what we already talked about above
const surfaceScalarField & phi = this->db().objectRegistry().lookupObject<surfaceScalarField>("phi");
// This is a reference to the boundaryField of phi, where I am
// using the patch index from above
const scalarField & phiw = phi.boundaryField()[patchIndex];
// Initialise the sumFlux variable
scalar sumFlux = 0.0;
// Sum all of the face values and assign it to sumFlux
sumFlux = Foam::sum(phiw);
// Now, to handle potential parallel computing, this statement sums
// the flux contributions from different processors in case your
// boundary has been divided by one or more processors.
reduce( sumFlux, sumOp<scalar>() );
// Now you have the complete flux across your boundary for serial and
// parallel computations.
Have a nice evening, Niels |
|
|
|
|
|
|
|
|
#3 |
|
New Member
David
Join Date: May 2013
Posts: 2
Rep Power: 0 ![]() |
Hi,
perfect ! This was exactly what I was looking for! I have just one question. When I use Code:
const surfaceScalarField & phi = this->db().objectRegistry().lookupObject<surfaceScalarField>("phi");
However I noticed that changing it to this works perfectly and matches what I expect Code:
const surfaceScalarField & phi = this->db().objectRegistry::lookupObject<surfaceScalarField>("phi");
David |
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| y+ and u+ values with low-Re RANS turbulence models: utility + testcase | florian_krause | OpenFOAM | 81 | April 5, 2013 12:48 |
| mixerVesselAMI2D's mass is not balancing | sharonyue | OpenFOAM Running, Solving & CFD | 2 | March 22, 2013 07:09 |
| No layers in a small gap | bobburnquist | OpenFOAM Native Meshers: snappyHexMesh and Others | 2 | November 25, 2012 08:54 |
| Add Mesh Layers doesnt work on the whole surface | Kryo | OpenFOAM Native Meshers: snappyHexMesh and Others | 8 | September 13, 2012 09:28 |
| [Other] Mesh Importing Problem | cuteapathy | ANSYS Meshing & Geometry | 1 | June 7, 2012 13:39 |