|
[Sponsors] | |||||
|
|
|
#1 |
|
New Member
nope
Join Date: Jul 2023
Posts: 1
Rep Power: 0 ![]() |
New to OpenFOAM and therefore I might am trying to make this to work out by force whereas there is a much better way to do it.
Basically I want to solve an advection equation for a passive scalar :![]() scalarTransportFoam is the ideal solver for that by setting the diffusivity to 0, however it lacks the possibility of setting a space-time dependent mathematical expression for the advection field. So I modified the solver by computing the volVectorField at each step of the simple loop, specifically Code:
while (simple.loop()){
#include "updateTransport.H"
while (simple.correctNonOrthogonal()){
fvScalarMatrix TEqn
(
fvm::ddt(T)+fvm::div(phi, T)== fvOptions(T)
);
TEqn.relax();
fvOptions.constrain(TEqn);
TEqn.solve();
fvOptions.correct(T);
}
runTime.write();
}
Code:
volVectorField U_update = U;
U_update.rename("U");
for(label l=0; l < mesh.C().size(); l++){
scalar x = mesh.C()[l][0];
scalar y = mesh.C()[l][1];
scalar z = mesh.C()[l][2];
scalar t = runTime.value();
U_update[l].x() = t+y;
U_update[l].y() = x*Foam::cos(t);
U_update[l].z() = z;
}
surfaceScalarField phi
(
IOobject
(
"phi",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
fvc::flux(U_update)
);
Ideally I would like to write the mathematical expression in the case directory (say for example in the constant/transportProperties file) and let the solver read it via an IOdictionary object to update the volVectorField at each time-step. I am aware of the existance of expressions however my understanding is that they are used to set IC/BCs in setExprFieldsDict and setFieldsDict and not to be used within the solver itself? Been searching the web and reading both the user and developer's guide for the last 2 days however nothing comes up that brings me closer to achieve what I just described. Any help/suggestion is greatly appreciated. |
|
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| courant number increases to rather large values | 6863523 | OpenFOAM Running, Solving & CFD | 22 | July 6, 2023 00:48 |
| Postprocess: sampleDict works but creates no output folder | shock77 | OpenFOAM Post-Processing | 14 | November 15, 2021 09:27 |
| SU2 7.0.7 Built on CentOS 7, parallel computation pyscript mpi exit error? | EternalSeekerX | SU2 | 3 | October 9, 2020 19:28 |
| High Courant Number @ icoFoam | Artex85 | OpenFOAM Running, Solving & CFD | 11 | February 16, 2017 14:40 |
| Floating point exception error | lpz_michele | OpenFOAM Running, Solving & CFD | 53 | October 19, 2015 03:50 |