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

Re-read basicPsiThermo from temperature file.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 7, 2017, 07:55
Default Re-read basicPsiThermo from temperature file.
  #1
Member
 
Oleg Sutyrin
Join Date: Feb 2016
Location: Russia
Posts: 41
Rep Power: 10
OlegSutyrin is on a distinguished road
I'm developing custom solver based on rhoCentralDyMFoam for foam-extend 3.2 (which is closest to OpenFOAM v3, I believe).
Initial condition, including thermodynamics, is read from 3 files: p, T, U:
Code:
autoPtr<basicPsiThermo> pThermo
(
    basicPsiThermo::New(mesh) 
);
basicPsiThermo& thermo = pThermo(); //reads p and T?
volScalarField& p = thermo.p();
volScalarField& e = thermo.e();
const volScalarField& T = thermo.T();
const volScalarField& psi = thermo.psi();
const volScalarField& mu = thermo.mu(); 

volVectorField U //reads U
(
    IOobject
    (
        "U",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
); 

volScalarField rho
(
    IOobject
    (
        "rho",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    thermo.rho(),
    rhoBoundaryTypes
);
For some in-solver preprocessing I use mag(grad(rho)) field to locally refine mesh. Then - apply some parts of setFields.C code so that p, T, U files are overwritten using new mesh and new values. The problem is that in-solver fields are not updated. I believe that p and U may simply be updated by re-reading from files with 'p.read()' and 'U.read()'. But how to update T and rho fields? Both 'thermo.correct()' and 'thermo.read()' seem not to do anything in this context.

In the original rhoCentralFoam, thermodynamics is updated via solving density, momentum and energy equations and using thermo.correct():
Code:
(code is simplified for reading)
solve(fvm::ddt(rho) + fvc::div(phi));

solve(fvm::ddt(rhoU) + fvc::div(phiUp));
U = rhoU/rho;

solve(fvm::ddt(rhoE) + fvc::div(phiEp) - fvc::div(sigmaDotU));
e = rhoE/rho - 0.5*magSqr(U);
thermo.correct();
p = rho/psi; //psi is 1/(RT)
So, if I understand that correctly, values are updated by chain: (rho) -> (U using rho) -> (e using rho and U) -> (T using e in thermo.correct) -> (p using rho and T).
Chain i'm trying to implement would be backward: (T) -> (rho).


P.s. The whole thing is needed only to apply setFields to locally refined mesh AND preserve correct refinementHistory for further adaptive mesh refinement. The other way would be to manually preprocess the mesh with setSet and refineMesh, then apply setFields command-line utility. But refineMesh doesn't generate refinementHistory (thus all cells are considered of refineLevel 0 which ruins AMR later). Maybe there is a way to generate refinement history upon preprocessing and the load it into solver upon creating dynamicFvMesh?
OlegSutyrin is offline   Reply With Quote

Old   January 7, 2017, 17:26
Default
  #2
Member
 
Oleg Sutyrin
Join Date: Feb 2016
Location: Russia
Posts: 41
Rep Power: 10
OlegSutyrin is on a distinguished road
Found a workaround that use standalone utility that reads fields (including thermo, like original rhoCentralFoam does), refines mesh once, writes mesh (including refinement history), applies setField and exits. Running this utility several times in a row results in exactly what I need as an initial state for my custom solver: refined mesh, updated field values and refinement history.
OlegSutyrin is offline   Reply With Quote

Old   March 18, 2021, 08:03
Default
  #3
New Member
 
Nicolas Cerulus
Join Date: Oct 2019
Location: Liverpool, United Kingdom
Posts: 4
Rep Power: 7
NCerulus is on a distinguished road
Hi Oleg,

I am currently trying to run rhoCentralDyMFoam with AMR using, like you mag(grad(rho)) as my criteria for refinement however it doesnt seem to work as, mag(grad(rho)) is not an available volScalarField. I've seen methods with creating new solvers etc but was wondering if you knew of an easier work around?

thanks
Nic
NCerulus is offline   Reply With Quote

Old   March 18, 2021, 08:13
Default
  #4
Member
 
Oleg Sutyrin
Join Date: Feb 2016
Location: Russia
Posts: 41
Rep Power: 10
OlegSutyrin is on a distinguished road
Hey NCerulus,
If i remember correctly, there was no easy workaround, so I had to create my custom solver. By the way, it turned out that AMR overhead computational costs were so big (in my case, at least) that using of simple fine even-sized mesh wasn't much slower that AMR mesh.

(edit) Here is, i believe, the latest code of my solver, OF4 version: https://yadi.sk/d/dlOe6YqwXfUNgA
OlegSutyrin is offline   Reply With Quote

Old   March 18, 2021, 10:20
Default
  #5
New Member
 
Nicolas Cerulus
Join Date: Oct 2019
Location: Liverpool, United Kingdom
Posts: 4
Rep Power: 7
NCerulus is on a distinguished road
Hi Again

thank you very much for your source files that helps a lot with my issues. i am going to try and use your solver you provide to see if it has the desired outcome. I have compiled your solver however when i try and run i get an error saying that the rhoCentralGradDyMFoamCoeffs keyword is undefined, which make sense as i have not defined it in my dynamicMeshDict, Attached:

dynamicMeshDict.txt

do you have an example of your dynamicMeshDict so i can understand what needs to be included?

I have been using the following resource to build my dict:
https://openfoamwiki.net/index.php/P...nt_Definitions and it works fine for the usual rhoCentralDyMFoam with OF-6
NCerulus is offline   Reply With Quote

Old   March 18, 2021, 10:29
Default
  #6
Member
 
Oleg Sutyrin
Join Date: Feb 2016
Location: Russia
Posts: 41
Rep Power: 10
OlegSutyrin is on a distinguished road
No, it seems that I haven't saved these dict files... It is possible to get the idea from the source code and reimplement these coeffs, I think.
OlegSutyrin is offline   Reply With Quote

Old   March 18, 2021, 10:41
Default
  #7
New Member
 
Nicolas Cerulus
Join Date: Oct 2019
Location: Liverpool, United Kingdom
Posts: 4
Rep Power: 7
NCerulus is on a distinguished road
No problem,

I will make my way through the source code and see if i can understand it all and will send through the dict once i have it working as well. thanks so much for your help already!
NCerulus is offline   Reply With Quote

Reply


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.org] Patches to compile OpenFOAM 2.2 on Mac OS X gschaider OpenFOAM Installation 136 October 10, 2017 18:25
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 towanda OpenFOAM Community Contributions 6 September 5, 2015 22:03
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 18:18
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44


All times are GMT -4. The time now is 17:21.