CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

surface and volume fields multiplication

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 2, 2011, 20:10
Default surface and volume fields multiplication
  #1
New Member
 
Ivan
Join Date: Sep 2010
Location: Russia , Moscow.
Posts: 14
Rep Power: 16
Zato_Ichi is on a distinguished road
Greetings !

I have two fields: volVectorField X and surfaceScalarField M. Is there any method to multiply them to get volume field on new time step like that :
X(n+1,i) = X(n,i-1)*M(n,1-1/2)-X(n,i+1)*M(n,i+1/2)
there n timestep index and i index of a cell. i+1/2 - right face of a cell i-1/2 - left face.

I assumed that this will look like interpolate(interpolate(X)*M) with upwind interpolation schemes, but as i know there is no method for interpolating face field onto cell volumes.
Is there any way to make such construction in solver ?

Best regards !
Zato_Ichi is offline   Reply With Quote

Old   March 7, 2011, 13:10
Default
  #2
Member
 
Ivor Clifford
Join Date: Mar 2009
Location: Switzerland
Posts: 94
Rep Power: 17
cliffoi is on a distinguished road
Something along these lines should do the trick. You're going to have to sort out the the discretization and mathematical correctness of it all. Since the mesh is unstructured you'll probably need to use the face normal vector or something to get the direction. Also take a look at finiteVolume/finiteVolume/fvc/fvcReconstruct.C, which does something similar.
Code:
    vectorField& Xi = X.internalField();
    const vectorField& X0i = X.oldTime().internalField();
    const scalarField& M0i = M.oldTime().internalField();

    const unallocLabelList& owner = mesh.owner();
    const unallocLabelList& neighbour = mesh.neighbour();

    Xi = vector::zero;
    
    forAll(owner, faceI)
    {
        label P = owner[faceI];
        label N = neighbour[faceI];

        // You're gonna have to sort out the sign issue here
        // This will probably need the face normal
        Xi[P] += X0i[N]*M0i[faceI];
        Xi[N] -= X0i[P]*M0i[faceI];
    }

    forAll(mesh.boundaryMesh(), patchI)
    {
        fvPatchVectorField& pf = X.boundaryField()[patchI];
        const fvPatchVectorField& pf0 = X.oldTime().boundaryField()[patchI];
        const fvsPatchScalarField& psf = M.oldTime().boundaryField()[patchI];

        const unallocLabelList& faceCells = mesh.boundaryMesh()[patchI].faceCells();

        if (pf.coupled())
        {
            // I'm going to leave this one up to you
        }
        else
        {
            forAll(pf, faceI)
            {
                Xi[faceCells[faceI]] += pf0[faceI]*psf[faceI];
            }
        }        
    }

    X.correctBoundaryConditions();

Last edited by cliffoi; March 7, 2011 at 13:21. Reason: Forgot the boundaries
cliffoi is offline   Reply With Quote

Old   March 7, 2011, 13:25
Default
  #3
Member
 
Ivor Clifford
Join Date: Mar 2009
Location: Switzerland
Posts: 94
Rep Power: 17
cliffoi is on a distinguished road
This might be a much simpler alternative. Again, you need to sort out the discretization and mathematical correctness.
X = fvc::surfaceSum(fvc::interpolate(X.oldTime())*M.ol dTime())
cliffoi is offline   Reply With Quote

Old   March 7, 2011, 18:44
Default
  #4
New Member
 
Ivan
Join Date: Sep 2010
Location: Russia , Moscow.
Posts: 14
Rep Power: 16
Zato_Ichi is on a distinguished road
Hi Ivor , thank you very much for your reply !

It was really helpful for me. I'm trying to add some another algorithms in OpenFoam like FLIC or Big particles method, but there is a very little information about classes and methods in OpenFoam and tutorials for their usage, except Doxygen documentation. Construction proposed by you in your second post looks to be that i need. I used it for coding 3rd step in FLIC method and solver is compiling well now. I will try to solve some test cases and work out correctness issue.

Best regards !
Zato_Ichi is offline   Reply With Quote

Old   May 26, 2022, 03:02
Default
  #5
Member
 
hari charan
Join Date: Sep 2021
Location: India,hyderabad
Posts: 97
Rep Power: 5
saicharan662000@gmail.com is on a distinguished road
Hi ivor,
I have a similar doubt.
I have interface area as a surfaceScalarField and my thermal conductivity as a volume scalar field. how to multiply them and get a volScalarField
Thanks in advance
saicharan662000@gmail.com is offline   Reply With Quote

Old   May 26, 2022, 07:27
Default
  #6
Member
 
Ivor Clifford
Join Date: Mar 2009
Location: Switzerland
Posts: 94
Rep Power: 17
cliffoi is on a distinguished road
Dear Hari,
I think you need to be more specific about what you're trying to achieve. What value are you trying to get at the cell centres. Are you trying to get face-area-averaged value for each cell? Are you trying to get the total interface area?
OpenFOAM has the surfaceSum function that might do what you want.
cliffoi is offline   Reply With Quote

Old   May 26, 2022, 07:43
Default
  #7
Member
 
hari charan
Join Date: Sep 2021
Location: India,hyderabad
Posts: 97
Rep Power: 5
saicharan662000@gmail.com is on a distinguished road
Thanks ivor surfaceSum solved my problem
saicharan662000@gmail.com is offline   Reply With Quote

Old   May 26, 2022, 08:03
Default
  #8
Member
 
hari charan
Join Date: Sep 2021
Location: India,hyderabad
Posts: 97
Rep Power: 5
saicharan662000@gmail.com is on a distinguished road
Hi ivor,
Can you tell me where can we find surfaceSum in openfoam libraries? I hope it is from surface integrals.C but if surfaceSum integrates and converts a surfaceScalar field to volScalarField then what does volIntegrals do?
Thanks in advance
saicharan662000@gmail.com is offline   Reply With Quote

Old   May 27, 2022, 03:44
Default
  #9
Member
 
Ivor Clifford
Join Date: Mar 2009
Location: Switzerland
Posts: 94
Rep Power: 17
cliffoi is on a distinguished road
#include "fvcSurfaceIntegrate.H"

fvc::surfaceSum sums the face values for each cell and returns a volField.

fvc::volumeIntegrate simply multiples the cell values by the cell volume.
cliffoi is offline   Reply With Quote

Old   May 27, 2022, 03:48
Default
  #10
Member
 
hari charan
Join Date: Sep 2021
Location: India,hyderabad
Posts: 97
Rep Power: 5
saicharan662000@gmail.com is on a distinguished road
Thanks ivor
saicharan662000@gmail.com 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
[Gmsh] Hex with transfinite Volume Mjoelnir OpenFOAM Meshing & Mesh Conversion 8 March 30, 2017 09:52
[Gmsh] Error : Self intersecting surface mesh, computing intersections & Error : Impossible velan OpenFOAM Meshing & Mesh Conversion 3 October 22, 2015 12:05
[Gmsh] Problem with Gmsh nishant_hull OpenFOAM Meshing & Mesh Conversion 23 August 5, 2015 03:09
[Gmsh] boundaries with gmshToFoam‏ ouafa OpenFOAM Meshing & Mesh Conversion 7 May 21, 2010 13:43
[Commercial meshers] CuBit t42 OpenFOAM Meshing & Mesh Conversion 6 July 10, 2008 08:51


All times are GMT -4. The time now is 23:21.