CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   how to dump individual components of a vector (https://www.cfd-online.com/Forums/openfoam-solving/115133-how-dump-individual-components-vector.html)

nandiganavishal March 24, 2013 15:57

how to dump individual components of a vector
 
Hello All,

I would like to know if it is possible to get the scalar values of a vector during the course of a simulation. For instance, I would like to dump the individual scalar velocity fields Ux, Uy, Uz, of the velocity vector U on the fly as the simulation runs. I understand that the "foamCalc components U" does this after the simulation is complete. Please let me know if there is any inbuilt utility in OF. I have been trying to implement this for a while now.

Thanks

Regards
Vishal

doubtsincfd March 24, 2013 16:17

Add this somewhere in your solver:

volScalarField Ux
(
IOobject
(
"Ux",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
U.component(vector::X)
);

Same for other two components

doubtsincfd March 24, 2013 16:18

refer the file write.H in the laplacianFoam solver

nandiganavishal March 24, 2013 16:25

Thanks very much, Omkar.

Regards
Vishal

nandiganavishal March 24, 2013 17:58

Hi Omkar,

I am looking to implementing the following Neumann boundary condition for the velocity on the walls of a surface

du/dy = A*E_x, where E_x is the x-compoment of the electric Field which is obtained by solving another PdE and A is a constant.

Now, from your earlier suggestion, I was able to extract E_x at every time step on the fly, I would like to know how to implement the above boundary condition in OF. Please let me know if you have any suggestions.

Thanks

Regards
Vishal

doubtsincfd March 26, 2013 07:57

I have not done this before, but I can say you might have to modify the fixedGradient bc (is du/dy the normal gradient on the surface?)

swak4FOAM might be able to implement this, but I am not sure if groovyBC reads non-standard variables. If groovyBC works, then that's the easiest way.

I can give it a shot over the weekend if you can upload or mail your files.

gschaider March 26, 2013 10:03

Quote:

Originally Posted by doubtsincfd (Post 416494)
I have not done this before, but I can say you might have to modify the fixedGradient bc (is du/dy the normal gradient on the surface?)

swak4FOAM might be able to implement this, but I am not sure if groovyBC reads non-standard variables. If groovyBC works, then that's the easiest way.

I can give it a shot over the weekend if you can upload or mail your files.

Not sure what "non-standard variable" is. If it is a field and it is in memory (groovyBC doesn't read fields from disc - at least that is not the standard-behaviour) then groovyBC can access it by its name

doubtsincfd March 26, 2013 10:26

Thanks, Bernhard. I guess then groovyBC will be able to do it.

By non-standard, I meant field variables that are not present in the standard package of openfoam i.e. user-defined field field variables

gschaider March 26, 2013 12:35

Quote:

Originally Posted by doubtsincfd (Post 416543)
Thanks, Bernhard. I guess then groovyBC will be able to do it.

By non-standard, I meant field variables that are not present in the standard package of openfoam i.e. user-defined field field variables

As long as their name is unique and they are registered with the mesh (it is rather hard NOT to register them) groovyBC should find them

nandiganavishal March 26, 2013 23:21

2 Attachment(s)
Quote:

Originally Posted by doubtsincfd (Post 416494)
I have not done this before, but I can say you might have to modify the fixedGradient bc (is du/dy the normal gradient on the surface?)

swak4FOAM might be able to implement this, but I am not sure if groovyBC reads non-standard variables. If groovyBC works, then that's the easiest way.

I can give it a shot over the weekend if you can upload or mail your files.

Hi Omkar,

"is du/dy the normal gradient on the surface?"

Yes, it is the normal gradient.

Attached please find the source code along with the solver conditions. In the initial guess ("0") folder, I would like to implement the following boundary condition on the DNAupperwall and DNAlower wall (the geometry is given in blockMesh file)for the velocity.

du/dy (normal to the surface) = -Ex*gamma, where gamma = -2.2164

Please let me know, how to implement this.

Thanks a lot for the help.

Regards
Vishal

doubtsincfd April 2, 2013 22:19

1 Attachment(s)
Hello,

Sorry for the late reply. I could achieve what you want by using groovyBC.
You will have to install swak4Foam first though.

Follow these steps:
1. untar
2. run blockMesh and DNAFoam (I have changed the timestep and endtime. Also add the ".so" files entry in controlDict) (ux gradient will be set equal to x-component of electrical field. you can modify the expression as you want)
3. run "wallGradU"
4. run "sample" (check out system/sampleDict) This will write electricField values, and value of wall gradients for the DNAupperwall patch in surfaces folder
5. Check the two values. The must be same (except for the sign)

Let me know if this helps or you need anything otherwise

nandiganavishal April 4, 2013 00:20

Quote:

Originally Posted by doubtsincfd (Post 417955)
Hello,

Sorry for the late reply. I could achieve what you want by using groovyBC.
You will have to install swak4Foam first though.

Follow these steps:
1. untar
2. run blockMesh and DNAFoam (I have changed the timestep and endtime. Also add the ".so" files entry in controlDict) (ux gradient will be set equal to x-component of electrical field. you can modify the expression as you want)
3. run "wallGradU"
4. run "sample" (check out system/sampleDict) This will write electricField values, and value of wall gradients for the DNAupperwall patch in surfaces folder
5. Check the two values. The must be same (except for the sign)

Let me know if this helps or you need anything otherwise


Thanks, very much Omkar. I will have a look and would get back to you soon.

Thanks

Regards
Vishal

nandiganavishal April 17, 2013 01:24

Hi Omkar,

I would like to create the following geometry in openfoam.

A small circular hole is drilled through a block (cuboid in shape). Can you give me a heads up on how to create such a geometry in openfoam.

Thanks

Vishal


All times are GMT -4. The time now is 15:49.