Jump to content

liquid duplication


FIXBUGFIXBUGFIX
  • Branch: Live Branch Version: Windows Pending

Environment:

  • Branch 661174, No DLC

Structure:

  • As below

image.png.a9b046aa787813b9960ac75c0c9fe3eb.png

Pseudocode:

float __fastcall DoLiquidPressureDisplacement(unsigned short elem_idx, int cell, int ncell, int nncell, SimData* simData)
{
    std::vector<float> massIdx   = simData->cells->mass;
    std::vector<float> massIdx_u = simData->updatedCells->mass;
    std::vector<float> tempIdx   = simData->cells->temperature;
    std::vector<float> tempIdx_u = simData->updatedCells->temperature;
    std::vector<unsigned short> elemIdx_u  = simData->updatedCells->elementIdx;
    std::vector<unsigned char>  diseIdx    = simData->cells->diseaseIdx;
    std::vector<int>            diseCntIdx = simData->cells->diseaseCount;

    if ((simData->updatedCells->properties[ncell] & 2) == 0) {
        char elem_idx_n = simData->cells->elementIdx[ncell];
        if (elem_idx != elem_idx_n && simData->updatedCells->elementIdx[cell] == elem_idx &&
            simData->updatedCells->elementIdx[ncell] == elem_idx_n) {
            if ((gElementPressureData[elem_idx_n].state & 3) == 2) {
                float massOrgin = massIdx[cell] - simData->flow[cell].y - simData->flow[cell].x + simData->flow[cell].z + simData->flow[cell].w;
                if (massOrgin > (massIdx[nncell] + massIdx[ncell])) {
                    if (DisplaceLiquidDirectional(simData, simData->simEvents, ncell, nncell)) {
                        float massDelta = massOrgin * 0.125;
                        massIdx_u[ncell] += massDelta;
                        tempIdx_u[ncell] = tempIdx[cell];
                        elemIdx_u[ncell] = elem_idx;
                        simData->simEvents->ChangeSubstance(simData, ncell);
                        float mass_tmp = massIdx_u[cell] - massDelta;
                        massIdx_u[cell] = mass_tmp > 0.0 ? mass_tmp : 0;
                        int diseDelta = diseCntIdx[cell] * 0.125;
                        gDisease->AddDiseaseToCell(simData->updatedCells, ncell, diseIdx[cell], diseDelta);
                        // simData->updatedCells->ModifyDiseaseCount(cell, diseDelta);
                        CellAccessor cellAccessor(simData->updatedCells, cell);
                        cellAccessor.ModifyDiseaseCount(diseDelta);
                        return massDelta;
                    }
                }
            }
        }
    }
    return 0;
}

Assumption: 

  • When the liquid passes through the red rectangle position, dut to liquid droping, updatedCells-mass[cell] is updated to 0.
  • But the function tries to use original mass cells-mass[cell] to calculate movement mass.

image.png.18fc9921844608504f91b8c09dbe0b24.png

Solution:

float massOrgin = massIdx[cell] - simData->flow[cell].y - simData->flow[cell].x + simData->flow[cell].z + simData->flow[cell].w;

=>

float massOrgin = massIdx_u[cell] - simData->flow[cell].y - simData->flow[cell].x + simData->flow[cell].z + simData->flow[cell].w;

Disclaimers:

  • I cannot guarantee the effectiveness of this solution
  • I cannot guarantee that this solution will not cause any side effects
  • I can guarantee the above code does not truly exist

Temporary fix solution:

  • Decompress the attached | Zipped Files 1 | x86_64.zip
  • Copy SimDLL_new.dll to ...\OxygenNotIncluded\OxygenNotIncluded_Data\Plugins\x86_64, and replace the origin file

 

 

BTW, I'm not sure if this make sense →   tempIdx_u[ncell] = tempIdx[cell];


Steps to Reproduce

Load the attached save file

LiquidCopy.sav




User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...