Skip to content

Suggestion on bufferzone to reduce acoustic reflection on TYPE_E boundaries #321

@WQChen1994

Description

@WQChen1994

I noticed period oscillations from acoustic waves reflecting on the TYPE_E boundaries. I've added a buffer zone to these boundaries to help reduce the reflection.

The buffer zone code is a first version. Please adjust the parameters as needed.

In LBM code. Add:

R(float compute_type_e_blend_factor_simple(const uint3 xyz) {
//const int dist_x = min((int)xyz.x, (int)def_Nx - 1 - (int)xyz.x);
const int dist_y = min((int)xyz.y, (int)def_Ny - 1 - (int)xyz.y);
const int dist_z = min((int)xyz.z, (int)def_Nz - 1 - (int)xyz.z);
const int min_dist = min(dist_y, dist_z);

// Bufferzone size=10!!!  Defined by your self
const int BLEND_RANGE = 10;

if(min_dist > BLEND_RANGE) {
    return 1.0f;  // }

// alpha = (dist/10)^3
const float normalized = (float)min_dist / (float)BLEND_RANGE;
return 0.5f*normalized * normalized* normalized;  // }


R(uxx find_nearest_boundary_cell(const uint3 xyz) {
//const int dist_left = (int)xyz.x;
//const int dist_right = (int)def_Nx - 1 - (int)xyz.x; // bufferzone on y and z boundaies
const int dist_front = (int)xyz.y;
const int dist_back = (int)def_Ny - 1 - (int)xyz.y;
const int dist_bottom = (int)xyz.z;
const int dist_top = (int)def_Nz - 1 - (int)xyz.z;

int min_dist = dist_front;
int boundary_dir = 2;

//if(dist_right < min_dist) { min_dist = dist_right; boundary_dir = 1; }
//if(dist_front < min_dist) { min_dist = dist_front; boundary_dir = 2; }
if(dist_back < min_dist) { min_dist = dist_back; boundary_dir = 3; }
if(dist_bottom < min_dist) { min_dist = dist_bottom; boundary_dir = 4; }
if(dist_top < min_dist) { min_dist = dist_top; boundary_dir = 5; }

switch(boundary_dir) {
    //case 0: return index((uint3)(0u, xyz.y, xyz.z));
    //case 1: return index((uint3)(def_Nx-1u, xyz.y, xyz.z));
    case 2: return index((uint3)(xyz.x, 0u, xyz.z));
    case 3: return index((uint3)(xyz.x, def_Ny-1u, xyz.z));
    case 4: return index((uint3)(xyz.x, xyz.y, 0u));
    case 5: return index((uint3)(xyz.x, xyz.y, def_Nz-1u));
    default: return index((uint3)(0u, xyz.y, xyz.z));
}}
`

Change in void stream_collide:

`)+"#ifndef EQUILIBRIUM_BOUNDARIES"+R(
calculate_rho_u(fhn, &rhon, &uxn, &uyn, &uzn);
)+"#else"+R( // EQUILIBRIUM_BOUNDARIES
if(flagsn_bo==TYPE_E) {
    rhon = rho[               n];
    uxn  = u[                 n];
    uyn  = u[    def_N+(ulong)n];
    uzn  = u[2ul*def_N+(ulong)n];
} else {
    calculate_rho_u(fhn, &rhon, &uxn, &uyn, &uzn);
    
    const uint3 xyz = coordinates(n);
    // compute_type_e_blend_factor
    const float blend_factor = compute_type_e_blend_factor_simple(xyz);
    
    // find_nearest_boundary
    if(blend_factor < 0.9999f) {
        const uxx type_e_cell = find_nearest_boundary_cell(xyz);
        
        const float rho_type_e = rho[               type_e_cell];
        const float ux_type_e  = u[                 type_e_cell];
        const float uy_type_e  = u[    def_N+(ulong)type_e_cell];
        const float uz_type_e  = u[2ul*def_N+(ulong)type_e_cell];
        
        // apply bufferzone
        rhon = fma(rho_type_e, 1.0f - blend_factor, blend_factor * rhon);
        uxn  = fma(ux_type_e,  1.0f - blend_factor, blend_factor * uxn);
        uyn  = fma(uy_type_e,  1.0f - blend_factor, blend_factor * uyn);
        uzn  = fma(uz_type_e,  1.0f - blend_factor, blend_factor * uzn);
    }
    })+"#endif"+R( // EQUILIBRIUM_BOUNDARIES`

While the buffer zone can reduce reflections from the initial acoustic pressure, I have not yet established a benchmark case to perform parameter variation studies.

At now, I have no idea how to add a point source in the simulation and how to record the pressure on the observer point. Maybe I will update the benchmark cases in the few days.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions