|
[Sponsors] |
time varying gravity for interFoam in OpenFOAM 6 |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 19, 2020, 15:52 |
time varying gravity for interFoam in OpenFOAM 6
|
#1 |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 9 |
Hi FOAMers!
Do you know how to change gravity to a function of time? I read a thread here but this is very dated. If anyone knows how to change this I'd be very grateful! |
|
May 19, 2020, 18:17 |
|
#2 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
I've done something similar a long time ago, but I think the following should point you in the right direction. If you look at solvers with buoyancy you'll see
Code:
#include "readGravitationalAcceleration.H" #include "gh.H" So something like : Create the field g and (initial) gh in create fields. Then inside the solver (probably after updating time with runTime++) something like Code:
g = cos(t)*dimensionedScalar(gmag,dimVelocity*dimVelocity,9.81) *vector(1,0,0) + sin(t)*dimensionedScalar(gmag,dimVelocity*dimVelocity,9.81) *vector(0,1,0) //update g //update gh, ghf gh = g & mesh.C(); ghf = g & mesh.Cf(); Caelan Last edited by clapointe; May 19, 2020 at 20:48. |
|
May 20, 2020, 02:12 |
|
#3 | |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 9 |
Quote:
The UEqn.H looks like this Code:
MRF.correctBoundaryVelocity(U); # define omega 0.05 const dimensionedVector mySource("mySource", dimensionSet(0,1,-2,0,0,0,0), 10*Foam::sin(runTime.value()*omega)*vector(0,1,0)); fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) + MRF.DDt(rho, U) + turbulence->divDevRhoReff(rho, U) == fvOptions(rho, U) + mysource ); UEqn.relax(); . . . Code:
In file included from bfInterFoam.C:142:0: UEqn.H: In function ‘int main(int, char**)’: UEqn.H:14:9: error: ‘mysource’ was not declared in this scope + mysource ^~~~~~~~ UEqn.H:14:9: note: suggested alternative: ‘mySource’ + mysource ^~~~~~~~ mySource /opt/openfoam6/wmake/rules/General/transform:25: recipe for target '/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/bfInterFoam/bfInterFoam.o' failed make: *** [/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/bfInterFoam/bfInterFoam.o] Error 1 |
||
May 20, 2020, 11:40 |
|
#4 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
There's a typo -- as the error message says try replacing "mysource" with "mySource".
Caelan |
|
May 20, 2020, 12:23 |
|
#5 |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 9 |
||
May 20, 2020, 12:37 |
|
#6 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
The error messages are always a good place to start -- and are usually pretty helpful. Using your case as an example, the relevant bit of the message read "note: suggested alternative: ‘mySource’". Otherwise carefully looking at the new code is good practice.. there's probably a post or guide floating around with more comprehensive debugging information.
Caelan |
|
May 20, 2020, 13:06 |
|
#7 | |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 9 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
pressure in incompressible solvers e.g. simpleFoam | chrizzl | OpenFOAM Running, Solving & CFD | 13 | March 28, 2017 06:49 |
High Courant Number @ icoFoam | Artex85 | OpenFOAM Running, Solving & CFD | 11 | February 16, 2017 14:40 |
Micro Scale Pore, icoFoam | gooya_kabir | OpenFOAM Running, Solving & CFD | 2 | November 2, 2013 14:58 |
mixerVesselAMI2D's mass is not balancing | sharonyue | OpenFOAM Running, Solving & CFD | 6 | June 10, 2013 10:34 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |