From 0417650c8ec649996147de5fe211787a1146ad6d Mon Sep 17 00:00:00 2001
From: Dave Whipp <dwhipp@dal.ca>
Date: Tue, 8 Nov 2011 18:29:08 +0000
Subject: [PATCH] Added user-supplied scaling factor for Kaus surface
 oscillation suppression algorithm

---
 src/build_system_wsmp.f90  | 4 ++--
 src/module_definitions.f90 | 1 +
 src/read_input_file.f90    | 6 ++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/build_system_wsmp.f90 b/src/build_system_wsmp.f90
index 19c14a32..dfca9429 100644
--- a/src/build_system_wsmp.f90
+++ b/src/build_system_wsmp.f90
@@ -200,9 +200,9 @@ do ileaves=1,osolve%nleaves
                         iloc=ifind_loc_wsmp(i1loc,i1,ja,ia,n_iproc,nz_loc)
                         elem_dz=(osolve%z(osolve%icon(5,ileaves))-osolve%z(osolve%icon(1,ileaves)))*params%vex
                         if (k1 < 5) then
-                          avals(iloc)=avals(iloc)-(params%dt*(-weightel(ileaves)))/(2.d0*elem_dz)
+                          avals(iloc)=avals(iloc)-params%damp_factor*(params%dt*(-weightel(ileaves)))/(2.d0*elem_dz)
                         else
-                          avals(iloc)=avals(iloc)+(params%dt*(-weightel(ileaves)))/(2.d0*elem_dz)
+                          avals(iloc)=avals(iloc)+params%damp_factor*(params%dt*(-weightel(ileaves)))/(2.d0*elem_dz)
                         endif
                       endif
                     endif
diff --git a/src/module_definitions.f90 b/src/module_definitions.f90
index ab5c6aaa..bb5ef914 100644
--- a/src/module_definitions.f90
+++ b/src/module_definitions.f90
@@ -274,6 +274,7 @@ module definitions
       double precision e2d0
       double precision minp
       double precision pressure0
+      double precision damp_factor
       character*128 restartfile
       character*40  infile
    end type
diff --git a/src/read_input_file.f90 b/src/read_input_file.f90
index 82af4eb8..146e8f5b 100644
--- a/src/read_input_file.f90
+++ b/src/read_input_file.f90
@@ -484,6 +484,10 @@ if (iproc==0) then
 end if
 call mpi_bcast(params%damp_surface,1,mpi_logical,0,mpi_comm_world,ierr)
 
+params%damp_factor=1.0d0
+if (iproc==0) call scanfile (params%infile,'damp_factor',params%damp_factor,ires)
+call mpi_bcast(params%damp_factor,1,mpi_double_precision,0,mpi_comm_world,ierr)
+
 params%remove_surf_pts=.false.
 if (iproc==0) then
    call scanfile (params%infile,'remove_surf_pts',answer,ires)
@@ -1158,6 +1162,7 @@ if (params%debug.gt.0 .and. iproc.eq.0) then
   write(*,'(a,i4)') shift//'initial_refine_level ',params%initial_refine_level
   write(*,'(a,e11.4)') shift//'dt ',params%dt
   write(*,'(a,l1)') shift//'damp_surface ',params%damp_surface
+  write(*,'(a,e11.4)') shift//'damp_factor ',params%damp_factor
   write(*,'(a,l1)') shift//'remove_surf_pts ',params%remove_surf_pts
   write(*,'(a,e11.4)') shift//'penalty ',params%penalty
   write(*,'(a,e11.4)') shift//'tempscale ',params%tempscale
@@ -1381,6 +1386,7 @@ if (params%debug.gt.1) then
   write(threadinfo%Logunit,'(a32,i4)') 'initial_refine_level ',params%initial_refine_level
   write(threadinfo%Logunit,'(a32,e11.4)') 'dt ',params%dt
   write(threadinfo%Logunit,'(a32,l1)') 'damp_surface ',params%damp_surface
+  write(threadinfo%Logunit,'(a32,e11.4)') 'damp_factor ',params%damp_factor
   write(threadinfo%Logunit,'(a32,l1)') 'remove_surf_pts ',params%remove_surf_pts
   write(threadinfo%Logunit,'(a32,e11.4)') 'penalty ',params%penalty
   write(threadinfo%Logunit,'(a32,e11.4)') 'tempscale ',params%tempscale
-- 
GitLab