CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Using a custom algorithm for cell center calculations

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By marupio

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 25, 2013, 09:37
Default Using a custom algorithm for cell center calculations
  #1
New Member
 
Andrej
Join Date: Jun 2013
Posts: 6
Rep Power: 12
Zvex is on a distinguished road
Hello,

I am not sure if it is not implemented already, but I haven't found any straight possibility to fully customly choose cell center coordinates for calculations. Maybe I am wrong?

If they are calculated during preprocessing once, and then are used for ALL calculations as a part of mesh - then it looks simple, just change it as a part of preprocessing. But do I need to calculate face centers aswell or it has nothing to do with cell centers for calculations?

If they are calculated dynamically as a part of scheme implementation, where should I look for it? I saw somewhere in sourcecode somesort of cell center giving function: it looked complicated, as splitting volume into pyramids and then averaging its weighted centers, but, I guess, it has nothing to do with the centers, that are used for calculations, since in comments it was told that it is deprecated. Maybe i should change scheme realization algorithm, but all my tryings to clarify the place, at which that code intervention should be made, failed, so I don't know where to start yet, any hints to do that would be awesome ...

I really need it, because i've constructed a mesh with triangle prisms, with acute triangles - so using Voronoy points as cell centers would solve problems with errors because of non-orthogonality.

So forcing OpenFOAM to use my custom cell centers in ALL calculations - is it possible? And at wich point of code should I implement that modification?

Thank you
regards,
Andrej

Last edited by Zvex; June 25, 2013 at 11:50.
Zvex is offline   Reply With Quote

Old   June 26, 2013, 10:42
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
Cell centres are calculated and stored by the fvMesh object, and automatically used by the discretization schemes. If you want to force OpenFOAM to use your custom cell centres for some reason, it would be a pretty big job.

You may be able to get away with defining a new set of discretization schemes within the finiteVolume library, or you may have to create your own library finiteVolumeWithBizzareCellCentres.

Why do you want to use your own custom cell centres if OF already calculates them?
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   June 26, 2013, 11:01
Default
  #3
New Member
 
Andrej
Join Date: Jun 2013
Posts: 6
Rep Power: 12
Zvex is on a distinguished road
we don't achieve a convergence of an order 1/N, where N is the number of volumes ... We have made a hand-made solver on pure c++, and achieve it by taking centers as Voronoy points.

So we need it, because we've constructed a mesh with triangle prisms, with acute triangles - so using Voronoy points as cell centers would solve problems with errors because of non-orthogonality.

"are calculated and stored by the fvMesh object" - is it done only once after reading a mesh?

As a see for now a syntaxis

mesh.C()[cell_index].x();

let's to access the cell center coordinate, there are two methods: returning it as a const, and just returning by reference. So the second one should let us to change it. But I am not sure if it will be enough and it will be calculating everything correctly
Zvex is offline   Reply With Quote

Old   June 26, 2013, 11:12
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
The cell centres are created when they are first requested (lazy evaluation). For a regular fvMesh, they are never recalculated. dynamicFvMesh must recalculate them, but I haven't looked at the code. I guess you could just create a copy of the finiteVolume library and change the cell centre calculation code, but, as you say, it may not be enough.

Will off-centre cell centres theoretically impact other parts of the code that just assume centroid locations? For instance, body forces would now also have a moment that are not accounted for. Would this also confuse non-orthogonality corrections and inverse distance calculations? Off the top of my head, I don't know.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   June 26, 2013, 11:22
Default
  #5
New Member
 
Andrej
Join Date: Jun 2013
Posts: 6
Rep Power: 12
Zvex is on a distinguished road
Quote:
Originally Posted by marupio View Post
The cell centres are created when they are first requested (lazy evaluation). For a regular fvMesh, they are never recalculated. dynamicFvMesh must recalculate them, but I haven't looked at the code. I guess you could just create a copy of the finiteVolume library and change the cell centre calculation code, but, as you say, it may not be enough.

Will off-centre cell centres theoretically impact other parts of the code that just assume centroid locations? For instance, body forces would now also have a moment that are not accounted for. Would this also confuse non-orthogonality corrections and inverse distance calculations? Off the top of my head, I don't know.
In our case there will be no non-orthogonality - that is the main reason for this thread ... there is no need for any corrections, if we use Voronoy points on acute triangles (prisms) mesh. There will be no incorrect distances, since the whole mesh is made of acute triangle prisms - Voronoy points will be always inside triangles.

I guess I'll just try to track the cell centers and check if they will change during calculations.
Zvex is offline   Reply With Quote

Old   June 26, 2013, 11:28
Default
  #6
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
fvMesh will never let the cell centres change.

Also, the finiteVolume library is littered with non-orthogonality corrections. I'd suggest you copy and rename this library, modify the cell centre calculations, and go through all the discretization schemes, stripping non-orthogonality corrections. They're easy to spot... any discretization or interpolation that looks more complicated than the theory says, it's likely non-orthogonality correction doing it.

Then copy a solver, e.g. simpleFoam, and rename it, link it instead to your custom fv library.
Zvex likes this.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   June 26, 2013, 12:02
Default
  #7
New Member
 
Andrej
Join Date: Jun 2013
Posts: 6
Rep Power: 12
Zvex is on a distinguished road
Quote:
Originally Posted by marupio View Post
fvMesh will never let the cell centres change.

Also, the finiteVolume library is littered with non-orthogonality corrections. I'd suggest you copy and rename this library, modify the cell centre calculations, and go through all the discretization schemes, stripping non-orthogonality corrections. They're easy to spot... any discretization or interpolation that looks more complicated than the theory says, it's likely non-orthogonality correction doing it.

Then copy a solver, e.g. simpleFoam, and rename it, link it instead to your custom fv library.
Thank's for tips, ill try to do somehting as soon as I will finish some other jobs
Zvex is offline   Reply With Quote

Old   June 30, 2013, 05:01
Default
  #8
New Member
 
Andrej
Join Date: Jun 2013
Posts: 6
Rep Power: 12
Zvex is on a distinguished road
I've just added a new method, that brakes encapsulation rules and allows to change centers. So all OpenFOAM functionality is kept, but inside my program I can add a second postrocessing after the mesh is read, just by reading center points from my file. It is a dirty solution, but very cheap, and easy to "turn on/off" original OpenFOAM functionality, so for our purposes this solution is pefect.

Results:
1) turning on/off any nonorthogonality corrections has zero effect on results
2) I've got the same convergence speed as in hand-made solver
3) Mesh centers are read from meshs tructure, and modifying it was enough. You were right, it is constant during calculations

Thank you for the tips again, my problems are solved .
Zvex is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



All times are GMT -4. The time now is 22:05.