|
[Sponsors] |
February 5, 2022, 14:47 |
Number of particles inside Cell
|
#1 |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 11 |
Dear all
I am working on a solution for OpenFOAM issue #2289 (https://develop.openfoam.com/Develop.../-/issues/2289), which affects both versions of OpenFOAM. The bug occurs when a particle-containing cell of level > 1, belonging to a wall boundary is unrefined. One approach would be protecting the boundary-cells from unrefinement, which is discussed here: dynamicRefineFvMesh - Protect cells from refinement (boundary). However, this approach is not convenient as it blocks refinement in wall cells, which very often need to be refined. The other option would be protecting from refinement cell containing particles. My idea is modifying the dynamicRefineFvMesh file, including something like: forAll(cells(), celli) { const cell& nParcels = cells()[celli]; if (nParcels.parcelNumberinCell > 0) { protectedCell_.set(celli); } I am aware that there is no such thing as "parcelNumberinCell". What would be the best approach? I am aware that p.cell() would return the cell number containing the parcel, but then it would require a loop through all parcels. This would be the same for cellOccupancy, right? Any ideas? Best regard J.A. Gutiérrez |
|
February 16, 2022, 04:42 |
|
#2 | |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
Quote:
Hi, Your point about cellOccupancy requiring a loop over all particles is incorrect, if I have understood your task correctly. You can simply do `cellOccupancy.size()', thus eliminating the need to loop over all particles. Here is a minimum example based on a time I have done something similar for cells containing no particles: Code:
const polyMesh& pmesh = this->owner().mesh(); List<DynamicList<typename CloudType::parcelType*>>& cellOccupancy = this->owner().cellOccupancy(); // check all cells containing particles forAll(pmesh.cells(), celli) { if ( cellOccupancy[celli].size() == 0 ) { // do something } else { // do something else } } Josh |
||
February 21, 2022, 08:48 |
|
#3 |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 11 |
Thank you Josh.. I am going to test it this week and I will let you know what happens.
Jairo. |
|
March 8, 2022, 09:59 |
|
#4 |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
Any luck, Jairo?
|
|
March 18, 2022, 17:14 |
|
#5 |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 11 |
Hi Josh, no I have not had any luck yet. I think my OpenFOAM C++ skills are lacking for this task, please correct me if I am wrong.
I suppose the modification must be included in the dynamicRefineFvMesh, as the protected cells (particle-containing) must be evaluated each time the mesh refinement / unrefinement is going to occur. I added something like this: Code:
const polyMesh& pmesh = this->owner().mesh(); List<DynamicList<typename CloudType::parcelType*>>& cellOccupancy = this->owner().cellOccupancy(); forAll(pmesh.cells(), celli) { if ( cellOccupancy[celli].size() > 0 ) { protectedCell_.set(celli); } } Code:
dynamicRefineFvMesh/dynamicRefineFvMesh.C: In member function ‘virtual bool Foam::dynamicRefineFvMesh::init(bool)’: dynamicRefineFvMesh/dynamicRefineFvMesh.C:1174:46: error: ‘const labelUList {aka const class Foam::UList<int>}’ has no member named ‘mesh’; did you mean ‘test’? const polyMesh& pmesh = this->owner().mesh(); ^~~~ test dynamicRefineFvMesh/dynamicRefineFvMesh.C:1175:49: error: template argument 1 is invalid List<DynamicList<typename CloudType::parcelType*>>& cellOccupancy = ^~ dynamicRefineFvMesh/dynamicRefineFvMesh.C:1175:53: error: ‘cellOccupancy’ was not declared in this scope List<DynamicList<typename CloudType::parcelType*>>& cellOccupancy = ^~~~~~~~~~~~~ dynamicRefineFvMesh/dynamicRefineFvMesh.C:1176:19: error: ‘const labelUList {aka const class Foam::UList<int>}’ has no member named ‘cellOccupancy’ this->owner().cellOccupancy(); ^~~~~~~~~~~~~ dynamicRefineFvMesh/dynamicRefineFvMesh.C:1176:33: error: template argument 1 is invalid this->owner().cellOccupancy(); ^ I've have included the intermediate library to "#include "kinematicCloud.H", where cellOccupancy is defined, but that specific error still persists. Any help is completely welcomed |
|
March 19, 2022, 08:51 |
|
#6 |
Member
Rishikesh
Join Date: Apr 2016
Posts: 63
Rep Power: 10 |
It appears you are using 'this' from within the dynamicFvMesh file, but trying to access cloud members? Using 'this' will only work from within the cloud functions.
Are you able to access the mesh using something like Code:
const polyMesh& mesh = cloud.pMesh(); |
|
March 19, 2022, 18:10 |
|
#7 | |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 11 |
Quote:
Code:
dynamicRefineFvMesh/dynamicRefineFvMesh.C:1176:36: error: expected primary-expression before ‘.’ token const polyMesh& mesh = cloud.pMesh(); ^ dynamicRefineFvMesh/dynamicRefineFvMesh.C:1178:49: error: template argument 1 is invalid List<DynamicList<typename CloudType::parcelType*>>& cellOccupancy = cloud.pMesh().cellOccupancy(); ^~ dynamicRefineFvMesh/dynamicRefineFvMesh.C:1178:53: error: ‘cellOccupancy’ was not declared in this scope List<DynamicList<typename CloudType::parcelType*>>& cellOccupancy = cloud.pMesh().cellOccupancy(); ^~~~~~~~~~~~~ dynamicRefineFvMesh/dynamicRefineFvMesh.C:1178:97: error: template argument 1 is invalid pename CloudType::parcelType*>>& cellOccupancy = cloud.pMesh().cellOccupancy(); dynamicRefineFvMesh/dynamicRefineFvMesh.C:1181:8: error: ‘pMesh’ was not declared in this scope forAll(pMesh.cells(), celli) Here is the attached file: dynamicRefineFvMesh.C All the modifications are commented as: // JAG |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF in case with DPM modle | POSTHU | Fluent UDF and Scheme Programming | 0 | March 3, 2021 07:21 |
[mesh manipulation] Importing Multiple Meshes | thomasnwalshiii | OpenFOAM Meshing & Mesh Conversion | 18 | December 19, 2015 18:57 |
[OpenFOAM.org] OF2.3.1 + OS13.2 - Trying to use the dummy Pstream library | aylalisa | OpenFOAM Installation | 23 | June 15, 2015 14:49 |
DecomposePar unequal number of shared faces | maka | OpenFOAM Pre-Processing | 6 | August 12, 2010 09:01 |
Unaligned accesses on IA64 | andre | OpenFOAM | 5 | June 23, 2008 10:37 |