|
[Sponsors] |
Add different source term in diffusion equation at each time step |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 7, 2018, 07:44 |
Add different source term in diffusion equation at each time step
|
#1 |
Member
Lewis
Join Date: Jun 2016
Posts: 34
Rep Power: 10 |
Dear Foamers,
I'm recently working on adding a series of source term into my governing equation in sovler B, which is a normal form of diffusion equation. More specifically, the source term calculated by another OF solver A. And the computational domain in both solver A and B are kept the same. It means that, at one time step, the solver B solve the diffusion equation by adding the corresponding time step result solved by solver A as a source term. In other words, the source term will re-load into the solver at each time step. So far, I'm sill looking for a way to do so. And I search on the CFD forum, some of people advised applying the fvOptions function or "udf.h" as introduced as below: reading in a field into fvOptions with type: scalarCodedSource Read txt file and import values to source term. But it still confuses me a lot. Could anyone help out of this problem? Thanks in advance! Regards, Lewis |
|
June 7, 2018, 11:10 |
|
#2 |
New Member
JPeternel
Join Date: Oct 2014
Posts: 19
Rep Power: 12 |
I do not know for any build in solutions for such a thing ... The udf.h example is not for OpenFOAM, this way custom functions are passed to solver in Ansys FLUENT program. And the other code snippet you pinned is a modification done to C++ source code of one of OpenFOAM solvers. It is a nice solution, if your source is time-independent.
Note that in openFoam, modifications are usually possible by modifying the source code of selected solver and compiling it under a different name, so basically rewriting the program. Assuming, you would want to program the thing in C++ and compile your own solver, here are some suggestions: You can load fields in same way as they are initialized in createFields.H, just put the code for e.g. myScalarField initializiation inside the main loop. When you run the solver B over the case result files of solver A, this will read myScalarField in each of solver A result files. But, this is like a post-process activity, that executes only at times solver A had written. However, this may become tricky if you want to run solver B as normal solver (with some timesteps in between write times). Your solver A results (along with myScalarField) are not written at every time step ... some how, you would need to catch same write times in solver B as in solver A, write results of B, load myScalarField from time directory written by solver A and then assume that it doesnt change till the next write time of solver A ... Sounds complicated. My suggestion, build a solver that incorporates solver A and solver B sequentially. This way you can share data easilly and calculate the whole thing in one throw. |
|
|
|
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 |
what is swap4foam ?? | AB08 | OpenFOAM | 28 | February 2, 2016 02:22 |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 16:33 |
dynamic Mesh is faster than MRF???? | sharonyue | OpenFOAM Running, Solving & CFD | 14 | August 26, 2013 08:47 |
plot over time | fferroni | OpenFOAM Post-Processing | 7 | June 8, 2012 08:56 |