|
[Sponsors] | |||||
|
|
|
#1 | ||
|
Member
Kai
Join Date: May 2010
Location: Stockholm
Posts: 39
Rep Power: 4 ![]() |
I have some problem with creating fields in parallel OpenFoam. For example if i create a fvPatch in createField.H, it seems that I can only create the patch in part of mesh. The code is like,
Code:
//find the patch:
label patchWall=mesh.boundaryMesh().findPatchID("walls");
const fvPatch &thePatchItselfWall=mesh.boundary()[patchWall];
//loop over the patch:
forAll(thePatchItselfWall,faceI)
{
label cellI=thePatchItselfWall.faceCells()[faceI];
Info<<"label="<<cellI<<endl;
SfPerVol[cellI]=mag(mesh.Sf().boundaryField()[patchWall][faceI])/mesh.V()[cellI];
}
Quote:
Quote:
Obviously I can only access part of mesh. So how could I create the fvPatch on the other 3 procs? If done, how could I know I have accessed to the other part of mesh? Does the output "Info<<cellI<<endl;" work? thx // Kai |
|||
|
|
|
|||
|
|
|
#2 |
|
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 364
Rep Power: 9 ![]() |
That's the way parallel works. Each instance uses only 1/4 of the mesh, and solves everything as if that is the entire mesh, except at the interface between the meshes. Information passes between the interfaces using PStream.
|
|
|
|
|
|
|
|
|
#3 |
|
Member
Kim Yusik
Join Date: Dec 2009
Posts: 39
Rep Power: 5 ![]() |
I am raising the same question on 'field handling with a parallel computation'. In my case, I haven't faced any problem with patch handling with a parallel computation. I do not know how does Kai have that problem. What I have done is pretty mush same.
label inletPatchID = mesh.boundaryMesh().findPatchID("inlet"); fvPatchVectorField refField= U.boundaryField()[inletPatchID]; forAll(refField, celli){ // any command } celli showed the same number as the 'inlet' patch has both single and parallel computing. But When I try to manipulate the field within the domain (not a patch on boundary conditions), I recognize that parallel and single computations show different number of cells in the field. code which I use, volVectorField U_= U; scalar i = 0; forAll(U_, facei){ i++; } Info<<"i= "<<i<<nl; with single processor : 'i' shows same number of cell as the domain contains i= 336000 with 4 processors : 'i' shows smaller number then it should i= 84332 To sum up, Could anyone can give a hint on field manipulation with a parallel computation? Thanks in advance. Yusik |
|
|
|
|
|
|
|
|
#4 |
|
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,877
Rep Power: 23 ![]() |
It really depends on the manipulation you are trying to do. In general, as shown in many examples:
1. Try to avoid looping. In many cases it is possible to avoid them by re-thinking the operations you have to do. For example, if you have to define a field using piece-wise function, you can use "pos" and "neg" functions, instead than if and forAll. Example: v = a, if x < b v = c if x > b can be coded as volScalarField v = neg(x - b)*a + pos(x-b)*c; since pos(x) = 1 if x is positive, and 0 if it's negative neg(x) = 1 if x is negative, and 0 if it's positive 2. If you loop over cells, and modify the cell values of a field directly, remember you most likely have to correct the BC for that field after the manipulation. Best,
__________________
Alberto GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as live DVD/USB, hard drive image and virtual image. GeekoCFD 32bit - The 32bit edition of GeekoCFD. GeekoCFD text mode - A smaller version of GeekoCFD, text-mode only, with only OpenFOAM. Available in a variety of virtual formats. |
|
|
|
|
|
|
|
|
#5 |
|
Member
Kim Yusik
Join Date: Dec 2009
Posts: 39
Rep Power: 5 ![]() |
Thanks alberto, I 've managed to manipulate the field. The code I used (it's bit simplified),
forAll(cells, celli){ if( fabs(0.19-xc[celli]) <0.02 ){ jj=(int)( (yc[celli] )/dy ); kk=(int)( (zc[celli]) / dz); U_[celli] = Um_[jj][kk]*vector(1, 0, 0) + vector( u2_[jj][kk], v2_[jj][kk], w2_[jj][kk] ); } } based on pisoFoam, application is a channel flow. intention was, imposing artificial fluctuations(u2_[jj][kk], v2_[jj][kk], _[jj][kk]) at a certain down stream distance of inlet (here x= 0.19). xc[celli], yc[celli] and zc[celli] are pre-defined cell-centre positions of the domain. mean velocity ( Um_[jj][kk]) and artificial fluctuations are generated N by M virtual grid where 0<jj<N and 0<kk<M. dy and dz are unifrom grid distance in the virtual grid. The previouse problem was, I pre-defined the plane (saved cell ID at this specific plane) where the fluctuations are imposed. and try to call these saved cell IDs at each time step. I suspect that these pre-saved cell IDs do not have same orders between single and paralle computations. That's why it didn't work out with the parallel computations. I am not sure whether I make myself clear or not but thank you very much for your great comments. Yusik |
|
|
|
|
|
|
|
|
#6 |
|
Member
Kim Yusik
Join Date: Dec 2009
Posts: 39
Rep Power: 5 ![]() |
Hi, Alberto.
Could you tell me more on the 'correcting boundary condition' from your reply? can you give me a simple example of requried BC corrections following by a field manipulation? In my case, I change cell centre values at one plane in the domain. I do not see a reason for correcting BC in this case. Please correct me, if I am wrong. Regards Yusik |
|
|
|
|
|
|
|
|
#7 |
|
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,877
Rep Power: 23 ![]() |
The reason to update boundary conditions is that the domain decomposition in OpenFOAM considers the interface between different processors as a boundary condition (the processor patch).
If you directly access a field (a forAll loop) to change its values, the processor patches won't be updated automatically. As a consequence, you might want to use correctBoundaryConditions(). Best,
__________________
Alberto GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as live DVD/USB, hard drive image and virtual image. GeekoCFD 32bit - The 32bit edition of GeekoCFD. GeekoCFD text mode - A smaller version of GeekoCFD, text-mode only, with only OpenFOAM. Available in a variety of virtual formats. |
|
|
|
|
|
|
|
|
#8 |
|
Member
Join Date: Jun 2011
Posts: 34
Rep Power: 3 ![]() |
what if a volScalarField is scaled with cmptMultiply function? is correctBoundaryConditions() still necessary?
also does the cmptMultiply function update both internalField() and boundaryField()? |
|
|
|
|
|
|
|
|
#9 |
|
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 677
Rep Power: 12 ![]() |
Just a note...
If you are running a parallel case and using the Info stream to output information, you need to remember that its only done for the main processor. Instead of Info, try using Sout if you want the information printed for every processor. |
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem in the CFX12.1 parallel computation | BalanceChen | ANSYS | 2 | July 7, 2011 10:26 |
| Parallel computation using NUMECA 6.1 | BalanceChen | NUMECA | 1 | June 5, 2011 06:24 |
| load balancing in parallel computation | shyamdsundar | Main CFD Forum | 0 | September 2, 2009 23:53 |
| Why the parallel computation is slow | ztdep | OpenFOAM Running, Solving & CFD | 1 | May 1, 2008 04:55 |
| how to parallel computation | Jane | CD-adapco | 2 | April 28, 2004 06:11 |