|
[Sponsors] |
February 27, 2014, 07:46 |
Using fvOptions to add a momentum source
|
#1 |
New Member
Wallace Green
Join Date: May 2010
Posts: 19
Rep Power: 15 |
… where the source term depends on the current velocity field. How can I make sure that it converges at each time-step in an unsteady simulation?
I'm using pimpleFoam and I've made a new fvOption which is similar to actuationDiskSource. I understand that it works as follows: Essentially, the class has a public function AddSup where eqn.source() is used to set the source term, where eqn would appear to reference UEqn when the IOOptionList is created by the solver, simple-/pimpleFoam. Using eqn.psi(), the fvOption class also has access to the current velocity, and mesh_ is a reference to the mesh database provided by the base class option. So it's straightforward to make a momentum source term, which depends on the current velocity field, in my case sampled at different points. In pimpleFoam, the UEqn is defined with == fvOptions(U) on the r.h.s., and then the solution loop is passed through. I hope I'm wrong, but from pisoFoam.C, I don't get the impression that fvOptions(U) is called again, (and addSup recalculates the source term based on the intermediate velocity field solution), during each time-step. Perhaps this is a question on how literally to interpret the top-level solver syntax (if you haven't had the time to trace back through everything). I hope I'm not getting terminology wrong here but in Code:
3 tmp<fvVectorMatrix> UEqn 4 ( 5 fvm::ddt(U) 6 + fvm::div(phi, U) 7 + turbulence->divDevReff(U) 8 == 9 fvOptions(U) 10 ); Assuming I'm right so far, my next step would be to modify s-/pimpleFoam to repeat the solution loop at each step. On my first attempt (for simplicity, with simpleFoam) I'm confused by the results: Clearly it's not as simple adding a loop, Code:
for (int i = 0; i < 2; i++){} Code:
59 // --- Pressure-velocity SIMPLE corrector 60 { 61 #include "UEqn.H" 62 #include "pEqn.H" 63 } 64 65 turbulence->correct(); 66 67 runTime.write(); I guess my questions are more implicit than explicit here Basically, I'd be glad if someone "in-the-know" could confirm my understanding of the way the fvOptions are adding source terms. I'm quite confident about that part, but then I'm much less sure how they are being dealt with in the solver. As my simpleFoam loop test didn't do what I expected, I'm unsure of how to make a time-step inner loop in pimpleFoam to converge the source term. |
|
April 16, 2015, 14:20 |
momentum source term in pimpleFoam, pimpleDyMFoam
|
#3 |
Member
Pruthvi
Join Date: Feb 2014
Posts: 41
Rep Power: 12 |
Hell everybody,
I'm working on a similar problem, trying to implement a solver in the non-inertial frame for a flapping airfoil study. I haven't tried using fvOptions but I explicitly added the body force term on the RHS of Ueqn. However I'm not confident that my implementation is correct. Here is a thread about it. Can you guys check it out and give your opinion on this issue? Thanks, Pruthvi. |
|
November 18, 2015, 04:48 |
Still issues about fvOptions...
|
#4 |
Member
Peter
Join Date: Nov 2015
Location: Hamburg, Germany
Posts: 57
Rep Power: 10 |
I would like to add a user-defined momentum source term to the Navier-Stokes equations.
The source depends on the actual flow field, it should be used in the solvers simpleFoam, pimpleFoam, ... and for OF 3.0.0 (or 2.4.0). I suppose, a reasonable approach would be the use of a 'fvOptions'-dictionary file with the 'vectorCodedSource'-type. Do you think, this is the best solution? If yes, where do I find information on how to write this 'fvOptions'-file? The OF-tutorials provide no help for this source type. |
|
November 18, 2015, 07:21 |
|
#5 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
||
November 18, 2015, 09:00 |
|
#6 |
Member
Peter
Join Date: Nov 2015
Location: Hamburg, Germany
Posts: 57
Rep Power: 10 |
Thanks for your fast answer! Unfortunately, Google had not helped me.
http://www.sourceflux.de/blog/adding...ons-fvoptions/ -> deals only with specific 'MRFSource'-option and gives no further information on a 'codedSource'-type option, http://www.sourceflux.de/blog/softwa...ign-fvoptions/ -> is the subsequent post and deals only with the modification of a special solver. My problem concerns still the 'vectorCodedSource'-type, especially the formulation of the 'code...'-parameters, or more exact the definition of the momentum source term. Here is my actual 'fvOptions'-file: Code:
FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // momentumSource { type vectorCodedSource; active on; vectorCodedSourceCoeffs { fieldNames (U); // ?? selectionMode cellZone; //cellSet;//cellZone; ?? cellZone sourceBox; redirectType sourceTime; //velocitySource; //none; codeInclude #{ #}; codeCorrect #{ Pout<< "**codeCorrect**" << endl; #}; codeAddSup #{ vectorField& USource = eqn.source(); USource = (1 1 1); // Definition of the user-defined momentum source term #}; codeSetValue #{ Pout<< "**codeSetValue**" << endl; #}; // Dummy entry. Make dependent on above to trigger recompilation code #{ $codeInclude $codeCorrect $codeAddSup $codeSetValue #}; } sourceTimeCoeffs { // Dummy entry } } - fieldNames - redirectType are defined correctly. Regards, Peter |
|
November 18, 2015, 09:51 |
|
#7 |
Senior Member
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13 |
If you're looking to add the source to the velocity field, you have the fieldNames entry correct. I'm not sure what redirectType means. The documentation is usually in the header files, but there is no explanation for that entry: https://github.com/OpenFOAM/OpenFOAM.../CodedSource.H
|
|
December 8, 2015, 04:22 |
Still no source term...
|
#8 |
Member
Peter
Join Date: Nov 2015
Location: Hamburg, Germany
Posts: 57
Rep Power: 10 |
Dear Foamers,
first: thanks Pete! Unfortunately, I still cannot introduce a momentum source into OF. And both google and the source code seem to be no help. At first, I would be quite happy to introduce a constant momentum source like e.g. (1 1 1). I think the Code:
codeAddSup{} This is my 'fvOptions'-file: (I use OF 2.4.0 or 3.0.0.) Code:
FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * momentumSource { type vectorCodedSource; active on; // true; vectorCodedSourceCoeffs { fieldNames (U); selectionMode cellZone; cellZone sourceBox; redirectType none; // redirectType velocitySource; // redirectType sourceTime; // redirectType ramp; codeInclude #{ #}; codeCorrect #{ Pout<< "**codeCorrect**" << endl; #}; codeAddSup #{ ....... // ### Momentum Source ### Pout << "***codeAddSup***" << endl; #}; codeSetValue #{ Pout<< "**codeSetValue**" << endl; #}; // Dummy entry #{ // $codeInclude // $codeCorrect $codeAddSup // $codeSetValue #}; } // sourceTimeCoeffs noneCoeffs { // Dummy entry } } Code:
vectorField& Usource = eqn.source(); Usource += vector(10000, 0, 0); and Code:
volVectorField& Usource = eqn.source(); Usource = (10000 0 0); I cannot solve this tiny nasty problem! And would be really glad for some help! |
|
December 8, 2015, 08:31 |
|
#9 |
Senior Member
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13 |
Well your second version doesn't work because you are trying to set a volVectorField& to a scalar. The first version looks like it should work. You should check that your cellZone is created properly by reading the topoSet log or inspecting in ParaView. Note that the newest version of the momentum sources in OpenFOAM use cellSets rather than cellZones. You could also try selecting all cells to make sure the source is being added.
|
|
December 9, 2015, 10:41 |
|
#10 |
Member
Peter
Join Date: Nov 2015
Location: Hamburg, Germany
Posts: 57
Rep Power: 10 |
Thanks again, Pete!
You were right, I did a mistake in 'topoSet'. So the upper code snippet works. Thanks a lot! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error | FerdiFuchs | OpenFOAM Community Contributions | 27 | April 16, 2014 15:14 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 10:57 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 19:08 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 01:24 |
no enthalpy change across the momentum source | Atit Koonsrisuk | CFX | 2 | December 19, 2005 02:33 |