Output of velocity gradients
Dear Foamers,
I am quite new to OpenFOAM and try to modify one solver to write the velocity gradients as output. The solver used is interDynMFoam. I started to add divergence of U as output as follows, and this is working good (green in code below) The next step was to add the velocity gradients output, as you seen in red in code below. First problem was, that I cant use muEff * (grad U+ gradU.T()) with an error, that it is not the same dimension. So I skipped it, as you can see in code below to think about later... any help is appreciated here. The second problem is, that it is able to compile now, and even able to run after adding it fvSolution and to 0/gradU and 0/tau, however, no output is written at all. The files 1/gradU and 1/tau are the same asa in 0/. Can anybody help with that? Or is there any other, even more simple possibility to get the velocity gradients in a interFoam solver? UEqn.H added: Code:
surfaceScalarField muEff Code:
-------------------snip/snap------------------------- Code:
-------------------snip/snap------------------------- |
Hallo Soeren,
I want to know why do you want to calculate the gradients of velocity and write them? I actually have an idea, I think you might also be trying to do the same. I want to do adaptive mesh refinement on the basis of velocity gradients. It would be really helpful for me if I could calculate the velocity gradients some how in each timestep I would then be able to do the adaptive mesh refinement. Tell me if you have the same idea. Regards, Awais Ali |
Dear Awais ,
I manage to write the gradients since some weeks... We are working in the field of biotech, and using CFD to optimize and/or develop bioreactors in which cells growth, which are quite sensitive to any stress. So, we would like to use the gradients to caculate shear strain and normal strain... However, we know, that these values (shear strain, vel gradients, ...) are quite much dependent on the size of the mesh... so we should be able to compare just same cases with different working parameters, e.g. stirrer speed... Later on, we would like to compare between different reactor sizes, which means different meshes, too. Therefore, we would need to adapt the mesh until the change in the gradients is small enough... If you could help me with adapting the mesh, I would much appreciate... Here the changes in the solver, I use interDyMFoam: file interDyMFoam.C Code:
. file shear.H Code:
volScalarField mu Code:
. Hope this helps, dont hesitate to ask again... If anybody finds this is really not good, please inform me, since this is my own hacking, and I did it the first time with OF... thanks Best, Sören |
Thanks for your reply Soeren,
Well if you are using interDyMFoam you must have seen the dambreak tutorial. My idea is that if you want to refine on the basis of strain and as you are able to write the strain at every step. You just need to redefine the dynamicMeshdict. Instead of alpha1 you need to refine on the basis of mag or gradients or strain. If hope this helps you and best of luck to you. But I have one problem. The solver that I have modiefied according to the information that you have provided asks me to provide a file for magnitude of gradients of U. And even if I provide a file it somehow is writing the same file every time step again. If you can suggest me something which could help me. Regards, Awais Ali |
Quote:
I'll keep you posted on any developments from my side... |
Quote:
Quote:
First, you have to provide the file because there is a Code:
IOobject::MUST_READ, //is read, needs to be in folder 0 Try to change it to NO_READ or something similar, I do not know the right keyword, so I just provided a file... And here the error may be caused: gradU is a volTensorField. So, in createFields it must be defined as volTensorField - and so it must be defined in 0/gradU: Code:
. Hope this helps, Sören |
Dear Sören,
//-------------------------------------------------------------------------------------------------------------------- D = alpha1*(gradU+gradU.T()); // needs to be declared in createFields.H Tau = alpha1 * mu * (gradU+gradU.T()); // Strain = alpha1 * pow(2,0.5) * mag(symm(fvc::grad(U))); // TauStrain= mu * Strain; I have a question. In the above code what does the "symm" function do or why are you using it. Does it make any difference if I calculate the gradients without using the symm function. Regards, Awais |
Quote:
|
Extract div(phi, U) tensor
Good day everyone
I am using OpenFOAM to assess a hydraulic structure which is designed to operate at critical condition (Fr=1). Previously I had assessed this structure using two commercial 2D FVM model, however the results were not acceptable. As a result I have created a 3D interFoam model of the structure and are aiming to prove that OpenFOAM is a suitable tool for designers. I need to determine the influence, if any, of the cross momentum terms from the convective velocity field, div (phi, U). The terms I am particularly interested in are: x-direction: u.du/dx + v.du/dy + w.du/dz y-direction: u.dv/dx + v.dv/dy + w.dv/dz z-direction: u.dw/dx + v.dw/dy + w.dw/dz (at this stage I am not interested in the RAS or LES stresses) I have not found anyway (in the forum or other references) to write this tensor out from the model. However, it appears that there is a way to extract these components from the model and your post provides some directions on how to do this. Could someone provide some direction on how this could be achieved in my case, please include file / dictionary names that may need to be amended. I have been using OpenFOAM for around a year but still have limited confidence when it comes to manipulation of source files therefore any assistance will be greatly appreciated - hopefully I can return the favour one day. Regards JFM |
You should use something like this in a seperate file:
-----------grad.H-------------------------- volScalarField X=U.component(0); volScalarField Y=U.component(1); volScalarField Z=U.component(2); volScalarField XX=gradU.component(0); volScalarField YY=gradU.component(4); volScalarField ZZ=gradU.component(8); volScalarField XY=gradU.component(1); volScalarField YZ=gradU.component(5); volScalarField ZX=gradU.component(6); volScalarField YX=gradU.component(3); volScalarField ZY=gradU.component(7); volScalarField XZ=gradU.component(2); Variable = X*XX + ... Include it in the solver, dont forget to create the fields in createFields.H... Just see my previous post... Then you will be able to write it during the calculation. It would be much easier and more comfortable if you calculate this solution after the simulation is done... There are a couple of tools which could be the basis, need to be changed and recompiled too... Best, Sören |
Hi:
I just use this code Code:
volTensorField graU = fvc::grad(UMean); Code:
scalarField graUyValues(channelIndexing.collapse(graUy)); |
Quote:
Can someone explain what gradU.T() means? Why here gradU+gradU.T(), but not just gradU? As I understand we want to get gradient field of U here. |
Quote:
|
I use the same code to calculate velocity gradients of the field in my case, but I get 0 gradients, which seems like the 0 file for gradU is being duplicated. Even with a NO_READ condition, I get 0 gradients. ANy idea as to why fvc::grad(U) outputs 0 gradient ?
|
All times are GMT -4. The time now is 17:47. |