synthetik-technologies / blastfoam

A CFD solver for multi-component compressible flow with application to high-explosive detonation, explosive safety and air blast
Other
227 stars 98 forks source link

decomposing refinementHistory #78

Open Ali-Shaha opened 1 year ago

Ali-Shaha commented 1 year ago

Greetings,

I think splitCellNum[index] == 8 condition here:

https://github.com/synthetik-technologies/blastfoam/blob/4e6ee07a0c1fc4629ee7206804f4f1fe802ec64c/src/dynamicMesh/fvMeshRefiner/fvMeshHexRefiner/hexRef/hexRefRefinementHistory.C#L950

needs to be changed to "splitCellNum[index] == nSubCellsPerCell" defined as: https://github.com/synthetik-technologies/blastfoam/blob/4e6ee07a0c1fc4629ee7206804f4f1fe802ec64c/src/dynamicMesh/fvMeshRefiner/fvMeshHexRefiner/hexRef/hexRefRefinementHistory.C#L1224

similar to:

https://github.com/synthetik-technologies/blastfoam/blob/4e6ee07a0c1fc4629ee7206804f4f1fe802ec64c/src/dynamicMesh/fvMeshRefiner/fvMeshHexRefiner/hexRef/hexRefRefinementHistory.C#L1238

in order to make the clone function work when re-decomposing a reconstructed refinementHistory with decomposerPar.

Thank you, Ali

scramjetFoam commented 3 months ago

Greetings,

I think splitCellNum[index] == 8 condition here:

https://github.com/synthetik-technologies/blastfoam/blob/4e6ee07a0c1fc4629ee7206804f4f1fe802ec64c/src/dynamicMesh/fvMeshRefiner/fvMeshHexRefiner/hexRef/hexRefRefinementHistory.C#L950

needs to be changed to "splitCellNum[index] == nSubCellsPerCell" defined as:

https://github.com/synthetik-technologies/blastfoam/blob/4e6ee07a0c1fc4629ee7206804f4f1fe802ec64c/src/dynamicMesh/fvMeshRefiner/fvMeshHexRefiner/hexRef/hexRefRefinementHistory.C#L1224

similar to:

https://github.com/synthetik-technologies/blastfoam/blob/4e6ee07a0c1fc4629ee7206804f4f1fe802ec64c/src/dynamicMesh/fvMeshRefiner/fvMeshHexRefiner/hexRef/hexRefRefinementHistory.C#L1238

in order to make the clone function work when re-decomposing a reconstructed refinementHistory with decomposerPar.

Thank you, Ali

Hi Ali,

Have you solved this problem? Can you provide the complete modified code for this function?

Regards, Sean

Ali-Shaha commented 3 months ago

Hello Sean,

Unfortunately, I do not have the original code at the moment. But to make the original clone function from here working only the following lines needed to be modified: `

// Compacted splitCells
DynamicList<splitCell8> newSplitCells(splitCells_.size());
const polyMesh& mesh = dynamic_cast<const polyMesh&>(db());
label nSubCellsPerCell = 1 << mesh.nGeometricD();

// Loop over all entries. Note: could recurse like countProc so only
// visit used entries but is probably not worth it.

forAll(splitCells_, index)
{
    if (splitCellProc[index] == procI && splitCellNum[index] == nSubCellsPerCell)
    {
        // Entry moves in its whole to procI
        oldToNewSplit[index] = newSplitCells.size();
        newSplitCells.append(splitCells_[index]);
    }
}

`

Best, Ali

scramjetFoam commented 3 months ago

Hi Ali,

Thank you for sharing, I will give it a try.

Regards, Sean

scramjetFoam commented 3 months ago

Hi Ali,

I made the changes as you suggested, but it didn't seem to work. After reconstruct the data and re-decomposing it, the mesh still becomes fixed.

截图_20240805212318

Ali-Shaha commented 3 months ago

Hi Sean,

Yes, that is right. There is (/was at least up to OF11) issue with the OF decomposer that didn't write/distribute the correct refinementHistory dictionary after decomposing an adaptively refined mesh. It seems that they refactored the code again after that at least in the current ofdev version.

The problem could be for two reasons:

  1. decomposerPar doesn't use the clone function that you wrote there.
  2. Even if it uses that, the new cell distribution is wrong (I explained it a little bit here). so OF just neglect that when running.

To fix it then:

  1. make a new domainDecomposition class that uses blastFoam's dynamicMesh library instead of polytopoChange.
  2. In the new class change the distributeCells() function. see Foam::labelList Foam::domainDecomposition::distributeCells()
  3. The new distribution can follow Voskuilen decomposition method, for that function you could use this.
  4. make a copy of decomposePar and use the new domainDecomposition class instead of default.

This at least was working a year ago there is a chance that new versions need some different modifications.

Best, Ali

scramjetFoam commented 3 months ago

Hi Ali,

Thank you for your detailed suggestions. I saw the contact info in the article you recommended and I thought it would be best to contact you by email? I added 1D/2D/3D AMR with reference to blastFoam's AMR library and updated it to OpenFOAM-dev. Based on your latest suggestion, I realized that I need to modify the src/parallel library, a task that does not seem to be easy. I would like to know if it is possible to contact you by e-mail to continue improving my code.

Best regards, Sean