CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Need an array with cell height values (https://www.cfd-online.com/Forums/openfoam-programming-development/218993-need-array-cell-height-values.html)

Mira July 11, 2019 05:09

Need an array with cell height values
 
What is it mean?

4:16: error: request for member 'component' in '((const Foam::dimensioned<double>*)this)->Foam::dimensioned<double>::value_', which is of non-class type 'const double'
value_.component(d)
~~~~~~~^~~~~~~~~

Here is the problem code:

forAll ( mesh.C(), celli)
{
const cell & cc = mesh.cells()[celli];
labelList pLabels(cc.labels(ff));
pointField pLocal(pLabels.size(), vector::zero);

forAll (pLabels, pointi)
pLocal[pointi] = pp[pLabels[pointi]];

scalar y1Dim = Foam::max(pLocal & vector(0,1,0)) - Foam::min(pLocal & vector(0,1,0));
yDim[celli]= y1Dim;

}

This code from the thread https://www.cfd-online.com/Forums/op...ize-x-y-z.html. Thanks for Niels.

I need an array with cell height values. yDim is the dimentioned scalar.

Any help will be greatly appreciated.

Thanks,

olesen July 16, 2019 05:32

Quote:

Originally Posted by Mira (Post 738646)
What is it mean?

4:16: error: request for member 'component' in '((const Foam::dimensioned<double>*)this)->Foam::dimensioned<double>::value_', which is of non-class type 'const double'
value_.component(d)
~~~~~~~^~~~~~~~~

Here is the problem code:

forAll ( mesh.C(), celli)
{
const cell & cc = mesh.cells()[celli];
labelList pLabels(cc.labels(ff));
pointField pLocal(pLabels.size(), vector::zero);

forAll (pLabels, pointi)
pLocal[pointi] = pp[pLabels[pointi]];

scalar y1Dim = Foam::max(pLocal & vector(0,1,0)) - Foam::min(pLocal & vector(0,1,0));
yDim[celli]= y1Dim;

}

This code from the thread https://www.cfd-online.com/Forums/op...ize-x-y-z.html. Thanks for Niels.

I need an array with cell height values. yDim is the dimentioned scalar.

Any help will be greatly appreciated.

Thanks,




Without the dimensions, you could simply try with the following:


Code:

scalarList yDims(mesh.nCells());

boundBox cellBb;

for (const celli < mesh.nCells(); ++celli)
{
    cellBb.clear();
    cellBb.add(mesh.points(), mesh.cellPoints(celli));
    yDim[celli] = cellBb.span().y();
}

Haven't tested it, but seems to be what you are looking for. Note that I've placed the cell bound box outside of the loop for two reasons: (1) allocation, (2) to avoid implicit parallel reduction. If you want to place it inside of the loop and as a single constructor, you should use the following:

Code:

for (const celli < mesh.nCells(); ++celli)
{
    boundBox cellBb(mesh.points(), mesh.cellPoints(celli), false);
    yDim[celli] = cellBb.span().y();
}

The 'false' is to skip parallel reduction. Your code will otherwise block. If you want the fewest lines of code, the following would be it:

Code:

scalarList yDims(mesh.nCells());

for (const celli < mesh.nCells(); ++celli)
{
    yDim[celli] = boundBox(mesh.points(), mesh.cellPoints(celli), false).span().y();
}



All times are GMT -4. The time now is 19:10.