CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Options for setFields (https://www.cfd-online.com/Forums/openfoam-pre-processing/90961-options-setfields.html)

Hisham July 26, 2011 17:16

Options for setFields
 
Hi all,

I need to define a setFieldsDict for a non-box region.

I am aware of swak4Foam and funkySetFields. However, I do not need all that sophistications. Is it possible to define parts (blocks) of the mesh for a zoneToCell instead of a boxToCell (just like the definition of porous media)? If yes, how can I do it? I need some descriptions .... like how to define the zones? (e.g. How to name the zone files?) How to add the zones in the setFieldsDict?

Best regards,
Hisham

gschaider July 27, 2011 12:13

Quote:

Originally Posted by Hisham (Post 317609)
I need to define a setFieldsDict for a non-box region.

I am aware of swak4Foam and funkySetFields. However, I do not need all that sophistications.

Well. I don't need the rasp on my pocket knife all the time, but should I ever get locked up then I don't have to ask the guard for one ;)

But suite yourself

Quote:

Originally Posted by Hisham (Post 317609)
Is it possible to define parts (blocks) of the mesh for a zoneToCell instead of a boxToCell (just like the definition of porous media)? If yes, how can I do it? I need some descriptions .... like how to define the zones? (e.g. How to name the zone files?) How to add the zones in the setFieldsDict?

Replace "boxToCell" with a topoSetSource-name that surly doesn't exist ("Hisham" for instance). setFields will fail with a list of existing topoSetSources. Pick one that looks right for you (preferably with ToCell in the name). The next run OF will ask you for the missing parameters. With a little bit of common sense its possible to guess the meaning of those

Bernhard

Hisham July 27, 2011 15:52

Hi Bernhard,

Thanks a lot for your response. You are great ... so as swak4Foam .. :)

It is just that I needed to do that thing quickly with the bread knife ...

I will use funkySetFields after all but I did not invest enough time in learning it until now and the task seemed easy enough for setFields ... But I guess it is a good chance to start learning it.

Thanks a lot for your great contributions!
I will try your idea (it seems like the way to go with OF)

Best regards,
Hisham

Hisham July 27, 2011 17:43

setFields zoneToCell (applications of setFields to mesh blocks)
 
I got it. I post here for future readers.

1. In the blockMeshDict, define the cellZone names for required blocks:
e.g. (from the damBreak example)

blocks
(
hex (0 1 5 4 12 13 17 16) cellZoneName (23 8 1) simpleGrading (1 1 1)
hex (2 3 7 6 14 15 19 18) (19 8 1) simpleGrading (1 1 1)
hex (4 5 9 8 16 17 21 20) (23 42 1) simpleGrading (1 1 1)
hex (5 6 10 9 17 18 22 21) cellZoneName (4 42 1) simpleGrading (1 1 1)
hex (6 7 11 10 18 19 23 22) (19 42 1) simpleGrading (1 1 1)
);


2. In the setFieldsDict,

defaultFieldValues
(
volScalarFieldValue alpha1 0
);

regions
(
zoneToCell
{
name "cellZoneName";
fieldValues
(
volScalarFieldValue alpha1 1
);
}
);

Pallav September 21, 2011 19:03

running the damBreak tutorial after using makeAxialMesh utility
 
Hello Hisham and Bernhard,

I am working on a modified damBreak case (http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2007/HassanHemida/Hassan_Hemida_VOF.pdf) to study the free surface tracking.

I wanted to make the case axisymmetric; so I modified the mesh using blockMeshDict and then used setFields to assign alpha1 values.

I then used the makeAxialMesh utility, followed by collapseEdges, to make the case axisymmetric.

I also added the new patches to p_rgh, U, alpha1 files.

Then I run decomposePar. However, at this point, I get an error saying that "keyword frontAndBack_pos is not defined in 0/alpha1::boundary" (which makes sense because after I use setFields, the contents of alpha1 file change to numbers 1 or 0 )

Please let me know if you have any ideas to solve this problem.

Thanks and regards.

Pallav

Hisham September 22, 2011 00:50

Hi Pallav,

It would be a good idea to compress your case into a single file and attach it to your post. A full copy paste of your error message (use the quote tags from the toolbar) also makes things easier. By doing that it is easier for others to give ideas on what may be wrong!

Also, starting a new post would be a good idea, in case there is no post that is not about the same problem (e.g. the same error message).

Back to your problem: Does it run without decomposePar?

Best regards,
Hisham

Hisham September 22, 2011 04:55

I imagine you need to run the setFields after you change the mesh.... not before.

gschaider September 22, 2011 05:29

Quote:

Originally Posted by Pallav (Post 325141)
Hello Hisham and Bernhard,

I am working on a modified damBreak case (http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2007/HassanHemida/Hassan_Hemida_VOF.pdf) to study the free surface tracking.

I wanted to make the case axisymmetric; so I modified the mesh using blockMeshDict and then used setFields to assign alpha1 values.

I then used the makeAxialMesh utility, followed by collapseEdges, to make the case axisymmetric.

I also added the new patches to p_rgh, U, alpha1 files.

Then I run decomposePar. However, at this point, I get an error saying that "keyword frontAndBack_pos is not defined in 0/alpha1::boundary" (which makes sense because after I use setFields, the contents of alpha1 file change to numbers 1 or 0 )

