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

Compute volVectorField at each time-step

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 20, 2023, 08:50
Default Compute volVectorField at each time-step
  #1
New Member
 
nope
Join Date: Jul 2023
Posts: 1
Rep Power: 0
papadeiv is on a distinguished road
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 T(x,t):

\partial_{t} T + \nabla\cdot(\vec{U}T)=0

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();
}
where in "updateTransport.H" I perform the operation of updating the surfaceScalarField phi modelling the advection

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)
);
Now, the solver works just fine however it is not conveniente since I must recompile it everytime I change the mathematical form for the advection field.

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.
papadeiv is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
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


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