|
[Sponsors] |
snippet for a custom variable which is a product of two variables |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 30, 2016, 20:33 |
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 |
Dear Fellows
In my solver, by solving transport equations, I am achieving which is bulk charge density and which is velocity. I have added the following snippet in my createFields.H file: I want to find the distribution of from my code in which 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 ); 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(); However if I use calculator filter in paraview, I would be able to create the distribution of . Does any body know, where did I make mistake? Regards |
|
December 1, 2016, 11:32 |
|
#2 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
You have to update the fields rhoE and Ux in every timestep, because at least for Ux in createFields.H you only do this once at the beginning of the simulation.
So your code should look something like this: Code:
// rhoE = ???; // not sure what this is. Do you set this somewhere else in your solver? Ux = U.component(vector::X); rhoEUx = rhoE * Ux; |
|
December 1, 2016, 12:58 |
|
#3 |
Senior Member
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 15 |
Many thanks Joachim
I will test it and give the feedback. This is my main code: Code:
while (runTime.run()) { #include "readTimeControls.H" #include "CourantNo.H" #include "alphaCourantNo.H" #include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; twoPhaseProperties.correct(); #include "alphaEqnSubCycle.H" #include "ElectricEqn.H" #include "SourceTerm.H" //Info<< "ElectricEqn over " << nl << endl; // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { #include "UEqn.H" // --- Pressure corrector loop while (pimple.correct()) { #include "pEqn.H" } if (pimple.turbCorr()) { turbulence->correct(); } } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } I updated the Ueqn.H file as: Code:
Ux = U.component(vector::X); 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(); Regards |
|
December 1, 2016, 15:29 |
|
#4 |
Senior Member
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 15 |
||
December 1, 2016, 17:35 |
|
#5 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Actually, I think, you don't need the Ux field. You could just use U.component(vector::X) in your calculation of rhoEUx. I would even expect the compiler to optimize it away.
|
|
December 1, 2016, 18:06 |
|
#6 |
Senior Member
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 15 |
Most likely, u are correct, since
Code:
U.component(vector::X) By invoking Code:
U.component(vector::X) Code:
rhoEUx = rhoE * U.component(vector::X); Regards |
|
June 27, 2019, 01:46 |
|
#7 |
Senior Member
Brett
Join Date: May 2013
Posts: 212
Rep Power: 13 |
Hey guys,
Do you know how to create custom variables in postprocessing, ie after the simulation has run? in order to say mucking around with the C and H files? |
|
|
|
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 |