CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] FunkySetFields for OF 141

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 29, 2008, 08:50
Default Hi Bernhard Thanks for the
  #21
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Bernhard

Thanks for the fast reply That will certainly give a smoother surface. Will try it out and report any success / failure / etc.

- Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 29, 2008, 09:31
Default Hi Niels. Just discovered that
  #22
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi Niels. Just discovered that I was bragging. There are essential things missing for that to work
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   May 29, 2008, 09:53
Default Okay. With respect to the v
  #23
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Okay.

With respect to the volume section, I found the following:

http://www.cfd-online.com/Wiki/Arbit...yhedral_Volume

With that in place, I will begin considering how to make the implementation - actually the recent f(x) = 0 posted by Hrv could come handy.

Best regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 29, 2008, 13:00
Default Now it works (new version just
  #24
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Now it works (new version just went to the SVN. Get it from there)

The expression would be:
"average(fpos().y < surf(0.) ? surf(1.) : surf(0.))"

The surf-functions generates surface-fields.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   May 30, 2008, 03:45
Default Hi Bernhard Thanks, it work
  #25
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Bernhard

Thanks, it works right out of the box. Though the expression in itself still gives rise to almost the same pattern, i.e. surface waves will still be present - see attached:



Thanks for your help!

/ Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 30, 2008, 04:35
Default I think waves like that can no
  #26
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
I think waves like that can not fully be avoided as long as you don't align the grid with the surface of the initial conditions.
The particular pattern in your picture seems to come from the fact that the faces are sharply switched (the way cells were before that). Try experimenting with a function that has a trancition area in the order of the cell size where faces get a value between 0 and 1 (that might even work for cell centers). The tools are there (have fun with the ?:-expressions)

Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   May 30, 2008, 04:54
Default Yeah, I actually had the same
  #27
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Yeah, I actually had the same thought that I needed to have the grid aligned like that, but I would like to avoid such extra considerations in the grid-generation.
The transition thought might be helpful.

Thanks,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 30, 2008, 04:54
Default Something else Niels: "I'll wa
  #28
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Something else Niels: "I'll wash your hands, you wash mine"
Should you get a satisfactory result using funkySF, could you add it to the section "Usage examples" on the Wiki page?
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   May 30, 2008, 05:15
Default Of course ... and if I at some
  #29
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Of course ... and if I at some point make a routine which calculates the fraction of water / air in each cell, would you be interested in the code to be implemented in FSF as an alternative way of setting the field?

Enjoy your weekend,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 9, 2008, 12:37
Default Hi Bernhard I have been loo
  #30
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Bernhard

I have been looking at a way of making these more refined weighting functions, and it seems that I need one more piece of information, which I do not know how to retrieve. So I hope you can help me.

The needed information is an approximate extend of the individual cell in the three dimensions. I think a reasonably approximation could be achieved by something like this (even though somewhat crude):

len = vector(max(fpos.x) - min(fpos.x),max(fpos.y) - min(fpos.y),max(fpos.z) - min(fpos.z))

Actually I only need the y-component. Hope you can help me.

Thanks for your help,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 11, 2008, 15:36
Default Hi Niels! I think this won'
  #31
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi Niels!

I think this won't work the way you want to. You want the max/min of the faces on a cell. But what you get is the total max/min.

Something that might work with the existing facilities (but I havn't tried, so it might give similar patterns to your last pictur) might be:

average(interpolate(pos().y<0 ? 1 : 0))

the conversion cellValue->faceValue->cellValue might blur out the border a bit

Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   June 11, 2008, 15:40
Default Hi! One last thing (and the
  #32
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi!

One last thing (and then I will shut up). If you can assume that the cells are approximately cubes then you might get their characteristic length with "pow(vol(),0.3333)"

Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   June 11, 2008, 15:58
Default Hi Bernhard Oh, I sincerely
  #33
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Bernhard

Oh, I sincerely appreciate you talking, thus you don't have to shut up
I have been around the cube-assumption, but my mesh is far from having uniform cells and the ratios of the characteristic lengths varies from cell to cell, thus it would not work (and would prefer a more genenic formulation).

Since writing you last time I have been looking into the code, and I have come up with a more clear and robust formulation of my problem. What I actually needs is the maximum projection of the face extend in the three cartesian coordinates. I will try to make an implementation of such a projection and if I get it to work post the code-snippet and make the wiki.
Because assuming edges aligned with the 'z'-axis, completely valid for 2D and also for my 3D-problems, the local ratio of intersected faces is easily written as

(fpos().y - 0.5 * proj().y) / proj().y

where proj is the projected face-extend and the surface is placed at y=0.

Keep you posted and thanks for your help,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 13, 2008, 04:48
Default Hi Bernhard I have made a s
  #34
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Bernhard

I have made a small 'reverse-engineering' and implemented a new part which gives the projection of the individual face. It looks like this:

Foam::surfaceVectorField *ValueExpressionDriver::makeFaceProjectionField()
{
Foam::dimensionSet nullDim(0,0,0,0,0);
Foam::surfaceVectorField *f=new Foam::surfaceVectorField(
Foam::IOobject
(
"fproj",
time,
mesh,
Foam::IOobject::NO_READ,
Foam::IOobject::NO_WRITE
),
mesh,
Foam::vector(0,0,0)
);
f->dimensions().reset(mesh.Cf().dimensions());

Foam::vector fmin(0,0,0);
Foam::vector fmax(0,0,0);

forAll(*f,faceI)
{
const Foam::face &fProp = mesh.faces()[faceI];
fmin = mesh.points()[fProp[0]];
fmax = fmin;
forAll(fProp,pointI)
{
forAll(mesh.points()[0],compI)
{
if(mesh.points()[fProp[pointI]].component(compI) < fmin.component(compI))
fmin.component(compI) = mesh.points()[fProp[pointI]].component(compI);
if(mesh.points()[fProp[pointI]].component(compI) > fmax.component(compI))
fmax.component(compI) = mesh.points()[fProp[pointI]].component(compI);
}
}
(*f)[faceI] = fmax - fmin;
}
f->dimensions().reset(nullDim);
return f;
}

It works perfectly when multiplying, addition and substraction, but dividing fails. The part which fails is:

... : (fproj().y <= surf(0.00001) ? surf(0.5) : (surf(0.5) - fpos().y / fproj().y))))"

It fails with a floating point exception, thus my guess is that I am somehow dividing by 0, even though I have my fail-safe, where I specify the value if the projected value is to small.

I am a little bit in the dark here, so I would appreciate your help.

Have a nice weekend,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 13, 2008, 07:47
Default Hi Niels! The problem ist t
  #35
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi Niels!

The problem ist the following: for the ?:-operator FSF evaluates all three fields (the condition, the true and the false-value) and then chooses the value for each cell according to the value of the condition in that cell. The only fix I can think of is to add a very small value to the divisor. For large values it won't matter, for small values it will be abandoned anyway.
Fixing it in FSF would mean a major rewrite, I think

Once you got it successfully tested would you commit the changed files to the SVN-repository (in other words: are you configured for write access to the SVN? If no: could you send me an EMail with the name of your sourceforge-account and I'll add you)

Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   June 13, 2008, 08:56
Default Hi Bernhard, It solved it,
  #36
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Bernhard,

It solved it, thanks So now I can bring a small comparison. In the picture below the top figure is a setField equivalent, the middle it using the approach suggested by you the 29th of May and the bottom figure is where the length of the face above and below the waterline is taken into consideration. Not surprisingly, the more information used the better the result.



I will verify my implementation and return to you.

Enjoy,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 13, 2008, 09:48
Default Wiki updated. / Niels
  #37
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Wiki updated.

/ Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 16, 2008, 10:03
Default Hi I actually thought that
  #38
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi

I actually thought that I had it figured out, and I did for the internal faces. The boundary faces on the other hand is not treated in the loop.

Therefor I have made an extra loop which loops over boundary-patches and faces in these. All works well, but I do not know how to assign the calculated value to the boundaryField.

I would very much appreciate any help in how to assign values to a boundaryPatch in a face per face approch.

Thanks,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 17, 2008, 05:57
Default Hi Bernhard The functionali
  #39
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Bernhard

The functionality fproj has now been tested. I cannot see your email-address. My address is ngj@mek.dtu.dk.

Best regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 28, 2008, 04:42
Default Hi, i used seccessfully funkys
  #40
New Member
 
Carlo De Angelis
Join Date: Mar 2009
Posts: 10
Rep Power: 17
carlodean is on a distinguished road
Hi, i used seccessfully funkysetFields to set an initial gamma field, but I would like to know if it's possible to set even an initial hydrostatic pressure field, something like pd=pd*rho*pos().z.
Someone could help me?
thank you very much
carlodean is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] groovyBC and funkySetFields married and got a kid named swak4Foam gschaider OpenFOAM Community Contributions 169 August 10, 2023 09:01
[swak4Foam] how to use funkySetFields function in muliregion case bryant_k OpenFOAM Community Contributions 15 October 15, 2021 02:50
[swak4Foam] funkySetFields and funkySetBoundaryFields zxj160 OpenFOAM Community Contributions 19 February 14, 2018 19:07
[swak4Foam] funkySetFields: problem with processor boundary nmikhailov OpenFOAM Community Contributions 4 May 26, 2015 09:48
[swak4Foam] numerical beach with funkySetFields?! maxonline OpenFOAM Community Contributions 6 June 17, 2011 04:59


All times are GMT -4. The time now is 14:03.