CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Unable to read all cell centers in OF v2.4

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 27, 2019, 10:00
Default Unable to read all cell centers in OF v2.4
  #1
New Member
 
Saketh Bharadwaj
Join Date: Jan 2018
Posts: 11
Rep Power: 8
Saketh Bharadwaj is on a distinguished road
Hi,


In my user-defined energy source file, I am trying to read the cellCenters of the mesh using the command "const vectorField& C = mesh_.C().internalField();" As next step I want to check if the cell center is in particular location. If yes I will introduce energy source into that cell. But for some reason that command does not function properly. It gives only 490 cell center points when I have 6174 points. It would of great help for me if you can identify the issue. Thank you.



sourceRegionNew.clear();
sourceRegionNew.set(new cellSet(mesh(), "sourceRegionRefine", IOobject::NO_READ, IOobject::AUTO_WRITE));
scalar cur_time = mesh().time().value();

if (cur_time <= 5e-8) {

const scalarField& V = mesh_.V();
//const vectorField& C = mesh_.C().internalField();
const volVectorField& C = mesh_.C();

scalarField& hSource = eqn.source();

scalar len = 0.00025;

scalar W_pm = 1.0*s_efficiency;
scalar power = W_pm*len;
scalarList power_actual(1, 0.0);
scalarList total_volume(1, 0.0);
scalarList x_max(1, 0.0);
scalar E = 0.000017;
scalar L_s = 0.0005;
scalar r_0 = 0.00005;
scalar r_02 = r_0 * r_0;
scalar preExpConst = E/L_s/r_02/M_PI;

forAll(C, i) {
vector s_off = C[i];
scalar x = s_off.x();
Info << PV(s_off) << endl;

if ((x > 0.0003) && (x < 0)) {
Info << "offset X " << endl;
vector s_off1 = C[i] - s_origin;
scalar r2 = s_off1.x()*s_off1.x() + s_off1.y()*s_off1.y() + s_off1.z()*s_off1.z();
sourceRegionNew().set(i);
Info << "3 directions checked and source found" << endl;

scalar cellPow = W_pm*V[i]*preExpConst*exp(-1*pow((sqrt(r2)/r_0),8))/cur_time;
Info << "calculating cellPow and preExpConst " << PV(cellPow) << PV(preExpConst) << endl;
hSource[i] -= cellPow;

power_actual[0] += cellPow;
total_volume[0] += V[i];
if (s_off.x() > x_max[0])
x_max[0] = s_off.x();
}
}

}
Saketh Bharadwaj is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] Creating multiple multiple cell zones with snappyHexMesh - a newbie in deep water! divergence OpenFOAM Meshing & Mesh Conversion 0 January 23, 2019 04:17
Interpolate from face centers to cell center AliE Main CFD Forum 10 February 5, 2018 04:15
How can I define the cell centers without using writeCellCenters? Taylorreihe OpenFOAM Post-Processing 4 February 19, 2016 12:46
Phase locked average in run time panara OpenFOAM 2 February 20, 2008 14:37
unable to read grid file ? bluebird FLUENT 3 July 20, 2001 10:17


All times are GMT -4. The time now is 00:56.