Assigning boundary value to every cell above it
Hello,
I'm stuck on something that seems rather trivial so I was hoping maybe somebody could give me a hand... :D I would like to assign the value of friction velocity, utau, AT A WALL (for a given x-coordinate) to every cell above it (i.e: utau(x=i,y=allCells)=utau(x=i,y=0)). My problem is that when I compute utau, I only get values at the boundaries, while the rest of the volScalarField is left as its initialized value (0). When I look at the output in the time step directories and ParaView, I can see that there are utau values for solid boundaries only, not for cell centers... which makes sense given how I defined utau (see below). The question: How can I tell OpenFOAM to assign the value of utau (at the wall) to all of the cells above it at each x-location? Reason for doing this: I am adding a scalar term to the dissipation equation that has utau in it. Since the solver loops through each cell, I need to assign the value of utau (at the wall) to each cell center in the corresponding column. I'm assuming that utau will vary as you move in the x-direction since dUdy will be different. Below are the definitions of utau and my implementation in OpenFOAM. I understand that the code below only gives me utau at the boundaries, I just don't know how to tell it to assign that value to all cells above. I aplogize, for my coding skills aren't the best :( utau = sqrt(tau_wall/rho) = sqrt(mu * dUdy / rho) = sqrt( nu * dUdy) in OpenFOAM: Code:
forAll(utau.boundaryField(), patchi) |
Hi,
You can access the cells next to a patch using faceCells(). Code:
forAll(mesh.boundary()[patchI], faceI) //patchI: label of your target patch Fumiya ------------------------------------------ My slides about OpenFOAM:) (http://www.slideshare.net/fumiyanozaki96) |
Hi Fumiya,
Thank you for replying! I'm still a little confused about what you are suggesting... What do you mean by 'target patch'? Also, how would I assign a single value (utauw at the boundary) to every cell above it so that OpenFOAM doesn't complain about assigning a Foam::Field<double> to a 'double' ? I have looked over some existing code and I'm implementing the following: Code:
I need to somehow store the value produced by Code:
utauw.boundaryField()[patchi] = sqrt |
Hi CHARLES,
You might want to try utau[faceCelli] = utauw.boundaryField()[patchi][facei]; //RHS: utauw value at each boundary face(label: facei) on the boundary(label: patchi) instead of utau[faceCelli] = utauw[patchi]; in your code. Hope this helps, Fumiya |
Fumiya,
I'm sorry but after re-reading my post, I realized that I wasn't very clear. What you suggested allowed the script to compile and run! It also gave the results you had expected: the utauw value (at the boundary) is being assigned to utau (at the cell centers in contact with the boundary). utau is now a nonuniform list, which also solved part of the problem that I was having before. However, what I intended to do was to copy the value of utauw (from the boundary) to ALL cell centers above it, not just the boundary cell centers. I tried to write another forAll loop that would loop through all of utau, which would compile but I get a segmentation fault in the log file on the first iteration. I think I'm trying to assign a boundary's value to a single cell, which may be the cause of the problem. Code:
label PatchID = mesh_.boundaryMesh().findPatchID("plate"); Code:
Starting time loop |
I believe I may have solved the segmentation problem...
However, I still have a few questions about the following part of the program: Code:
forAll(Boundaries, patchi) //loops through boundaries The reason I ask is because the value of utauw that is output to the time directory doesn't change (for a flat plate) but one would expect that the gradient of the velocity would be a function of the streamwise-distance along the plate. When I look at utauw for a different geometry, like a 2D bump, it varies in the time directory output. 2. Why is the following not correct Code:
utau2[faceCelli] = sqrt Code:
SPLRRIP.C: In member function ‘virtual void Foam::incompressible::RASModels::SPLRRIP::correct()’: Code:
utauw.boundaryField()[patchi] = |
All times are GMT -4. The time now is 15:07. |