CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   volPointInterpolation on boundaryField only? (http://www.cfd-online.com/Forums/openfoam-programming-development/93298-volpointinterpolation-boundaryfield-only.html)

Arnoldinho October 11, 2011 06:01

volPointInterpolation on boundaryField only?
 
Hi all,

I want to make an interpolation from (boundary) cell faces to cell points.

I know that an interpolation for the (whole) internalField of a mesh can be done using volPointInterpolation :

Quote:

volPointInterpolation interpolateHbVolPoints (mesh);
hbVolPoints = interpolateHbVolPoints.interpolate(hbVol);
whereas hbVolPoints is a pointScalarField and hbVol is a volScalarField previously declared.
hbVol does only have values on the boundaryField patches, which where previously mapped using vsm.mapToVolume (FAM->FVM).

When I do the above interpolation, hbVol boundaryField values are interpolated to the hbVolPoints internalField. Thats not exactly what I need... I need an interpolation from the boundary cell faces to the boundary cell points, both stored in the boundaryField! Is this possible?

I guess I could make a mapping back from the internalField to the boundaryField, but I guess this could be done directly and without loosing accuracy. Furthermore, I do not need the interpolation for the whole mesh (which is done using above function), but only for the boundaryFields.

Any suggestions?

Arne

doubtsincfd October 11, 2011 13:18

Have a look at sampleDict. you can sample data on patches and there are few interpolation schemes available.www.openfoam.com/docs/user/sample.php

Arnoldinho October 11, 2011 15:00

Thanks doubstincfd. I guess I forgot to say that I need the interpolation during runtime, within th solver directly.
sampleDict seems to be working in postprocessing only. But I will have a look at the source code of it.

Arne

doubtsincfd October 11, 2011 16:15

you are welcome. Let me know if it works. Else I will dig in more

doubtsincfd October 11, 2011 16:16

Meanwhile:


psip_(volPointInterpolation::New(psi.mesh()).inter polate(psi))

in

http://foam.sourceforge.net/docs/cpp/a04429_source.html

bigphil October 12, 2011 04:47

Hi Arne,


You could use primitivePatchInterpolation to interpolate from boundary faces to boundary points (and vice versa).

i.e.
Code:

//- set-up interpolator
primitivePatchInterpolation patchInterpolator
        (
        mesh.boundaryMesh()[patchOfInterestIndex]
        );

//- perform interpolation
vectorField faceValues =
            patchInterpolator.pointToFaceInterpolate<vector>
            (
            pointValues
            );


Philip

Arnoldinho October 12, 2011 10:23

Bigphil, thanks for the hint. This is exactly what I was looking for and seems to be doing what it should.

1. Now I have another problem, mainly in the syntax of OF: I want to store the interpolated boundary points values in a previously declared pointScalarField hbVolPoints.

Quote:

scalarField hbVolPatch = hbVol.boundaryField()[patchi];
scalarField hbVolPointsPatch = patchInterpolateHbVolPoints.faceToPointInterpolate (hbVolPatch);
gives the scalarField of interpolated point values, originally coming from the hbVol boundaryField patch. Storing/Overwriting this scalarField in the pointScalarField hbVolPoints using

Quote:

hbVolPoints.boundaryField()[patchi] = hbVolPointsPatch;
does not compile. I guess I have to cast this somehow, but am not sure how to...

2. Another one: I'm also missing the correct syntax for storing the values of a pointScalarField hbVolPoints into components of a pointVectorField hbVolPoints2.

Quote:

hbVolPoints2.component(2) = hbVolPoints.component(0);
does not have any effect on hbVolPoints2.


Any clue?

bigphil October 12, 2011 10:35

Arne,


Good to hear that it is starting to work.

Hmnnn you could always use a forAll loop to set each value:
Code:

forAll(hbVolPoints.boundaryField()[patchi], pointi)
{
hbVolPoints.boundaryField()[patchi][pointi] = hbVolPointsPatch[pointi];
}

And do the same for the components.

I am not sure why your current method does not work, maybe the "=" operator is not defined for this.


Philip

Arnoldinho October 12, 2011 11:29

Quote:

forAll(hbVolPoints.boundaryField()[patchi], pointi) { hbVolPoints.boundaryField()[patchi][pointi] = hbVolPointsPatch[pointi]; }
Hmm, thats what I already tried. It gives an error during compilation:

Quote:

sedTrans.C:329: error: no match for ‘operator[]’ in ‘((Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::GeometricBoundaryField*)hbVolPoi nts.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField [with Type = double, PatchField = Foam::pointPatchField, GeoMesh = Foam::pointMesh]())->Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::GeometricBoundaryField::<anonymo us>.Foam::FieldField<Foam::pointPatchField, double>::<anonymous>.Foam::PtrList<T>::operator[] [with T = Foam::pointPatchField<double>](patchi)[pointi]’
Could it have to do with the initialization of hbVolPoints?

Quote:

pointMesh pMesh(mesh);

pointScalarField hbVolPoints
(
IOobject
(
"hbVolPoints",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pMesh,
dimensionedScalar("hbVolPoints", dimensionSet(0, 1, 0, 0, 0, 0, 0), 0.0),
"zeroGradient"
);
Any hints are welcome!

bigphil October 12, 2011 11:46

Hmnnn I am not sure, maybe someone else has an idea.
I am not very familiar with pointScalarFields.

What happens when you:
Info << hbVolPoints.boundaryField()[patchi] << endl;
Does it just print out a scalarfield?

Philip

Arnoldinho October 12, 2011 12:00

Quote:

Info << "hbVolPoints.boundaryField()[patchi]: " << hbVolPoints.boundaryField()[patchi] << endl;
Info << "hbVolPointsPatch: " << hbVolPointsPatch << endl;
gives

Quote:

hbVolPoints.boundaryField()[patchi]: type zeroGradient;

hbVolPointsPatch:
525
(
-5.4949228e-07
-1.7257233e-07
1.686064e-07
1.0247966e-07
...
)
where patchi has been declared as const label patchi = mesh.boundaryMesh().findPatchID("name"); before.
hbVolPoints.boundaryField()[patchi] has not been initialized with any values before.

Arne

Arnoldinho October 12, 2011 13:00

Hi,

Quote:

hbVolPoints.internalField() = hbVolPointsPatch;
compiles and writes it as internalField values into hbVolPoints, which is wrong in the sense of the mesh nodes/numbers. hbVolPointsPatch values are boundary patch node values!

Quote:

hbVolPoints.boundaryField()[patchi] = hbVolPointsPatch;
which should be right in the sense of the mesh nodes/numbers gives the compilation error

Quote:

sedTrans.C:330: error: no match for ‘operator=’ in ‘((Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::GeometricBoundaryField*)hbVolPoi nts.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField [with Type = double, PatchField = Foam::pointPatchField, GeoMesh = Foam::pointMesh]())->Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::GeometricBoundaryField::<anonymo us>.Foam::FieldField<Foam::pointPatchField, double>::<anonymous>.Foam::PtrList<T>::operator[] [with T = Foam::pointPatchField<double>](patchi) = hbVolPointsPatch’
So is there no function to write boundaryField() patch values directly?

fredo490 March 11, 2013 10:55

Hello,
I know this topic is a bit old, but did you find a solution to your problem ?
Can you provide the final version of your technique ?

Thx

Fanfei October 27, 2014 09:37

Quote:

Originally Posted by Arnoldinho (Post 327442)
Hi all,

I want to make an interpolation from (boundary) cell faces to cell points.

I know that an interpolation for the (whole) internalField of a mesh can be done using volPointInterpolation :

whereas hbVolPoints is a pointScalarField and hbVol is a volScalarField previously declared.
hbVol does only have values on the boundaryField patches, which where previously mapped using vsm.mapToVolume (FAM->FVM).

When I do the above interpolation, hbVol boundaryField values are interpolated to the hbVolPoints internalField. Thats not exactly what I need... I need an interpolation from the boundary cell faces to the boundary cell points, both stored in the boundaryField! Is this possible?

I guess I could make a mapping back from the internalField to the boundaryField, but I guess this could be done directly and without loosing accuracy. Furthermore, I do not need the interpolation for the whole mesh (which is done using above function), but only for the boundaryFields.

Any suggestions?

Arne

Hi Arne:
I'm the student of Yuchuan Bai of Tianjin University, I get my master degree on Ocean Univerity of China. my master tutor is Bingchen Liang. Both of them attend the China-Germany seminar on september. They saied you do a good job on local scour. so I want to following with you. the problem you mentioned above make me confused.
You mapped the internalField of FAM to the boundayField of FVM, which was stored in the centre of volume. And you want to get the displacement of boundary point. so you need a interpolated. what confused me is that, why you interpoated from the cell face to cell point. On my understood, the variables are stored on Vol centre, so, the interpolated should be from vol to point. could you make me clear about this?
In your paper, 3D sand slide model is used. I have understood the 2D sand slide model, but for 3D ,I have some problem. could you give me some hints about how does is work? Thanks .

Best Regards

Fan Fei

Arnoldinho October 31, 2014 03:52

Hei Fanfei,

yes you are right, we talked about OF scour modeling at CGJoint Sysposium here in Hanover.

Coming to your questions:
1. If I'm not totally wrong now - I wrote the source code almost two years ago and do not have easy access to it right now - the interpolation FAM (after solving the Exner equation) to FVM is carried out to the FVM boundary faces, not the volume! So from FAM volume (which is actually 2D) center to FVM boundary face center. In order to calculate the mesh motion, which I in my case did for the mesh points and not the volumes, the boundary face center values where then calculated to the boundary points, serving as 'boundary condition' for the inner point motion of the entire 3D domain.

2. For the sand slide routine, I did this using the bed load calculation procedure I implemented. If you give qb from the bed load calculation an 'artificial' high and meaningful calculated value with limiter function in the direction of the steepest slope of the boundary face, this can serve as a sliding procedure. In a first step, you of cource have to calculate the direction of steepest slope, which is however quite simple, as you can easily get all boundary face angles from the boundary (boundary faces/points) domain.

Greetings,
Arne

Fanfei November 3, 2014 06:50

Quote:

Originally Posted by Arnoldinho (Post 516785)
Hei Fanfei,

yes you are right, we talked about OF scour modeling at CGJoint Sysposium here in Hanover.

Coming to your questions:
1. If I'm not totally wrong now - I wrote the source code almost two years ago and do not have easy access to it right now - the interpolation FAM (after solving the Exner equation) to FVM is carried out to the FVM boundary faces, not the volume! So from FAM volume (which is actually 2D) center to FVM boundary face center. In order to calculate the mesh motion, which I in my case did for the mesh points and not the volumes, the boundary face center values where then calculated to the boundary points, serving as 'boundary condition' for the inner point motion of the entire 3D domain.

2. For the sand slide routine, I did this using the bed load calculation procedure I implemented. If you give qb from the bed load calculation an 'artificial' high and meaningful calculated value with limiter function in the direction of the steepest slope of the boundary face, this can serve as a sliding procedure. In a first step, you of cource have to calculate the direction of steepest slope, which is however quite simple, as you can easily get all boundary face angles from the boundary (boundary faces/points) domain.

Greetings,
Arne


Hi Arne:
Thank you very much. I'm clear to those now.
Greetings,
Fan fei

Fanfei November 3, 2014 22:50

Quote:

Originally Posted by Fanfei (Post 517112)
Hi Arne:
Thank you very much. I'm clear to those now.
Greetings,
Fan fei

[SIZE="5"]Hi Arne:
[SIZE="5"] I'm so sorry to trouble you again. I have some question about your sand slid model.:)
From what I understood. First, the bed level change was calculated with bed load model, and stored in face centre.:D Then, the displacement of point was interploated, and mesh was update. ;)And then, the steepest slope angle of boundary face was calcuted. If the steepest angle of a face exceed the repose angle, the face should be adjusted. However,due to the mass conservation, the centroid of face shouldn't move , in order to statisfy the need of angle, the face should rotate around the centroid of face. And the displacement of point of this face are solve. Is that right?

Best regards
Fan Fei


All times are GMT -4. The time now is 14:03.