Please let me know if you have any ideas to solve this problem.

Thanks and regards.

Pallav

If he asks for these boundary conditions then give them to him. Either by editing them by hand or by adding a scipt like pyFoamCreateBoundaryPatches.py

Pallav September 23, 2011 01:56

Quote:

Originally Posted by Hisham (Post 325186)
I imagine you need to run the setFields after you change the mesh.... not before.

Thanks a lot Hisham. This did it.

Goutam February 20, 2012 11:59

SetFields
 
Dear friends

For the HeatTransfer->buoyantBoussinsqSimpleFoam->HotRoom problem:
I wrote

1. In the blockMeshDict:

blocks
(
hex (0 1 2 3 4 5 6 7) cellZoneName (20 20 20) simpleGrading (1 1 1)
);

2. In the setFieldsDict,

defaultFieldValues
(
volScalarFieldValue alphat 0
);

regions
(
zoneToCell
{
name "cellZoneName";
fieldValues
(
volScalarFieldValue alphat 1
);
}

But its not working, could you help me?

Hisham February 20, 2012 12:54

Hi Goutam

It is easier to help if you post the error message generated by OF.

In the case you outlined, it is easier to assign a uniform internal field value for alphat in its file in the 0 directory (for the whole domain is a single zone)

I have introduced the editions you wrote and it worked fine. It is highly probable that you need to copy the T.org file to a T file in the 0 directory:

Code:

:~/openfoam210/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/0$ cp T.org T
Best regards,
Hisham

Goutam February 21, 2012 05:34

Dear Hisham,

Thanks for your reply. I have copied T.org to T before I run the problem. I did this. When I run setFields, I got the following massage:

FOAM Warning:

From function zoneToFace:: combine (topoSet&, const bool) in file sets/faceSources/zoneToFace/zoneToFace.C at line 86.

Cannot find any faceZone named cellZoneName

Valid names are
0
(
)
Setting patchField values of volScalarField alphat

End

What I will do, can you please help me? I am trying to solve this for the last 7 days.
Can I send you my files? I set the model for laminar instead of turbulent and I did the changes that required. Only, setFields option are not working when I use cellZoneName.

Hisham February 21, 2012 05:42

From the error message, it seems that the problem lies in the zoneToFace assignment in the setFieldsDict.

Please zip the case up in one file and attach it to a reply!

or maybe paste the setFieldsDict file in your reply

Hisham

Goutam February 21, 2012 06:28

Hot Room laminar case
 
1 Attachment(s)
Dear Hisham

Please see the attached zip file.

Thanks

Goutam

Hisham February 21, 2012 06:49

I'm not sure what you want to do exactly. But the error is generated because you provide a zoneToCell data to a zoneToFace keyword. So you either have to change the line number 25 of the setFieldsDict to "zoneToCell" instead of "zoneToFace" or else provide valid data to the zoneToFace function

Goutam February 21, 2012 07:05

Quote:

Originally Posted by Hisham (Post 345507)
I'm not sure what you want to do exactly. But the error is generated because you provide a zoneToCell data to a zoneToFace keyword. So you either have to change the line number 25 of the setFieldsDict to "zoneToCell" instead of "zoneToFace" or else provide valid data to the zoneToFace function

Dear Hisham,

Firstly, I want to use bouyant force for the laminar case for 3D geometry. I found that this is the nearest solver to do this. Before, I used icoFoam solver for p, U and T, but for buoyant force, its not working.

When I consider a pipe flow problem, then the setFields command is not working. I did meshing in Fluent and I use fluentMeshToFoam file.msh command. After that I checked the meshing by checkMesh command. its fine.

Regards

Goutam

Hisham February 21, 2012 07:13

The error messages from OF are very helpful ... just read them carefully to figure out your next step

Good luck with your work :)

Goutam February 21, 2012 07:18

Quote:

Originally Posted by Hisham (Post 345510)
The error messages from OF are very helpful ... just read them carefully to figure out your next step

Good luck with your work :)

Dear Hisham

Thanks for your kind help.

fengjq January 28, 2014 09:37

Options for setFields
 
I like the "zoneToCell" option, better than the "boxToCell" one. Can we use the "zoneToCell" option for the wedge cells in an axisymmetric case?

viraj20feb March 24, 2018 21:22

setFields for multiple components of a phase
 
Hello everyone,

I am using reactingTwoPhaseEulerFoam for two multicomponent phases analysis. I want to use interfaceCompositionPhaseChangePhaseSystem utility in OpenFOAM to take care of one of the components of a phase.

My geometry is a cylindrical vessel. I want to set the volume fraction in such a way that the bottom 45% part of the vessel contains 60% volume fraction of component A of phase 1 and 1% volume fraction of component B of phase 1 and the rest 39% in the bottom 45% fill volume of the vessel is all phase 2. The upper 55% is 100% phase 2.

What I was thinking is define the entire internal field with for the entire volume of the cylinder with 60% component A of phase 1, 1% of component B of phase 1 and 39% of phase 2. Then I am trying to use setFieldsDict for the above 55% volume to be 100% phase 2 so that it deletes the above mentioned combination for the above 55% of the vessel and replaces it entirely with phase 2.

But this doesn't work! Can anyone please help me with this?

Thanks
Viraj


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