CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Forces caused by fluids (https://www.cfd-online.com/Forums/openfoam-solving/60227-forces-caused-fluids.html)

 anja April 21, 2006 09:13

Hi, is there a possibility

Hi,

is there a possibility to output the forces a fluid causes on certain walls?

Thanks
Anja

 anja April 24, 2006 05:39

Hi again, or can someone ju

Hi again,

or can someone just tell me, whether this option exists at all??

Anja

 eugene April 24, 2006 05:47

The posibility doesn't exist a

The posibility doesn't exist as an option, but it is a very simple operation to code. See the lift/drag utility for example.

 anja April 24, 2006 06:30

Sorry, but I can't find this u

Sorry, but I can't find this utility? Where is it supposed to be?

Anja

 gschaider April 24, 2006 07:20

It's missing from the 1.3 dist

It's missing from the 1.3 distribution (and the folder src/postProcessing that contains the real calculation is missing, too).

Is this by mistake or by design?

 eugene April 24, 2006 07:22

Hmm, my mistake. This code

Hmm, my mistake.

This code should do the trick though:

pressureForce = vector::zero;
viscousForce = vector::zero;

forAll(patchNames, i)
{
label patchI = mesh.boundaryMesh().findPatchID(patchNames[i]);

if (patchI != -1)
{
vectorField pf =
p.boundaryField()[patchI]
*mesh.Sf().boundaryField()[patchI];

pressureForce += gSum(pf);

vectorField vf =
-mu.boundaryField()[patchI]
*mesh.magSf().boundaryField()[patchI];

viscousForce += gSum(vf);
}
else
{
pressureForce += gSum(vectorField(0));
viscousForce += gSum(vectorField(0));
}
}

where patchNames are the names of the boundaries you wish to sum forces for and mu is an effective viscosity field (laminar + turbulent).

 anja April 24, 2006 08:14

Hi Eugene, some more questi

Hi Eugene,

some more questions:
- where do I get the mu field from?
- do I have to change the code for a compressible fluid?
- where do I have to write the code?
- how can I actually use it?

Thanks alot
Anja

 anja May 3, 2006 13:19

Hi all, maybe someone else

Hi all,

maybe someone else can answer my questions?

Moreover I do not know how to write the header, I mean which functions to call.

Thanks
Anja

 msrinath80 May 3, 2006 16:22

Hi Anja, I am currently try

Hi Anja,

I am currently trying to follow instructions given by another user. I have moved back to the 1.2 version. I have no choice. I will give it an try and if everything works fine, I will post the source code and the instructions to get it working. Hope that is fine?

 anja May 4, 2006 04:54

Hi you, that would be great

Hi you,

that would be great. Thanks.

And maybe you also have an answer to that problem:
I want to multiply the pressure of each face of one patch by it's area, something like p*A (for each face). But how to get A. In te program above it is:
p.boundaryField()[patchI]
*mesh.Sf().boundaryField()[patchI];
I don't how the size of the area is connected with the surface vector.

Anja

 hjasak May 4, 2006 05:06

The magnitude of the face area

The magnitude of the face area vector is equal to the area. If you don't want the vector, try mesh.magSf(). Quoting from fvMesh.H:

//- Return cell face area magnitudes
const surfaceScalarField& magSf() const;

Hrv

 anja May 4, 2006 07:39

Hi pUI, could you please fo

Hi pUI,

could you please forward me the instructions from the other user? or do you already have any news? I really need some hints!

Anja

 msrinath80 May 4, 2006 12:48

Working on it. Will get back t

Working on it. Will get back to you in a few hours (hopefully).

 anja May 5, 2006 07:01

Hi all, concerning the lift

Hi all,

concerning the liftDrag utility.
I can find the following chapter there:

vector Uav = vector::zero;
forAll(U.boundaryField(), patchI)
{
if (U.boundaryField()[patchI].fixesValue())
{
Uav += average(U.boundaryField()[patchI]);
}
}

Why does that not work for p? I tried to compile the changed file and got this error message:

liftDrag2.C:111: error: no match for 'operator+=' in 'pav += Foam::average [with Type = Foam::scalar](((const Foam::UList<foam::scalar>&)((const Foam::UList<foam::scalar>*)(&(+(+ p. Foam::GeometricField<type,>::boundaryField [with Type = Foam::scalar, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]())->Foam::GeometricField<foam::scalar,>::GeometricBou ndaryField:: <anonymous>.Foam::FieldField<foam::fvpatchfield,>: :<anonymous>.Foam::PtrList<t>: :operator[] [with T = Foam::fvPatchField<foam::scalar>](patchI))->Foam::fvPatchField<foam::scalar>::<a nonymous>.Foam::Field<foam::scalar>::<anonymous>.F oam::List<foam::scalar>::<anon ymous>))))'

Anja

 hjasak May 5, 2006 07:57

Hi Anja, I really appreciat

Hi Anja,

I really appreciate the effort you are putting in and the above should work for p with no trouble. I have written the following piece of code which works for me with no trouble - please compare with your stuff and tell me what's the difference:

volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
mesh
);

scalar pav = 0.0;
forAll(p.boundaryField(), patchI)
{
if (p.boundaryField()[patchI].fixesValue())
{
pav += average(p.boundaryField()[patchI]);

}
}

Hrv

 anja May 8, 2006 04:58

Hi Hrvoje, thanks for the ans

Hi Hrvoje,
thanks for the answer. Yes I can compile this part, but unfortunately the result is p=0 (at each time step).

Where do I define which patch is to be calculated within the liftDrag utility?

Anja

 hjasak May 8, 2006 05:37

That would be because of the

That would be because of the if (p.boundaryField()[patchI].fixesValue()) bit.

If you want to do a specific patch, do the findPatchID trick - beware, if there's no such patch, the index returned will be -1.

You can do something like:

label fixedPatchID=aMesh().boundary().findPatchID(myPatc hName);

if (fixedPatchID != -1)
{
mesh.boundaryMesh()[fixedPatchID];

}

In liftDrag, the force will be calculated for all patches of the wall type:

forAll(patches, patchI)
{
if (isType<wallfvpatch>(patches[patchI]))
{

Hope this helps,

Hrv

 anja May 8, 2006 05:53

Hi,

This time I tried:
scalar pav = 0.0;
label fixedPatchID=aMesh().boundary().findPatchID("inlet ");
if (fixedPatchID != -1)
{
forAll(p.boundaryField(), patchI)
{
if (p.boundaryField()[patchI].fixesValue())
{
pav += average(p.boundaryField()[patchI]);
}
}
mesh.boundaryMesh()[fixedPatchID];
}

Error:'aMesh' was not declared in this scope

Moreover I want to come back to the Uavg I have posted before. It does not calculate an average inlet velocity?!

Anja

 hjasak May 8, 2006 06:14

Sorry, my mistake: use mesh in

Sorry, my mistake: use mesh instead of amesh().

The Uav will sum up the values for all patches that fix the value, which will probably be inlet and all the walls.

Hrv

 anja May 8, 2006 06:16

Hi, it "works" with: label

Hi,
it "works" with:
label fixedPatchID = mesh.boundaryMesh().findPatchID("inlet");

But what I got when I use it for one of my cases is:
Time = 50