# Initialization of U by code

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

 October 19, 2009, 08:09 #21 Senior Member   Laurence R. McGlashan Join Date: Mar 2009 Posts: 370 Rep Power: 14 Sorry for the late reply, I've been really busy! I'm not sure why you're getting the behaviour that you observe. Possibly U has gone out of scope or something? The write() function just writes the current U field to the 0/U file. I'd probably need to see it for myself, feel free to post your files in a tarball and I can take a quick look. __________________ Laurence R. McGlashan :: Website

 October 20, 2009, 20:31 #22 Senior Member     Santiago Marquez Damian Join Date: Aug 2009 Location: Santa Fe, Santa Fe, Argentina Posts: 420 Rep Power: 15 Thanks Laurence for your attention even with all your work. Well, this is the code: Code: ```// Velocity field initialization // Angular velocity scalar omega=2000; // Maximum velocity en parabolic profile scalar Vmax=2.0; // Tube radius scalar tubeR=0.05; // Cell centroid coordinates const volVectorField& centres = mesh.C(); // Coordinate system origin point origin(0, 0, 0); // Axis of rotation vector axis(0, 0, 1); // Force arm calculation vectorField palanca; palanca = centres.internalField() - ((centres.internalField()-origin) & axis)*axis; // Parabolic velocity field calculation scalarField zComp=Vmax*(1-sqr(mag(palanca)/tubeR)); // Option with rotation and the parabolic // Rotation U.internalField()=omega*(axis^palanca); // Parabolic in z direction U.internalField().replace(vector::Z,zComp); // Write to /0/U U.write();``` The sequence of includes is that follows: Code: ```# include "createTime.H" # include "createMesh.H" # include "createFields.H" # include "USetUp.H"``` (mine is the last one, added in scalarTransportFoam.C) As you can see, after rewriting in memory the U vector field I call the .write() method to write the field to the hard disk. The problem is that if you run the code once, the initializated U field doesn't remain in memory, i.e. the advection equation is solved with another field, maybe zero, I don't know. But, in the other hand, if you run the code some steps, then stop it and run it again with the /0/U recently written things go well. That's all. Regards. __________________ Santiago MÁRQUEZ DAMIÁN, Ph.D. Post-doctoral Fellow Research Center for Computational Mechanics (CIMEC) - CONICET/FICH-UNL T.E.: 54-342-4511594 Ext. 1005 Güemes 3450 - (3000) Santa Fe Santa Fe - Argentina http://www.cimec.org.ar

 October 21, 2009, 06:00 #23 Senior Member   Laurence R. McGlashan Join Date: Mar 2009 Posts: 370 Rep Power: 14 This worried me slightly, so I took a look, and I think I've figured it out. The scalar transport equation takes phi as the coefficient in fvm::div, not U. So you have overwritten U, but now you have to recreate the flux. So just put Code: `#include "createPhi.H"` below Code: `#include "USetUp.H"` Hope that's the problem. __________________ Laurence R. McGlashan :: Website

 December 11, 2009, 15:09 #24 Senior Member     Santiago Marquez Damian Join Date: Aug 2009 Location: Santa Fe, Santa Fe, Argentina Posts: 420 Rep Power: 15 Laurence, I've been working in another things last months but I've returned to this problem. Your suggestion was right, FOAM was assembling the flux with the original U not with the one calculated by my code. I had to put the Code: `#include "createPhi.H"` below Code: `#include "USetUp.H"` Nevertheless it is necessary to comment the original invocation of createPhi.H file in createFields.H because the Code: `#ifndef createPhi_H` clause within createPhi.H. As you know, this line impedes that definition can be repeated. Regards. __________________ Santiago MÁRQUEZ DAMIÁN, Ph.D. Post-doctoral Fellow Research Center for Computational Mechanics (CIMEC) - CONICET/FICH-UNL T.E.: 54-342-4511594 Ext. 1005 Güemes 3450 - (3000) Santa Fe Santa Fe - Argentina http://www.cimec.org.ar

 December 29, 2013, 17:06 #25 Member   Tony Join Date: Nov 2013 Posts: 35 Rep Power: 4 Dear Santiago, I am struggling with getting a parabolic internal field for pipe flow in openfoam and I've found your post very useful. Could you please give me some hints on the line "U.internalField()=omega*(axis^palanca);" ? Another silly question, where shall I put the code, in 0/U or somewhere else? Do I need to derive my own solver for it? I really appreciate your reply. Thank you very much. Best regards, Tony Last edited by wzx1989221; December 30, 2013 at 08:29.

 January 2, 2014, 20:09 #27 Member   Tony Join Date: Nov 2013 Posts: 35 Rep Power: 4 Hi, Bruno Thank you very much for the information. I will have a look at that and get back to you if I have further questions. Best regards, Tony

 Tags set up fields, vector manipulation

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post David Liu Main CFD Forum 22 June 26, 2012 17:59 edna CD-adapco 0 January 29, 2008 11:56 ma Main CFD Forum 4 January 10, 2005 21:47 John C. Chien Main CFD Forum 19 May 17, 2001 15:56 Juan Carlos GARCIA SALAS Main CFD Forum 39 November 1, 1999 15:34

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