CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   how can use a property at a point in groovyBC? (http://www.cfd-online.com/Forums/openfoam-solving/112177-how-can-use-property-point-groovybc.html)

immortality January 23, 2013 07:44

how can use a property at a point in groovyBC?
 
i want to use value of pressure at a point to set a boundary condition.more clear i need to set a p0,T0 boundary condition when shock is reached at the end of the channel.what command shouldp i use at fractionExpression?

gschaider January 23, 2013 09:32

Quote:

Originally Posted by immortality (Post 403527)
i want to use value of pressure at a point to set a boundary condition.more clear i need to set a p0,T0 boundary condition when shock is reached at the end of the channel.what command shouldp i use at fractionExpression?

You've got to use a "remote" variable (that can be calculated on sampled sets or patches. Your post does not make clear what you mean with "point"). The usage is described in my presentation from the 6th workshop (see the swak-page) and there are several examples in the swak4Foam-distribution

startingWithCFD April 3, 2013 07:28

Hello, I have more or less the same problem.
I would like to set the pressure on a patch equal to a fraction of the pressure in a specific point inside the domain.
So far I was not able to finish the job just by looking at the fillingTheDam example.
Below is what I have done so far.

file 0/p:

Code:

myPatch
{
  type            groovyBC;
  value          uniform 10000;
  valueExpression "pinside/2.";
  storedVariables
  (
    {
      name pinside;
      initialValue "10000";
    }
  );
  variables
  (
    "pupstream=p;"
  );
}

file system/controlDict:

Code:

functions
(
  defineInsidePoint
  {
    type createSampledSet;
    outputControl timeStep;
    outputInterval 1;
    setName insidePoint;
    set
    {
      type cloud;
      axis x;
      points
      (
        (1. 0. 0.)
      );
    }
  }

...

);

Could you please let me know how I can connect these two?

gschaider April 3, 2013 07:58

Quote:

Originally Posted by startingWithCFD (Post 418067)
Hello, I have more or less the same problem.
I would like to set the pressure on a patch equal to a fraction of the pressure in a specific point inside the domain.
So far I was not able to finish the job just by looking at the fillingTheDam example.
Below is what I have done so far.

file 0/p:

Code:

myPatch
{
  type            groovyBC;
  value          uniform 10000;
  valueExpression "pinside/2.";
  storedVariables
  (
    {
      name pinside;
      initialValue "10000";
    }
  );
  variables
  (
    "pupstream=p;"
  );
}

file system/controlDict:

Code:

functions
(
  defineInsidePoint
  {
    type createSampledSet;
    outputControl timeStep;
    outputInterval 1;
    setName insidePoint;
    set
    {
      type cloud;
      axis x;
      points
      (
        (1. 0. 0.)
      );
    }
  }

...

);

Could you please let me know how I can connect these two?

A variable like
Code:

pInside{set'insidePoint}=average(p);
would get p at the set insidePoint and put it into pInside (just the way it is shown in that example. The storedVariable-business there is just so that the inlet doesn't switch back once it has been switched. Depends on your application whether you need such a thing)

startingWithCFD April 3, 2013 09:30

First of all thanks a lot for your answer, it was very helpful.
I have changed the pressure file as follows:

Code:

myPatch
{
  type            groovyBC;
  value          uniform 10000;
  variables
  (
    "pinside{set'insidePoint}=average(p);"
  );
  valueExpression "pinside/2.";
}

It seems to work :-) I was originally confused about {set'insidePoint} going on the left hand side, but it now seems more clear.
If I understand correctly, the average function indicates an averaging of the pressure values of the cells around the point only, right?

gschaider April 3, 2013 09:49

Quote:

Originally Posted by startingWithCFD (Post 418101)
First of all thanks a lot for your answer, it was very helpful.
I have changed the pressure file as follows:

Code:

myPatch
{
  type            groovyBC;
  value          uniform 10000;
  variables
  (
    "pinside{set'insidePoint}=average(p);"
  );
  valueExpression "pinside/2.";
}

It seems to work :-) I was originally confused about {set'insidePoint} going on the left hand side, but it now seems more clear.

I know. The original synax of "pinside@set'insidePoint" might have been clearer. But @ is a valid character in OF-names so that might have caused problems with fields/patches/sets with that kind of name

Quote:

Originally Posted by startingWithCFD (Post 418101)
If I understand correctly, the average function indicates an averaging of the pressure values of the cells around the point only, right?

No. It's just a precaution. These "external variables" only allow one value. So if your set has more than one point it will do an arithmetic average of those and use that. In your case: the general expression for the average value of one value is left as an exercise to the reader ;)


All times are GMT -4. The time now is 06:45.