CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   sampledSurface/Plane has no faces (https://www.cfd-online.com/Forums/openfoam-solving/132110-sampledsurface-plane-has-no-faces.html)

chrisb2244 March 26, 2014 01:14

sampledSurface/Plane has no faces
 
I have created a vector containing all the discrete values of x within my simulation, and then a sampledPlane at each value of x, (I want these to be normal to x, but I have also tested with other normals due to this problem)

When I ran my solver (mostly identical to dnsFoam), it all seemed nice and average values for each value of x, of Uy and Uz in my pipe were all 0. However, this seemed a little too good to be true, so I tested for average Ux, expecting everywhere a positive value, and also found 1024{0} (I have 1024 cells in the x direction)

Some further investigation led me to find that my sampledPlanes have no faces/points on them - hence the use of different normals (I figured that way at least some faces would have to be cut?)

I'm sure I'm making a stupid mistake - any help would be appreciated.

Below is the code I'm using, followed by a section of the output.
The code requires a `--std=c++11` flag within the options file for wmake, since emplace_back is a new(ish, now, I suppose) function for std::vector.
Using
Code:

Foam::vector<sampledPlane> xList;
xList.append(blah);

doesn't work, since the sampledPlane/Surface/etc classes all disable the copy assignment operators.

Code:

DynamicList<scalar> discreteX;
forAll(mesh.cellCentres(), cellI)
{
        //~ Info<< "cellI = " << cellI << endl;
        if (discreteX.size() < 2)
        {
                discreteX.append(mesh.cellCentres()[cellI][0]);
                continue;
        }
        if (mesh.cellCentres()[cellI][0] < discreteX[discreteX.size()-2])
        {
                //~ Info << "Break" << endl;
                break;
        }
        discreteX.append(mesh.cellCentres()[cellI][0]);
}

std::vector<sampledPlane> planeListX;
forAll(discreteX, x)
{
        planeListX.emplace_back
        (
                sampledPlane
                (
                        "xPlane",
                        mesh,
                        plane
                        (
                                point(discreteX[x], 0.001, 0.0001),
                                vector(1,0,0)
                        )
                )
        );
        Info<< "planeListX[" << x<< "] = ";
        //~ dynamic_cast so as to avoid ambiguous << operator call.
        Info<< dynamic_cast<Foam::sampledSurface&>(planeListX[x]);
        Info<< endl;
}

DynamicList<scalar> UzField;
DynamicList<scalar> UyField;
DynamicList<scalar> UxField;
forAll(planeListX, x)
{
        UzField.append(planeListX[x].average(U.internalField().component(2)));
        UxField.append(planeListX[x].average(U.internalField().component(0)));
        UyField.append(planeListX[x].average(U.internalField().component(1)));
}
Info<< "UzField = " << UzField << endl;
Info<< "UyField = " << UyField << endl;
Info<< "UxField = " << UxField << endl;

with
Code:

UxField.clear();
UzField.clear();
UyField.clear();
forAll(planeListX, x)
{
        UxField.append(planeListX[x].average(U.internalField().component(0)));
        UyField.append(planeListX[x].average(U.internalField().component(1)));
        UzField.append(planeListX[x].average(U.internalField().component(2)));
}
Info<< "UxField = " << UxField << endl;
Info<< "UyField = " << UyField << endl;
Info<< "UzField = " << UzField << endl;

appended to the end of each timestep within the myDnsFoam.C solver file.

Output:
Code:

Reading transportProperties

Reading field p

Reading field U

Reading/calculating face flux field phi

Creating list Avg(U.z)

planeListX[0] = sampledPlane: lowPlane :  base:(0.000549316 0.001 0.0001)  normal:(0.880451 0.440225 0.17609)  triangulate:1  faces:0  points:0
planeListX[1] = sampledPlane: lowPlane :  base:(0.00164795 0.001 0.0001)  normal:(0.880451 0.440225 0.17609)  triangulate:1  faces:0  points:0
planeListX[2] = sampledPlane: lowPlane :  base:(0.00274658 0.001 0.0001)  normal:(0.880451 0.440225 0.17609)  triangulate:1  faces:0  points:0
planeListX[3] = sampledPlane: lowPlane :  base:(0.00384521 0.001 0.0001)  normal:(0.880451 0.440225 0.17609)  triangulate:1  faces:0  points:0
planeListX[4] = sampledPlane: lowPlane :  base:(0.00494385 0.001 0.0001)  normal:(0.880451 0.440225 0.17609)  triangulate:1  faces:0  points:0
planeListX[5] = sampledPlane: lowPlane :  base:(0.00604248 0.001 0.0001)  normal:(0.880451 0.440225 0.17609)  triangulate:1  faces:0  points:0
planeListX[6] = sampledPlane: lowPlane :  base:(0.00714111 0.001 0.0001)  normal:(0.880451 0.440225 0.17609)  triangulate:1  faces:0  points:0
planeListX[7] = sampledPlane: lowPlane :  base:(0.00823975 0.001 0.0001)  normal:(0.880451 0.440225 0.17609)  triangulate:1  faces:0  points:0
...
...



All times are GMT -4. The time now is 11:33.