Skip to content

Claude/check fortran stiffness 01 fc wd zx w goy s9 bwg74n88os - #8

Open
daisy20170101 wants to merge 17 commits into
v2.0.1from
claude/check-fortran-stiffness-01FCWdZxWGoyS9BWG74n88os
Open

daisy20170101 wants to merge 17 commits into
v2.0.1from
claude/check-fortran-stiffness-01FCWdZxWGoyS9BWG74n88os

Conversation

@daisy20170101

Copy link
Copy Markdown
Owner

update stiffness with Nikkhoo

claude and others added 17 commits December 8, 2025 09:33
1. trimode_finder: Fix index mapping for barycentric coordinates
   - MATLAB uses 2-element vectors where p(1)=y, p(2)=z
   - Fortran uses 3-element vectors where p(2)=y, p(3)=z
   - Changed p2(2)-p3(2) to p2(3)-p3(3) for z-coordinate differences
   - Changed p3(2)-p1(2) to p3(3)-p1(3) in b calculation

2. tdstress_harfunc: Fix transformation matrix construction
   - Changed from row-based (A(i,:)=vec) to column-based (A(:,i)=vec)
   - Now consistent with tdstress_fs which uses columns

3. debug_nikkhoo.f90: Fix matrix construction for debug output
   - Changed to column-based matrix matching sub_nikkhoo.f90
   - coord_trans uses transpose(A), so columns are required
… points

Changes:
1. Added ieee_arithmetic module for NaN generation
2. Changed casez_log (trimode=0) handling to return NaN for all strain
   components, matching MATLAB TDstressFS.m behavior:
   - MATLAB sets: exx(casezLog,1) = nan; etc.
   - Points on triangle edges are singular and have undefined strain
   - Previous implementation tried to average configurations which
     produced unreliable results

This fix, combined with the previous trimode_finder index mapping fix,
should resolve discrepancies between Fortran and MATLAB implementations.
- Move debug/test files to debug/ subfolder:
  - debug_matlab.m, debug_nikkhoo.f90
  - Makefile.debug, compile_test.sh, test_nikkhoo.f90
- Update README_NIKKHOO.md with new folder structure
  and documentation of bug fixes applied
Implements parallel triangular stiffness matrix calculation similar to
TriGreen/calc_trigreen.f90 but using Nikkhoo & Walter (2015) method:

- calc_nikkhoo.f90: Main program with MPI distribution and OpenMP parallelization
- m_nikkhoo_green.f90: Parameter module (material properties, geometry)
- Makefile: Build system for parallel compilation
- runcompile_nikkhoo.sh: Alternative compilation script

Features:
- Hybrid MPI+OpenMP parallelization for large meshes
- Dynamic load balancing across MPI processes
- Silent/production versions of strain calculation routines
- Output format compatible with TriGreen (nikkhoo_<rank>.bin)

Usage:
  make
  mpirun -np <nprocs> ./calc_nikkhoo
- Replace custom isnan_check function with intrinsic ieee_is_nan
- Add 'use, intrinsic :: ieee_arithmetic' to calc_nikkhoo_allcell
- Remove unused isnan_check function definition
- Flip sign of z coordinates when reading mesh vertices
  (mesh has positive z, half-space solution requires negative z)
- Change output file prefix from 'nikkhoo_' to 'trigreen_' for
  compatibility with existing TriBIE workflow
…' of https://github.com/daisy20170101/TriBIE into claude/check-fortran-stiffness-01FCWdZxWGoyS9BWG74n88os

flip z coordinates
- Remove incorrect reimplementations of strain functions from calc_nikkhoo.f90
- Use validated nikkhoo_walter module's tdstress_hs function directly
- Comment out 123 debug write statements in sub_nikkhoo.f90 for production use
- Update Makefile and runcompile_nikkhoo.sh to compile sub_nikkhoo.f90 as dependency
Add comment markers to continuation lines of commented-out multi-line
write statements to prevent Fortran compilation errors.
- runcompile_nikkhoo.sh: Accept command line argument (gfortran/mpi)
- Makefile: Add FC variable override and 'make gfortran' convenience target
- Updated help messages in both files
- Remove verbose write statements during deallocation that caused delays
- Add allocated() checks before deallocate calls
- Add stat= parameter to handle deallocation errors gracefully
- Remove unused timing variables (dealloc_start_time, dealloc_end_time)
…' of https://github.com/daisy20170101/TriBIE into claude/check-fortran-stiffness-01FCWdZxWGoyS9BWG74n88os

update trigreen deallocation
1. Move input validation outside OpenMP loop:
   - Pre-validate parm_nu, ss, ds, op once before entering nested loops
   - Eliminates millions of redundant isnan() checks

2. Add dynamic OpenMP scheduling:
   - Changed from default static to SCHEDULE(DYNAMIC, 10)
   - Better load balancing for non-uniform dstuart() computation costs

3. Reduce diagnostic output:
   - Remove verbose write statements inside OMP CRITICAL sections
   - Remove per-process status messages that serialized execution
   - Use OMP ATOMIC instead of OMP CRITICAL for error flag

Expected improvement: 20-40% runtime reduction
…' of https://github.com/daisy20170101/TriBIE into claude/check-fortran-stiffness-01FCWdZxWGoyS9BWG74n88os

 update parallelization and structure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants