Thursday, April 17, 2014

CFD: Generating Non-Uniform 2D Rectangular Grid Meshes in Fortran

In Computational Fluid Dynamics (CFD), resolving boundary layers and high-gradient shear regions requires non-uniform grid clustering near solid walls while keeping cell counts manageable in free-stream regions. Here is a Fortran routine to generate a geometrically stretched, symmetric 2D rectangular grid.

Domain: Rectangular 2D domain \([a, b] imes [c, d]\) • Method: Geometric progression expansion clustering toward boundaries

Mathematical Formulation

Given domain limits \(x \in [a, b]\) with \(n_x\) divisions and expansion ratio \(r_x\), the initial wall-adjacent step size \(\eta_x\) is computed from the geometric sum across the symmetric half-domain:

eta_x = (b - a) * (1 - exp_x) / (2 * (1 - exp_x**(n_x / 2)))
eta_y = (d - c) * (1 - exp_y) / (2 * (1 - exp_y**(n_y / 2)))

Fortran Source Code

! ====================================================================
! 2D Non-Uniform Symmetric Rectangular Grid Generator
! ====================================================================
      exp_x = 1.05   ! x-axis expansion factor
      exp_y = 1.10   ! y-axis expansion factor

      a = 0.0
      b = 1.0
      c = 0.0
      d = 1.0

! Uniform step sizes for reference
      del_x = (b - a) / n_x
      del_y = (d - c) / n_y

! Compute first wall-adjacent step sizes (eta_x, eta_y)
      eta_x = (b - a) * (1.0 - exp_x) / (2.0 * (1.0 - exp_x**(n_x / 2)))
      eta_y = (d - c) * (1.0 - exp_y) / (2.0 * (1.0 - exp_y**(n_y / 2)))

      x(1) = a
      y(1) = c

! --- X-Direction Mesh Generation ---
! Half 1: Wall to Center (Expanding)
      DO i = 2, n_x / 2 + 1
          x(i) = x(i - 1) + eta_x * exp_x**(i - 2)
      END DO

! Half 2: Center to Opposite Wall (Contracting)
      DO i = n_x / 2 + 2, n_x + 1
          x(i) = x(i - 1) + eta_x * exp_x**(n_x + 1 - i)
      END DO

! --- Y-Direction Mesh Generation ---
! Half 1: Wall to Center (Expanding)
      DO j = 2, n_y / 2 + 1
          y(j) = y(j - 1) + eta_y * exp_y**(j - 2)
      END DO

! Half 2: Center to Opposite Wall (Contracting)
      DO j = n_y / 2 + 2, n_y + 1
          y(j) = y(j - 1) + eta_y * exp_y**(n_y + 1 - j)
      END DO
! ====================================================================

Sunday, January 5, 2014

How to Disable 'Sort by Subject' in Roundcube Webmail

In Roundcube Webmail, accidentally clicking on the Subject column header triggers an expensive mailbox-wide sort operation. On large mail folders with thousands of messages, sorting by subject can freeze the UI and create heavy server load. Here is how to disable sorting on the Subject column while keeping date and status sorting intact.

File: program/steps/mail/func.inc • Target: Subject header click handler

Step-by-Step Fix

  1. Open program/steps/mail/func.inc in your text editor.
  2. Search for ./#sort (typically around line 440–445).
  3. Locate the onclick attribute generation:
    'onclick' => 'return ' . JS_OBJECT_NAME . ".command('sort','" . $col . "',this)"
  4. Replace it with a no-op handler for the subject column (or globally):
    'onclick' => 'return true'

Save the file. Clicking the Subject column header will no longer initiate slow sorting queries.

Tuesday, October 8, 2013

How to Log PHP mail() Sender Scripts and Headers to Detect Outgoing Spam

When a web server hosting multiple PHP applications or CMS sites is compromised by spammers, identifying the exact malicious PHP script sending unauthorized emails can be notoriously difficult. In PHP 5.3 and newer, built-in configuration directives allow you to track the exact script filename and originating source of every outgoing message.

Key Directives: mail.log for auditing script paths • mail.add_x_header for tracking script UID in email headers.

1. Enable mail.log

Open your server's php.ini (or pool configuration in PHP-FPM) and configure a dedicated mail log:

; Log all mail() function invocations, including script path and line number
mail.log = /var/log/php_mail.log

Ensure the web server user (e.g. apache or www-data) has write permissions to the destination file:

touch /var/log/php_mail.log
chown www-data:www-data /var/log/php_mail.log
chmod 660 /var/log/php_mail.log

2. Enable X-PHP-Originating-Script Header

To embed the sender script path directly into outgoing mail headers, enable mail.add_x_header:

; Adds X-PHP-Originating-Script header containing the UID and filename
mail.add_x_header = On

When an email is sent, the recipient headers will contain:

X-PHP-Originating-Script: 1000:contact_form.php

This allows you to immediately trace spam reports back to the offending script or compromised user account.

Thursday, August 29, 2013

Troubleshooting FSI System Coupling Errors in ANSYS Fluent and CFX (Excessive Distortion)

During two-way Fluid-Structure Interaction (FSI) simulations using ANSYS System Coupling between Transient Structural and Fluent or CFX, a sudden simulation abort often occurs at the very first coupling iteration with excessive mesh distortion errors.

Simulation Environments: ANSYS Workbench • System Coupling • Transient Structural • Fluent / CFX

Error Symptoms

Fluent System Coupling Exception:

System Coupling Exception: Origin: Transient Structural (Solution)
Error Code: 2
Error Description: One or more elements have become highly distorted.
Excessive distortion of elements is usually a symptom indicating the need for corrective action elsewhere.
Try ramping the load up instead of step applying the load (KBC,1).

CFX System Coupling Error:

ERROR #001100279 has occurred in subroutine ErrAction.
Message: CFX encountered the error: Read. Fatal error occurred when requesting Total Mesh Displacement for FSI.

Root Causes and Solutions

  1. Operating / Reference Pressure Mismatch:

    Both Fluent and CFX compute pressures relative to a designated operating/reference pressure. If your structural model expects gauge pressure but receives absolute pressure (or vice versa), the structural boundary experiences an instantaneous massive pressure spike at time step zero, causing severe structural element distortion. Ensure your fluid reference pressure aligns with your structural reference state.

  2. Velocity Inlet Vector Misalignment:

    Ensure velocity inlet boundary conditions match the physical geometry coordinate axes. For example, if a cylindrical fluid channel lies along the X-axis and the inlet velocity is erroneously assigned to Y or Z, fluid impacts the boundary wall immediately, creating an unphysical pressure surge and massive displacement.

  3. Load Ramping:

    In Transient Structural, avoid step-applying initial loads (KBC,1). Instead, ramp fluid forces gradually over the first few coupling sub-iterations to prevent transient shockwaves from inverting flexible mesh elements.

Thursday, August 22, 2013

Fixing ANSYS Fluent FSI Error: Unassigned Interface Zone Detected

When preparing an ANSYS Fluent mesh for two-way Fluid-Structure Interaction (FSI) coupled with ANSYS Mechanical, clicking Check Mesh may trigger the following warning and cause the mesh validation to fail:

Context: ANSYS Fluent mesh validation • Dynamic Mesh • Boundary Conditions
WARNING: Unassigned interface zone detected for interface 6.
WARNING: Mesh check failed.
To get more detailed information about the mesh check failure,
increase the mesh check verbosity via the TUI command /mesh/check-verbosity.

Root Cause & Solution

This error occurs when the boundary condition type for the FSI surface is set to Interface rather than Wall.

  • In Fluent, the boundary type Interface is exclusively reserved for grid interface pairs (such as sliding meshes or non-conformal meshes joined via Mesh Interfaces).
  • For an FSI coupling surface where fluid interacts with a solid structure, the boundary condition type must be set to Wall.
  • Under the Dynamic Mesh panel, designate this Wall as a dynamic boundary zone and assign it to System Coupling.

Once changed from Interface to Wall, re-running Check Mesh passes cleanly with zero warnings.

Monday, August 19, 2013

Troubleshooting ADINA FSI Simulation: INPUT ERROR: No Node Found in BCD

When running a Fluid-Structure Interaction (FSI) simulation in the ADINA FEM software suite, generating the solver DATA file may abort with the following error:

Environment: ADINA Structures • ADINA CFD • FSI Boundary Condition Definition
*** INPUT ERROR: No node found in BCD 1

Cause and Resolution

This error occurs when the FSI Boundary Condition (BCD) is assigned to the incorrect model body or geometric surface:

  • In ADINA FSI modeling, the fluid-structure boundary condition must be explicitly defined on the shared interface surface corresponding to the proper model domain (e.g. defining structural boundary nodes on the solid body and fluid boundary nodes on the fluid body).
  • If the FSI boundary surface is mapped to a geometry surface that lacks associated mesh nodes in that model component, ADINA cannot bind any degrees of freedom and throws the No node found in BCD error.

Verify that your interface boundary assignments match the mesh geometry of the active model component before regenerating the DATA file.

Wednesday, July 31, 2013

How to Install mod_flvx and mod_h264_streaming on cPanel Apache 2

Serving progressive download video files (such as MP4 and FLV) with seeking capabilities directly from Apache on a cPanel/WHM server requires compiling custom Apache modules: mod_flvx for FLV streaming and mod_h264_streaming for pseudo-streaming H.264/MP4 files.

Environment: cPanel / WHM • EasyApache • Apache 2.2 / 2.4 • H.264 / FLV Streaming

1. Persistent Hook Script

To ensure modules are compiled and reinstalled automatically whenever cPanel runs EasyApache, add the build commands to /scripts/after_apache_make_install:

#!/bin/bash
cd /usr/local/src

# Compile mod_flvx
wget http://people.apache.org/~pquerna/modules/mod_flvx.c
/usr/local/apache/bin/apxs -i -c mod_flvx.c

# Compile mod_h264_streaming
wget http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
tar -zxvf apache_mod_h264_streaming-2.2.7.tar.gz
cd mod_h264_streaming-2.2.7
./configure --with-apxs='/usr/local/apache/bin/apxs'
make && make install

# Update cPanel Apache configuration distiller
/usr/local/cpanel/bin/apache_conf_distiller --update

Ensure the hook script is executable:

chmod +x /scripts/after_apache_make_install

2. Apache Global Configuration

Add the module declarations and file extension handlers to /usr/local/apache/conf/includes/pre_virtualhost_global.conf:

LoadModule h264_streaming_module modules/mod_h264_streaming.so
<IfModule mod_h264_streaming.c>
    AddHandler h264-streaming.extensions .mp4
</IfModule>

LoadModule flvx_module modules/mod_flvx.so
<IfModule mod_flvx.c>
    AddHandler flv-stream .flv
</IfModule>

3. Rebuild with EasyApache

Execute EasyApache through WHM or the command line to finalize the build. Once complete, video seeking will work seamlessly over HTTP.

How Google Antigravity Solved the Mysterious NVIDIA Sleep Reboot on My Dell Inspiron 7567 (Ubuntu Linux)

If you run modern Ubuntu or Linux on a Dell Inspiron 15 Gaming (7567) or a similar 7th-gen Intel laptop paired with an NVIDIA GeForce GTX ...