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

snippet for a custom variable which is a product of two variables

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By jherb
  • 2 Post By jherb

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   November 30, 2016, 20:33
Default snippet for a custom variable which is a product of two variables
  #1
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 15
babakflame is on a distinguished road
Dear Fellows

In my solver, by solving transport equations, I am achieving \rho_e which is bulk charge density and U which is velocity. I have added the following snippet in my createFields.H file:

I want to find the distribution of \rho_e * U_x from my code in which U_x is the component of velocity in x direction.

I have added the following snippet in my createFields.H file:

Code:
 volScalarField Ux
        (
            IOobject
            (
                "Ux",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            U.component(vector::X)
        );

volScalarField rhoE      
    (
        IOobject
        (
            "rhoE",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh
//    dimensionedScalar("rhoE", dimensionSet(0, -3, 1, 0, 0, 1, 0), scalar(0.0))
    );

  volScalarField rhoEUx
    ( 
     IOobject
        (
            "rhoEUx",
             runTime.timeName(),
             mesh,
             IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
         rhoE*Ux
     );
And I have added this line to my Ueqn.H


Code:
     rhoEUx = rhoE * Ux;
    
 //     volVectorField temptemp = rhoE*E;


//    volVectorField temptemp = 3e-06*(fvc::grad(UeExt));
    fvVectorMatrix UEqn
    (
        fvm::ddt(rho, U)
      + fvm::div(rhoPhi, U)
      - fvm::laplacian(muEff, U)
      - (fvc::grad(U) & fvc::grad(muEff))
      - tmp2
      - tmp1 
    );

    UEqn.relax();
Everything with the solver is fine, However, although the values for \rho_e and U are calculated correctly, the \rho_e * U_x is not correct from the code,


However if I use calculator filter in paraview, I would be able to create the distribution of \rho_e * U_x. Does any body know, where did I make mistake?

Regards
babakflame is offline   Reply With Quote

 


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
[OpenFOAM] Integrating a custom variable over a line babakflame ParaView 9 May 19, 2019 19:45
emag beta feature: charge density charlotte CFX 4 March 22, 2011 09:14
error in COMSOL:'ERROR:6164 Duplicate Variable' bhushas COMSOL 1 May 30, 2008 04:35
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 04:27
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 20:09


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