Compare commits

..

85 Commits

Author SHA1 Message Date
5d8dfaf679 Add plot-only restart script to skip recomputation when plotting is interrupted
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 15:01:25 +08:00
24f4a45097 Fix macrodef.h include and clean up stale z4c_gpu_rhs_ss.cu
Include macrodef.h (not macrodef.fh) in gpu_rhsSS_mem.h and
bssn_gpu.h so that ABEtype is visible to #if guards in CUDA files.
Remove the separate z4c_gpu_rhs_ss.cu (merged into bssn_gpu_rhs_ss.cu).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 20:02:35 +08:00
f16469ea77 Simplify Z4C Shell GPU: CPU-side trKd+TZ_rhs wrapper
Replace the duplicated z4c_gpu_rhs_ss.cu with a lightweight
gpu_rhs_z4c_ss wrapper inside bssn_gpu_rhs_ss.cu (guarded by
#if ABEtype==2). The wrapper:
1. Builds trKd = trK + 2*TZ on host and passes it to gpu_rhs_ss
2. After BSSN GPU returns, computes TZ_rhs = alpn1*Hcon/2 and
   applies kappa1/kappa2 constraint damping on CPU

This avoids duplicate kernel definitions (linker errors) and
keeps all shell GPU code in a single file. The CPU-side Z4C
corrections are O(100K) operations — negligible vs GPU RHS time.

Also remove the separate z4c_gpu_rhs_ss.cu and its build rule.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 16:05:56 +08:00
f754aa1ec2 Add Z4C Shell-Patch GPU acceleration (Phase 3 complete)
Create z4c_gpu_rhs_ss.cu (reusing BSSN shell FD/chain-rule kernels):
- Uploads trKd = trK + 2*TZ to GPU so existing BSSN algebraic kernels
  compute correct Z4C physical equations without modification
- New kern_z4c_post applies TZ_rhs = alpn1 * Hcon / 2, kappa1/kappa2
  constraint damping, TZ advection (lopsided), and dissipation (kodis)
- Adds TZ/TZ_rhs to Meta struct, alloc/upload/download/free lifecycle

Add cuda_compute_rhs_z4c_ss() wrapper in Z4c_class.C matching the
Fortran f_compute_rhs_Z4c_ss signature, with #define redirection for
Step/SHStep call sites and #undef before analysis functions.

Add z4c_gpu_rhs_ss.o to ABE_CUDA_CFILES and build rule in makefile.
Add kappa1_c/kappa2_c constants to gpu_rhsSS_mem.h.

Build verified with USE_CUDA_Z4C=1 + WithShell — compiles and links
cleanly. All three Shell GPU files now coexist: bssn_gpu_rhs_ss.o
(BSSN), z4c_gpu_rhs_ss.o (Z4C), both sharing FD/chain-rule kernels.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 13:52:48 +08:00
c4194214c6 Enable Z4C + Shell-Patch GPU coexistence (Phase 3)
Remove the compile-time #error that blocked USE_CUDA_Z4C + WithShell.
Add GPU-to-CPU state sync at the start of both Z4C Step functions
(non-CPBC and CPBC) so shell CPU consumers read valid field data
after Cartesian GPU RHS with resident state.

Move bssn_cuda_use_resident_sync and bssn_cuda_download_level_state
_if_present from anonymous namespace to file scope in bssn_class.C
so derived classes (Z4C) can call them. Declare both in
bssn_rhs_cuda.h. Include bssn_rhs_cuda.h in Z4c_class.C.

Z4C shell RHS remains on CPU (Fortran Z4c_rhs_ss.f90) pending
future GPU kernel implementation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 12:08:02 +08:00
0ca86afd41 Use static OpenMP schedule in ShellPatch::setupintintstuff
Static scheduling has lower overhead than guided for uniform workloads
(grid points all have equal computational cost).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:23:07 +08:00
f5bf3ab252 Add thread-safe ShellPatch::setupintintstuff with OpenMP
Split prolongpointstru into search-only (prolongpointstru_search) and
append-only (prolongpointstru_append) functions. The search is read-only
and thread-safe; each thread builds private linked lists via
prolongpointstru_append, merged after the parallel loop.

This eliminates critical-section contention and delivers ~2.2x speedup:
setupintintstuff: 511s -> 252s, total init: 592s -> 267s.

Also add -qopenmp to ShellPatch.o compilation via makefile override rule
and <omp.h> include with _OPENMP guards + fallback stubs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:10:20 +08:00
d0d3f965a6 Add diagnostic timing to Shell-Patch initialization
Print MPI_Wtime breakdown of Initialize() shell setup steps and
Read_Ansorg::Compute_Constraint duration. Reveals that
ShellPatch::setupintintstuff() takes ~511s of the ~590s startup.

The function builds interpolation tables by searching every shell
grid point against all Cartesian patches — thread-safe OpenMP
parallelization is blocked by shared linked-list mutations in
prolongpointstru(), which would need a search/append split first.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 21:51:07 +08:00
fbb2ed112d Fix Compile_Constraint/analysis use CPU Fortran for shell RHS
Limit GPU shell RHS redirection to Step and SHStep only via #define/#undef.
Compute_Constraint, Interp_Constraint, and Constraint_Out continue using
the CPU Fortran path to avoid GPU alloc-per-call overhead during
initialization and analysis phases.

Also: wrap compare_result_gpu in #ifdef RESULT_CHECK to avoid link error.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 19:25:45 +08:00
bd4ce3fbf3 GPU-accelerate Shell-Patch BSSN evolution
Phase 1: Enable GPU resident state for Cartesian patches in Shell mode.
- Remove WithShell guard from bssn_cuda_use_resident_sync().
- Add GPU-to-CPU state sync before shell CPU consumers (SHStep,
  CS_Inter, inline shell RHS blocks).

Phase 2: GPU-accelerate BSSN Shell Patch RHS.
- Create bssn_gpu.h with RHS_SS_PARA macro and gpu_rhs_ss declaration.
- Fix compilation bugs in legacy bssn_gpu_rhs_ss.cu (deprecated
  cudaThreadSynchronize, tmp_con2 redeclaration, ijkmin3_h typo,
  CUDA_SAFE_CALL, missing compare_result guard).
- Add bssn_gpu_rhs_ss.o to CFILES_CUDA_BSSN with build rule.
- Write cuda_compute_rhs_bssn_ss() wrapper bridging Fortran and GPU
  parameter conventions, redirect all shell RHS call sites via #define.

Verified: 30-step Shell-Patch GPU run completes without errors/NaN.
Step wall time ~4.4s (step_fn ~2.0s + RP ~0.68s + constraint ~0.70s).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 18:50:10 +08:00
5eb49949d9 Fix AHF crash under CUDA resident-sync mode
Download BSSN StateList from GPU to CPU before AHFinderDirect_find_horizons
so that AH_Interp_Points reads valid field data instead of stale CPU arrays.
The resident-sync path keeps canonical state on GPU; without this download the
Newton iteration diverges and probes outside the computational domain.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 16:11:56 +08:00
39450228f5 Accelerate Shell-Patch interpolation fast paths 2026-05-08 13:26:16 +08:00
063f28b3b4 Add Shell-Patch GPU runtime fast paths 2026-05-08 09:26:36 +08:00
1064a68d16 Optimize BSSN-EM 8th-order AMR transfers 2026-05-07 21:38:16 +08:00
dcc83bafcb Support 2nd and 8th order CUDA AMR paths 2026-05-07 20:31:26 +08:00
c4d8d41b25 Cover Z4C CUDA AMR restrict prolong 2026-05-07 19:49:09 +08:00
0076b3ca18 Optimize 6th-order CUDA AMR stencils 2026-05-07 19:22:37 +08:00
9ff2f065be Apply BSSN AMR sync default to EScalar 2026-05-07 17:12:33 +08:00
2317e4abde Fix BSSN GPU resident AMR sync default 2026-05-07 17:11:09 +08:00
fea2dcc0d5 Fix BSSN-EM runtime crash 2026-05-07 16:47:55 +08:00
5525465cad Support CUDA finite-difference order selection 2026-05-07 16:28:02 +08:00
96829d0441 Optimize Z4C GPU runtime defaults 2026-05-07 15:37:09 +08:00
83afaf19ce Skip zero EM resident downloads 2026-05-07 13:04:46 +08:00
cb911dec06 Add EM GPU fast paths and defaults 2026-05-07 12:18:56 +08:00
dd0e20d8c7 Fix BSSN-EScalar CUDA boundary and scalar KO 2026-05-06 15:44:35 +08:00
ffa0d801ed Default Python GPU runner to EScalar fast path 2026-05-06 00:12:46 +08:00
ae64a22178 Complete BSSN-EScalar CUDA resident transfers 2026-05-05 23:57:42 +08:00
85fe29cc2e Optimize BSSN-EScalar CUDA path 2026-05-05 10:47:46 +08:00
06f62dee36 Switch back to Intel toolchain as the default option
Seems that Intel MPI also supports CUDA-aware by setting I_MPI_OFFLOAD to 1. Besides, I_MPI_OFFLOAD_IPC=0 is needed to avoid segfaults.
2026-05-01 21:59:13 +08:00
35b6ceff02 Broaden cached CUDA sync paths 2026-05-01 18:03:04 +08:00
51f3819892 Save generated source formatting state 2026-04-30 20:47:44 +08:00
a9a3809148 Default Python launcher to fast GPU path 2026-04-30 20:15:34 +08:00
b1974ef146 Stabilize device AMR restrict across regrid 2026-04-30 20:01:18 +08:00
be9033f449 Add optional CUDA surface interpolation 2026-04-30 19:21:19 +08:00
6835608f92 Add configurable analysis MAP cadence 2026-04-30 19:10:12 +08:00
e0d0673c8e Enable optimized GPU runs from Python launcher 2026-04-30 18:31:31 +08:00
da4d56ccf7 Optimize BSSN surface interpolation fast path 2026-04-30 18:25:21 +08:00
a6483d013d Add CUDA AMR restrict diagnostics 2026-04-30 12:20:44 +08:00
8486532920 Add resident BSSN GPU point interpolation 2026-04-30 11:39:15 +08:00
18e9c9cc50 Optimize BSSN CUDA resident AMR prolong path 2026-04-30 10:58:15 +08:00
1ee229a91f Add keyed BSSN CUDA resident banks 2026-04-29 19:44:19 +08:00
68eab03bac Add opt-in BSSN CUDA resident AMR path 2026-04-29 19:15:37 +08:00
090d8657ae Optimize BSSN CUDA state transfers 2026-04-29 18:34:31 +08:00
22c1e7168b Optimize BSSN CUDA resident state and CUDA-aware MPI 2026-04-29 17:05:10 +08:00
a0dab90bcb Switch to NVIDIA HPC Toolchain 2026-04-29 08:31:49 +08:00
c689cc8dc9 [WIP] Add CUDA support for Z4C
Rewritten done by Codex.
This still has errors, do not pick this one now.
2026-04-27 11:58:43 +08:00
60fee8f1c1 Fix Z4C C++ gauge damping ordering 2026-04-26 15:38:13 +08:00
843b116954 Add C++ Z4C RHS path and port some BSSN optimizations 2026-04-25 10:39:01 +08:00
c768e1220b Also disable cached sync for Z4C 2026-04-25 10:25:54 +08:00
02f149e2e3 Disable cached sync for BSSN-EScalar 2026-04-25 10:17:47 +08:00
422e8ec4dc Fallback BSSN-EScalar restrict/prolong path 2026-04-25 10:10:34 +08:00
c4909b9843 更新精度检查脚本加入图像比对检查
(cherry picked from commit ac82ebd889)
2026-04-25 09:40:12 +08:00
f521a97563 Fix ABE CPU version build error 2026-04-25 09:39:49 +08:00
53c55451b3 Update makefile and scripts for CUDA BSSN configuration and build commands 2026-04-25 09:19:50 +08:00
768345954f Add optional BSSN kernel profiling switches
(cherry picked from commit 9c31384b2f)
2026-04-25 08:39:43 +08:00
9a6df6438b Remove dead chi derivative setup in BSSN RHS
(cherry picked from commit e4e741caa1)
2026-04-25 08:38:01 +08:00
8e9463aa90 Localize chi Ricci intermediates in RHS
(cherry picked from commit 65e0f95f40)
2026-04-25 08:37:41 +08:00
7c6f15002e Elide dead stores in BSSN RHS hot path
(cherry picked from commit f9fbf97e64)
2026-04-25 08:37:40 +08:00
6410c62e3e Add fine-grained step timing and trim BH RHS overhead
(cherry picked from commit 968522995b)
2026-04-25 08:37:19 +08:00
11977eb82f Merge wave and mass extraction interpolation
(cherry picked from commit f3988ac8ca)
2026-04-25 08:25:34 +08:00
cce8a44fc4 Cache wave extraction angular kernels
(cherry picked from commit e4c25eb21f)
2026-04-25 08:24:36 +08:00
c589097618 Reuse mass integrand across detector radii
(cherry picked from commit 4b10519876)
2026-04-25 08:24:11 +08:00
b713e5a9be Batch constraint norm reductions
(cherry picked from commit 3a58273501)
2026-04-25 08:22:00 +08:00
0396701572 Optimize constraint refresh after regrid
(cherry picked from commit 5c65cea2f0)
2026-04-25 08:18:51 +08:00
bb20c9a876 fix ADM Constrant Violation Analysis 2026-04-15 19:19:16 +08:00
8fe60ea703 Add zero matter handling and interpolation for resident state in CUDA BSSN 2026-04-15 00:25:53 +08:00
9ab7e7c7f9 Fuse phases 5 and 6 for Gamma_rhs computation and optimize phases 8 and 9 for efficiency 2026-04-14 23:23:04 +08:00
f9119e8a2a Add resident-GA mode switch and simplify sync logic 2026-04-14 21:09:27 +08:00
726d743376 Fuse Ricci assembly and optimize trK/Aij gauge kernels 2026-04-14 19:20:12 +08:00
af344bf1e5 Add Phase-10 Ricci kernels and batch launch flow 2026-04-14 19:00:22 +08:00
7191fc0b96 Move resident sync comm buffers into StepAllocation pool 2026-04-13 21:04:44 +08:00
b3ec244cf9 Add batched first/second derivative kernels for CUDA RHS 2026-04-13 20:51:08 +08:00
e952ee8e91 Batch GA/BH subset sync with indexed GPU pack/unpack buffers 2026-04-13 20:40:09 +08:00
c5d1268dd1 Batch patch-boundary copy and gate CPU BC in GPU substeps 2026-04-13 11:52:17 +08:00
4bdfc90f22 Pass pointer tables as kernel args and skip redundant symbol uploads 2026-04-13 11:19:00 +08:00
c49a4e00c9 Batch symbd_pack/lopsided/kodiss over all state variables 2026-04-13 11:02:55 +08:00
1b3c0b80d2 Refactor CUDA step buffers to remove loop-time allocations 2026-04-13 10:33:03 +08:00
636e35bfd8 Add direct CUDA resident-state sync path and profiling hooks 2026-04-13 00:57:05 +08:00
7f2a391dd2 Cache matter fields in StepContext across RK4 substeps 2026-04-12 22:19:45 +08:00
4fa12a2009 Integrate CUDA support into RK4 substep execution 2026-04-12 22:11:44 +08:00
86a683de26 Replace legacy ABEGPU stack with ABE_CUDA backend 2026-04-12 21:19:14 +08:00
aaf7bf0a26 Merge remote-tracking branch 'origin/main' 2026-04-12 20:55:42 +08:00
9c44d1c885 fix(bssn_rhs) 2026-03-03 16:00:45 +08:00
4b9de28feb 将 Restrict/Prolong 链路里的 coarse-level Sync_cached 改为可选(默认跳过)
OutBdLow2Hi_cached 读的是 coarse owned 区域(非 coarse ghost/buffer)
回退旧行为:编译时定义 RP_SYNC_COARSE_AFTER_RESTRICT=1
2026-03-03 14:25:27 +08:00
4eb5dc4ddb 删除重复的一次 chi 一阶导计算 2026-03-03 14:23:56 +08:00
226 changed files with 186026 additions and 170969 deletions

4
.gitignore vendored
View File

@@ -1,6 +1,6 @@
__pycache__ __pycache__
GW150914 GW150914
GW150914-origin GW150914*
docs docs
*.tmp *.tmp
.codex

6
.idea/vcs.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -16,9 +16,9 @@ import numpy
File_directory = "GW150914" ## output file directory File_directory = "GW150914" ## output file directory
Output_directory = "binary_output" ## binary data file directory Output_directory = "binary_output" ## binary data file directory
## The file directory name should not be too long ## The file directory name should not be too long
MPI_processes = 64 ## number of mpi processes used in the simulation MPI_processes = 2 ## number of mpi processes used in the simulation
GPU_Calculation = "no" ## Use GPU or not GPU_Calculation = "yes" ## Use GPU or not
## (prefer "no" in the current version, because the GPU part may have bugs when integrated in this Python interface) ## (prefer "no" in the current version, because the GPU part may have bugs when integrated in this Python interface)
CPU_Part = 1.0 CPU_Part = 1.0
GPU_Part = 0.0 GPU_Part = 0.0
@@ -158,7 +158,7 @@ Detector_Rmax = 160.0 ## farest dector distance
## Setting the apprent horizon ## Setting the apprent horizon
AHF_Find = "no" ## whether to find the apparent horizon: choose "yes" or "no" AHF_Find = "yes" ## whether to find the apparent horizon: choose "yes" or "no"
AHF_Find_Every = 24 AHF_Find_Every = 24
AHF_Dump_Time = 20.0 AHF_Dump_Time = 20.0

View File

@@ -58,31 +58,36 @@ File_directory = os.path.join(input_data.File_directory)
## If the specified output directory exists, ask the user whether to continue ## If the specified output directory exists, ask the user whether to continue
if os.path.exists(File_directory): if os.path.exists(File_directory):
print( " Output dictionary has been existed !!! " ) auto_overwrite = str(getattr(input_data, "Auto_Overwrite_Output", "yes")).strip().lower()
print( " If you want to overwrite the existing file directory, please input 'continue' in the terminal !! " ) if auto_overwrite in ("1", "yes", "y", "true", "on", "continue"):
print( " If you want to retain the existing file directory, please input 'stop' in the terminal to stop the " ) print( " Output dictionary has been existed; Auto_Overwrite_Output=yes, continue the calculation. " )
print( " simulation. Then you can reset the output dictionary in the input script file AMSS_NCKU_Input.py !!! " ) print( )
print( ) else:
## Prompt whether to overwrite the existing directory print( " Output dictionary has been existed !!! " )
while True: print( " If you want to overwrite the existing file directory, please input 'continue' in the terminal !! " )
try: print( " If you want to retain the existing file directory, please input 'stop' in the terminal to stop the " )
inputvalue = input() print( " simulation. Then you can reset the output dictionary in the input script file AMSS_NCKU_Input.py !!! " )
## If the user agrees to overwrite, proceed and remove the existing directory print( )
if ( inputvalue == "continue" ): ## Prompt whether to overwrite the existing directory
print( " Continue the calculation !!! " ) while True:
print( ) try:
break inputvalue = input()
## If the user chooses not to overwrite, exit and keep the existing directory ## If the user agrees to overwrite, proceed and remove the existing directory
elif ( inputvalue == "stop" ): if ( inputvalue == "continue" ):
print( " Stop the calculation !!! " ) print( " Continue the calculation !!! " )
sys.exit() print( )
## If the user input is invalid, prompt again break
else: ## If the user chooses not to overwrite, exit and keep the existing directory
elif ( inputvalue == "stop" ):
print( " Stop the calculation !!! " )
sys.exit()
## If the user input is invalid, prompt again
else:
print( " Please input your choice !!! " )
print( " Input 'continue' or 'stop' in the terminal !!! " )
except ValueError:
print( " Please input your choice !!! " ) print( " Please input your choice !!! " )
print( " Input 'continue' or 'stop' in the terminal !!! " ) print( " Input 'continue' or 'stop' in the terminal !!! " )
except ValueError:
print( " Please input your choice !!! " )
print( " Input 'continue' or 'stop' in the terminal !!! " )
## Remove the existing output directory if present ## Remove the existing output directory if present
shutil.rmtree(File_directory, ignore_errors=True) shutil.rmtree(File_directory, ignore_errors=True)
@@ -126,7 +131,12 @@ setup.generate_AMSSNCKU_input()
#inputvalue = input() ## Wait for user input (press Enter) to proceed #inputvalue = input() ## Wait for user input (press Enter) to proceed
#print() #print()
## Generate AMSS-NCKU program input files based on the configured parameters setup.print_puncture_information()
##################################################################
## Generate AMSS-NCKU program input files based on the configured parameters
print( ) print( )
print( " Generating the AMSS-NCKU input parfile for the ABE executable. " ) print( " Generating the AMSS-NCKU input parfile for the ABE executable. " )
@@ -253,7 +263,7 @@ print()
if (input_data.GPU_Calculation == "no"): if (input_data.GPU_Calculation == "no"):
ABE_file = os.path.join(AMSS_NCKU_source_copy, "ABE") ABE_file = os.path.join(AMSS_NCKU_source_copy, "ABE")
elif (input_data.GPU_Calculation == "yes"): elif (input_data.GPU_Calculation == "yes"):
ABE_file = os.path.join(AMSS_NCKU_source_copy, "ABEGPU") ABE_file = os.path.join(AMSS_NCKU_source_copy, "ABE_CUDA")
if not os.path.exists( ABE_file ): if not os.path.exists( ABE_file ):
print( ) print( )
@@ -307,7 +317,7 @@ if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
import generate_TwoPuncture_input import generate_TwoPuncture_input
generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input(numerical_grid.puncture_data) generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input()
print( ) print( )
print( " The input parfile for the TwoPunctureABE executable has been generated. " ) print( " The input parfile for the TwoPunctureABE executable has been generated. " )
@@ -349,7 +359,7 @@ if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
import renew_puncture_parameter import renew_puncture_parameter
renew_puncture_parameter.append_AMSSNCKU_BSSN_input(File_directory, output_directory, numerical_grid.puncture_data) renew_puncture_parameter.append_AMSSNCKU_BSSN_input(File_directory, output_directory)
## Generated AMSS-NCKU input filename ## Generated AMSS-NCKU input filename

100
AMSS_NCKU_Program_Plot.py Normal file
View File

@@ -0,0 +1,100 @@
##################################################################
##
## AMSS-NCKU Plot-Only Restart Script
## Author: Xiaoqu / Claude
## 2026/05/12
##
## This script checks for existing output data from AMSS_NCKU_Program.py.
## If data exists, it skips all computation and goes directly to plotting,
## saving time when plotting was interrupted.
## If no data is found, it exits with a message.
##
##################################################################
## Guard against re-execution by multiprocessing child processes.
if __name__ != '__main__':
import sys as _sys
_sys.exit(0)
import os
import sys
import AMSS_NCKU_Input as input_data
##################################################################
## Construct paths from input configuration
File_directory = os.path.join(input_data.File_directory)
output_directory = os.path.join(File_directory, "AMSS_NCKU_output")
binary_results_directory = os.path.join(output_directory, input_data.Output_directory)
figure_directory = os.path.join(File_directory, "figure")
##################################################################
## Check whether the required output data files exist
required_files = [
os.path.join(binary_results_directory, "bssn_BH.dat"),
os.path.join(binary_results_directory, "bssn_ADMQs.dat"),
os.path.join(binary_results_directory, "bssn_psi4.dat"),
os.path.join(binary_results_directory, "bssn_constraint.dat"),
]
missing_files = [f for f in required_files if not os.path.exists(f)]
if missing_files:
print(" No existing AMSS_NCKU_Program.py output data found. ")
print(" The following required files are missing: ")
for f in missing_files:
print(f" {f}")
print()
print(" Please run AMSS_NCKU_Program.py first to generate the simulation data. ")
print(" Exiting. ")
sys.exit(1)
print(" Found existing AMSS_NCKU_Program.py output data. " )
print(" Skipping all computation and going directly to plotting. " )
print()
## Ensure the figure directory exists (it should, but be safe)
os.makedirs(figure_directory, exist_ok=True)
##################################################################
## Plot the AMSS-NCKU program results
import plot_xiaoqu
import plot_GW_strain_amplitude_xiaoqu
from parallel_plot_helper import run_plot_tasks_parallel
plot_tasks = []
## Plot black hole trajectory
plot_tasks.append((plot_xiaoqu.generate_puncture_orbit_plot, (binary_results_directory, figure_directory)))
plot_tasks.append((plot_xiaoqu.generate_puncture_orbit_plot3D, (binary_results_directory, figure_directory)))
## Plot black hole separation vs. time
plot_tasks.append((plot_xiaoqu.generate_puncture_distence_plot, (binary_results_directory, figure_directory)))
## Plot gravitational waveforms (psi4 and strain amplitude)
for i in range(input_data.Detector_Number):
plot_tasks.append((plot_xiaoqu.generate_gravitational_wave_psi4_plot, (binary_results_directory, figure_directory, i)))
plot_tasks.append((plot_GW_strain_amplitude_xiaoqu.generate_gravitational_wave_amplitude_plot, (binary_results_directory, figure_directory, i)))
## Plot ADM mass evolution
for i in range(input_data.Detector_Number):
plot_tasks.append((plot_xiaoqu.generate_ADMmass_plot, (binary_results_directory, figure_directory, i)))
## Plot Hamiltonian constraint violation over time
for i in range(input_data.grid_level):
plot_tasks.append((plot_xiaoqu.generate_constraint_check_plot, (binary_results_directory, figure_directory, i)))
run_plot_tasks_parallel(plot_tasks)
## Plot stored binary data (runs serially, not in the parallel pool)
plot_xiaoqu.generate_binary_data_plot(binary_results_directory, figure_directory)
print()
print(" Plotting completed successfully. ")
print()

View File

@@ -198,16 +198,16 @@ int main(int argc, char *argv[])
if (myrank == 0) if (myrank == 0)
{ {
string out_dir; string out_dir;
char filename[50]; string filename;
map<string, string>::iterator iter; map<string, string>::iterator iter;
iter = parameters::str_par.find("output dir"); iter = parameters::str_par.find("output dir");
if (iter != parameters::str_par.end()) if (iter != parameters::str_par.end())
{ {
out_dir = iter->second; out_dir = iter->second;
} }
sprintf(filename, "%s/setting.par", out_dir.c_str()); filename = out_dir + "/setting.par";
ofstream setfile; ofstream setfile;
setfile.open(filename, ios::trunc); setfile.open(filename.c_str(), ios::trunc);
if (!setfile.good()) if (!setfile.good())
{ {
@@ -484,7 +484,11 @@ int main(int argc, char *argv[])
cout << endl; cout << endl;
} }
delete ADM; // Let the process teardown reclaim the simulation object. Some derived
// equation classes keep MPI/CUDA-backed state whose destructor ordering
// is fragile at program shutdown.
if (getenv("AMSS_DELETE_ADM_ON_EXIT"))
delete ADM;
//=======================caculation done============================================================= //=======================caculation done=============================================================

View File

@@ -1,53 +1,53 @@
#ifndef Ansorg_H #ifndef Ansorg_H
#define Ansorg_H #define Ansorg_H
#ifdef newc #ifdef newc
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <cmath> #include <cmath>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <fstream.h> #include <fstream.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#endif #endif
#include <mpi.h> #include <mpi.h>
#define PI M_PI #define PI M_PI
class Ansorg class Ansorg
{ {
protected: protected:
int n1, n2, n3, ntotal; int n1, n2, n3, ntotal;
int order; int order;
double *coordA, *coordB, *coordphi; double *coordA, *coordB, *coordphi;
int ps_rxx, ps_rxy, ps_ryx, ps_ryy; int ps_rxx, ps_rxy, ps_ryx, ps_ryy;
double ps_b, ps_dx; double ps_b, ps_dx;
double PIh; double PIh;
double *pu_ps; double *pu_ps;
int myrank; int myrank;
public: public:
Ansorg(char *filename, int orderi); Ansorg(char *filename, int orderi);
~Ansorg(); ~Ansorg();
double ps_u_at_xyz(double x, double y, double z); double ps_u_at_xyz(double x, double y, double z);
void set_ABp(); void set_ABp();
void xyz_to_ABp(double x, double y, double z, void xyz_to_ABp(double x, double y, double z,
double *A, double *B, double *phi); double *A, double *B, double *phi);
double interpolate_tri_bar(double x, double y, double z, double interpolate_tri_bar(double x, double y, double z,
int n1, int n2, int n3, int n1, int n2, int n3,
double *x1, double *x2, double *x3, double *yp); double *x1, double *x2, double *x3, double *yp);
int find_point_bisection(double x, int n, double *xp, int o); int find_point_bisection(double x, int n, double *xp, int o);
void barycentric_omega(int n, int s, double *x, double *omega); void barycentric_omega(int n, int s, double *x, double *omega);
double barycentric(double x0, int n, int s, double *x, double *y, double barycentric(double x0, int n, int s, double *x, double *y,
double *omega); double *omega);
}; };
#endif /* Ansorg_H */ #endif /* Ansorg_H */

View File

@@ -1,101 +1,101 @@
#ifndef BH_DIAGNOSTICS_H #ifndef BH_DIAGNOSTICS_H
#define BH_DIAGNOSTICS_H #define BH_DIAGNOSTICS_H
namespace AHFinderDirect namespace AHFinderDirect
{ {
struct BH_diagnostics struct BH_diagnostics
{ {
public: public:
// mean x,y,z // mean x,y,z
fp centroid_x, centroid_y, centroid_z; fp centroid_x, centroid_y, centroid_z;
// these are quadrupole moments about the centroid, i.e. // these are quadrupole moments about the centroid, i.e.
// mean(xi*xj) - centroid_i*centroid_j // mean(xi*xj) - centroid_i*centroid_j
fp quadrupole_xx, quadrupole_xy, quadrupole_xz, fp quadrupole_xx, quadrupole_xy, quadrupole_xz,
quadrupole_yy, quadrupole_yz, quadrupole_yy, quadrupole_yz,
quadrupole_zz; quadrupole_zz;
// min,max,mean surface radius about local coordinate origin // min,max,mean surface radius about local coordinate origin
fp min_radius, max_radius, mean_radius; fp min_radius, max_radius, mean_radius;
// xyz bounding box // xyz bounding box
fp min_x, max_x, fp min_x, max_x,
min_y, max_y, min_y, max_y,
min_z, max_z; min_z, max_z;
// proper circumference // proper circumference
// (computed using induced metric along these local-coordinate planes) // (computed using induced metric along these local-coordinate planes)
fp circumference_xy, fp circumference_xy,
circumference_xz, circumference_xz,
circumference_yz; circumference_yz;
// surface area (computed using induced metric) // surface area (computed using induced metric)
// and quantities derived from it // and quantities derived from it
fp area, irreducible_mass, areal_radius; fp area, irreducible_mass, areal_radius;
double Px, Py, Pz, Sx, Sy, Sz; double Px, Py, Pz, Sx, Sy, Sz;
public: public:
// position of diagnostics in buffer and number of diagnostics // position of diagnostics in buffer and number of diagnostics
enum enum
{ {
posn__centroid_x = 0, posn__centroid_x = 0,
posn__centroid_y, posn__centroid_y,
posn__centroid_z, posn__centroid_z,
posn__quadrupole_xx, posn__quadrupole_xx,
posn__quadrupole_xy, posn__quadrupole_xy,
posn__quadrupole_xz, posn__quadrupole_xz,
posn__quadrupole_yy, posn__quadrupole_yy,
posn__quadrupole_yz, posn__quadrupole_yz,
posn__quadrupole_zz, posn__quadrupole_zz,
posn__min_radius, posn__min_radius,
posn__max_radius, posn__max_radius,
posn__mean_radius, posn__mean_radius,
posn__min_x, posn__min_x,
posn__max_x, posn__max_x,
posn__min_y, posn__min_y,
posn__max_y, posn__max_y,
posn__min_z, posn__min_z,
posn__max_z, posn__max_z,
posn__circumference_xy, posn__circumference_xy,
posn__circumference_xz, posn__circumference_xz,
posn__circumference_yz, posn__circumference_yz,
posn__area, posn__area,
posn__irreducible_mass, posn__irreducible_mass,
posn__areal_radius, posn__areal_radius,
N_buffer // no comma // size of buffer N_buffer // no comma // size of buffer
}; };
// copy diagnostics to/from buffer // copy diagnostics to/from buffer
void copy_to_buffer(double buffer[N_buffer]) const; void copy_to_buffer(double buffer[N_buffer]) const;
void copy_from_buffer(const double buffer[N_buffer]); void copy_from_buffer(const double buffer[N_buffer]);
public: public:
void compute(patch_system &ps); void compute(patch_system &ps);
void compute_signature(patch_system &ps, const double dT); void compute_signature(patch_system &ps, const double dT);
FILE *setup_output_file(int N_horizons, int hn) FILE *setup_output_file(int N_horizons, int hn)
const; const;
void output(FILE *fileptr, double time) void output(FILE *fileptr, double time)
const; const;
BH_diagnostics(); BH_diagnostics();
private: private:
static double surface_integral(const patch_system &ps, static double surface_integral(const patch_system &ps,
int src_gfn, bool src_gfn_is_even_across_xy_plane, int src_gfn, bool src_gfn_is_even_across_xy_plane,
bool src_gfn_is_even_across_xz_plane, bool src_gfn_is_even_across_xz_plane,
bool src_gfn_is_even_across_yz_plane, bool src_gfn_is_even_across_yz_plane,
enum patch::integration_method method); enum patch::integration_method method);
}; };
//****************************************************************************** //******************************************************************************
} // namespace AHFinderDirect } // namespace AHFinderDirect
#endif /* BH_DIAGNOSTICS_H */ #endif /* BH_DIAGNOSTICS_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,210 +0,0 @@
#ifndef BSSN_GPU_CLASS_H
#define BSSN_GPU_CLASS_H
#ifdef newc
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;
#else
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#endif
#include <mpi.h>
#include "macrodef.h"
#include "cgh.h"
#include "ShellPatch.h"
#include "misc.h"
#include "var.h"
#include "MyList.h"
#include "monitor.h"
#include "surface_integral.h"
#include "checkpoint.h"
// added by yangquan
#include "bssn_macro.h"
extern void setpbh(int iBHN, double **iPBH, double *iMass, int rBHN);
class bssn_class
{
public:
// added by yangquan
//----------------------
int gpu_num_mynode;
int cpu_core_num_mynode;
int mpi_process_num_mynode;
int my_sequence_mynode;
int mynode_id;
int use_gpu;
virtual void Step_GPU(int lev, int YN);
virtual void Get_runtime_envirment();
// virtual void Step_OPENMP(int lev,int YN);
//----------------------
int ngfs;
int nprocs, myrank;
cgh *GH;
ShellPatch *SH;
double PhysTime;
int checkrun;
char checkfilename[50];
int Steps;
double StartTime, TotalTime;
double AnasTime, DumpTime, d2DumpTime, CheckTime;
double LastAnas, LastConsOut;
double Courant;
double numepss, numepsb, numepsh;
int Symmetry;
int maxl, decn;
double maxrex, drex;
int trfls, a_lev;
double dT;
double chitiny;
double **Porg0, **Porgbr, **Porg, **Porg1, **Porg_rhs;
int BH_num, BH_num_input;
double *Mass, *Pmom, *Spin;
double ADMMass;
var *phio, *trKo;
var *gxxo, *gxyo, *gxzo, *gyyo, *gyzo, *gzzo;
var *Axxo, *Axyo, *Axzo, *Ayyo, *Ayzo, *Azzo;
var *Gmxo, *Gmyo, *Gmzo;
var *Lapo, *Sfxo, *Sfyo, *Sfzo;
var *dtSfxo, *dtSfyo, *dtSfzo;
var *phi0, *trK0;
var *gxx0, *gxy0, *gxz0, *gyy0, *gyz0, *gzz0;
var *Axx0, *Axy0, *Axz0, *Ayy0, *Ayz0, *Azz0;
var *Gmx0, *Gmy0, *Gmz0;
var *Lap0, *Sfx0, *Sfy0, *Sfz0;
var *dtSfx0, *dtSfy0, *dtSfz0;
var *phi, *trK;
var *gxx, *gxy, *gxz, *gyy, *gyz, *gzz;
var *Axx, *Axy, *Axz, *Ayy, *Ayz, *Azz;
var *Gmx, *Gmy, *Gmz;
var *Lap, *Sfx, *Sfy, *Sfz;
var *dtSfx, *dtSfy, *dtSfz;
var *phi1, *trK1;
var *gxx1, *gxy1, *gxz1, *gyy1, *gyz1, *gzz1;
var *Axx1, *Axy1, *Axz1, *Ayy1, *Ayz1, *Azz1;
var *Gmx1, *Gmy1, *Gmz1;
var *Lap1, *Sfx1, *Sfy1, *Sfz1;
var *dtSfx1, *dtSfy1, *dtSfz1;
var *phi_rhs, *trK_rhs;
var *gxx_rhs, *gxy_rhs, *gxz_rhs, *gyy_rhs, *gyz_rhs, *gzz_rhs;
var *Axx_rhs, *Axy_rhs, *Axz_rhs, *Ayy_rhs, *Ayz_rhs, *Azz_rhs;
var *Gmx_rhs, *Gmy_rhs, *Gmz_rhs;
var *Lap_rhs, *Sfx_rhs, *Sfy_rhs, *Sfz_rhs;
var *dtSfx_rhs, *dtSfy_rhs, *dtSfz_rhs;
var *rho, *Sx, *Sy, *Sz, *Sxx, *Sxy, *Sxz, *Syy, *Syz, *Szz;
var *Gamxxx, *Gamxxy, *Gamxxz, *Gamxyy, *Gamxyz, *Gamxzz;
var *Gamyxx, *Gamyxy, *Gamyxz, *Gamyyy, *Gamyyz, *Gamyzz;
var *Gamzxx, *Gamzxy, *Gamzxz, *Gamzyy, *Gamzyz, *Gamzzz;
var *Rxx, *Rxy, *Rxz, *Ryy, *Ryz, *Rzz;
var *Rpsi4, *Ipsi4;
var *t1Rpsi4, *t1Ipsi4, *t2Rpsi4, *t2Ipsi4;
var *Cons_Ham, *Cons_Px, *Cons_Py, *Cons_Pz, *Cons_Gx, *Cons_Gy, *Cons_Gz;
#ifdef Point_Psi4
var *phix, *phiy, *phiz;
var *trKx, *trKy, *trKz;
var *Axxx, *Axxy, *Axxz;
var *Axyx, *Axyy, *Axyz;
var *Axzx, *Axzy, *Axzz;
var *Ayyx, *Ayyy, *Ayyz;
var *Ayzx, *Ayzy, *Ayzz;
var *Azzx, *Azzy, *Azzz;
#endif
// FIXME: uc = StateList, up = OldStateList, upp = SynchList_cor; so never touch these three data
MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList;
MyList<var> *OldStateList, *DumpList;
MyList<var> *ConstraintList;
monitor *ErrorMonitor, *Psi4Monitor, *BHMonitor, *MAPMonitor;
monitor *ConVMonitor;
surface_integral *Waveshell;
checkpoint *CheckPoint;
public:
bssn_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei,
int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi,
int a_levi, int maxli, int decni, double maxrexi, double drexi);
~bssn_class();
void Evolve(int Steps);
void RecursiveStep(int lev);
#if (PSTR == 1)
void ParallelStep();
void SHStep();
#endif
void RestrictProlong(int lev, int YN, bool BB, MyList<var> *SL, MyList<var> *OL, MyList<var> *corL);
void RestrictProlong_aux(int lev, int YN, bool BB, MyList<var> *SL, MyList<var> *OL, MyList<var> *corL);
void RestrictProlong(int lev, int YN, bool BB);
void ProlongRestrict(int lev, int YN, bool BB);
void Setup_Black_Hole_position();
void compute_Porg_rhs(double **BH_PS, double **BH_RHS, var *forx, var *fory, var *forz, int lev);
bool read_Pablo_file(int *ext, double *datain, char *filename);
void write_Pablo_file(int *ext, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax,
char *filename);
void AnalysisStuff(int lev, double dT_lev);
void Setup_KerrSchild();
void Enforce_algcon(int lev, int fg);
void testRestrict();
void testOutBd();
virtual void Setup_Initial_Data_Lousto();
virtual void Setup_Initial_Data_Cao();
virtual void Initialize();
virtual void Read_Ansorg();
virtual void Read_Pablo() {};
virtual void Compute_Psi4(int lev);
virtual void Step(int lev, int YN);
virtual void Interp_Constraint(bool infg);
virtual void Constraint_Out();
virtual void Compute_Constraint();
#ifdef With_AHF
protected:
MyList<var> *AHList, *AHDList, *GaugeList;
int AHfindevery;
double AHdumptime;
int *lastahdumpid, HN_num; // number of possible horizons
int *findeveryl;
double *xc, *yc, *zc, *xr, *yr, *zr;
bool *trigger;
double *dTT;
int *dumpid;
public:
void AH_Prepare_derivatives();
bool AH_Interp_Points(MyList<var> *VarList,
int NN, double **XX,
double *Shellf, int Symmetryi);
void AH_Step_Find(int lev, double dT_lev);
#endif
};
#endif /* BSSN_GPU_CLASS_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,199 +1,258 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <cmath> #include <cmath>
#include <new> #include <new>
using namespace std; using namespace std;
#include "Block.h" #include "Block.h"
#include "misc.h" #include "misc.h"
Block::Block(int DIM, int *shapei, double *bboxi, int ranki, int ingfsi, int fngfsi, int levi, const int cgpui) : rank(ranki), ingfs(ingfsi), fngfs(fngfsi), lev(levi), cgpu(cgpui) #if USE_CUDA_BSSN || USE_CUDA_Z4C
#include <cuda_runtime_api.h>
#endif
namespace {
bool cuda_pin_gridfuncs_enabled()
{ {
for (int i = 0; i < dim; i++) static int enabled = -1;
X[i] = 0; if (enabled < 0)
if (DIM != dim)
{ {
cout << "dimension is not consistent in Block construction" << endl; const char *env = getenv("AMSS_CUDA_PIN_GRIDFUNCS");
MPI_Abort(MPI_COMM_WORLD, 1); enabled = (env && atoi(env) != 0) ? 1 : 0;
} }
return enabled != 0;
}
bool flag = false; double *alloc_gridfunc(size_t count, unsigned char &pinned)
for (int i = 0; i < dim; i++) {
pinned = 0;
#if USE_CUDA_BSSN || USE_CUDA_Z4C
if (cuda_pin_gridfuncs_enabled())
{ {
shape[i] = shapei[i]; double *ptr = 0;
if (shape[i] <= 0) cudaError_t err = cudaMallocHost((void **)&ptr, count * sizeof(double));
flag = true; if (err == cudaSuccess)
bbox[i] = bboxi[i];
bbox[dim + i] = bboxi[dim + i];
}
int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (flag)
{
cout << "myrank: " << myrank << ", on rank: " << rank << endl;
cout << "error shape in Block construction: (" << shape[0] << "," << shape[1] << "," << shape[2] << ")" << endl;
cout << "box boundary: (" << bbox[0] << ":" << bbox[3] << "," << bbox[1] << ":" << bbox[4] << "," << bbox[2] << ":" << bbox[5] << ")" << endl;
cout << "belong to level " << lev << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
#ifndef FAKECHECK
if (myrank == rank)
{
for (int i = 0; i < dim; i++)
{ {
X[i] = new double[shape[i]]; pinned = 1;
#ifdef Vertex return ptr;
#ifdef Cell
#error Both Cell and Vertex are defined
#endif
double h = (bbox[dim + i] - bbox[i]) / (shape[i] - 1);
for (int j = 0; j < shape[i]; j++)
X[i][j] = bbox[i] + j * h;
#else
#ifdef Cell
double h = (bbox[dim + i] - bbox[i]) / shape[i];
for (int j = 0; j < shape[i]; j++)
X[i][j] = bbox[i] + (j + 0.5) * h;
#else
#error Not define Vertex nor Cell
#endif
#endif
} }
cudaGetLastError();
}
#endif
return (double *)malloc(sizeof(double) * count);
}
void free_gridfunc(double *ptr, unsigned char pinned)
{
if (!ptr)
return;
#if USE_CUDA_BSSN || USE_CUDA_Z4C
if (pinned)
{
cudaFreeHost(ptr);
return;
}
#else
(void)pinned;
#endif
free(ptr);
}
}
Block::Block(int DIM, int *shapei, double *bboxi, int ranki, int ingfsi, int fngfsi, int levi, const int cgpui) : rank(ranki), lev(levi), cgpu(cgpui), ingfs(ingfsi), fngfs(fngfsi), igfs(0), fgfs(0), fgfs_pinned(0)
{
for (int i = 0; i < dim; i++)
X[i] = 0;
if (DIM != dim)
{
cout << "dimension is not consistent in Block construction" << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
bool flag = false;
for (int i = 0; i < dim; i++)
{
shape[i] = shapei[i];
if (shape[i] <= 0)
flag = true;
bbox[i] = bboxi[i];
bbox[dim + i] = bboxi[dim + i];
}
int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (flag)
{
cout << "myrank: " << myrank << ", on rank: " << rank << endl;
cout << "error shape in Block construction: (" << shape[0] << "," << shape[1] << "," << shape[2] << ")" << endl;
cout << "box boundary: (" << bbox[0] << ":" << bbox[3] << "," << bbox[1] << ":" << bbox[4] << "," << bbox[2] << ":" << bbox[5] << ")" << endl;
cout << "belong to level " << lev << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
#ifndef FAKECHECK
if (myrank == rank)
{
for (int i = 0; i < dim; i++)
{
X[i] = new double[shape[i]];
#ifdef Vertex
#ifdef Cell
#error Both Cell and Vertex are defined
#endif
double h = (bbox[dim + i] - bbox[i]) / (shape[i] - 1);
for (int j = 0; j < shape[i]; j++)
X[i][j] = bbox[i] + j * h;
#else
#ifdef Cell
double h = (bbox[dim + i] - bbox[i]) / shape[i];
for (int j = 0; j < shape[i]; j++)
X[i][j] = bbox[i] + (j + 0.5) * h;
#else
#error Not define Vertex nor Cell
#endif
#endif
}
int nn = shape[0] * shape[1] * shape[2]; int nn = shape[0] * shape[1] * shape[2];
fgfs = new double *[fngfs]; fgfs = new double *[fngfs];
fgfs_pinned = new unsigned char[fngfs];
for (int i = 0; i < fngfs; i++) for (int i = 0; i < fngfs; i++)
{ {
fgfs[i] = (double *)malloc(sizeof(double) * nn); fgfs[i] = alloc_gridfunc((size_t)nn, fgfs_pinned[i]);
if (!(fgfs[i])) if (!(fgfs[i]))
{ {
cout << "on node#" << rank << ", out of memory when constructing Block." << endl; cout << "on node#" << rank << ", out of memory when constructing Block." << endl;
MPI_Abort(MPI_COMM_WORLD, 1); MPI_Abort(MPI_COMM_WORLD, 1);
} }
memset(fgfs[i], 0, sizeof(double) * nn); memset(fgfs[i], 0, sizeof(double) * nn);
} }
igfs = new int *[ingfs]; igfs = new int *[ingfs];
for (int i = 0; i < ingfs; i++) for (int i = 0; i < ingfs; i++)
{ {
igfs[i] = (int *)malloc(sizeof(int) * nn); igfs[i] = (int *)malloc(sizeof(int) * nn);
if (!(igfs[i])) if (!(igfs[i]))
{ {
cout << "on node#" << rank << ", out of memory when constructing Block." << endl; cout << "on node#" << rank << ", out of memory when constructing Block." << endl;
MPI_Abort(MPI_COMM_WORLD, 1); MPI_Abort(MPI_COMM_WORLD, 1);
} }
memset(igfs[i], 0, sizeof(int) * nn); memset(igfs[i], 0, sizeof(int) * nn);
} }
} }
#endif #endif
} }
Block::~Block() Block::~Block()
{ {
int myrank; int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank); MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == rank) if (myrank == rank)
{ {
for (int i = 0; i < dim; i++) for (int i = 0; i < dim; i++)
delete[] X[i]; delete[] X[i];
for (int i = 0; i < ingfs; i++) for (int i = 0; i < ingfs; i++)
free(igfs[i]); free(igfs[i]);
delete[] igfs; delete[] igfs;
for (int i = 0; i < fngfs; i++) for (int i = 0; i < fngfs; i++)
free(fgfs[i]); free_gridfunc(fgfs[i], fgfs_pinned ? fgfs_pinned[i] : 0);
delete[] fgfs; delete[] fgfs;
delete[] fgfs_pinned;
X[0] = X[1] = X[2] = 0; X[0] = X[1] = X[2] = 0;
igfs = 0; igfs = 0;
fgfs = 0; fgfs = 0;
fgfs_pinned = 0;
} }
} }
void Block::checkBlock() void Block::checkBlock()
{ {
int myrank; int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank); MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == 0) if (myrank == 0)
{ {
cout << "belong to level " << lev << endl; cout << "belong to level " << lev << endl;
cout << "shape: ["; cout << "shape: [";
for (int i = 0; i < dim; i++) for (int i = 0; i < dim; i++)
{ {
cout << shape[i]; cout << shape[i];
if (i < dim - 1) if (i < dim - 1)
cout << ","; cout << ",";
else else
cout << "]"; cout << "]";
} }
cout << " resolution: ["; cout << " resolution: [";
for (int i = 0; i < dim; i++) for (int i = 0; i < dim; i++)
{ {
cout << getdX(i); cout << getdX(i);
if (i < dim - 1) if (i < dim - 1)
cout << ","; cout << ",";
else else
cout << "]" << endl; cout << "]" << endl;
} }
cout << "locate on node " << rank << ", at (includes ghost zone):" << endl; cout << "locate on node " << rank << ", at (includes ghost zone):" << endl;
cout << "("; cout << "(";
for (int i = 0; i < dim; i++) for (int i = 0; i < dim; i++)
{ {
cout << bbox[i] << ":" << bbox[dim + i]; cout << bbox[i] << ":" << bbox[dim + i];
if (i < dim - 1) if (i < dim - 1)
cout << ","; cout << ",";
else else
cout << ")" << endl; cout << ")" << endl;
} }
cout << "has " << ingfs << " int type grids functions," << fngfs << " double type grids functions" << endl; cout << "has " << ingfs << " int type grids functions," << fngfs << " double type grids functions" << endl;
} }
} }
double Block::getdX(int dir) double Block::getdX(int dir)
{ {
if (dir < 0 || dir >= dim) if (dir < 0 || dir >= dim)
{ {
cout << "Block::getdX: error input dir = " << dir << ", this Block has direction (0," << dim - 1 << ")" << endl; cout << "Block::getdX: error input dir = " << dir << ", this Block has direction (0," << dim - 1 << ")" << endl;
MPI_Abort(MPI_COMM_WORLD, 1); MPI_Abort(MPI_COMM_WORLD, 1);
} }
double h; double h;
#ifdef Vertex #ifdef Vertex
#ifdef Cell #ifdef Cell
#error Both Cell and Vertex are defined #error Both Cell and Vertex are defined
#endif #endif
if (shape[dir] == 1) if (shape[dir] == 1)
{ {
cout << "Block::getdX: for direction " << dir << ", this Block has only one point. Can not determine dX for vertex center grid." << endl; cout << "Block::getdX: for direction " << dir << ", this Block has only one point. Can not determine dX for vertex center grid." << endl;
MPI_Abort(MPI_COMM_WORLD, 1); MPI_Abort(MPI_COMM_WORLD, 1);
} }
h = (bbox[dim + dir] - bbox[dir]) / (shape[dir] - 1); h = (bbox[dim + dir] - bbox[dir]) / (shape[dir] - 1);
#else #else
#ifdef Cell #ifdef Cell
h = (bbox[dim + dir] - bbox[dir]) / shape[dir]; h = (bbox[dim + dir] - bbox[dir]) / shape[dir];
#else #else
#error Not define Vertex nor Cell #error Not define Vertex nor Cell
#endif #endif
#endif #endif
return h; return h;
} }
void Block::swapList(MyList<var> *VarList1, MyList<var> *VarList2, int myrank) void Block::swapList(MyList<var> *VarList1, MyList<var> *VarList2, int myrank)
{ {
if (rank == myrank) if (rank == myrank)
{ {
MyList<var> *varl1 = VarList1, *varl2 = VarList2; MyList<var> *varl1 = VarList1, *varl2 = VarList2;
while (varl1 && varl2) while (varl1 && varl2)
{ {
misc::swap<double *>(fgfs[varl1->data->sgfn], fgfs[varl2->data->sgfn]); misc::swap<double *>(fgfs[varl1->data->sgfn], fgfs[varl2->data->sgfn]);
if (fgfs_pinned)
misc::swap<unsigned char>(fgfs_pinned[varl1->data->sgfn], fgfs_pinned[varl2->data->sgfn]);
varl1 = varl1->next; varl1 = varl1->next;
varl2 = varl2->next; varl2 = varl2->next;
} }
if (varl1 || varl2) if (varl1 || varl2)
{ {
cout << "error in Block::swaplist, var lists does not match." << endl; cout << "error in Block::swaplist, var lists does not match." << endl;
MPI_Abort(MPI_COMM_WORLD, 1); MPI_Abort(MPI_COMM_WORLD, 1);
} }
} }
} }

View File

@@ -1,34 +1,35 @@
#ifndef BLOCK_H #ifndef BLOCK_H
#define BLOCK_H #define BLOCK_H
#include <mpi.h> #include <mpi.h>
#include "macrodef.h" //need dim here; Vertex or Cell #include "macrodef.h" //need dim here; Vertex or Cell
#include "var.h" #include "var.h"
#include "MyList.h" #include "MyList.h"
class Block class Block
{ {
public: public:
int shape[dim]; int shape[dim];
double bbox[2 * dim]; double bbox[2 * dim];
double *X[dim]; double *X[dim];
int rank; // where the real data locate in int rank; // where the real data locate in
int lev, cgpu; int lev, cgpu;
int ingfs, fngfs; int ingfs, fngfs;
int *(*igfs); int *(*igfs);
double *(*fgfs); double *(*fgfs);
unsigned char *fgfs_pinned;
public:
Block() {}; public:
Block(int DIM, int *shapei, double *bboxi, int ranki, int ingfsi, int fngfs, int levi, const int cgpui = 0); Block() : rank(0), lev(0), cgpu(0), ingfs(0), fngfs(0), igfs(0), fgfs(0), fgfs_pinned(0) {};
Block(int DIM, int *shapei, double *bboxi, int ranki, int ingfsi, int fngfs, int levi, const int cgpui = 0);
~Block();
~Block();
void checkBlock();
void checkBlock();
double getdX(int dir);
void swapList(MyList<var> *VarList1, MyList<var> *VarList2, int myrank); double getdX(int dir);
}; void swapList(MyList<var> *VarList1, MyList<var> *VarList2, int myrank);
};
#endif /* BLOCK_H */
#endif /* BLOCK_H */

View File

@@ -1,283 +1,283 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Read binary files and do fancy things with them... // Read binary files and do fancy things with them...
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
#ifdef newc #ifdef newc
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
using namespace std; using namespace std;
#else #else
#include <math.h> #include <math.h>
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <fstream.h> #include <fstream.h>
#endif #endif
#include "microdef.fh" #include "microdef.fh"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// //
// USE: DataCT flag file1 [ file2 ] // USE: DataCT flag file1 [ file2 ]
// //
// where: - flag can be XY,XZ,YZ // where: - flag can be XY,XZ,YZ
// //
void set_fname(char *fname); void set_fname(char *fname);
if (argc < 3) if (argc < 3)
{ {
cout << "\aUsage: DataCT flag binaryfile1 [ binaryfile2 ] \n " cout << "\aUsage: DataCT flag binaryfile1 [ binaryfile2 ] \n "
<< " where: - flag can be XY,XZ,YZ" << " where: - flag can be XY,XZ,YZ"
<< endl; << endl;
exit(1); exit(1);
} }
ifstream infile1; ifstream infile1;
infile1.open(argv[2]); infile1.open(argv[2]);
if (!infile1) if (!infile1)
{ {
cerr << "\a Can't open " << argv[2] << " for input." << endl; cerr << "\a Can't open " << argv[2] << " for input." << endl;
exit(1); exit(1);
} }
/* read properties of the binary file */ /* read properties of the binary file */
double time; double time;
int nx, ny, nz; int nx, ny, nz;
double xmin, xmax, ymin, ymax, zmin, zmax; double xmin, xmax, ymin, ymax, zmin, zmax;
infile1.seekg(0, ios::beg); infile1.seekg(0, ios::beg);
infile1.read((char *)&time, sizeof(double)); infile1.read((char *)&time, sizeof(double));
infile1.read((char *)&nx, sizeof(int)); infile1.read((char *)&nx, sizeof(int));
infile1.read((char *)&ny, sizeof(int)); infile1.read((char *)&ny, sizeof(int));
infile1.read((char *)&nz, sizeof(int)); infile1.read((char *)&nz, sizeof(int));
infile1.read((char *)&xmin, sizeof(double)); infile1.read((char *)&xmin, sizeof(double));
infile1.read((char *)&xmax, sizeof(double)); infile1.read((char *)&xmax, sizeof(double));
infile1.read((char *)&ymin, sizeof(double)); infile1.read((char *)&ymin, sizeof(double));
infile1.read((char *)&ymax, sizeof(double)); infile1.read((char *)&ymax, sizeof(double));
infile1.read((char *)&zmin, sizeof(double)); infile1.read((char *)&zmin, sizeof(double));
infile1.read((char *)&zmax, sizeof(double)); infile1.read((char *)&zmax, sizeof(double));
/* get rid of any 4 character suffix */ /* get rid of any 4 character suffix */
set_fname(argv[2]); set_fname(argv[2]);
/* sanity check */ /* sanity check */
if (nx != ny || nx != nz) if (nx != ny || nx != nz)
{ {
cout << "\n" cout << "\n"
<< endl; << endl;
cout << " nx, ny and nz do not agree! Using a symmetry?... "; cout << " nx, ny and nz do not agree! Using a symmetry?... ";
cout << "\n" cout << "\n"
<< endl; << endl;
} }
cout << "\n Reading file : " << argv[2] << endl; cout << "\n Reading file : " << argv[2] << endl;
cout << "\n Time : " << time << endl; cout << "\n Time : " << time << endl;
cout << " Dimensions : " << setw(16) << nx << setw(16) << ny << setw(16) << nz << endl; cout << " Dimensions : " << setw(16) << nx << setw(16) << ny << setw(16) << nz << endl;
cout << " xmin, xmax : " << setw(16) << xmin << setw(16) << xmax << endl; cout << " xmin, xmax : " << setw(16) << xmin << setw(16) << xmax << endl;
cout << " ymin, ymax : " << setw(16) << ymin << setw(16) << ymax << endl; cout << " ymin, ymax : " << setw(16) << ymin << setw(16) << ymax << endl;
cout << " zmin, zmax : " << setw(16) << zmin << setw(16) << zmax << endl; cout << " zmin, zmax : " << setw(16) << zmin << setw(16) << zmax << endl;
cout << "\n"; cout << "\n";
double *data; double *data;
data = new double[nx * ny * nz]; data = new double[nx * ny * nz];
int i = 0, j = 0, k = 0; int i = 0, j = 0, k = 0;
infile1.read((char *)data, nx * ny * nz * sizeof(double)); infile1.read((char *)data, nx * ny * nz * sizeof(double));
infile1.close(); infile1.close();
// //
// //
// if second file given, open second file and subtract from first one! // if second file given, open second file and subtract from first one!
// //
// //
if (argc == 4) if (argc == 4)
{ {
infile1.open(argv[3]); infile1.open(argv[3]);
if (!infile1) if (!infile1)
{ {
cerr << "\a Can't open " << argv[3] << " for input." << endl; cerr << "\a Can't open " << argv[3] << " for input." << endl;
exit(1); exit(1);
} }
double *indata; double *indata;
indata = new double[nx * ny * nz]; indata = new double[nx * ny * nz];
// read in header // read in header
infile1.seekg(0, ios::beg); infile1.seekg(0, ios::beg);
int nxin, nyin, nzin; int nxin, nyin, nzin;
infile1.read((char *)&time, sizeof(double)); infile1.read((char *)&time, sizeof(double));
infile1.read((char *)&nxin, sizeof(int)); infile1.read((char *)&nxin, sizeof(int));
infile1.read((char *)&nyin, sizeof(int)); infile1.read((char *)&nyin, sizeof(int));
infile1.read((char *)&nzin, sizeof(int)); infile1.read((char *)&nzin, sizeof(int));
infile1.read((char *)&xmin, sizeof(double)); infile1.read((char *)&xmin, sizeof(double));
infile1.read((char *)&xmax, sizeof(double)); infile1.read((char *)&xmax, sizeof(double));
infile1.read((char *)&ymin, sizeof(double)); infile1.read((char *)&ymin, sizeof(double));
infile1.read((char *)&ymax, sizeof(double)); infile1.read((char *)&ymax, sizeof(double));
infile1.read((char *)&zmin, sizeof(double)); infile1.read((char *)&zmin, sizeof(double));
infile1.read((char *)&zmax, sizeof(double)); infile1.read((char *)&zmax, sizeof(double));
if (nxin != nx || nyin != ny || nzin != nz) if (nxin != nx || nyin != ny || nzin != nz)
{ {
cerr << "\a Number of indices do not agree! " << endl; cerr << "\a Number of indices do not agree! " << endl;
exit(1); exit(1);
} }
cout << " Comparing with data at time " << time << "\n" cout << " Comparing with data at time " << time << "\n"
<< endl; << endl;
infile1.read((char *)indata, nx * ny * nz * sizeof(double)); infile1.read((char *)indata, nx * ny * nz * sizeof(double));
infile1.close(); infile1.close();
for (i = 0; i < nx * ny * nz; i++) for (i = 0; i < nx * ny * nz; i++)
data[i] -= indata[i]; data[i] -= indata[i];
} }
double *X, *Y, *Z; double *X, *Y, *Z;
X = new double[nx]; X = new double[nx];
Y = new double[ny]; Y = new double[ny];
Z = new double[nz]; Z = new double[nz];
double dd; double dd;
#ifdef Vertex #ifdef Vertex
#ifdef Cell #ifdef Cell
#error Both Cell and Vertex are defined #error Both Cell and Vertex are defined
#endif #endif
dd = (xmax - xmin) / (nx - 1); dd = (xmax - xmin) / (nx - 1);
for (i = 0; i < nx; i++) for (i = 0; i < nx; i++)
X[i] = xmin + i * dd; X[i] = xmin + i * dd;
dd = (ymax - ymin) / (ny - 1); dd = (ymax - ymin) / (ny - 1);
for (j = 0; j < ny; j++) for (j = 0; j < ny; j++)
Y[j] = ymin + j * dd; Y[j] = ymin + j * dd;
dd = (zmax - zmin) / (nz - 1); dd = (zmax - zmin) / (nz - 1);
for (k = 0; k < nz; k++) for (k = 0; k < nz; k++)
Z[k] = zmin + k * dd; Z[k] = zmin + k * dd;
#else #else
#ifdef Cell #ifdef Cell
dd = (xmax - xmin) / nx; dd = (xmax - xmin) / nx;
for (i = 0; i < nx; i++) for (i = 0; i < nx; i++)
X[i] = xmin + (i + 0.5) * dd; X[i] = xmin + (i + 0.5) * dd;
dd = (ymax - ymin) / ny; dd = (ymax - ymin) / ny;
for (j = 0; j < ny; j++) for (j = 0; j < ny; j++)
Y[j] = ymin + (j + 0.5) * dd; Y[j] = ymin + (j + 0.5) * dd;
dd = (zmax - zmin) / nz; dd = (zmax - zmin) / nz;
for (k = 0; k < nz; k++) for (k = 0; k < nz; k++)
Z[k] = zmin + (k + 0.5) * dd; Z[k] = zmin + (k + 0.5) * dd;
#else #else
#error Not define Vertex nor Cell #error Not define Vertex nor Cell
#endif #endif
#endif #endif
int ext[3]; int ext[3];
ext[0] = nx; ext[0] = nx;
ext[1] = ny; ext[1] = ny;
ext[2] = nz; ext[2] = nz;
void writefile(int *ext, double *XX, double *YY, double *ZZ, double *datain, void writefile(int *ext, double *XX, double *YY, double *ZZ, double *datain,
char *filename, const char *flag); char *filename, const char *flag);
writefile(ext, X, Y, Z, data, argv[2], argv[1]); writefile(ext, X, Y, Z, data, argv[2], argv[1]);
delete[] data; delete[] data;
delete[] X; delete[] X;
delete[] Y; delete[] Y;
delete[] Z; delete[] Z;
} }
/*-----------------------------------*/ /*-----------------------------------*/
/* get rid of any 4 character suffix */ /* get rid of any 4 character suffix */
/*-----------------------------------*/ /*-----------------------------------*/
void set_fname(char *fname) void set_fname(char *fname)
{ {
int len = strlen(fname) - 4; int len = strlen(fname) - 4;
char *n_fname; char *n_fname;
n_fname = new char[len]; n_fname = new char[len];
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
{ {
n_fname[i] = fname[i]; n_fname[i] = fname[i];
// cout << n_fname[i] << " " << i << endl; // cout << n_fname[i] << " " << i << endl;
} }
n_fname[len] = '\0'; n_fname[len] = '\0';
// cout << "n_fname: " << n_fname << " fname: " << fname << ", " // cout << "n_fname: " << n_fname << " fname: " << fname << ", "
// << len << endl; // << len << endl;
strcpy(fname, n_fname); /* Send back the old pointer */ strcpy(fname, n_fname); /* Send back the old pointer */
delete n_fname; delete n_fname;
} }
//|---------------------------------------------------------------------------- //|----------------------------------------------------------------------------
// writefile // writefile
//|---------------------------------------------------------------------------- //|----------------------------------------------------------------------------
void writefile(int *ext, double *XX, double *YY, double *ZZ, double *datain, void writefile(int *ext, double *XX, double *YY, double *ZZ, double *datain,
char *filename, const char *flag) char *filename, const char *flag)
{ {
int nx = ext[0], ny = ext[1], nz = ext[2]; int nx = ext[0], ny = ext[1], nz = ext[2];
int i, j, k; int i, j, k;
char filename_h[50]; char filename_h[50];
//|--->open out put file //|--->open out put file
ofstream outfile; ofstream outfile;
if (!strcmp(flag, "YZ")) if (!strcmp(flag, "YZ"))
{ {
for (i = 0; i < nx; i++) for (i = 0; i < nx; i++)
{ {
sprintf(filename_h, "%s_%d.dat", filename, i); sprintf(filename_h, "%s_%d.dat", filename, i);
outfile.open(filename_h); outfile.open(filename_h);
outfile << "# CT along X at " << i << endl; outfile << "# CT along X at " << i << endl;
for (k = 0; k < nz; k++) for (k = 0; k < nz; k++)
{ {
for (j = 0; j < ny; j++) for (j = 0; j < ny; j++)
{ {
outfile << setw(10) << setprecision(10) << YY[j] << " " outfile << setw(10) << setprecision(10) << YY[j] << " "
<< setw(10) << setprecision(10) << ZZ[k] << " " << setw(10) << setprecision(10) << ZZ[k] << " "
<< datain[i + j * nx + k * nx * ny] << " " << datain[i + j * nx + k * nx * ny] << " "
<< endl; << endl;
} }
outfile << "\n"; /* blanck line for gnuplot */ outfile << "\n"; /* blanck line for gnuplot */
} }
outfile.close(); outfile.close();
} }
} }
else if (!strcmp(flag, "XZ")) else if (!strcmp(flag, "XZ"))
{ {
for (j = 0; j < ny; j++) for (j = 0; j < ny; j++)
{ {
sprintf(filename_h, "%s_%d.dat", filename, j); sprintf(filename_h, "%s_%d.dat", filename, j);
outfile.open(filename_h); outfile.open(filename_h);
outfile << "# CT along Y at " << j << endl; outfile << "# CT along Y at " << j << endl;
for (k = 0; k < nz; k++) for (k = 0; k < nz; k++)
{ {
for (i = 0; i < nx; i++) for (i = 0; i < nx; i++)
{ {
outfile << setw(10) << setprecision(10) << XX[i] << " " outfile << setw(10) << setprecision(10) << XX[i] << " "
<< setw(10) << setprecision(10) << ZZ[k] << " " << setw(10) << setprecision(10) << ZZ[k] << " "
<< datain[i + j * nx + k * nx * ny] << " " << datain[i + j * nx + k * nx * ny] << " "
<< endl; << endl;
} }
outfile << "\n"; /* blanck line for gnuplot */ outfile << "\n"; /* blanck line for gnuplot */
} }
outfile.close(); outfile.close();
} }
} }
else if (!strcmp(flag, "XY")) else if (!strcmp(flag, "XY"))
{ {
for (k = 0; k < nz; k++) for (k = 0; k < nz; k++)
{ {
sprintf(filename_h, "%s_%d.dat", filename, k); sprintf(filename_h, "%s_%d.dat", filename, k);
outfile.open(filename_h); outfile.open(filename_h);
outfile << "# CT along Z at " << k << endl; outfile << "# CT along Z at " << k << endl;
for (j = 0; j < ny; j++) for (j = 0; j < ny; j++)
{ {
for (i = 0; i < nx; i++) for (i = 0; i < nx; i++)
{ {
outfile << setw(10) << setprecision(10) << XX[i] << " " outfile << setw(10) << setprecision(10) << XX[i] << " "
<< setw(10) << setprecision(10) << YY[j] << " " << setw(10) << setprecision(10) << YY[j] << " "
<< datain[i + j * nx + k * nx * ny] << " " << datain[i + j * nx + k * nx * ny] << " "
<< endl; << endl;
} }
outfile << "\n"; /* blanck line for gnuplot */ outfile << "\n"; /* blanck line for gnuplot */
} }
outfile.close(); outfile.close();
} }
} }
else else
{ {
cout << "In output_data: not recognized flag-->" << flag << endl; cout << "In output_data: not recognized flag-->" << flag << endl;
exit(0); exit(0);
} }
} }

View File

@@ -1,87 +1,87 @@
#if 0 #if 0
program checkFFT program checkFFT
use dfport use dfport
implicit none implicit none
double precision::x double precision::x
integer,parameter::N=256 integer,parameter::N=256
double precision,dimension(N*2)::p double precision,dimension(N*2)::p
double precision,dimension(N/2)::s double precision,dimension(N/2)::s
integer::ncount,j,idum integer::ncount,j,idum
character(len=8)::tt character(len=8)::tt
tt=clock() tt=clock()
idum=iachar(tt(8:8))-48 idum=iachar(tt(8:8))-48
p=0.0 p=0.0
open(77,file='prime.dat',status='unknown') open(77,file='prime.dat',status='unknown')
loop1:do ncount=1,N loop1:do ncount=1,N
x=ran(idum) x=ran(idum)
p(2*ncount-1)=x p(2*ncount-1)=x
write(77,'(f15.3)')x write(77,'(f15.3)')x
enddo loop1 enddo loop1
close(77) close(77)
call four1(p,N,1) call four1(p,N,1)
do j=1,N/2 do j=1,N/2
s(j)=p(2*j)*p(2*j)+p(2*j-1)*p(2*j-1) s(j)=p(2*j)*p(2*j)+p(2*j-1)*p(2*j-1)
enddo enddo
x=0.0 x=0.0
do j=1,N/2 do j=1,N/2
x=x+s(j) x=x+s(j)
enddo enddo
s=s/x s=s/x
open(77,file='power.dat',status='unknown') open(77,file='power.dat',status='unknown')
do j=1,N/2 do j=1,N/2
write(77,'(2(1x,f15.3))')dble(j-1)/dble(N),s(j) write(77,'(2(1x,f15.3))')dble(j-1)/dble(N),s(j)
enddo enddo
close(77) close(77)
end program checkFFT end program checkFFT
#endif #endif
!------------- !-------------
! Optimized FFT using Intel oneMKL DFTI ! Optimized FFT using Intel oneMKL DFTI
! Mathematical equivalence: Standard DFT definition ! Mathematical equivalence: Standard DFT definition
! Forward (isign=1): X[k] = sum_{n=0}^{N-1} x[n] * exp(-2*pi*i*k*n/N) ! Forward (isign=1): X[k] = sum_{n=0}^{N-1} x[n] * exp(-2*pi*i*k*n/N)
! Backward (isign=-1): X[k] = sum_{n=0}^{N-1} x[n] * exp(+2*pi*i*k*n/N) ! Backward (isign=-1): X[k] = sum_{n=0}^{N-1} x[n] * exp(+2*pi*i*k*n/N)
! Input/Output: dataa is interleaved complex array [Re(0),Im(0),Re(1),Im(1),...] ! Input/Output: dataa is interleaved complex array [Re(0),Im(0),Re(1),Im(1),...]
!------------- !-------------
SUBROUTINE four1(dataa,nn,isign) SUBROUTINE four1(dataa,nn,isign)
use MKL_DFTI use MKL_DFTI
implicit none implicit none
INTEGER, intent(in) :: isign, nn INTEGER, intent(in) :: isign, nn
DOUBLE PRECISION, dimension(2*nn), intent(inout) :: dataa DOUBLE PRECISION, dimension(2*nn), intent(inout) :: dataa
type(DFTI_DESCRIPTOR), pointer :: desc type(DFTI_DESCRIPTOR), pointer :: desc
integer :: status integer :: status
! Create DFTI descriptor for 1D complex-to-complex transform ! Create DFTI descriptor for 1D complex-to-complex transform
status = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 1, nn) status = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 1, nn)
if (status /= 0) return if (status /= 0) return
! Set input/output storage as interleaved complex (default) ! Set input/output storage as interleaved complex (default)
status = DftiSetValue(desc, DFTI_PLACEMENT, DFTI_INPLACE) status = DftiSetValue(desc, DFTI_PLACEMENT, DFTI_INPLACE)
if (status /= 0) then if (status /= 0) then
status = DftiFreeDescriptor(desc) status = DftiFreeDescriptor(desc)
return return
endif endif
! Commit the descriptor ! Commit the descriptor
status = DftiCommitDescriptor(desc) status = DftiCommitDescriptor(desc)
if (status /= 0) then if (status /= 0) then
status = DftiFreeDescriptor(desc) status = DftiFreeDescriptor(desc)
return return
endif endif
! Execute FFT based on direction ! Execute FFT based on direction
if (isign == 1) then if (isign == 1) then
! Forward FFT: exp(-2*pi*i*k*n/N) ! Forward FFT: exp(-2*pi*i*k*n/N)
status = DftiComputeForward(desc, dataa) status = DftiComputeForward(desc, dataa)
else else
! Backward FFT: exp(+2*pi*i*k*n/N) ! Backward FFT: exp(+2*pi*i*k*n/N)
status = DftiComputeBackward(desc, dataa) status = DftiComputeBackward(desc, dataa)
endif endif
! Free descriptor ! Free descriptor
status = DftiFreeDescriptor(desc) status = DftiFreeDescriptor(desc)
return return
END SUBROUTINE four1 END SUBROUTINE four1

View File

@@ -1,97 +1,97 @@
//$Id: IntPnts.C,v 1.1 2012/04/03 10:49:42 zjcao Exp $ //$Id: IntPnts.C,v 1.1 2012/04/03 10:49:42 zjcao Exp $
#include "macrodef.h" #include "macrodef.h"
#ifdef With_AHF #ifdef With_AHF
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
#include "myglobal.h" #include "myglobal.h"
namespace AHFinderDirect namespace AHFinderDirect
{ {
extern struct state state; extern struct state state;
int globalInterpGFL(double *X, double *Y, double *Z, int Ns, int globalInterpGFL(double *X, double *Y, double *Z, int Ns,
double *Data) double *Data)
{ {
if (Ns == 0) if (Ns == 0)
return 0; return 0;
int n; int n;
double *pox[3]; double *pox[3];
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
pox[i] = new double[Ns]; pox[i] = new double[Ns];
for (n = 0; n < Ns; n++) for (n = 0; n < Ns; n++)
{ {
pox[0][n] = X[n]; pox[0][n] = X[n];
pox[1][n] = Y[n]; pox[1][n] = Y[n];
pox[2][n] = Z[n]; pox[2][n] = Z[n];
} }
const int InList = 35; const int InList = 35;
double *datap; double *datap;
datap = new double[Ns * InList]; datap = new double[Ns * InList];
if (!(state.ADM->AH_Interp_Points(state.AHList, Ns, pox, datap, state.Symmetry))) if (!(state.ADM->AH_Interp_Points(state.AHList, Ns, pox, datap, state.Symmetry)))
return 0; return 0;
// reform data // reform data
for (int pnt = 0; pnt < Ns; pnt++) for (int pnt = 0; pnt < Ns; pnt++)
for (int ii = 0; ii < InList; ii++) for (int ii = 0; ii < InList; ii++)
{ {
if (ii == 0 || ii == 12 || ii == 20) if (ii == 0 || ii == 12 || ii == 20)
Data[pnt + ii * Ns] = datap[ii + pnt * InList] + 1; Data[pnt + ii * Ns] = datap[ii + pnt * InList] + 1;
else if (ii == 24) // from chi-1 to psi else if (ii == 24) // from chi-1 to psi
Data[pnt + ii * Ns] = pow(datap[ii + pnt * InList] + 1, -0.25); Data[pnt + ii * Ns] = pow(datap[ii + pnt * InList] + 1, -0.25);
else if (ii == 25 || ii == 26 || ii == 27) // from chi,i to psi,i else if (ii == 25 || ii == 26 || ii == 27) // from chi,i to psi,i
Data[pnt + ii * Ns] = -pow(datap[24 + pnt * InList] + 1, -1.25) / 4 * datap[ii + pnt * InList]; Data[pnt + ii * Ns] = -pow(datap[24 + pnt * InList] + 1, -1.25) / 4 * datap[ii + pnt * InList];
else else
Data[pnt + ii * Ns] = datap[ii + pnt * InList]; Data[pnt + ii * Ns] = datap[ii + pnt * InList];
} }
delete[] datap; delete[] datap;
delete[] pox[0]; delete[] pox[0];
delete[] pox[1]; delete[] pox[1];
delete[] pox[2]; delete[] pox[2];
return 1; return 1;
} }
// inerpolate lapse and shift // inerpolate lapse and shift
int globalInterpGFLlash(double *X, double *Y, double *Z, int Ns, int globalInterpGFLlash(double *X, double *Y, double *Z, int Ns,
double *Data) double *Data)
{ {
if (Ns == 0) if (Ns == 0)
return 0; return 0;
int n; int n;
double *pox[3]; double *pox[3];
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
pox[i] = new double[Ns]; pox[i] = new double[Ns];
for (n = 0; n < Ns; n++) for (n = 0; n < Ns; n++)
{ {
pox[0][n] = X[n]; pox[0][n] = X[n];
pox[1][n] = Y[n]; pox[1][n] = Y[n];
pox[2][n] = Z[n]; pox[2][n] = Z[n];
} }
double SYM = 1.0, ANT = -1.0; double SYM = 1.0, ANT = -1.0;
const int InList = 4; const int InList = 4;
double *datap; double *datap;
datap = new double[Ns * InList]; datap = new double[Ns * InList];
state.ADM->AH_Interp_Points(state.GaugeList, Ns, pox, datap, state.Symmetry); state.ADM->AH_Interp_Points(state.GaugeList, Ns, pox, datap, state.Symmetry);
// reform data // reform data
for (int pnt = 0; pnt < Ns; pnt++) for (int pnt = 0; pnt < Ns; pnt++)
for (int ii = 0; ii < InList; ii++) for (int ii = 0; ii < InList; ii++)
Data[pnt + ii * Ns] = datap[ii + pnt * InList]; Data[pnt + ii * Ns] = datap[ii + pnt * InList];
delete[] datap; delete[] datap;
delete[] pox[0]; delete[] pox[0];
delete[] pox[1]; delete[] pox[1];
delete[] pox[2]; delete[] pox[2];
return 1; return 1;
} }
} // namespace AHFinderDirect } // namespace AHFinderDirect
#endif #endif

View File

@@ -1,43 +1,43 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <mpi.h> #include <mpi.h>
#include "myglobal.h" #include "myglobal.h"
int CCTK_VInfo(const char *thorn, const char *format, ...) int CCTK_VInfo(const char *thorn, const char *format, ...)
{ {
int myrank; int myrank;
MPI_Comm_rank(MPI_COMM_WORLD,&myrank); MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
if (myrank !=0) return 0; if (myrank !=0) return 0;
va_list ap; va_list ap;
va_start (ap, format); va_start (ap, format);
fprintf (stdout, "INFO (%s): ", thorn); fprintf (stdout, "INFO (%s): ", thorn);
vfprintf (stdout, format, ap); vfprintf (stdout, format, ap);
fprintf (stdout, "\n"); fprintf (stdout, "\n");
va_end (ap); va_end (ap);
return 0; return 0;
} }
int CCTK_VWarn (int level, int CCTK_VWarn (int level,
int line, int line,
const char *file, const char *file,
const char *thorn, const char *thorn,
const char *format, const char *format,
...) ...)
{ {
int myrank; int myrank;
MPI_Comm_rank(MPI_COMM_WORLD,&myrank); MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
if (myrank !=0) return 0; if (myrank !=0) return 0;
va_list ap; va_list ap;
va_start (ap, format); va_start (ap, format);
fprintf (stdout, "WARN (%s): ", thorn); fprintf (stdout, "WARN (%s): ", thorn);
vfprintf (stdout, format, ap); vfprintf (stdout, format, ap);
fprintf (stdout, "\n"); fprintf (stdout, "\n");
va_end (ap); va_end (ap);
return 0; return 0;
} }

View File

@@ -1,270 +1,270 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include "util_Table.h" #include "util_Table.h"
#include "cctk.h" #include "cctk.h"
#include "config.h" #include "config.h"
#include "stdc.h" #include "stdc.h"
#include "util.h" #include "util.h"
#include "array.h" #include "array.h"
#include "cpm_map.h" #include "cpm_map.h"
#include "linear_map.h" #include "linear_map.h"
#include "coords.h" #include "coords.h"
#include "tgrid.h" #include "tgrid.h"
#include "fd_grid.h" #include "fd_grid.h"
#include "patch.h" #include "patch.h"
#include "patch_edge.h" #include "patch_edge.h"
#include "patch_interp.h" #include "patch_interp.h"
#include "ghost_zone.h" #include "ghost_zone.h"
#include "patch_system.h" #include "patch_system.h"
#include "Jacobian.h" #include "Jacobian.h"
#include "ilucg.h" #include "ilucg.h"
// all the code in this file is inside this namespace // all the code in this file is inside this namespace
namespace AHFinderDirect namespace AHFinderDirect
{ {
// this represents a single element stored in the matrix for // this represents a single element stored in the matrix for
// sort_row_into_column_order() and sort_row_into_column_order__cmp() // sort_row_into_column_order() and sort_row_into_column_order__cmp()
struct matrix_element struct matrix_element
{ {
int JA; int JA;
fp A; fp A;
}; };
Jacobian::Jacobian(patch_system &ps) Jacobian::Jacobian(patch_system &ps)
: ps_(ps), : ps_(ps),
N_rows_(ps.N_grid_points()), N_rows_(ps.N_grid_points()),
N_nonzeros_(0), current_N_rows_(0), N_nonzeros_allocated_(0), N_nonzeros_(0), current_N_rows_(0), N_nonzeros_allocated_(0),
IA_(new integer[N_rows_ + 1]), JA_(NULL), A_(NULL), IA_(new integer[N_rows_ + 1]), JA_(NULL), A_(NULL),
itemp_(NULL), rtemp_(NULL) itemp_(NULL), rtemp_(NULL)
{ {
IO_ = 1; IO_ = 1;
zero_matrix(); zero_matrix();
} }
Jacobian::~Jacobian() Jacobian::~Jacobian()
{ {
if (A_) if (A_)
delete[] A_; delete[] A_;
if (JA_) if (JA_)
delete[] JA_; delete[] JA_;
if (IA_) if (IA_)
delete[] IA_; delete[] IA_;
if (rtemp_) if (rtemp_)
delete[] rtemp_; delete[] rtemp_;
if (itemp_) if (itemp_)
delete[] itemp_; delete[] itemp_;
} }
double Jacobian::element(int II, int JJ) double Jacobian::element(int II, int JJ)
const const
{ {
const int posn = find_element(II, JJ); const int posn = find_element(II, JJ);
return (posn >= 0) ? A_[posn] : 0.0; return (posn >= 0) ? A_[posn] : 0.0;
} }
void Jacobian::zero_matrix() void Jacobian::zero_matrix()
{ {
N_nonzeros_ = 0; N_nonzeros_ = 0;
current_N_rows_ = 0; current_N_rows_ = 0;
IA_[0] = IO_; IA_[0] = IO_;
} }
void Jacobian::set_element(int II, int JJ, fp value) void Jacobian::set_element(int II, int JJ, fp value)
{ {
const int posn = find_element(II, JJ); const int posn = find_element(II, JJ);
if (posn >= 0) if (posn >= 0)
then A_[posn] = value; then A_[posn] = value;
else else
insert_element(II, JJ, value); insert_element(II, JJ, value);
} }
void Jacobian::sum_into_element(int II, int JJ, fp value) void Jacobian::sum_into_element(int II, int JJ, fp value)
{ {
const int posn = find_element(II, JJ); const int posn = find_element(II, JJ);
if (posn >= 0) if (posn >= 0)
then A_[posn] += value; then A_[posn] += value;
else else
insert_element(II, JJ, value); insert_element(II, JJ, value);
} }
int Jacobian::find_element(int II, int JJ) int Jacobian::find_element(int II, int JJ)
const const
{ {
if (II >= current_N_rows_) if (II >= current_N_rows_)
then return -1; // this row not defined yet then return -1; // this row not defined yet
const int start = IA_[II] - IO_; const int start = IA_[II] - IO_;
const int stop = IA_[II + 1] - IO_; const int stop = IA_[II + 1] - IO_;
for (int posn = start; posn < stop; ++posn) for (int posn = start; posn < stop; ++posn)
{ {
if (JA_[posn] - IO_ == JJ) if (JA_[posn] - IO_ == JJ)
then return posn; // found then return posn; // found
} }
return -1; // not found return -1; // not found
} }
int Jacobian::insert_element(int II, int JJ, double value) int Jacobian::insert_element(int II, int JJ, double value)
{ {
if (!((II == current_N_rows_ - 1) || (II == current_N_rows_))) if (!((II == current_N_rows_ - 1) || (II == current_N_rows_)))
{ {
printf( printf(
"***** row_sparse_Jacobian::insert_element(II=%d, JJ=%d, value=%g):\n" "***** row_sparse_Jacobian::insert_element(II=%d, JJ=%d, value=%g):\n"
" attempt to insert element elsewhere than {last row, last row+1}!\n" " attempt to insert element elsewhere than {last row, last row+1}!\n"
" N_rows_=%d current_N_rows_=%d IO_=%d\n" " N_rows_=%d current_N_rows_=%d IO_=%d\n"
" N_nonzeros_=%d N_nonzeros_allocated_=%d\n", " N_nonzeros_=%d N_nonzeros_allocated_=%d\n",
II, JJ, double(value), II, JJ, double(value),
N_rows_, current_N_rows_, IO_, N_rows_, current_N_rows_, IO_,
N_nonzeros_, N_nonzeros_allocated_); N_nonzeros_, N_nonzeros_allocated_);
abort(); abort();
} }
// start a new row if necessary // start a new row if necessary
if (II == current_N_rows_) if (II == current_N_rows_)
then then
{ {
assert(current_N_rows_ < N_rows_); assert(current_N_rows_ < N_rows_);
IA_[current_N_rows_ + 1] = IA_[current_N_rows_]; IA_[current_N_rows_ + 1] = IA_[current_N_rows_];
++current_N_rows_; ++current_N_rows_;
} }
// insert into current row // insert into current row
assert(II == current_N_rows_ - 1); assert(II == current_N_rows_ - 1);
if (IA_[II + 1] - IO_ >= N_nonzeros_allocated_) if (IA_[II + 1] - IO_ >= N_nonzeros_allocated_)
then grow_arrays(); then grow_arrays();
const int posn = IA_[II + 1] - IO_; const int posn = IA_[II + 1] - IO_;
assert(posn < N_nonzeros_allocated_); assert(posn < N_nonzeros_allocated_);
JA_[posn] = JJ + IO_; JA_[posn] = JJ + IO_;
A_[posn] = value; A_[posn] = value;
++IA_[II + 1]; ++IA_[II + 1];
++N_nonzeros_; ++N_nonzeros_;
return posn; return posn;
} }
void Jacobian::grow_arrays() void Jacobian::grow_arrays()
{ {
N_nonzeros_allocated_ += base_growth_amount + (N_nonzeros_allocated_ >> 1); N_nonzeros_allocated_ += base_growth_amount + (N_nonzeros_allocated_ >> 1);
int *const new_JA = new int[N_nonzeros_allocated_]; int *const new_JA = new int[N_nonzeros_allocated_];
double *const new_A = new double[N_nonzeros_allocated_]; double *const new_A = new double[N_nonzeros_allocated_];
for (int posn = 0; posn < N_nonzeros_; ++posn) for (int posn = 0; posn < N_nonzeros_; ++posn)
{ {
new_JA[posn] = JA_[posn]; new_JA[posn] = JA_[posn];
new_A[posn] = A_[posn]; new_A[posn] = A_[posn];
} }
delete[] A_; delete[] A_;
delete[] JA_; delete[] JA_;
JA_ = new_JA; JA_ = new_JA;
A_ = new_A; A_ = new_A;
} }
int compare_matrix_elements(const void *x, const void *y) int compare_matrix_elements(const void *x, const void *y)
{ {
const struct matrix_element *const px = static_cast<const struct matrix_element *>(x); const struct matrix_element *const px = static_cast<const struct matrix_element *>(x);
const struct matrix_element *const py = static_cast<const struct matrix_element *>(y); const struct matrix_element *const py = static_cast<const struct matrix_element *>(y);
return px->JA - py->JA; return px->JA - py->JA;
} }
void Jacobian::sort_each_row_into_column_order() void Jacobian::sort_each_row_into_column_order()
{ {
// buffer must be big enough to hold the largest row // buffer must be big enough to hold the largest row
int max_N_in_row = 0; int max_N_in_row = 0;
{ {
for (int II = 0; II < N_rows_; ++II) for (int II = 0; II < N_rows_; ++II)
{ {
max_N_in_row = max(max_N_in_row, IA_[II + 1] - IA_[II]); max_N_in_row = max(max_N_in_row, IA_[II + 1] - IA_[II]);
} }
} }
// contiguous buffer for sorting // contiguous buffer for sorting
struct matrix_element *const buffer = new struct matrix_element[max_N_in_row]; struct matrix_element *const buffer = new struct matrix_element[max_N_in_row];
{ {
for (int II = 0; II < N_rows_; ++II) for (int II = 0; II < N_rows_; ++II)
{ {
const int N_in_row = IA_[II + 1] - IA_[II]; const int N_in_row = IA_[II + 1] - IA_[II];
// copy this row's JA_[] and A_[] values to the buffer // copy this row's JA_[] and A_[] values to the buffer
const int start = IA_[II] - IO_; const int start = IA_[II] - IO_;
for (int p = 0; p < N_in_row; ++p) for (int p = 0; p < N_in_row; ++p)
{ {
const int posn = start + p; const int posn = start + p;
buffer[p].JA = JA_[posn]; buffer[p].JA = JA_[posn];
buffer[p].A = A_[posn]; buffer[p].A = A_[posn];
} }
// sort the buffer // sort the buffer
qsort(static_cast<void *>(buffer), N_in_row, sizeof(buffer[0]), qsort(static_cast<void *>(buffer), N_in_row, sizeof(buffer[0]),
&compare_matrix_elements); &compare_matrix_elements);
// copy the buffer values back to this row's JA_[] and A_[] // copy the buffer values back to this row's JA_[] and A_[]
for (int p = 0; p < N_in_row; ++p) for (int p = 0; p < N_in_row; ++p)
{ {
const int posn = start + p; const int posn = start + p;
JA_[posn] = buffer[p].JA; JA_[posn] = buffer[p].JA;
A_[posn] = buffer[p].A; A_[posn] = buffer[p].A;
} }
} }
} }
delete[] buffer; delete[] buffer;
} }
double Jacobian::solve_linear_system(int rhs_gfn, int x_gfn, bool print_msg_flag) double Jacobian::solve_linear_system(int rhs_gfn, int x_gfn, bool print_msg_flag)
{ {
assert(IO_ == Fortran_index_origin); assert(IO_ == Fortran_index_origin);
assert(current_N_rows_ == N_rows_); assert(current_N_rows_ == N_rows_);
if (itemp_ == NULL) if (itemp_ == NULL)
then then
{ {
itemp_ = new int[3 * N_rows_ + 3 * N_nonzeros_ + 2]; itemp_ = new int[3 * N_rows_ + 3 * N_nonzeros_ + 2];
rtemp_ = new double[4 * N_rows_ + N_nonzeros_]; rtemp_ = new double[4 * N_rows_ + N_nonzeros_];
} }
// initial guess = all zeros // initial guess = all zeros
double *x = ps_.gridfn_data(x_gfn); double *x = ps_.gridfn_data(x_gfn);
for (int II = 0; II < N_rows_; ++II) for (int II = 0; II < N_rows_; ++II)
{ {
x[II] = 0.0; x[II] = 0.0;
} }
const int N = N_rows_; const int N = N_rows_;
const double *rhs = ps_.gridfn_data(rhs_gfn); const double *rhs = ps_.gridfn_data(rhs_gfn);
const double eps = 1e-10; const double eps = 1e-10;
const int max_iterations = N_rows_; const int max_iterations = N_rows_;
int istatus; int istatus;
// the actual linear solution // the actual linear solution
f_ilucg(N, f_ilucg(N,
IA_, JA_, A_, IA_, JA_, A_,
rhs, x, rhs, x,
itemp_, rtemp_, itemp_, rtemp_,
eps, max_iterations, eps, max_iterations,
istatus); istatus);
if (istatus < 0) if (istatus < 0)
{ {
printf( printf(
"***** row_sparse_Jacobian__ILUCG::solve_linear_system(rhs_gfn=%d, x_gfn=%d):\n" "***** row_sparse_Jacobian__ILUCG::solve_linear_system(rhs_gfn=%d, x_gfn=%d):\n"
" error return from [sd]ilucg() routine!\n" " error return from [sd]ilucg() routine!\n"
" istatus=%d < 0 ==> bad matrix structure, eg. zero diagonal element!\n", " istatus=%d < 0 ==> bad matrix structure, eg. zero diagonal element!\n",
rhs_gfn, x_gfn, rhs_gfn, x_gfn,
int(istatus)); int(istatus));
abort(); abort();
} }
return -1.0; return -1.0;
} }
} // namespace AHFinderDirect } // namespace AHFinderDirect

View File

@@ -1,90 +1,90 @@
#ifndef AHFINDERDIRECT__JACOBIAN_HH #ifndef AHFINDERDIRECT__JACOBIAN_HH
#define AHFINDERDIRECT__JACOBIAN_HH #define AHFINDERDIRECT__JACOBIAN_HH
namespace AHFinderDirect namespace AHFinderDirect
{ {
class Jacobian class Jacobian
{ {
public: public:
// basic meta-info // basic meta-info
patch_system &my_patch_system() const { return ps_; } patch_system &my_patch_system() const { return ps_; }
int N_rows() const { return N_rows_; } int N_rows() const { return N_rows_; }
// convert (patch,irho,isigma) <--> row/column index // convert (patch,irho,isigma) <--> row/column index
int II_of_patch_irho_isigma(const patch &p, int irho, int isigma) int II_of_patch_irho_isigma(const patch &p, int irho, int isigma)
const const
{ {
return ps_.gpn_of_patch_irho_isigma(p, irho, isigma); return ps_.gpn_of_patch_irho_isigma(p, irho, isigma);
} }
const patch &patch_irho_isigma_of_II(int II, int &irho, int &isigma) const patch &patch_irho_isigma_of_II(int II, int &irho, int &isigma)
const const
{ {
return ps_.patch_irho_isigma_of_gpn(II, irho, isigma); return ps_.patch_irho_isigma_of_gpn(II, irho, isigma);
} }
double element(int II, int JJ) const; double element(int II, int JJ) const;
// is the matrix element (II,JJ) stored explicitly? // is the matrix element (II,JJ) stored explicitly?
bool is_explicitly_stored(int II, int JJ) const bool is_explicitly_stored(int II, int JJ) const
{ {
return find_element(II, JJ) > 0; return find_element(II, JJ) > 0;
} }
int IO() const { return IO_; } int IO() const { return IO_; }
enum enum
{ {
C_index_origin = 0, C_index_origin = 0,
Fortran_index_origin = 1 Fortran_index_origin = 1
}; };
void zero_matrix(); void zero_matrix();
void set_element(int II, int JJ, fp value); void set_element(int II, int JJ, fp value);
void sum_into_element(int II, int JJ, fp value); void sum_into_element(int II, int JJ, fp value);
int find_element(int II, int JJ) const; int find_element(int II, int JJ) const;
int insert_element(int II, int JJ, fp value); int insert_element(int II, int JJ, fp value);
void grow_arrays(); void grow_arrays();
enum enum
{ {
base_growth_amount = 1000 base_growth_amount = 1000
}; };
void sort_each_row_into_column_order(); void sort_each_row_into_column_order();
double solve_linear_system(int rhs_gfn, int x_gfn, double solve_linear_system(int rhs_gfn, int x_gfn,
bool print_msg_flag); bool print_msg_flag);
public: public:
Jacobian(patch_system &ps); Jacobian(patch_system &ps);
~Jacobian(); ~Jacobian();
protected: protected:
patch_system &ps_; patch_system &ps_;
int N_rows_; int N_rows_;
int IO_; int IO_;
int N_nonzeros_; int N_nonzeros_;
int current_N_rows_; int current_N_rows_;
int N_nonzeros_allocated_; int N_nonzeros_allocated_;
int *IA_; int *IA_;
int *JA_; int *JA_;
double *A_; double *A_;
int *itemp_; int *itemp_;
double *rtemp_; double *rtemp_;
}; };
//****************************************************************************** //******************************************************************************
} // namespace AHFinderDirect } // namespace AHFinderDirect
#endif /* AHFINDERDIRECT__JACOBIAN_HH */ #endif /* AHFINDERDIRECT__JACOBIAN_HH */

File diff suppressed because it is too large Load Diff

View File

@@ -1,55 +1,55 @@
#ifndef PATCH_H #ifndef PATCH_H
#define PATCH_H #define PATCH_H
#include <mpi.h> #include <mpi.h>
#include "MyList.h" #include "MyList.h"
#include "Block.h" #include "Block.h"
#include "var.h" #include "var.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width #include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
class Patch class Patch
{ {
public: public:
int lev; int lev;
int shape[dim]; int shape[dim];
double bbox[2 * dim]; // this bbox includes buffer points double bbox[2 * dim]; // this bbox includes buffer points
MyList<Block> *blb, *ble; MyList<Block> *blb, *ble;
int lli[dim], uui[dim]; // denote the buffer points on each boundary int lli[dim], uui[dim]; // denote the buffer points on each boundary
public: public:
Patch() {}; Patch() {};
Patch(int DIM, int *shapei, double *bboxi, int levi, bool buflog, int Symmetry); Patch(int DIM, int *shapei, double *bboxi, int levi, bool buflog, int Symmetry);
~Patch(); ~Patch();
void checkPatch(bool buflog); void checkPatch(bool buflog);
void checkPatch(bool buflog, const int out_rank); void checkPatch(bool buflog, const int out_rank);
void checkBlock(); void checkBlock();
void Interp_Points(MyList<var> *VarList, void Interp_Points(MyList<var> *VarList,
int NN, double **XX, int NN, double **XX,
double *Shellf, int Symmetry); double *Shellf, int Symmetry);
bool Interp_ONE_Point(MyList<var> *VarList, double *XX, bool Interp_ONE_Point(MyList<var> *VarList, double *XX,
double *Shellf, int Symmetry); double *Shellf, int Symmetry);
double getdX(int dir); double getdX(int dir);
void Find_Maximum(MyList<var> *VarList, double *XX, void Find_Maximum(MyList<var> *VarList, double *XX,
double *Shellf); double *Shellf);
bool Find_Point(double *XX); bool Find_Point(double *XX);
void Interp_Points(MyList<var> *VarList, void Interp_Points(MyList<var> *VarList,
int NN, double **XX, int NN, double **XX,
double *Shellf, int Symmetry, double *Shellf, int Symmetry,
int Nmin_consumer, int Nmax_consumer); int Nmin_consumer, int Nmax_consumer);
void Interp_Points(MyList<var> *VarList, void Interp_Points(MyList<var> *VarList,
int NN, double **XX, int NN, double **XX,
double *Shellf, int Symmetry, MPI_Comm Comm_here); double *Shellf, int Symmetry, MPI_Comm Comm_here);
bool Interp_ONE_Point(MyList<var> *VarList, double *XX, bool Interp_ONE_Point(MyList<var> *VarList, double *XX,
double *Shellf, int Symmetry, MPI_Comm Comm_here); double *Shellf, int Symmetry, MPI_Comm Comm_here);
void Find_Maximum(MyList<var> *VarList, double *XX, void Find_Maximum(MyList<var> *VarList, double *XX,
double *Shellf, MPI_Comm Comm_here); double *Shellf, MPI_Comm Comm_here);
}; };
#endif /* PATCH_H */ #endif /* PATCH_H */

View File

@@ -1,109 +1,109 @@
#ifndef MYLIST_H #ifndef MYLIST_H
#define MYLIST_H #define MYLIST_H
// Note: There is never an implementation file (*.C) for a template class // Note: There is never an implementation file (*.C) for a template class
template <class T> template <class T>
class MyList class MyList
{ {
public: public:
MyList *next; MyList *next;
T *data; T *data;
public: public:
MyList(); MyList();
MyList(T *p); MyList(T *p);
~MyList(); ~MyList();
void insert(T *p); void insert(T *p);
void clearList(); void clearList();
void destroyList(); void destroyList();
void catList(MyList<T> *p); void catList(MyList<T> *p);
void CloneList(MyList<T> *p); void CloneList(MyList<T> *p);
}; };
template <class T> template <class T>
MyList<T>::MyList() MyList<T>::MyList()
{ {
data = 0; data = 0;
next = 0; next = 0;
} }
template <class T> template <class T>
MyList<T>::MyList(T *p) MyList<T>::MyList(T *p)
{ {
data = p; data = p;
next = 0; next = 0;
} }
template <class T> template <class T>
MyList<T>::~MyList() MyList<T>::~MyList()
{ {
} }
template <class T> template <class T>
void MyList<T>::insert(T *p) void MyList<T>::insert(T *p)
{ {
MyList *ct = this; MyList *ct = this;
if (data == 0) if (data == 0)
{ {
data = p; data = p;
} }
else else
{ {
while (ct->next) while (ct->next)
{ {
ct = ct->next; ct = ct->next;
} }
ct->next = new MyList(p); ct->next = new MyList(p);
ct = ct->next; ct = ct->next;
ct->next = 0; ct->next = 0;
} }
} }
template <class T> template <class T>
void MyList<T>::clearList() void MyList<T>::clearList()
{ {
MyList *ct = this, *n; MyList *ct = this, *n;
while (ct) while (ct)
{ {
n = ct->next; n = ct->next;
delete ct; delete ct;
ct = n; ct = n;
} }
} }
template <class T> template <class T>
void MyList<T>::destroyList() void MyList<T>::destroyList()
{ {
MyList *ct = this, *n; MyList *ct = this, *n;
while (ct) while (ct)
{ {
n = ct->next; n = ct->next;
delete ct->data; delete ct->data;
delete ct; delete ct;
ct = n; ct = n;
} }
} }
template <class T> template <class T>
void MyList<T>::catList(MyList<T> *p) void MyList<T>::catList(MyList<T> *p)
{ {
MyList *ct = this; MyList *ct = this;
while (ct->next) while (ct->next)
{ {
ct = ct->next; ct = ct->next;
} }
ct->next = p; ct->next = p;
} }
template <class T> template <class T>
void MyList<T>::CloneList(MyList<T> *p) void MyList<T>::CloneList(MyList<T> *p)
{ {
MyList *ct = this; MyList *ct = this;
p = 0; p = 0;
while (ct) while (ct)
{ {
if (!p) if (!p)
p = new MyList<T>(ct->data); p = new MyList<T>(ct->data);
else else
p->insert(ct->data); p->insert(ct->data);
ct = ct->next; ct = ct->next;
} }
} }
#endif /* MyList_H */ #endif /* MyList_H */

View File

@@ -1,225 +1,225 @@
#ifndef NULLEVOL_H #ifndef NULLEVOL_H
#define NULLEVOL_H #define NULLEVOL_H
#ifdef fortran1 #ifdef fortran1
#define f_setup_dyad setup_dyad #define f_setup_dyad setup_dyad
#define f_eth_derivs eth_derivs #define f_eth_derivs eth_derivs
#define f_eth_dderivs eth_dderivs #define f_eth_dderivs eth_dderivs
#define f_fill_symmetric_boundarybuffer fill_symmetric_boundarybuffer #define f_fill_symmetric_boundarybuffer fill_symmetric_boundarybuffer
#define f_fill_symmetric_boundarybuffer2 fill_symmetric_boundarybuffer2 #define f_fill_symmetric_boundarybuffer2 fill_symmetric_boundarybuffer2
#define f_calculate_K calculate_k #define f_calculate_K calculate_k
#define f_NullEvol_beta nullevol_beta #define f_NullEvol_beta nullevol_beta
#define f_NullEvol_Q nullevol_q #define f_NullEvol_Q nullevol_q
#define f_NullEvol_U nullevol_u #define f_NullEvol_U nullevol_u
#define f_NullEvol_W nullevol_w #define f_NullEvol_W nullevol_w
#define f_NullEvol_Theta nullevol_theta #define f_NullEvol_Theta nullevol_theta
#define f_NullEvol_Theta_givenx nullevol_theta_givenx #define f_NullEvol_Theta_givenx nullevol_theta_givenx
#define f_Eq_Theta eq_theta #define f_Eq_Theta eq_theta
#define f_Eq_Theta_2 eq_theta_2 #define f_Eq_Theta_2 eq_theta_2
#define f_NullEvol_g01 nullevol_g01 #define f_NullEvol_g01 nullevol_g01
#define f_NullEvol_pg0A nullevol_pg0a #define f_NullEvol_pg0A nullevol_pg0a
#define f_NullEvol_Theta2 nullevol_theta2 #define f_NullEvol_Theta2 nullevol_theta2
#define f_NullEvol_Thetag00 nullevol_thetag00 #define f_NullEvol_Thetag00 nullevol_thetag00
#endif #endif
#ifdef fortran2 #ifdef fortran2
#define f_setup_dyad SETUP_DYAD #define f_setup_dyad SETUP_DYAD
#define f_eth_derivs ETH_DERIVS #define f_eth_derivs ETH_DERIVS
#define f_eth_dderivs ETH_DDERIVS #define f_eth_dderivs ETH_DDERIVS
#define f_fill_symmetric_boundarybuffer FILL_SYMMETRIC_BOUNDARYBUFFER #define f_fill_symmetric_boundarybuffer FILL_SYMMETRIC_BOUNDARYBUFFER
#define f_fill_symmetric_boundarybuffer2 FILL_SYMMETRIC_BOUNDARYBUFFER2 #define f_fill_symmetric_boundarybuffer2 FILL_SYMMETRIC_BOUNDARYBUFFER2
#define f_calculate_K CALCULATE_K #define f_calculate_K CALCULATE_K
#define f_NullEvol_beta NULLEVOL_BETA #define f_NullEvol_beta NULLEVOL_BETA
#define f_NullEvol_Q NULLEVOL_Q #define f_NullEvol_Q NULLEVOL_Q
#define f_NullEvol_U NULLEVOL_U #define f_NullEvol_U NULLEVOL_U
#define f_NullEvol_W NULLEVOL_W #define f_NullEvol_W NULLEVOL_W
#define f_NullEvol_Theta NULLEVOL_THETA #define f_NullEvol_Theta NULLEVOL_THETA
#define f_NullEvol_Theta_givenx NULLEVOL_THETA_GIVENX #define f_NullEvol_Theta_givenx NULLEVOL_THETA_GIVENX
#define f_Eq_Theta EQ_THETA #define f_Eq_Theta EQ_THETA
#define f_Eq_Theta_2 EQ_THETA_2 #define f_Eq_Theta_2 EQ_THETA_2
#define f_NullEvol_g01 NULLEVOL_G01 #define f_NullEvol_g01 NULLEVOL_G01
#define f_NullEvol_pg0A NULLEVOL_PG0A #define f_NullEvol_pg0A NULLEVOL_PG0A
#define f_NullEvol_Theta2 NULLEVOL_THETA2 #define f_NullEvol_Theta2 NULLEVOL_THETA2
#define f_NullEvol_Thetag00 NULLEVOL_THETAG00 #define f_NullEvol_Thetag00 NULLEVOL_THETAG00
#endif #endif
#ifdef fortran3 #ifdef fortran3
#define f_setup_dyad setup_dyad_ #define f_setup_dyad setup_dyad_
#define f_eth_derivs eth_derivs_ #define f_eth_derivs eth_derivs_
#define f_eth_dderivs eth_dderivs_ #define f_eth_dderivs eth_dderivs_
#define f_fill_symmetric_boundarybuffer fill_symmetric_boundarybuffer_ #define f_fill_symmetric_boundarybuffer fill_symmetric_boundarybuffer_
#define f_fill_symmetric_boundarybuffer2 fill_symmetric_boundarybuffer2_ #define f_fill_symmetric_boundarybuffer2 fill_symmetric_boundarybuffer2_
#define f_calculate_K calculate_k_ #define f_calculate_K calculate_k_
#define f_NullEvol_beta nullevol_beta_ #define f_NullEvol_beta nullevol_beta_
#define f_NullEvol_Q nullevol_q_ #define f_NullEvol_Q nullevol_q_
#define f_NullEvol_U nullevol_u_ #define f_NullEvol_U nullevol_u_
#define f_NullEvol_W nullevol_w_ #define f_NullEvol_W nullevol_w_
#define f_NullEvol_Theta nullevol_theta_ #define f_NullEvol_Theta nullevol_theta_
#define f_NullEvol_Theta_givenx nullevol_theta_givenx_ #define f_NullEvol_Theta_givenx nullevol_theta_givenx_
#define f_Eq_Theta eq_theta_ #define f_Eq_Theta eq_theta_
#define f_Eq_Theta_2 eq_theta_2_ #define f_Eq_Theta_2 eq_theta_2_
#define f_NullEvol_g01 nullevol_g01_ #define f_NullEvol_g01 nullevol_g01_
#define f_NullEvol_pg0A nullevol_pg0a_ #define f_NullEvol_pg0A nullevol_pg0a_
#define f_NullEvol_Theta2 nullevol_theta2_ #define f_NullEvol_Theta2 nullevol_theta2_
#define f_NullEvol_Thetag00 nullevol_thetag00_ #define f_NullEvol_Thetag00 nullevol_thetag00_
#endif #endif
extern "C" extern "C"
{ {
void f_setup_dyad(int *, double *, double *, double *, void f_setup_dyad(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
int &, double &); int &, double &);
} }
extern "C" extern "C"
{ {
void f_eth_derivs(int *, double *, double *, void f_eth_derivs(int *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *,
int &, int &, int &, int &,
double *, double *, double *, double *, double *, double *); double *, double *, double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
void f_eth_dderivs(int *, double *, double *, void f_eth_dderivs(int *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *,
int &, int &, int &, int &, int &, int &,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *); double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
void f_fill_symmetric_boundarybuffer(int *, double *, double *, double *, void f_fill_symmetric_boundarybuffer(int *, double *, double *, double *,
double &, double &, double &, double &,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, int &, int &, int &); double *, double *, int &, int &, int &);
} }
extern "C" extern "C"
{ {
void f_fill_symmetric_boundarybuffer2(int *, double *, double *, double *, void f_fill_symmetric_boundarybuffer2(int *, double *, double *, double *,
double &, double &, double &, double &,
double *, int &, int &, double *); double *, int &, int &, double *);
} }
extern "C" extern "C"
{ {
void f_calculate_K(int *, double *, double *, double *, void f_calculate_K(int *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *); double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
int f_NullEvol_beta(int *, double *, double *, double *, int f_NullEvol_beta(int *, double *, double *, double *,
double *, double *, double *, double *, double *); double *, double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
int f_NullEvol_Q(int *, double *, double *, double *, int f_NullEvol_Q(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *); double *, double *, double *, double *, double *, double *, double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
int f_NullEvol_U(int *, double *, double *, double *, int f_NullEvol_U(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double &); double *, double *, double &);
} }
extern "C" extern "C"
{ {
int f_NullEvol_W(int *, double *, double *, double *, int f_NullEvol_W(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double &, double *, double *, double *, double *, double &,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *); double *, double *, double *, double *, double *, double *, double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
int f_NullEvol_Theta(int *, double *, double *, double *, int f_NullEvol_Theta(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double &, double &,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *); double *, double *, double *, double *, double *, double *, double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
int f_NullEvol_Theta_givenx(int *, double *, double *, double *, int f_NullEvol_Theta_givenx(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double &, double &,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double &, int &); double &, int &);
} }
extern "C" extern "C"
{ {
int f_Eq_Theta(int *, double *, double *, double *, int f_Eq_Theta(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double &, double *, double *, double *, double *, double *, double *, double *, double &,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *); double *, double *, double *, double *, double *, double *, double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
int f_Eq_Theta_2(int *, double *, double *, double *, int f_Eq_Theta_2(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double &, double *, double *, double *, double *, double *, double *, double *, double &,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double &, int &); double &, int &);
} }
extern "C" extern "C"
{ {
int f_NullEvol_g01(int *, double *, double *, double *, int f_NullEvol_g01(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double &); double &);
} }
extern "C" extern "C"
{ {
int f_NullEvol_pg0A(int *, double *, double *, double *, int f_NullEvol_pg0A(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double &); double &);
} }
extern "C" extern "C"
{ {
int f_NullEvol_Theta2(int *, double *, double *, double *, int f_NullEvol_Theta2(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double &); double &);
} }
extern "C" extern "C"
{ {
int f_NullEvol_Thetag00(int *, double *, double *, double *, int f_NullEvol_Thetag00(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double &); double &);
} }
#endif /* NULLEVOL_H */ #endif /* NULLEVOL_H */

View File

@@ -1,106 +1,106 @@
#ifndef NULLNEWS_H #ifndef NULLNEWS_H
#define NULLNEWS_H #define NULLNEWS_H
#ifdef fortran1 #ifdef fortran1
#define f_drive_null_news drive_null_news #define f_drive_null_news drive_null_news
#define f_get_null_news2 get_null_news2 #define f_get_null_news2 get_null_news2
#define f_drive_null_news_diff drive_null_news_diff #define f_drive_null_news_diff drive_null_news_diff
#define f_omega_rhs omega_rhs #define f_omega_rhs omega_rhs
#define f_get_exact_omega get_exact_omega #define f_get_exact_omega get_exact_omega
#define f_get_omega_and_dtomega_pre get_omega_and_dtomega_pre #define f_get_omega_and_dtomega_pre get_omega_and_dtomega_pre
#define f_get_omega_and_dtomega_LN get_omega_and_dtomega_ln #define f_get_omega_and_dtomega_LN get_omega_and_dtomega_ln
#define f_get_dtomega get_dtomega #define f_get_dtomega get_dtomega
#endif #endif
#ifdef fortran2 #ifdef fortran2
#define f_drive_null_news DRIVE_NULL_NEWS #define f_drive_null_news DRIVE_NULL_NEWS
#define f_get_null_news2 GET_NULL_NEWS2 #define f_get_null_news2 GET_NULL_NEWS2
#define f_drive_null_news_diff DRIVE_NULL_NEWS_DIFF #define f_drive_null_news_diff DRIVE_NULL_NEWS_DIFF
#define f_omega_rhs OMEGA_RHS #define f_omega_rhs OMEGA_RHS
#define f_get_exact_omega GET_EXACT_OMEGA #define f_get_exact_omega GET_EXACT_OMEGA
#define f_get_omega_and_dtomega_pre GET_OMEGA_AND_DTOMEGA_PRE #define f_get_omega_and_dtomega_pre GET_OMEGA_AND_DTOMEGA_PRE
#define f_get_omega_and_dtomega_LN GET_OMEGA_AND_DTOMEGA_LN #define f_get_omega_and_dtomega_LN GET_OMEGA_AND_DTOMEGA_LN
#define f_get_dtomega GET_DTOMEGA #define f_get_dtomega GET_DTOMEGA
#endif #endif
#ifdef fortran3 #ifdef fortran3
#define f_drive_null_news drive_null_news_ #define f_drive_null_news drive_null_news_
#define f_get_null_news2 get_null_news2_ #define f_get_null_news2 get_null_news2_
#define f_drive_null_news_diff drive_null_news_diff_ #define f_drive_null_news_diff drive_null_news_diff_
#define f_omega_rhs omega_rhs_ #define f_omega_rhs omega_rhs_
#define f_get_exact_omega get_exact_omega_ #define f_get_exact_omega get_exact_omega_
#define f_get_omega_and_dtomega_pre get_omega_and_dtomega_pre_ #define f_get_omega_and_dtomega_pre get_omega_and_dtomega_pre_
#define f_get_omega_and_dtomega_LN get_omega_and_dtomega_ln_ #define f_get_omega_and_dtomega_LN get_omega_and_dtomega_ln_
#define f_get_dtomega get_dtomega_ #define f_get_dtomega get_dtomega_
#endif #endif
extern "C" extern "C"
{ {
void f_drive_null_news(int *, double *, double *, double *, void f_drive_null_news(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double &, int &); double *, double *, double &, int &);
} }
extern "C" extern "C"
{ {
void f_drive_null_news_diff(int *, double *, double *, double *, void f_drive_null_news_diff(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double &, int &, double &); double *, double *, double &, int &, double &);
} }
extern "C" extern "C"
{ {
void f_omega_rhs(int *, double *, double *, double *, void f_omega_rhs(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *); double *, double *);
} }
extern "C" extern "C"
{ {
void f_get_exact_omega(int *, double *, double *, double *, void f_get_exact_omega(int *, double *, double *, double *,
double *, double *,
int &, double &, double &); int &, double &, double &);
} }
extern "C" extern "C"
{ {
void f_get_null_news2(int *, double *, double *, double *, void f_get_null_news2(int *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double &, int &); double *, double *, double &, int &);
} }
extern "C" extern "C"
{ {
void f_get_omega_and_dtomega_pre(int *, double *, double *, double *, void f_get_omega_and_dtomega_pre(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double &); double *, double *, double &);
} }
extern "C" extern "C"
{ {
void f_get_dtomega(int *, double *, double *, double *, void f_get_dtomega(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double &); double *, double *, double &);
} }
extern "C" extern "C"
{ {
void f_get_omega_and_dtomega_LN(double &, int *, double *, double *, double *, void f_get_omega_and_dtomega_LN(double &, int *, double *, double *, double *,
double *, double *, double &, int &); double *, double *, double &, int &);
} }
#endif /* NULLNEWS_H */ #endif /* NULLNEWS_H */

View File

@@ -1,189 +1,189 @@
#ifndef NULLSHELLPATCH_H #ifndef NULLSHELLPATCH_H
#define NULLSHELLPATCH_H #define NULLSHELLPATCH_H
#ifdef newc #ifdef newc
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <cmath> #include <cmath>
#include <complex> #include <complex>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <fstream.h> #include <fstream.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <complex.h> #include <complex.h>
#endif #endif
#include <mpi.h> #include <mpi.h>
#include "MyList.h" #include "MyList.h"
#include "Block.h" #include "Block.h"
#include "Parallel.h" #include "Parallel.h"
#include "ShellPatch.h" #include "ShellPatch.h"
#include "var.h" #include "var.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width #include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3) #if (dim != 3)
#error NullShellPatch only supports 3 dimensional stuff yet #error NullShellPatch only supports 3 dimensional stuff yet
#endif #endif
class xp_npatch : public ss_patch class xp_npatch : public ss_patch
{ {
public: public:
xp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 2; }; xp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 2; };
}; };
class xm_npatch : public ss_patch class xm_npatch : public ss_patch
{ {
public: public:
xm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 3; }; xm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 3; };
}; };
class yp_npatch : public ss_patch class yp_npatch : public ss_patch
{ {
public: public:
yp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 4; }; yp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 4; };
}; };
class ym_npatch : public ss_patch class ym_npatch : public ss_patch
{ {
public: public:
ym_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 5; }; ym_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 5; };
}; };
class zp_npatch : public ss_patch class zp_npatch : public ss_patch
{ {
public: public:
zp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 0; }; zp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 0; };
}; };
class zm_npatch : public ss_patch class zm_npatch : public ss_patch
{ {
public: public:
zm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; }; zm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
}; };
class NullShellPatch class NullShellPatch
{ {
public: public:
struct pointstru struct pointstru
{ {
double gpox[dim]; // global cordinate double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate double lpox[dim]; // local cordinate
Block *Bg; Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef; double *coef;
int *sind; int *sind;
int dumyd; // the dimension which has common lines, only useful in interdata_packer int dumyd; // the dimension which has common lines, only useful in interdata_packer
complex<double> swtf; // exp(i gamma) of Eq.(26) of CQG 24 S327 complex<double> swtf; // exp(i gamma) of Eq.(26) of CQG 24 S327
}; };
var *FXZEO; var *FXZEO;
var *gx, *gy, *gz; var *gx, *gy, *gz;
// we always assume the number of VarList = 2* the number of Varwt // we always assume the number of VarList = 2* the number of Varwt
// so VarList must apear with pairs, either components of complex number or a fake pair // so VarList must apear with pairs, either components of complex number or a fake pair
var *beta, *W; var *beta, *W;
var *Rnu, *Inu, *Rk, *Ik, *RB, *IB; var *Rnu, *Inu, *Rk, *Ik, *RB, *IB;
var *RQ, *IQ, *RU, *IU, *RTheta, *ITheta; var *RQ, *IQ, *RU, *IU, *RTheta, *ITheta;
var *KK, *HKK, *KKx, *HKKx; var *KK, *HKK, *KKx, *HKKx;
var *RJo, *IJo, *omegao; var *RJo, *IJo, *omegao;
var *RJ0, *IJ0, *omega0; var *RJ0, *IJ0, *omega0;
var *RJ, *IJ, *omega; var *RJ, *IJ, *omega;
var *RJ1, *IJ1, *omega1; var *RJ1, *IJ1, *omega1;
var *RJ_rhs, *IJ_rhs, *omega_rhs; var *RJ_rhs, *IJ_rhs, *omega_rhs;
var *quR1, *quR2, *quI1, *quI2; var *quR1, *quR2, *quI1, *quI2;
var *qlR1, *qlR2, *qlI1, *qlI2; var *qlR1, *qlR2, *qlI1, *qlI2;
var *gR, *gI; var *gR, *gI;
var *dquR1, *dquR2, *dquI1, *dquI2; var *dquR1, *dquR2, *dquI1, *dquI2;
var *bdquR1, *bdquR2, *bdquI1, *bdquI2; var *bdquR1, *bdquR2, *bdquI1, *bdquI2;
var *dgR, *dgI; var *dgR, *dgI;
var *bdgR, *bdgI; var *bdgR, *bdgI;
var *RNews, *INews; var *RNews, *INews;
MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList; MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList;
MyList<var> *OldStateList, *DumpList, *CheckList; MyList<var> *OldStateList, *DumpList, *CheckList;
MyList<var> *betaList, *QUList, *WTheList, *TheList, *JrhsList, *J1List; MyList<var> *betaList, *QUList, *WTheList, *TheList, *JrhsList, *J1List;
int betawt[1], QUwt[2], WThewt[2]; int betawt[1], QUwt[2], WThewt[2];
int myrank; int myrank;
int shape[dim]; // for (rho, sigma, X), for rho and sigma means number of points for every pi/2 int shape[dim]; // for (rho, sigma, X), for rho and sigma means number of points for every pi/2
double Rmin, xmin, xmax; double Rmin, xmin, xmax;
int Symmetry; int Symmetry;
int ingfs, fngfs; int ingfs, fngfs;
MyList<ss_patch> *PatL; MyList<ss_patch> *PatL;
MyList<pointstru> **ss_src, **ss_dst; MyList<pointstru> **ss_src, **ss_dst;
MyList<pointstru> **cs_src, **cs_dst; MyList<pointstru> **cs_src, **cs_dst;
public: public:
NullShellPatch(int *shapei, double Rmini, double xmini, double xmaxi, int Symmetry, int myranki); NullShellPatch(int *shapei, double Rmini, double xmini, double xmaxi, int Symmetry, int myranki);
~NullShellPatch(); ~NullShellPatch();
void destroypsuList(MyList<pointstru> *ct); void destroypsuList(MyList<pointstru> *ct);
void fill_symmetric_boundarybuffer(MyList<var> *VarList, int *Varwt); void fill_symmetric_boundarybuffer(MyList<var> *VarList, int *Varwt);
MyList<Block> *compose_sh(int cpusize); MyList<Block> *compose_sh(int cpusize);
int getdumydimension(int acsst, int posst); int getdumydimension(int acsst, int posst);
void Setup_dyad(); void Setup_dyad();
void Setup_Initial_Data(bool checkrun, double PhysTime); void Setup_Initial_Data(bool checkrun, double PhysTime);
void eth_derivs(var *Rv, var *Iv, var *ethRv, var *ethIv, int s, int e); void eth_derivs(var *Rv, var *Iv, var *ethRv, var *ethIv, int s, int e);
void eth_dderivs(var *Rv, var *Iv, var *ethRv, var *ethIv, int s, int e1, int e2); void eth_dderivs(var *Rv, var *Iv, var *ethRv, var *ethIv, int s, int e1, int e2);
void getlocalpox_ss(int isst, double ix, double iy, double iz, int &sst, double &lx, double &ly, double &lz); void getlocalpox_ss(int isst, double ix, double iy, double iz, int &sst, double &lx, double &ly, double &lz);
void getlocalpox_fake(double x, double y, double z, int &sst, double &lx, double &ly, double &lz); void getlocalpox_fake(double x, double y, double z, int &sst, double &lx, double &ly, double &lz);
void getlocalpox(double x, double y, double z, int &sst, double &lx, double &ly, double &lz); void getlocalpox(double x, double y, double z, int &sst, double &lx, double &ly, double &lz);
void getlocalpoxsst_ss(int isst, double ix, double iy, double iz, int lsst, double &lx, double &ly, double &lz); void getlocalpoxsst_ss(int isst, double ix, double iy, double iz, int lsst, double &lx, double &ly, double &lz);
void getlocalpoxsst(double x, double y, double z, int sst, double &lx, double &ly, double &lz); void getlocalpoxsst(double x, double y, double z, int sst, double &lx, double &ly, double &lz);
void getglobalpox(double &x, double &y, double &z, int sst, double lx, double ly, double lz); void getglobalpox(double &x, double &y, double &z, int sst, double lx, double ly, double lz);
complex<double> get_swtf(double *pox, int tsst, int ssst); complex<double> get_swtf(double *pox, int tsst, int ssst);
void prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPpi, double DH[dim], void prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPpi, double DH[dim],
MyList<Patch> *Ppi, double CDH[dim], MyList<pointstru> *pss); MyList<Patch> *Ppi, double CDH[dim], MyList<pointstru> *pss);
bool prolongpointstru(MyList<pointstru> *&psul, bool ssyn, int tsst, MyList<ss_patch> *sPp, double DH[dim], bool prolongpointstru(MyList<pointstru> *&psul, bool ssyn, int tsst, MyList<ss_patch> *sPp, double DH[dim],
MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in); MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in);
bool prolongpointstru_ss(MyList<pointstru> *&psul, int tsst, MyList<ss_patch> *sPp, double DH[dim], bool prolongpointstru_ss(MyList<pointstru> *&psul, int tsst, MyList<ss_patch> *sPp, double DH[dim],
MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in); MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in);
void setupintintstuff(int cpusize, MyList<Patch> *CPatL, int Symmetry); void setupintintstuff(int cpusize, MyList<Patch> *CPatL, int Symmetry);
void checkPatch(); void checkPatch();
void checkBlock(int sst); void checkBlock(int sst);
double getdX(int dir); double getdX(int dir);
void shellname(char *sn, int i); void shellname(char *sn, int i);
void Dump_xyz(char *tag, double time, double dT); void Dump_xyz(char *tag, double time, double dT);
void Dump_Data(MyList<var> *DumpListi, char *tag, double time, double dT); void Dump_Data(MyList<var> *DumpListi, char *tag, double time, double dT);
void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst, void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry, int *Varwt); int Symmetry, int *Varwt);
int interdata_packer(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, int rank_in, int dir, int interdata_packer(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, int rank_in, int dir,
MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry, int *Varwt); MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry, int *Varwt);
void Synch(MyList<var> *VarList, int Symmetry, int *Varwt); void Synch(MyList<var> *VarList, int Symmetry, int *Varwt);
void CS_Inter(MyList<var> *VarList, int Symmetry, int *Varwt); void CS_Inter(MyList<var> *VarList, int Symmetry, int *Varwt);
void check_pointstrul(MyList<pointstru> *pp, bool first_only); void check_pointstrul(MyList<pointstru> *pp, bool first_only);
void check_pointstrul2(MyList<pointstru> *pp, int first_last_only); void check_pointstrul2(MyList<pointstru> *pp, int first_last_only);
void matchcheck(MyList<Patch> *CPatL); void matchcheck(MyList<Patch> *CPatL);
void Interp_Points(MyList<var> *VarList, void Interp_Points(MyList<var> *VarList,
int NN, double **XX, /*input global Cartesian coordinate*/ int NN, double **XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry); double *Shellf, int Symmetry);
void Interp_Points_2D(MyList<var> *VarList, void Interp_Points_2D(MyList<var> *VarList,
int NN, double **XX, /*input global Cartesian coordinate*/ int NN, double **XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry); double *Shellf, int Symmetry);
void Step(double dT, double PhysTime, monitor *ErrorMonitor); void Step(double dT, double PhysTime, monitor *ErrorMonitor);
void Null_Boundary(double PhysTime); void Null_Boundary(double PhysTime);
void HyperSlice(double dT, double PhysTime, monitor *ErrorMonitor, int RK_count); void HyperSlice(double dT, double PhysTime, monitor *ErrorMonitor, int RK_count);
double News_Error_Check(double PhysTime, double dT, bool dp); double News_Error_Check(double PhysTime, double dT, bool dp);
double Error_Check(double PhysTime, double dT, bool dp); double Error_Check(double PhysTime, double dT, bool dp);
double EqTheta_Check(double PhysTime, double dT, bool dp); double EqTheta_Check(double PhysTime, double dT, bool dp);
void Compute_News(double PhysTime, double dT, bool dp); void Compute_News(double PhysTime, double dT, bool dp);
void Check_News(double PhysTime, double dT, bool dp); void Check_News(double PhysTime, double dT, bool dp);
}; };
#endif /* NULLSHELLPATCH_H */ #endif /* NULLSHELLPATCH_H */

View File

@@ -1,183 +1,183 @@
#ifndef NULLSHELLPATCH2_H #ifndef NULLSHELLPATCH2_H
#define NULLSHELLPATCH2_H #define NULLSHELLPATCH2_H
#ifdef newc #ifdef newc
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <cmath> #include <cmath>
#include <complex> #include <complex>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <fstream.h> #include <fstream.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <complex.h> #include <complex.h>
#endif #endif
#include <mpi.h> #include <mpi.h>
#include "MyList.h" #include "MyList.h"
#include "Block.h" #include "Block.h"
#include "Parallel.h" #include "Parallel.h"
#include "ShellPatch.h" #include "ShellPatch.h"
#include "var.h" #include "var.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width #include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3) #if (dim != 3)
#error NullShellPatch2 only supports 3 dimensional stuff yet #error NullShellPatch2 only supports 3 dimensional stuff yet
#endif #endif
// x x x x x o * // x x x x x o *
// * o x x x x x // * o x x x x x
// each side contribute an overlap points // each side contribute an overlap points
// so we need half of that // so we need half of that
#define overghost ((ghost_width + 1) / 2 + ghost_width) #define overghost ((ghost_width + 1) / 2 + ghost_width)
class NullShellPatch2 class NullShellPatch2
{ {
class xp_npatch : public ss_patch class xp_npatch : public ss_patch
{ {
public: public:
xp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 2; }; xp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 2; };
}; };
class xm_npatch : public ss_patch class xm_npatch : public ss_patch
{ {
public: public:
xm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 3; }; xm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 3; };
}; };
class yp_npatch : public ss_patch class yp_npatch : public ss_patch
{ {
public: public:
yp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 4; }; yp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 4; };
}; };
class ym_npatch : public ss_patch class ym_npatch : public ss_patch
{ {
public: public:
ym_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 5; }; ym_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 5; };
}; };
class zp_npatch : public ss_patch class zp_npatch : public ss_patch
{ {
public: public:
zp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 0; }; zp_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 0; };
}; };
class zm_npatch : public ss_patch class zm_npatch : public ss_patch
{ {
public: public:
zm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; }; zm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
}; };
public: public:
struct pointstru struct pointstru
{ {
double gpox[dim]; // global cordinate double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate double lpox[dim]; // local cordinate
Block *Bg; Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef; double *coef;
int *sind; // index position, considered dummy dimension already int *sind; // index position, considered dummy dimension already
int dumyd; // the dimension which has common lines, only useful in interdata_packer int dumyd; // the dimension which has common lines, only useful in interdata_packer
double Jacob[2][2]; double Jacob[2][2];
int indz; // index position of r direction int indz; // index position of r direction
}; };
var *gx, *gy, *gz; var *gx, *gy, *gz;
// surface variable // surface variable
var *g00, *g01, *p02, *p03, *g02, *g03; var *g00, *g01, *p02, *p03, *g02, *g03;
var *Theta22, *Theta23, *Theta33; var *Theta22, *Theta23, *Theta33;
// evolution variables // evolution variables
var *g22o, *g23o, *g33o; var *g22o, *g23o, *g33o;
var *g220, *g230, *g330; var *g220, *g230, *g330;
var *g22, *g23, *g33; var *g22, *g23, *g33;
var *g221, *g231, *g331; var *g221, *g231, *g331;
var *g22_rhs, *g23_rhs, *g33_rhs; var *g22_rhs, *g23_rhs, *g33_rhs;
var *RNews, *INews; var *RNews, *INews;
var *omega, *dtomega; var *omega, *dtomega;
MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList; MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList;
MyList<var> *OldStateList, *DumpList, *CheckList; MyList<var> *OldStateList, *DumpList, *CheckList;
MyList<var> *NewsList; MyList<var> *NewsList;
MyList<var> *g01List, *pg0AList, *g00List, *ThetaList; MyList<var> *g01List, *pg0AList, *g00List, *ThetaList;
double **g01wt, **pg0Awt, **g00wt, **Thetawt; double **g01wt, **pg0Awt, **g00wt, **Thetawt;
int myrank; int myrank;
int shape[dim]; // for (rho, sigma, X), for rho and sigma means number of points for every pi/2 int shape[dim]; // for (rho, sigma, X), for rho and sigma means number of points for every pi/2
double Rmin, xmin, xmax; double Rmin, xmin, xmax;
int Symmetry; int Symmetry;
int ingfs, fngfs; int ingfs, fngfs;
MyList<ss_patch> *PatL; MyList<ss_patch> *PatL;
MyList<pointstru> **ss_src, **ss_dst; MyList<pointstru> **ss_src, **ss_dst;
MyList<pointstru> **cs_src, **cs_dst; MyList<pointstru> **cs_src, **cs_dst;
public: public:
NullShellPatch2(int *shapei, double Rmini, double xmini, double xmaxi, int Symmetry, int myranki); NullShellPatch2(int *shapei, double Rmini, double xmini, double xmaxi, int Symmetry, int myranki);
~NullShellPatch2(); ~NullShellPatch2();
double getdX(int dir); double getdX(int dir);
void shellname(char *sn, int i); void shellname(char *sn, int i);
void destroypsuList(MyList<pointstru> *ct); void destroypsuList(MyList<pointstru> *ct);
MyList<Block> *compose_sh(int cpusize); MyList<Block> *compose_sh(int cpusize);
void Dump_xyz(char *tag, double time, double dT); void Dump_xyz(char *tag, double time, double dT);
void Dump_Data(MyList<var> *DumpListi, char *tag, double time, double dT); void Dump_Data(MyList<var> *DumpListi, char *tag, double time, double dT);
void setupintintstuff(int cpusize, MyList<Patch> *CPatL, int Symmetry); void setupintintstuff(int cpusize, MyList<Patch> *CPatL, int Symmetry);
void getlocalpox_ss(int isst, double ix, double iy, double iz, int &sst, double &lx, double &ly, double &lz); void getlocalpox_ss(int isst, double ix, double iy, double iz, int &sst, double &lx, double &ly, double &lz);
void getlocalpox_fake(double x, double y, double z, int &sst, double &lx, double &ly, double &lz); void getlocalpox_fake(double x, double y, double z, int &sst, double &lx, double &ly, double &lz);
void getlocalpox(double x, double y, double z, int &sst, double &lx, double &ly, double &lz); void getlocalpox(double x, double y, double z, int &sst, double &lx, double &ly, double &lz);
void getlocalpoxsst_ss(int isst, double ix, double iy, double iz, int lsst, double &lx, double &ly, double &lz); void getlocalpoxsst_ss(int isst, double ix, double iy, double iz, int lsst, double &lx, double &ly, double &lz);
void getlocalpoxsst(double x, double y, double z, int sst, double &lx, double &ly, double &lz); void getlocalpoxsst(double x, double y, double z, int sst, double &lx, double &ly, double &lz);
void getglobalpox(double &x, double &y, double &z, int sst, double lx, double ly, double lz); void getglobalpox(double &x, double &y, double &z, int sst, double lx, double ly, double lz);
int getdumydimension(int acsst, int posst); int getdumydimension(int acsst, int posst);
void get_Jacob(double *pox, int tsst, int ssst, double J[2][2]); void get_Jacob(double *pox, int tsst, int ssst, double J[2][2]);
void prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPpi, double DH[dim], void prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPpi, double DH[dim],
MyList<Patch> *Ppi, double CDH[dim], MyList<pointstru> *pss); MyList<Patch> *Ppi, double CDH[dim], MyList<pointstru> *pss);
bool prolongpointstru(MyList<pointstru> *&psul, bool ssyn, int tsst, MyList<ss_patch> *sPp, double DH[dim], bool prolongpointstru(MyList<pointstru> *&psul, bool ssyn, int tsst, MyList<ss_patch> *sPp, double DH[dim],
MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in, const int iz); MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in, const int iz);
bool prolongpointstru_ss(MyList<pointstru> *&psul, int tsst, MyList<ss_patch> *sPp, double DH[dim], bool prolongpointstru_ss(MyList<pointstru> *&psul, int tsst, MyList<ss_patch> *sPp, double DH[dim],
MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in, const int iz); MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in, const int iz);
void Setup_Initial_Data(bool checkrun, double PhysTime); void Setup_Initial_Data(bool checkrun, double PhysTime);
void Step(double dT, double PhysTime, monitor *ErrorMonitor); void Step(double dT, double PhysTime, monitor *ErrorMonitor);
void HyperSlice(double dT, double PhysTime, monitor *ErrorMonitor, int RK_count); void HyperSlice(double dT, double PhysTime, monitor *ErrorMonitor, int RK_count);
void Synch(MyList<var> *VarList, int Symmetry, double **Varwt, const short int svt); void Synch(MyList<var> *VarList, int Symmetry, double **Varwt, const short int svt);
void fill_symmetric_boundarybuffer(MyList<var> *VarList, double **Varwt); void fill_symmetric_boundarybuffer(MyList<var> *VarList, double **Varwt);
void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst, void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry, double **Varwt, const short int svt); int Symmetry, double **Varwt, const short int svt);
int interdata_packer(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, int rank_in, int dir, int interdata_packer(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, int rank_in, int dir,
MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry, double **Varwt, MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry, double **Varwt,
const short int svt); const short int svt);
int interdata_packer_pre(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, int rank_in, int dir, int interdata_packer_pre(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, int rank_in, int dir,
MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry, double **Varwt, MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry, double **Varwt,
const short int svt); const short int svt);
int interdata_packer_pot(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, int rank_in, int dir, int interdata_packer_pot(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, int rank_in, int dir,
MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry, double **Varwt, MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry, double **Varwt,
const short int svt); const short int svt);
void check_pointstrul(MyList<pointstru> *pp, bool first_only); void check_pointstrul(MyList<pointstru> *pp, bool first_only);
void checkBlock(int sst); void checkBlock(int sst);
void Null_Boundary(double PhysTime); void Null_Boundary(double PhysTime);
void Compute_News(double PhysTime); void Compute_News(double PhysTime);
void Interp_Points_2D(MyList<var> *VarList, void Interp_Points_2D(MyList<var> *VarList,
int NN, double **XX, /*input fake global Cartesian coordinate*/ int NN, double **XX, /*input fake global Cartesian coordinate*/
double *Shellf, int Symmetry); double *Shellf, int Symmetry);
double Error_Check(double PhysTime); double Error_Check(double PhysTime);
}; };
#endif /* NULLSHELLPATCH2_H */ #endif /* NULLSHELLPATCH2_H */

View File

@@ -1,231 +1,241 @@
#ifndef PARALLEL_H #ifndef PARALLEL_H
#define PARALLEL_H #define PARALLEL_H
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <cmath> #include <cmath>
#include <new> #include <new>
using namespace std; using namespace std;
#include "Parallel_bam.h" #include "Parallel_bam.h"
#include "var.h" #include "var.h"
#include "MPatch.h" #include "MPatch.h"
#include "Block.h" #include "Block.h"
#include "MyList.h" #include "MyList.h"
#include "macrodef.h" //need dim; ghost_width; CONTRACT #include "macrodef.h" //need dim; ghost_width; CONTRACT
namespace Parallel namespace Parallel
{ {
struct gridseg struct gridseg
{ {
double llb[dim]; double llb[dim];
double uub[dim]; double uub[dim];
int shape[dim]; int shape[dim];
double illb[dim], iuub[dim]; // only use for OutBdLow2Hi double illb[dim], iuub[dim]; // only use for OutBdLow2Hi
Block *Bg; Block *Bg;
}; };
int partition1(int &nx, int split_size, int min_width, int cpusize, int shape); // special for 1 diemnsion int partition1(int &nx, int split_size, int min_width, int cpusize, int shape); // special for 1 diemnsion
int partition2(int *nxy, int split_size, int *min_width, int cpusize, int *shape); // special for 2 diemnsions int partition2(int *nxy, int split_size, int *min_width, int cpusize, int *shape); // special for 2 diemnsions
int partition3(int *nxyz, int split_size, int *min_width, int cpusize, int *shape); int partition3(int *nxyz, int split_size, int *min_width, int cpusize, int *shape);
MyList<Block> *distribute(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); // produce corresponding Blocks MyList<Block> *distribute(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); // produce corresponding Blocks
MyList<Block> *distribute_optimize(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); MyList<Block> *distribute_optimize(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0);
Block* splitHotspotBlock(MyList<Block>* &BlL, int _dim, Block* splitHotspotBlock(MyList<Block>* &BlL, int _dim,
int ib0_orig, int ib3_orig, int ib0_orig, int ib3_orig,
int jb1_orig, int jb4_orig, int jb1_orig, int jb4_orig,
int kb2_orig, int kb5_orig, int kb2_orig, int kb5_orig,
Patch* PP, int r_left, int r_right, Patch* PP, int r_left, int r_right,
int ingfsi, int fngfsi, bool periodic, int ingfsi, int fngfsi, bool periodic,
Block* &split_first_block, Block* &split_last_block); Block* &split_first_block, Block* &split_last_block);
Block* createMappedBlock(MyList<Block>* &BlL, int _dim, int* shape, double* bbox, Block* createMappedBlock(MyList<Block>* &BlL, int _dim, int* shape, double* bbox,
int block_id, int ingfsi, int fngfsi, int lev); int block_id, int ingfsi, int fngfsi, int lev);
void KillBlocks(MyList<Patch> *PatchLIST); void KillBlocks(MyList<Patch> *PatchLIST);
void setfunction(MyList<Block> *BlL, var *vn, double func(double x, double y, double z)); void setfunction(MyList<Block> *BlL, var *vn, double func(double x, double y, double z));
void setfunction(int rank, MyList<Block> *BlL, var *vn, double func(double x, double y, double z)); void setfunction(int rank, MyList<Block> *BlL, var *vn, double func(double x, double y, double z));
void writefile(double time, int nx, int ny, int nz, double xmin, double xmax, double ymin, double ymax, void writefile(double time, int nx, int ny, int nz, double xmin, double xmax, double ymin, double ymax,
double zmin, double zmax, char *filename, double *data_out); double zmin, double zmax, char *filename, double *data_out);
void writefile(double time, int nx, int ny, double xmin, double xmax, double ymin, double ymax, void writefile(double time, int nx, int ny, double xmin, double xmax, double ymin, double ymax,
char *filename, double *datain); char *filename, double *datain);
void getarrayindex(int DIM, int *shape, int *index, int n); void getarrayindex(int DIM, int *shape, int *index, int n);
int getarraylocation(int DIM, int *shape, int *index); int getarraylocation(int DIM, int *shape, int *index);
void copy(int DIM, double *llbout, double *uubout, int *Dshape, double *DD, double *llbin, double *uubin, void copy(int DIM, double *llbout, double *uubout, int *Dshape, double *DD, double *llbin, double *uubin,
int *shape, double *datain, double *llb, double *uub); int *shape, double *datain, double *llb, double *uub);
void Dump_CPU_Data(MyList<Block> *BlL, MyList<var> *DumpList, char *tag, double time, double dT); void Dump_CPU_Data(MyList<Block> *BlL, MyList<var> *DumpList, char *tag, double time, double dT);
void Dump_Data(MyList<Patch> *PL, MyList<var> *DumpList, char *tag, double time, double dT); void Dump_Data(MyList<Patch> *PL, MyList<var> *DumpList, char *tag, double time, double dT);
void Dump_Data(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT, int grd); void Dump_Data(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT, int grd);
double *Collect_Data(Patch *PP, var *VP); double *Collect_Data(Patch *PP, var *VP);
void d2Dump_Data(MyList<Patch> *PL, MyList<var> *DumpList, char *tag, double time, double dT); void d2Dump_Data(MyList<Patch> *PL, MyList<var> *DumpList, char *tag, double time, double dT);
void d2Dump_Data(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT, int grd); void d2Dump_Data(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT, int grd);
void Dump_Data0(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT); void Dump_Data0(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT);
double global_interp(int DIM, int *ext, double **CoX, double *datain, double global_interp(int DIM, int *ext, double **CoX, double *datain,
double *poX, int ordn, double *SoA, int Symmetry); double *poX, int ordn, double *SoA, int Symmetry);
double global_interp(int DIM, int *ext, double **CoX, double *datain, double global_interp(int DIM, int *ext, double **CoX, double *datain,
double *poX, int ordn); double *poX, int ordn);
double Lagrangian_Int(double x, int npts, double *xpts, double *funcvals); double Lagrangian_Int(double x, int npts, double *xpts, double *funcvals);
double LagrangePoly(double x, int pt, int npts, double *xpts); double LagrangePoly(double x, int pt, int npts, double *xpts);
MyList<gridseg> *build_complete_gsl(Patch *Pat); MyList<gridseg> *build_complete_gsl(Patch *Pat);
MyList<gridseg> *build_complete_gsl(MyList<Patch> *PatL); MyList<gridseg> *build_complete_gsl(MyList<Patch> *PatL);
MyList<gridseg> *build_complete_gsl_virtual(MyList<Patch> *PatL); MyList<gridseg> *build_complete_gsl_virtual(MyList<Patch> *PatL);
MyList<gridseg> *build_complete_gsl_virtual2(MyList<Patch> *PatL); // - buffer MyList<gridseg> *build_complete_gsl_virtual2(MyList<Patch> *PatL); // - buffer
MyList<gridseg> *build_owned_gsl0(Patch *Pat, int rank_in); // - ghost without extension, special for Sync usage MyList<gridseg> *build_owned_gsl0(Patch *Pat, int rank_in); // - ghost without extension, special for Sync usage
MyList<gridseg> *build_owned_gsl1(Patch *Pat, int rank_in); // - ghost, similar to build_owned_gsl0 but extend one point on left side for vertex grid MyList<gridseg> *build_owned_gsl1(Patch *Pat, int rank_in); // - ghost, similar to build_owned_gsl0 but extend one point on left side for vertex grid
MyList<gridseg> *build_owned_gsl2(Patch *Pat, int rank_in); // - buffer - ghost MyList<gridseg> *build_owned_gsl2(Patch *Pat, int rank_in); // - buffer - ghost
MyList<gridseg> *build_owned_gsl3(Patch *Pat, int rank_in, int Symmetry); // - ghost - BD ghost MyList<gridseg> *build_owned_gsl3(Patch *Pat, int rank_in, int Symmetry); // - ghost - BD ghost
MyList<gridseg> *build_owned_gsl4(Patch *Pat, int rank_in, int Symmetry); // - buffer - ghost - BD ghost MyList<gridseg> *build_owned_gsl4(Patch *Pat, int rank_in, int Symmetry); // - buffer - ghost - BD ghost
MyList<gridseg> *build_owned_gsl5(Patch *Pat, int rank_in); // similar to build_owned_gsl2 but no extension MyList<gridseg> *build_owned_gsl5(Patch *Pat, int rank_in); // similar to build_owned_gsl2 but no extension
MyList<gridseg> *build_owned_gsl(MyList<Patch> *PatL, int rank_in, int type, int Symmetry); MyList<gridseg> *build_owned_gsl(MyList<Patch> *PatL, int rank_in, int type, int Symmetry);
void build_gstl(MyList<gridseg> *srci, MyList<gridseg> *dsti, MyList<gridseg> **out_src, MyList<gridseg> **out_dst); void build_gstl(MyList<gridseg> *srci, MyList<gridseg> *dsti, MyList<gridseg> **out_src, MyList<gridseg> **out_dst);
int data_packer(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir, int data_packer(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry); MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
void transfer(MyList<gridseg> **src, MyList<gridseg> **dst, void transfer(MyList<gridseg> **src, MyList<gridseg> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry); int Symmetry);
int data_packermix(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir, int data_packermix(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry); MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
void transfermix(MyList<gridseg> **src, MyList<gridseg> **dst, void transfermix(MyList<gridseg> **src, MyList<gridseg> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry); int Symmetry);
void Sync(Patch *Pat, MyList<var> *VarList, int Symmetry); void Sync(Patch *Pat, MyList<var> *VarList, int Symmetry);
void Sync(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry); void Sync(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry);
void Sync_merged(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry); void Sync_merged(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry);
struct SyncCache { struct SyncCache {
bool valid; bool valid;
int cpusize; int cpusize;
MyList<gridseg> **combined_src; MyList<gridseg> **combined_src;
MyList<gridseg> **combined_dst; MyList<gridseg> **combined_dst;
int *send_lengths; int *send_lengths;
int *recv_lengths; int *recv_lengths;
double **send_bufs; double **send_bufs;
double **recv_bufs; double **recv_bufs;
int *send_buf_caps; int *send_buf_caps;
int *recv_buf_caps; int *recv_buf_caps;
MPI_Request *reqs; unsigned char *send_buf_pinned;
MPI_Status *stats; unsigned char *recv_buf_pinned;
int max_reqs; unsigned char *send_buf_is_dev;
bool lengths_valid; unsigned char *recv_buf_is_dev;
int *tc_req_node; int *send_buf_caps_dev;
int *tc_req_is_recv; int *recv_buf_caps_dev;
int *tc_completed; double **send_bufs_dev;
SyncCache(); double **recv_bufs_dev;
void invalidate(); MPI_Request *reqs;
void destroy(); MPI_Status *stats;
}; int max_reqs;
bool lengths_valid;
void Sync_cached(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry, SyncCache &cache); int *tc_req_node;
void transfer_cached(MyList<gridseg> **src, MyList<gridseg> **dst, int *tc_req_is_recv;
MyList<var> *VarList1, MyList<var> *VarList2, int *tc_completed;
int Symmetry, SyncCache &cache); bool cuda_aware_mode;
SyncCache();
struct AsyncSyncState { void invalidate();
int req_no; void destroy();
bool active; };
int *req_node;
int *req_is_recv; void Sync_cached(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry, SyncCache &cache);
int pending_recv; void Sync_ensure_cache(MyList<Patch> *PatL, int Symmetry, SyncCache &cache);
AsyncSyncState() : req_no(0), active(false), req_node(0), req_is_recv(0), pending_recv(0) {} void transfer_cached(MyList<gridseg> **src, MyList<gridseg> **dst,
}; MyList<var> *VarList1, MyList<var> *VarList2,
int Symmetry, SyncCache &cache);
void Sync_start(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry,
SyncCache &cache, AsyncSyncState &state); struct AsyncSyncState {
void Sync_finish(SyncCache &cache, AsyncSyncState &state, int req_no;
MyList<var> *VarList, int Symmetry); bool active;
void OutBdLow2Hi(Patch *Patc, Patch *Patf, int *req_node;
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, int *req_is_recv;
int Symmetry); int pending_recv;
void OutBdLow2Hi(MyList<Patch> *PatcL, MyList<Patch> *PatfL, AsyncSyncState() : req_no(0), active(false), req_node(0), req_is_recv(0), pending_recv(0) {}
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, };
int Symmetry);
void OutBdLow2Himix(Patch *Patc, Patch *Patf, void Sync_start(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, SyncCache &cache, AsyncSyncState &state);
int Symmetry); void Sync_finish(SyncCache &cache, AsyncSyncState &state,
void OutBdLow2Himix(MyList<Patch> *PatcL, MyList<Patch> *PatfL, MyList<var> *VarList, int Symmetry);
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, void OutBdLow2Hi(Patch *Patc, Patch *Patf,
int Symmetry); MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
void Restrict_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL, int Symmetry);
MyList<var> *VarList1, MyList<var> *VarList2, void OutBdLow2Hi(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
int Symmetry, SyncCache &cache); MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
void OutBdLow2Hi_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL, int Symmetry);
MyList<var> *VarList1, MyList<var> *VarList2, void OutBdLow2Himix(Patch *Patc, Patch *Patf,
int Symmetry, SyncCache &cache); MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
void OutBdLow2Himix_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL, int Symmetry);
MyList<var> *VarList1, MyList<var> *VarList2, void OutBdLow2Himix(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
int Symmetry, SyncCache &cache); MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
void Prolong(Patch *Patc, Patch *Patf, int Symmetry);
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, void Restrict_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
int Symmetry); MyList<var> *VarList1, MyList<var> *VarList2,
void Prolongint(Patch *Patc, Patch *Patf, int Symmetry, SyncCache &cache);
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, void OutBdLow2Hi_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
int Symmetry); MyList<var> *VarList1, MyList<var> *VarList2,
void Restrict(MyList<Patch> *PatcL, MyList<Patch> *PatfL, int Symmetry, SyncCache &cache);
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, void OutBdLow2Himix_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
int Symmetry); MyList<var> *VarList1, MyList<var> *VarList2,
void Restrict_after(MyList<Patch> *PatcL, MyList<Patch> *PatfL, int Symmetry, SyncCache &cache);
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, void Prolong(Patch *Patc, Patch *Patf,
int Symmetry); // for -ghost - BDghost MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::gridseg> *build_PhysBD_gsl(Patch *Pat); int Symmetry);
MyList<Parallel::gridseg> *build_ghost_gsl(MyList<Patch> *PatL); void Prolongint(Patch *Patc, Patch *Patf,
MyList<Parallel::gridseg> *build_ghost_gsl(Patch *Pat); MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::gridseg> *build_buffer_gsl(Patch *Pat); int Symmetry);
MyList<Parallel::gridseg> *build_buffer_gsl(MyList<Patch> *PatL); void Restrict(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<Parallel::gridseg> *gsl_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B); MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::gridseg> *gs_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B); int Symmetry);
MyList<Parallel::gridseg> *gsl_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B); void Restrict_after(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<Parallel::gridseg> *gs_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B); MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::gridseg> *clone_gsl(MyList<Parallel::gridseg> *p, bool first_only); int Symmetry); // for -ghost - BDghost
MyList<Parallel::gridseg> *build_bulk_gsl(Patch *Pat); // similar to build_owned_gsl0 but does not care rank issue MyList<Parallel::gridseg> *build_PhysBD_gsl(Patch *Pat);
MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp, Patch *Pat); MyList<Parallel::gridseg> *build_ghost_gsl(MyList<Patch> *PatL);
void build_PhysBD_gstl(Patch *Pat, MyList<Parallel::gridseg> *srci, MyList<Parallel::gridseg> *dsti, MyList<Parallel::gridseg> *build_ghost_gsl(Patch *Pat);
MyList<Parallel::gridseg> **out_src, MyList<Parallel::gridseg> **out_dst); MyList<Parallel::gridseg> *build_buffer_gsl(Patch *Pat);
void PeriodicBD(Patch *Pat, MyList<var> *VarList, int Symmetry); MyList<Parallel::gridseg> *build_buffer_gsl(MyList<Patch> *PatL);
double L2Norm(Patch *Pat, var *vf); MyList<Parallel::gridseg> *gsl_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
void L2Norm7(Patch *Pat, var **vf, double *norms); MyList<Parallel::gridseg> *gs_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
void checkgsl(MyList<Parallel::gridseg> *pp, bool first_only); MyList<Parallel::gridseg> *gsl_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
void checkvarl(MyList<var> *pp, bool first_only); MyList<Parallel::gridseg> *gs_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *divide_gsl(MyList<Parallel::gridseg> *p, Patch *Pat); MyList<Parallel::gridseg> *clone_gsl(MyList<Parallel::gridseg> *p, bool first_only);
MyList<Parallel::gridseg> *divide_gs(MyList<Parallel::gridseg> *p, Patch *Pat); MyList<Parallel::gridseg> *build_bulk_gsl(Patch *Pat); // similar to build_owned_gsl0 but does not care rank issue
void prepare_inter_time_level(Patch *Pat, MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp, Patch *Pat);
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */, void build_PhysBD_gstl(Patch *Pat, MyList<Parallel::gridseg> *srci, MyList<Parallel::gridseg> *dsti,
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex); MyList<Parallel::gridseg> **out_src, MyList<Parallel::gridseg> **out_dst);
void prepare_inter_time_level(Patch *Pat, void PeriodicBD(Patch *Pat, MyList<var> *VarList, int Symmetry);
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */, double L2Norm(Patch *Pat, var *vf);
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex); void L2Norm7(Patch *Pat, var **vf, double *norms);
void prepare_inter_time_level(MyList<Patch> *PatL, void checkgsl(MyList<Parallel::gridseg> *pp, bool first_only);
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */, void checkvarl(MyList<var> *pp, bool first_only);
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex); MyList<Parallel::gridseg> *divide_gsl(MyList<Parallel::gridseg> *p, Patch *Pat);
void prepare_inter_time_level(MyList<Patch> *Pat, MyList<Parallel::gridseg> *divide_gs(MyList<Parallel::gridseg> *p, Patch *Pat);
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */, void prepare_inter_time_level(Patch *Pat,
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex); MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
void merge_gsl(MyList<gridseg> *&A, const double ratio); MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
bool merge_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C, const double ratio); void prepare_inter_time_level(Patch *Pat,
// Add ghost region to tangent plane MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
// we assume the grids have the same resolution MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
void add_ghost_touch(MyList<gridseg> *&A); void prepare_inter_time_level(MyList<Patch> *PatL,
void cut_gsl(MyList<gridseg> *&A); MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
bool cut_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C); MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
MyList<Parallel::gridseg> *gs_subtract_virtual(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B); void prepare_inter_time_level(MyList<Patch> *Pat,
void fill_level_data(MyList<Patch> *PatLd, MyList<Patch> *PatLs, MyList<Patch> *PatcL, MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *FutureList, MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
MyList<var> *tmList, int Symmetry, bool BB, bool CC); void merge_gsl(MyList<gridseg> *&A, const double ratio);
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList, bool merge_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C, const double ratio);
int NN, double **XX, // Add ghost region to tangent plane
double *Shellf, int Symmetry); // we assume the grids have the same resolution
void aligncheck(double *bbox0, double *bboxl, int lev, double *DH0, int *shape); void add_ghost_touch(MyList<gridseg> *&A);
bool point_locat_gsl(double *pox, MyList<Parallel::gridseg> *gsl); void cut_gsl(MyList<gridseg> *&A);
void checkpatchlist(MyList<Patch> *PatL, bool buflog); bool cut_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C);
MyList<Parallel::gridseg> *gs_subtract_virtual(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
double L2Norm(Patch *Pat, var *vf, MPI_Comm Comm_here); void fill_level_data(MyList<Patch> *PatLd, MyList<Patch> *PatLs, MyList<Patch> *PatcL,
void L2Norm7(Patch *Pat, var **vf, double *norms, MPI_Comm Comm_here); MyList<var> *OldList, MyList<var> *StateList, MyList<var> *FutureList,
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList, MyList<var> *tmList, int Symmetry, bool BB, bool CC);
int NN, double **XX, bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList,
double *Shellf, int Symmetry, MPI_Comm Comm_here); int NN, double **XX,
#if (PSTR == 1 || PSTR == 2 || PSTR == 3) double *Shellf, int Symmetry);
MyList<Block> *distribute(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfsi, void aligncheck(double *bbox0, double *bboxl, int lev, double *DH0, int *shape);
bool periodic, int start_rank, int end_rank, int nodes = 0); bool point_locat_gsl(double *pox, MyList<Parallel::gridseg> *gsl);
#endif void checkpatchlist(MyList<Patch> *PatL, bool buflog);
}
#endif /*PARALLEL_H */ double L2Norm(Patch *Pat, var *vf, MPI_Comm Comm_here);
void L2Norm7(Patch *Pat, var **vf, double *norms, MPI_Comm Comm_here);
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList,
int NN, double **XX,
double *Shellf, int Symmetry, MPI_Comm Comm_here);
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
MyList<Block> *distribute(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfsi,
bool periodic, int start_rank, int end_rank, int nodes = 0);
#endif
}
#endif /*PARALLEL_H */

View File

@@ -1,53 +1,53 @@
#ifndef PARALLEL_BAM_H #ifndef PARALLEL_BAM_H
#define PARALLEL_BAM_H #define PARALLEL_BAM_H
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <cmath> #include <cmath>
#include <new> #include <new>
using namespace std; using namespace std;
#include "var.h" #include "var.h"
#include "MPatch.h" #include "MPatch.h"
#include "Block.h" #include "Block.h"
#include "MyList.h" #include "MyList.h"
#include "macrodef.h" #include "macrodef.h"
namespace Parallel namespace Parallel
{ {
struct pointstru_bam struct pointstru_bam
{ {
double pox[dim]; // cordinate double pox[dim]; // cordinate
Block *Bgs; // interplate from Block *Bgs; // interplate from
Block *Bgd; // interplate for Block *Bgd; // interplate for
double *coef; // interpolation coefficients double *coef; // interpolation coefficients
int sind[dim]; // interpolation starting array index int sind[dim]; // interpolation starting array index
}; };
void destroypsuList_bam(MyList<pointstru_bam> *ct); void destroypsuList_bam(MyList<pointstru_bam> *ct);
void OutBdLow2Hi_bam(MyList<Patch> *PLc, MyList<Patch> *PLf, void OutBdLow2Hi_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry); int Symmetry);
void OutBdLow2Hi_bam(MyList<Patch> *PLc, MyList<Patch> *PLf, void OutBdLow2Hi_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::pointstru_bam> *bdsul, int Symmetry); MyList<Parallel::pointstru_bam> *bdsul, int Symmetry);
void Constr_pointstr_OutBdLow2Hi(MyList<Patch> *PLf, MyList<Patch> *PLc, void Constr_pointstr_OutBdLow2Hi(MyList<Patch> *PLf, MyList<Patch> *PLc,
MyList<Parallel::pointstru_bam> *&bdsul); MyList<Parallel::pointstru_bam> *&bdsul);
void Restrict_bam(MyList<Patch> *PLc, MyList<Patch> *PLf, void Restrict_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry); int Symmetry);
void Restrict_bam(MyList<Patch> *PLc, MyList<Patch> *PLf, void Restrict_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::pointstru_bam> *rsul, int Symmetry); MyList<Parallel::pointstru_bam> *rsul, int Symmetry);
void Constr_pointstr_Restrict(MyList<Patch> *PLf, MyList<Patch> *PLc, void Constr_pointstr_Restrict(MyList<Patch> *PLf, MyList<Patch> *PLc,
MyList<Parallel::pointstru_bam> *&rsul); MyList<Parallel::pointstru_bam> *&rsul);
void intertransfer(MyList<Parallel::pointstru_bam> *&sul, void intertransfer(MyList<Parallel::pointstru_bam> *&sul,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */, MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry); int Symmetry);
int interdata_packer(double *data, MyList<Parallel::pointstru_bam> *sul, int myrank, int node, int dir, int interdata_packer(double *data, MyList<Parallel::pointstru_bam> *sul, int myrank, int node, int dir,
MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry); MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, int Symmetry);
} }
#endif /*PARALLEL_BAM_H */ #endif /*PARALLEL_BAM_H */

View File

@@ -1,271 +1,271 @@
! define scalar field distribution and potential in F(R) scalar-tensor theory ! define scalar field distribution and potential in F(R) scalar-tensor theory
! 1: Case C of 1112.3928, V=0 ! 1: Case C of 1112.3928, V=0
! 2: shell with a2^2*phi0/(1+a2^2), f(R) = R+a2*R^2 induced V ! 2: shell with a2^2*phi0/(1+a2^2), f(R) = R+a2*R^2 induced V
! 3: ground state of Schrodinger-Newton system, f(R) = R+a2*R^2 induced V ! 3: ground state of Schrodinger-Newton system, f(R) = R+a2*R^2 induced V
! 4: a2 = oo and \phi = \phi_0*0.5*(tanh((r+r_0)/\sigma)-tanh((r-r_0)/\sigma)) ! 4: a2 = oo and \phi = \phi_0*0.5*(tanh((r+r_0)/\sigma)-tanh((r-r_0)/\sigma))
! 5: shell with phi0*dexp(-(r-r0)**2/sigma), V = 0 ! 5: shell with phi0*dexp(-(r-r0)**2/sigma), V = 0
! original way, manually define the preprocessor macro ! original way, manually define the preprocessor macro
! #define CC 2 ! #define CC 2
! the new way, define according to the preprocessor macro in "macrodef.fh" ! the new way, define according to the preprocessor macro in "macrodef.fh"
#include "macrodef.fh" #include "macrodef.fh"
#define CC EScalar_CC #define CC EScalar_CC
subroutine setparameters(a2,r0,phi0,sigma,l2) subroutine setparameters(a2,r0,phi0,sigma,l2)
implicit none implicit none
real*8,intent(out) :: a2,r0,phi0,sigma,l2 real*8,intent(out) :: a2,r0,phi0,sigma,l2
! original way: read in parameters one by one ! original way: read in parameters one by one
! call seta2(a2) ! call seta2(a2)
! call setphi0(phi0) ! call setphi0(phi0)
! new way: read in all parameters at once ! new way: read in all parameters at once
call set_escalar_parameter(a2, phi0, r0, sigma, l2) call set_escalar_parameter(a2, phi0, r0, sigma, l2)
! r0=120.d0 ! r0=120.d0
! sigma=8.d0 ! sigma=8.d0
! l2=1.d4 ! l2=1.d4
! write(*,*) ! write(*,*)
! write(*,*) " Set_Rho_ADM.f90 a2 = ", a2 ! write(*,*) " Set_Rho_ADM.f90 a2 = ", a2
! write(*,*) " Set_Rho_ADM.f90 phi0 = ", phi0 ! write(*,*) " Set_Rho_ADM.f90 phi0 = ", phi0
! write(*,*) " Set_Rho_ADM.f90 r0 = ", r0 ! write(*,*) " Set_Rho_ADM.f90 r0 = ", r0
! write(*,*) " Set_Rho_ADM.f90 sigma0 = ", sigma ! write(*,*) " Set_Rho_ADM.f90 sigma0 = ", sigma
! write(*,*) " Set_Rho_ADM.f90 l2 = ", l2 ! write(*,*) " Set_Rho_ADM.f90 l2 = ", l2
! write(*,*) ! write(*,*)
return return
end subroutine setparameters end subroutine setparameters
!=================================================================== !===================================================================
function phi(X,Y,Z) result(gont) function phi(X,Y,Z) result(gont)
implicit none implicit none
double precision,intent(in)::X double precision,intent(in)::X
double precision,intent(in)::Y double precision,intent(in)::Y
double precision,intent(in)::Z double precision,intent(in)::Z
real*8 :: gont real*8 :: gont
real*8 ::r real*8 ::r
real*8 :: a2,r0,phi0,sigma,l2 real*8 :: a2,r0,phi0,sigma,l2
call setparameters(a2,r0,phi0,sigma,l2) call setparameters(a2,r0,phi0,sigma,l2)
r=dsqrt(X*X+Y*Y+Z*Z) r=dsqrt(X*X+Y*Y+Z*Z)
#if ( CC == 1) #if ( CC == 1)
! configuration 1 ! configuration 1
gont = phi0*dtanh((r-r0)/sigma) gont = phi0*dtanh((r-r0)/sigma)
#elif ( CC == 2) #elif ( CC == 2)
! configuration 2 ! configuration 2
phi0 = a2**2*phi0/(1+a2**2) phi0 = a2**2*phi0/(1+a2**2)
gont = phi0*dexp(-(r-r0)**2/sigma) gont = phi0*dexp(-(r-r0)**2/sigma)
#elif ( CC == 3) #elif ( CC == 3)
gont = (0.0481646d0*dexp(-0.0581545d0*(r-1.8039d-8)*(r-1.8039d-8)/l2) & gont = (0.0481646d0*dexp(-0.0581545d0*(r-1.8039d-8)*(r-1.8039d-8)/l2) &
+0.298408d0*dexp(-0.111412d0*(r+9.6741d-9)*(r+9.6741d-9)/l2)+ & +0.298408d0*dexp(-0.111412d0*(r+9.6741d-9)*(r+9.6741d-9)/l2)+ &
0.42755d0*dexp(-0.207156d0*(r-1.09822d-8)*(r-1.09822d-8)/l2)+ & 0.42755d0*dexp(-0.207156d0*(r-1.09822d-8)*(r-1.09822d-8)/l2)+ &
0.204229d0*dexp(-0.37742d0*(r+2.13778d-8)*(r+2.13778d-8)/l2)+ & 0.204229d0*dexp(-0.37742d0*(r+2.13778d-8)*(r+2.13778d-8)/l2)+ &
0.021649d0*dexp(-0.68406d0*(r-8.78608d-8)*(r-8.78608d-8)/l2))/l2 0.021649d0*dexp(-0.68406d0*(r-8.78608d-8)*(r-8.78608d-8)/l2))/l2
#elif ( CC == 4) #elif ( CC == 4)
! configuration 4, a2 = oo ! configuration 4, a2 = oo
phi0 = 0.5d0*phi0 phi0 = 0.5d0*phi0
gont = phi0*(dtanh((r+r0)/sigma)-dtanh((r-r0)/sigma)) gont = phi0*(dtanh((r+r0)/sigma)-dtanh((r-r0)/sigma))
#elif ( CC == 5) #elif ( CC == 5)
! configuration 5 ! configuration 5
gont = phi0*dexp(-(r-r0)**2/sigma) gont = phi0*dexp(-(r-r0)**2/sigma)
#endif #endif
return return
end function phi end function phi
! d phi/dr ! d phi/dr
function dphi(X,Y,Z) result(gont) function dphi(X,Y,Z) result(gont)
implicit none implicit none
double precision,intent(in)::X double precision,intent(in)::X
double precision,intent(in)::Y double precision,intent(in)::Y
double precision,intent(in)::Z double precision,intent(in)::Z
real*8 :: gont real*8 :: gont
real*8 ::r real*8 ::r
real*8 :: a2,r0,phi0,sigma,l2 real*8 :: a2,r0,phi0,sigma,l2
call setparameters(a2,r0,phi0,sigma,l2) call setparameters(a2,r0,phi0,sigma,l2)
r=dsqrt(X*X+Y*Y+Z*Z) r=dsqrt(X*X+Y*Y+Z*Z)
#if ( CC == 1) #if ( CC == 1)
! configuration 1 ! configuration 1
gont = phi0/sigma*(1-(dtanh((r-r0)/sigma))**2) gont = phi0/sigma*(1-(dtanh((r-r0)/sigma))**2)
#elif ( CC == 2) #elif ( CC == 2)
! configuration 2 ! configuration 2
phi0 = a2**2*phi0/(1+a2**2) phi0 = a2**2*phi0/(1+a2**2)
gont = -2.d0*phi0*(r-r0)/sigma*exp(-(r-r0)**2/sigma) gont = -2.d0*phi0*(r-r0)/sigma*exp(-(r-r0)**2/sigma)
#elif ( CC == 3) #elif ( CC == 3)
gont = (-0.5601976461d-2*(r-0.18039d-7)/l2*dexp(-0.581545d-1*(r-0.18039d-7)**2/l2) & gont = (-0.5601976461d-2*(r-0.18039d-7)/l2*dexp(-0.581545d-1*(r-0.18039d-7)**2/l2) &
-0.6649246419d-1*(r+0.96741d-8)/l2*dexp(-0.111412d0*(r+.96741e-8)**2/l2) & -0.6649246419d-1*(r+0.96741d-8)/l2*dexp(-0.111412d0*(r+.96741e-8)**2/l2) &
-0.1771390956d0*(r-0.109822d-7)/l2*dexp(-0.207156d0*(r-0.109822d-7)**2/l2) & -0.1771390956d0*(r-0.109822d-7)/l2*dexp(-0.207156d0*(r-0.109822d-7)**2/l2) &
-0.1541602184d0*(r+0.213778d-7)/l2*dexp(-0.37742d0*(r+0.213778d-7)**2/l2) & -0.1541602184d0*(r+0.213778d-7)/l2*dexp(-0.37742d0*(r+0.213778d-7)**2/l2) &
-0.2961842988d-1*(r-0.878608d-7)/l2*dexp(-0.68406*(r-0.878608d-7)**2/l2))/l2 -0.2961842988d-1*(r-0.878608d-7)/l2*dexp(-0.68406*(r-0.878608d-7)**2/l2))/l2
#elif ( CC == 4) #elif ( CC == 4)
! configuration 4, a2 = oo ! configuration 4, a2 = oo
phi0 = 0.5d0*phi0 phi0 = 0.5d0*phi0
gont = phi0*((1-dtanh((r+r0)/sigma)**2)/sigma- & gont = phi0*((1-dtanh((r+r0)/sigma)**2)/sigma- &
(1-dtanh((r-r0)/sigma)**2)/sigma) (1-dtanh((r-r0)/sigma)**2)/sigma)
#elif ( CC == 5) #elif ( CC == 5)
! configuration 5 ! configuration 5
gont = -2.d0*phi0*(r-r0)/sigma*exp(-(r-r0)**2/sigma) gont = -2.d0*phi0*(r-r0)/sigma*exp(-(r-r0)**2/sigma)
#endif #endif
return return
end function dphi end function dphi
!================================================================== !==================================================================
function potential(X,Y,Z) result(gont) function potential(X,Y,Z) result(gont)
implicit none implicit none
double precision,intent(in)::X double precision,intent(in)::X
double precision,intent(in)::Y double precision,intent(in)::Y
double precision,intent(in)::Z double precision,intent(in)::Z
real*8 :: gont real*8 :: gont
real*8 :: phi real*8 :: phi
real*8 :: PI,v real*8 :: PI,v
real*8 :: a2,r0,phi0,sigma,l2 real*8 :: a2,r0,phi0,sigma,l2
#if ( CC == 1 || CC == 4 || CC == 5) #if ( CC == 1 || CC == 4 || CC == 5)
gont = 0.d0 gont = 0.d0
#elif ( CC == 2 || CC == 3) #elif ( CC == 2 || CC == 3)
call setparameters(a2,r0,phi0,sigma,l2) call setparameters(a2,r0,phi0,sigma,l2)
PI = dacos(-1.d0) PI = dacos(-1.d0)
v = phi(X,Y,Z) v = phi(X,Y,Z)
gont = dexp(-8.d0*dsqrt(PI/3)*v)*(1-dexp(4*dsqrt(PI/3)*v))**2/32/PI/a2 gont = dexp(-8.d0*dsqrt(PI/3)*v)*(1-dexp(4*dsqrt(PI/3)*v))**2/32/PI/a2
#endif #endif
return return
end function potential end function potential
!================================================================== !==================================================================
!Note this part is for evolution !Note this part is for evolution
!not just for initial configuration !not just for initial configuration
!f(R) potential F=R+a_2R^2 !f(R) potential F=R+a_2R^2
subroutine frpotential(ex,Sphi,V,dVdSphi) subroutine frpotential(ex,Sphi,V,dVdSphi)
implicit none implicit none
integer,intent(in ):: ex(1:3) integer,intent(in ):: ex(1:3)
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Sphi real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Sphi
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: V,dVdSphi real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: V,dVdSphi
real*8 :: a2,r0,phi0,sigma,l2 real*8 :: a2,r0,phi0,sigma,l2
real*8, parameter :: Four = 4.d0, TWO = 2.d0,ONE = 1.d0,ZEO=0.d0 real*8, parameter :: Four = 4.d0, TWO = 2.d0,ONE = 1.d0,ZEO=0.d0
real*8 :: PI real*8 :: PI
PI = dacos(-ONE) PI = dacos(-ONE)
#if ( CC == 1 || CC == 4 || CC == 5) #if ( CC == 1 || CC == 4 || CC == 5)
V = ZEO V = ZEO
dVdSphi = ZEO dVdSphi = ZEO
#elif ( CC == 2 || CC == 3) #elif ( CC == 2 || CC == 3)
call setparameters(a2,r0,phi0,sigma,l2) call setparameters(a2,r0,phi0,sigma,l2)
V = dexp(-8.d0*dsqrt(PI/3)*Sphi)*(1-dexp(4*dsqrt(PI/3)*Sphi))**2/32/PI/a2 V = dexp(-8.d0*dsqrt(PI/3)*Sphi)*(1-dexp(4*dsqrt(PI/3)*Sphi))**2/32/PI/a2
dVdSphi = 1.d0/a2/1.2d1*dsqrt(3.d0/PI)*dexp(-8.d0*dsqrt(PI/3.d0)*Sphi)*(-1+dexp(4*dsqrt(Pi/3)*Sphi)) dVdSphi = 1.d0/a2/1.2d1*dsqrt(3.d0/PI)*dexp(-8.d0*dsqrt(PI/3.d0)*Sphi)*(-1+dexp(4*dsqrt(Pi/3)*Sphi))
#endif #endif
return return
end subroutine frpotential end subroutine frpotential
!================================================================== !==================================================================
!f(R) potential F=R+a_2R^2 !f(R) potential F=R+a_2R^2
!fprim(R) = 1+2*a_2*R !fprim(R) = 1+2*a_2*R
subroutine frfprim(ex,RR,fprim) subroutine frfprim(ex,RR,fprim)
implicit none implicit none
integer,intent(in ):: ex(1:3) integer,intent(in ):: ex(1:3)
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: RR real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: RR
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: fprim real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: fprim
real*8 :: a2,r0,phi0,sigma,l2 real*8 :: a2,r0,phi0,sigma,l2
real*8, parameter :: ONE=1.d0, TWO = 2.d0 real*8, parameter :: ONE=1.d0, TWO = 2.d0
#if ( CC == 1 || CC == 4 || CC == 5) #if ( CC == 1 || CC == 4 || CC == 5)
fprim = ONE fprim = ONE
#elif ( CC == 2 || CC == 3) #elif ( CC == 2 || CC == 3)
call setparameters(a2,r0,phi0,sigma,l2) call setparameters(a2,r0,phi0,sigma,l2)
fprim = ONE+TWO*a2*RR fprim = ONE+TWO*a2*RR
#endif #endif
return return
end subroutine frfprim end subroutine frfprim
!================================================================== !==================================================================
subroutine set_rho_adm2(ex,rho,X,Y,Z) subroutine set_rho_adm2(ex,rho,X,Y,Z)
implicit none implicit none
! argument variables ! argument variables
integer,intent(in)::ex integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z double precision,intent(in),dimension(ex)::Z
double precision,intent(out),dimension(ex)::rho double precision,intent(out),dimension(ex)::rho
integer :: i integer :: i
real*8 :: dphi real*8 :: dphi
do i=1,ex do i=1,ex
! rho(i) = dphi(X,Y,Z) ! rho(i) = dphi(X,Y,Z)
rho(i) = dphi(X(i),Y(i),Z(i)) rho(i) = dphi(X(i),Y(i),Z(i))
rho(i) = rho(i)*rho(i) rho(i) = rho(i)*rho(i)
enddo enddo
return return
end subroutine set_rho_adm2 end subroutine set_rho_adm2
subroutine set_rho_adm1(ex,rho,X,Y,Z) subroutine set_rho_adm1(ex,rho,X,Y,Z)
implicit none implicit none
! argument variables ! argument variables
integer,intent(in)::ex integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z double precision,intent(in),dimension(ex)::Z
double precision,intent(out),dimension(ex)::rho double precision,intent(out),dimension(ex)::rho
real*8 :: potential real*8 :: potential
integer :: i integer :: i
do i=1,ex do i=1,ex
rho(i) = potential(X(i),Y(i),Z(i)) rho(i) = potential(X(i),Y(i),Z(i))
enddo enddo
return return
end subroutine set_rho_adm1 end subroutine set_rho_adm1
subroutine set_rho_adm(ex,rho,X,Y,Z) subroutine set_rho_adm(ex,rho,X,Y,Z)
implicit none implicit none
! argument variables ! argument variables
integer,intent(in)::ex integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z double precision,intent(in),dimension(ex)::Z
! in psivac, out rho_adm ! in psivac, out rho_adm
double precision,intent(inout),dimension(ex)::rho double precision,intent(inout),dimension(ex)::rho
double precision,dimension(ex)::rho1,rho2 double precision,dimension(ex)::rho1,rho2
call set_rho_adm1(ex,rho1,X,Y,Z) call set_rho_adm1(ex,rho1,X,Y,Z)
call set_rho_adm2(ex,rho2,X,Y,Z) call set_rho_adm2(ex,rho2,X,Y,Z)
rho = rho**4 rho = rho**4
rho = rho**2*rho1+rho*rho2 rho = rho**2*rho1+rho*rho2
return return
end subroutine set_rho_adm end subroutine set_rho_adm

View File

@@ -1,205 +1,221 @@
#ifndef SHELLPATCH_H #ifndef SHELLPATCH_H
#define SHELLPATCH_H #define SHELLPATCH_H
#include <mpi.h> #include <mpi.h>
#include "MyList.h" #include "MyList.h"
#include "Block.h" #include "Block.h"
#include "Parallel.h" #include "Parallel.h"
#include "var.h" #include "var.h"
#include "monitor.h" #include "monitor.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width #include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3) #if (dim != 3)
#error shellpatch only supports 3 dimensional stuff yet #error shellpatch only supports 3 dimensional stuff yet
#endif #endif
class ss_patch class ss_patch
{ {
public: public:
int sst; // ss_patch type: 0:zp, 1:zm, 2:xp, 3:xm, 4:yp, 5:ym int sst; // ss_patch type: 0:zp, 1:zm, 2:xp, 3:xm, 4:yp, 5:ym
int myrank; int myrank;
int shape[dim]; int shape[dim];
double bbox[2 * dim]; // this bbox includes nominal points and overlap points double bbox[2 * dim]; // this bbox includes nominal points and overlap points
MyList<Block> *blb, *ble; MyList<Block> *blb, *ble;
int ingfs, fngfs; int ingfs, fngfs;
ss_patch() {}; ss_patch() {};
ss_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki); ss_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki);
~ss_patch(); ~ss_patch();
virtual void setupcordtrans() {}; virtual void setupcordtrans() {};
void Sync(MyList<var> *VarList, int Symmetry); void Sync(MyList<var> *VarList, int Symmetry);
MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp); MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp);
MyList<Parallel::gridseg> *build_ghost_gsl(); MyList<Parallel::gridseg> *build_ghost_gsl();
MyList<Parallel::gridseg> *build_owned_gsl0(int rank_in); MyList<Parallel::gridseg> *build_owned_gsl0(int rank_in);
}; };
class xp_patch : public ss_patch class xp_patch : public ss_patch
{ {
public: public:
xp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 2; }; xp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 2; };
void setupcordtrans(); void setupcordtrans();
}; };
class xm_patch : public ss_patch class xm_patch : public ss_patch
{ {
public: public:
xm_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 3; }; xm_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 3; };
void setupcordtrans(); void setupcordtrans();
}; };
class yp_patch : public ss_patch class yp_patch : public ss_patch
{ {
public: public:
yp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 4; }; yp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 4; };
void setupcordtrans(); void setupcordtrans();
}; };
class ym_patch : public ss_patch class ym_patch : public ss_patch
{ {
public: public:
ym_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 5; }; ym_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 5; };
void setupcordtrans(); void setupcordtrans();
}; };
class zp_patch : public ss_patch class zp_patch : public ss_patch
{ {
public: public:
zp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 0; }; zp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 0; };
void setupcordtrans(); void setupcordtrans();
}; };
class zm_patch : public ss_patch class zm_patch : public ss_patch
{ {
public: public:
zm_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; }; zm_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
void setupcordtrans(); void setupcordtrans();
}; };
// Shell Patch system // Shell Patch system
// for derivatives usage we ask 27 more double type grid functions // for derivatives usage we ask 27 more double type grid functions
// here we use **sngfs corresponding to fngfs to store them: // here we use **sngfs corresponding to fngfs to store them:
// drho/dx, drho/dy, drho/dz // drho/dx, drho/dy, drho/dz
// dsigma/dx, dsigma/dy, dsigma/dz // dsigma/dx, dsigma/dy, dsigma/dz
// dR/dx, dR/dy, dR/dz // dR/dx, dR/dy, dR/dz
// drho/dxdx, drho/dxdy, drho/dxdz, drho/dydy, drho/dydz, drho/dzdz // drho/dxdx, drho/dxdy, drho/dxdz, drho/dydy, drho/dydz, drho/dzdz
// dsigma/dxdx, dsigma/dxdy, dsigma/dxdz, dsigma/dydy, dsigma/dydz, dsigma/dzdz // dsigma/dxdx, dsigma/dxdy, dsigma/dxdz, dsigma/dydy, dsigma/dydz, dsigma/dzdz
// dR/dxdx, dR/dxdy, dR/dxdz, dR/dydy, dR/dydz, dR/dzdz // dR/dxdx, dR/dxdy, dR/dxdz, dR/dydy, dR/dydz, dR/dzdz
class ShellPatch class ShellPatch
{ {
public: public:
struct pointstru struct pointstru
{ {
double gpox[dim]; // global cordinate double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate double lpox[dim]; // local cordinate
Block *Bg; Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef; double *coef;
int *sind; int *sind;
int dumyd; // the dimension which has common lines, only useful in interdata_packer int dumyd; // the dimension which has common lines, only useful in interdata_packer
//-1: means no dumy dimension at all; 0: means rho; 1: means sigma //-1: means no dumy dimension at all; 0: means rho; 1: means sigma
}; };
int myrank; // Thread-safe search result (no pointers to shared mutable state)
int shape[dim]; // for (rho, sigma, R), for rho and sigma means number of points for every pi/2 struct PointSearchResult
double Rrange[2]; // for Rmin and Rmax {
int Symmetry; bool found;
int ingfs, fngfs; Block *Bg;
double gx, gy, gz; // global Cartesian coordinates
MyList<ss_patch> *PatL; double lx, ly, lz; // local coordinates within the found block
int ssst; // source shell-patch type (-1 = Cartesian)
// we use fngfs+v to reference the variable };
enum
{ int myrank;
gx = 0, int shape[dim]; // for (rho, sigma, R), for rho and sigma means number of points for every pi/2
gy, double Rrange[2]; // for Rmin and Rmax
gz, int Symmetry;
drhodx, int ingfs, fngfs;
drhody,
drhodz, MyList<ss_patch> *PatL;
dsigmadx,
dsigmady, // we use fngfs+v to reference the variable
dsigmadz, enum
dRdx, {
dRdy, gx = 0,
dRdz, gy,
drhodxx, gz,
drhodxy, drhodx,
drhodxz, drhody,
drhodyy, drhodz,
drhodyz, dsigmadx,
drhodzz, dsigmady,
dsigmadxx, dsigmadz,
dsigmadxy, dRdx,
dsigmadxz, dRdy,
dsigmadyy, dRdz,
dsigmadyz, drhodxx,
dsigmadzz, drhodxy,
dRdxx, drhodxz,
dRdxy, drhodyy,
dRdxz, drhodyz,
dRdyy, drhodzz,
dRdyz, dsigmadxx,
dRdzz dsigmadxy,
}; dsigmadxz,
dsigmadyy,
MyList<pointstru> **ss_src, **ss_dst; dsigmadyz,
// at means target dsigmadzz,
MyList<pointstru> **csatc_src, **csatc_dst; dRdxx,
MyList<pointstru> **csats_src, **csats_dst; dRdxy,
dRdxz,
public: dRdyy,
ShellPatch(int ingfsi, int fngfsi, char *filename, int Symmetry, int myranki, monitor *ErrorMonitor); dRdyz,
dRdzz
~ShellPatch(); };
MyList<Block> *compose_sh(int cpusize, int nodes = 0); MyList<pointstru> **ss_src, **ss_dst;
MyList<Block> *compose_shr(int cpusize, int nodes = 0); // at means target
void setupcordtrans(); MyList<pointstru> **csatc_src, **csatc_dst;
double getR(double r); MyList<pointstru> **csats_src, **csats_dst;
double getsr(double R);
void checkPatch(); public:
void checkBlock(int sst); ShellPatch(int ingfsi, int fngfsi, char *filename, int Symmetry, int myranki, monitor *ErrorMonitor);
void check_pointstrul(MyList<pointstru> *pp, bool first_only);
void check_pointstrul2(MyList<pointstru> *pp, int first_last_only); ~ShellPatch();
double getdX(int dir); //(rho, sigma, R)
void Dump_xyz(char *tag, double time, double dT); MyList<Block> *compose_sh(int cpusize, int nodes = 0);
void Dump_Data(MyList<var> *DumpList, char *tag, double time, double dT); MyList<Block> *compose_shr(int cpusize, int nodes = 0);
double *Collect_Data(ss_patch *PP, var *VP); void setupcordtrans();
void getlocalpoxsst(double gx, double gy, double gz, int sst, double &lx, double &ly, double &lz); double getR(double r);
void getlocalpox(double gx, double gy, double gz, int &sst, double &lx, double &ly, double &lz); double getsr(double R);
void getglobalpox(double &x, double &y, double &z, int sst, double lx, double ly, double lz); void checkPatch();
void prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPp, double DH[dim], void checkBlock(int sst);
MyList<Patch> *Pp, double CDH[dim], MyList<pointstru> *pss); void check_pointstrul(MyList<pointstru> *pp, bool first_only);
bool prolongpointstru(MyList<pointstru> *&psul, bool ssyn, int tsst, MyList<ss_patch> *sPp, double DH[dim], void check_pointstrul2(MyList<pointstru> *pp, int first_last_only);
MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in); double getdX(int dir); //(rho, sigma, R)
void setupintintstuff(int cpusize, MyList<Patch> *CPatL, int Symmetry); void Dump_xyz(char *tag, double time, double dT);
void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst, void Dump_Data(MyList<var> *DumpList, char *tag, double time, double dT);
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */, double *Collect_Data(ss_patch *PP, var *VP);
int Symmetry); void getlocalpoxsst(double gx, double gy, double gz, int sst, double &lx, double &ly, double &lz);
int interdata_packer(double *data, MyList<pointstru> *src, MyList<pointstru> *dst, void getlocalpox(double gx, double gy, double gz, int &sst, double &lx, double &ly, double &lz);
int rank_in, int dir, void getglobalpox(double &x, double &y, double &z, int sst, double lx, double ly, double lz);
MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */, void prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPp, double DH[dim],
int Symmetry); MyList<Patch> *Pp, double CDH[dim], MyList<pointstru> *pss);
void Synch(MyList<var> *VarList, int Symmetry); bool prolongpointstru(MyList<pointstru> *&psul, bool ssyn, int tsst, MyList<ss_patch> *sPp, double DH[dim],
void CS_Inter(MyList<var> *VarList, int Symmetry); MyList<Patch> *Pp, double CDH[dim], double x, double y, double z, int Symmetry, int rank_in);
void destroypsuList(MyList<pointstru> *ct); // Read-only point search — thread-safe (no shared mutable state modified)
int getdumydimension(int acsst, int posst); // -1 means no dumy dimension PointSearchResult prolongpointstru_search(bool ssyn, int tsst, MyList<ss_patch> *sPp, double DH[dim],
void matchcheck(MyList<Patch> *CPatL); MyList<Patch> *Pp, double CDH[dim], double x, double y, double z,
void shellname(char *sn, int i); int Symmetry, int rank_in);
void Interp_Points(MyList<var> *VarList, // Append a search result to a linked list — use inside omp critical section
int NN, double **XX, /*input global Cartesian coordinate*/ void prolongpointstru_append(MyList<pointstru> *&psul, const PointSearchResult &sr, int tsst);
double *Shellf, int Symmetry); void setupintintstuff(int cpusize, MyList<Patch> *CPatL, int Symmetry);
bool Interp_One_Point(MyList<var> *VarList, void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst,
double *XX, /*input global Cartesian coordinate*/ MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
double *Shellf, int Symmetry); int Symmetry);
void write_Pablo_file_ss(int *ext, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, int interdata_packer(double *data, MyList<pointstru> *src, MyList<pointstru> *dst,
char *filename, int sst); int rank_in, int dir,
double L2Norm(var *vf); MyList<var> *VarLists /* source */, MyList<var> *VarListd /* target */,
void L2Norm7(var **vf, double *norms); int Symmetry);
void Find_Maximum(MyList<var> *VarList, double *XX, double *Shellf); void Synch(MyList<var> *VarList, int Symmetry);
}; void CS_Inter(MyList<var> *VarList, int Symmetry);
void destroypsuList(MyList<pointstru> *ct);
#endif /* SHELLPATCH_H */ int getdumydimension(int acsst, int posst); // -1 means no dumy dimension
void matchcheck(MyList<Patch> *CPatL);
void shellname(char *sn, int i);
void Interp_Points(MyList<var> *VarList,
int NN, double **XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry);
bool Interp_One_Point(MyList<var> *VarList,
double *XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry);
void write_Pablo_file_ss(int *ext, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax,
char *filename, int sst);
double L2Norm(var *vf);
void L2Norm7(var **vf, double *norms);
void Find_Maximum(MyList<var> *VarList, double *XX, double *Shellf);
};
#endif /* SHELLPATCH_H */

View File

@@ -1,221 +1,221 @@
#ifdef newc #ifdef newc
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <cmath> #include <cmath>
#include <strstream> #include <strstream>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <fstream.h> #include <fstream.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#endif #endif
#include "TwoPunctures.h" #include "TwoPunctures.h"
inline string &lTrim(string &ss) inline string &lTrim(string &ss)
{ {
string::iterator p = find_if(ss.begin(), ss.end(), not1(ptr_fun<int, int>(isspace))); string::iterator p = find_if(ss.begin(), ss.end(), not1(ptr_fun<int, int>(isspace)));
ss.erase(ss.begin(), p); ss.erase(ss.begin(), p);
return ss; return ss;
} }
inline string &rTrim(string &ss) inline string &rTrim(string &ss)
{ {
string::reverse_iterator p = find_if(ss.rbegin(), ss.rend(), not1(ptr_fun<int, int>(isspace))); string::reverse_iterator p = find_if(ss.rbegin(), ss.rend(), not1(ptr_fun<int, int>(isspace)));
ss.erase(p.base(), ss.end()); ss.erase(p.base(), ss.end());
return ss; return ss;
} }
inline string &Trim(string &st) inline string &Trim(string &st)
{ {
lTrim(rTrim(st)); lTrim(rTrim(st));
return st; return st;
} }
int parse_parts(string str, string &sgrp, string &skey, string &sval, int &ind) int parse_parts(string str, string &sgrp, string &skey, string &sval, int &ind)
{ {
int pos1, pos2; int pos1, pos2;
string s0; string s0;
ind = 0; ind = 0;
// remove comments // remove comments
str = str.substr(0, str.find("#")); str = str.substr(0, str.find("#"));
if (rTrim(str).empty()) if (rTrim(str).empty())
return 0; // continue; return 0; // continue;
// parse {group, key, val} // parse {group, key, val}
pos1 = str.find("::"); pos1 = str.find("::");
pos2 = str.find("="); pos2 = str.find("=");
if (pos1 == string::npos || pos2 == string::npos) if (pos1 == string::npos || pos2 == string::npos)
return -1; return -1;
s0 = str.substr(0, pos1); s0 = str.substr(0, pos1);
sgrp = lTrim(s0); sgrp = lTrim(s0);
s0 = str.substr(pos1 + 2, pos2 - pos1 - 2); s0 = str.substr(pos1 + 2, pos2 - pos1 - 2);
skey = rTrim(s0); skey = rTrim(s0);
s0 = str.substr(pos2 + 1); s0 = str.substr(pos2 + 1);
sval = Trim(s0); sval = Trim(s0);
pos1 = sval.find("\""); pos1 = sval.find("\"");
pos2 = sval.rfind("\""); pos2 = sval.rfind("\"");
if (pos1 != string::npos) if (pos1 != string::npos)
{ {
sval = sval.substr(1, pos2 - 1); sval = sval.substr(1, pos2 - 1);
} }
pos1 = skey.find("["); pos1 = skey.find("[");
pos2 = skey.find("]"); pos2 = skey.find("]");
if (pos1 != string::npos) if (pos1 != string::npos)
{ {
s0 = skey.substr(0, pos1); s0 = skey.substr(0, pos1);
ind = atoi(skey.substr(pos1 + 1, pos2 - pos1 - 1).c_str()); ind = atoi(skey.substr(pos1 + 1, pos2 - pos1 - 1).c_str());
skey = s0; skey = s0;
} }
return 1; return 1;
} }
//======================================= //=======================================
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
double mp, mm, b, Mp, Mm, admtol, Newtontol; double mp, mm, b, Mp, Mm, admtol, Newtontol;
int nA, nB, nphi, Newtonmaxit; int nA, nB, nphi, Newtonmaxit;
double P_plusx, P_plusy, P_plusz; double P_plusx, P_plusy, P_plusz;
double P_minusx, P_minusy, P_minusz; double P_minusx, P_minusy, P_minusz;
double S_plusx, S_plusy, S_plusz; double S_plusx, S_plusy, S_plusz;
double S_minusx, S_minusy, S_minusz; double S_minusx, S_minusy, S_minusz;
// read parameter from file // read parameter from file
{ {
const int LEN = 256; const int LEN = 256;
char pline[LEN]; char pline[LEN];
string str, sgrp, skey, sval; string str, sgrp, skey, sval;
int sind; int sind;
const char pname[] = "TwoPunctureinput.par"; const char pname[] = "TwoPunctureinput.par";
ifstream inf(pname, ifstream::in); ifstream inf(pname, ifstream::in);
if (!inf.good()) if (!inf.good())
{ {
cout << "Can not open parameter file " << pname << endl; cout << "Can not open parameter file " << pname << endl;
exit(0); exit(0);
} }
for (int i = 1; inf.good(); i++) for (int i = 1; inf.good(); i++)
{ {
inf.getline(pline, LEN); inf.getline(pline, LEN);
str = pline; str = pline;
int status = parse_parts(str, sgrp, skey, sval, sind); int status = parse_parts(str, sgrp, skey, sval, sind);
if (status == -1) if (status == -1)
{ {
cout << "error reading parameter file " << pname << " in line " << i << endl; cout << "error reading parameter file " << pname << " in line " << i << endl;
exit(0); exit(0);
} }
else if (status == 0) else if (status == 0)
continue; continue;
// we assume input in Brugmann's convention // we assume input in Brugmann's convention
if (sgrp == "ABE") if (sgrp == "ABE")
{ {
if (skey == "mm") if (skey == "mm")
mm = atof(sval.c_str()); mm = atof(sval.c_str());
else if (skey == "mp") else if (skey == "mp")
mp = atof(sval.c_str()); mp = atof(sval.c_str());
else if (skey == "b") else if (skey == "b")
b = atof(sval.c_str()); b = atof(sval.c_str());
else if (skey == "P_plusx") else if (skey == "P_plusx")
P_plusy = -atof(sval.c_str()); P_plusy = -atof(sval.c_str());
else if (skey == "P_plusy") else if (skey == "P_plusy")
P_plusx = atof(sval.c_str()); P_plusx = atof(sval.c_str());
else if (skey == "P_plusz") else if (skey == "P_plusz")
P_plusz = atof(sval.c_str()); P_plusz = atof(sval.c_str());
else if (skey == "P_minusx") else if (skey == "P_minusx")
P_minusy = -atof(sval.c_str()); P_minusy = -atof(sval.c_str());
else if (skey == "P_minusy") else if (skey == "P_minusy")
P_minusx = atof(sval.c_str()); P_minusx = atof(sval.c_str());
else if (skey == "P_minusz") else if (skey == "P_minusz")
P_minusz = atof(sval.c_str()); P_minusz = atof(sval.c_str());
else if (skey == "S_plusx") else if (skey == "S_plusx")
S_plusy = -atof(sval.c_str()); S_plusy = -atof(sval.c_str());
else if (skey == "S_plusy") else if (skey == "S_plusy")
S_plusx = atof(sval.c_str()); S_plusx = atof(sval.c_str());
else if (skey == "S_plusz") else if (skey == "S_plusz")
S_plusz = atof(sval.c_str()); S_plusz = atof(sval.c_str());
else if (skey == "S_minusx") else if (skey == "S_minusx")
S_minusy = -atof(sval.c_str()); S_minusy = -atof(sval.c_str());
else if (skey == "S_minusy") else if (skey == "S_minusy")
S_minusx = atof(sval.c_str()); S_minusx = atof(sval.c_str());
else if (skey == "S_minusz") else if (skey == "S_minusz")
S_minusz = atof(sval.c_str()); S_minusz = atof(sval.c_str());
else if (skey == "Mp") else if (skey == "Mp")
Mp = atof(sval.c_str()); Mp = atof(sval.c_str());
else if (skey == "Mm") else if (skey == "Mm")
Mm = atof(sval.c_str()); Mm = atof(sval.c_str());
else if (skey == "admtol") else if (skey == "admtol")
admtol = atof(sval.c_str()); admtol = atof(sval.c_str());
else if (skey == "Newtontol") else if (skey == "Newtontol")
Newtontol = atof(sval.c_str()); Newtontol = atof(sval.c_str());
else if (skey == "nA") else if (skey == "nA")
nA = atoi(sval.c_str()); nA = atoi(sval.c_str());
else if (skey == "nB") else if (skey == "nB")
nB = atoi(sval.c_str()); nB = atoi(sval.c_str());
else if (skey == "nphi") else if (skey == "nphi")
nphi = atoi(sval.c_str()); nphi = atoi(sval.c_str());
else if (skey == "Newtonmaxit") else if (skey == "Newtonmaxit")
Newtonmaxit = atoi(sval.c_str()); Newtonmaxit = atoi(sval.c_str());
} }
} }
inf.close(); inf.close();
} }
// echo parameters // echo parameters
{ {
cout << "///////////////////////////////////////////////////////////////" << endl; cout << "///////////////////////////////////////////////////////////////" << endl;
cout << " mp = " << mp << endl; cout << " mp = " << mp << endl;
cout << " mm = " << mm << endl; cout << " mm = " << mm << endl;
cout << " b = " << b << endl; cout << " b = " << b << endl;
cout << " P_plusx = " << P_plusx << endl; cout << " P_plusx = " << P_plusx << endl;
cout << " P_plusy = " << P_plusy << endl; cout << " P_plusy = " << P_plusy << endl;
cout << " P_plusz = " << P_plusz << endl; cout << " P_plusz = " << P_plusz << endl;
cout << " P_minusx = " << P_minusx << endl; cout << " P_minusx = " << P_minusx << endl;
cout << " P_minusy = " << P_minusy << endl; cout << " P_minusy = " << P_minusy << endl;
cout << " P_minusz = " << P_minusz << endl; cout << " P_minusz = " << P_minusz << endl;
cout << " S_plusx = " << S_plusx << endl; cout << " S_plusx = " << S_plusx << endl;
cout << " S_plusy = " << S_plusy << endl; cout << " S_plusy = " << S_plusy << endl;
cout << " S_plusz = " << S_plusz << endl; cout << " S_plusz = " << S_plusz << endl;
cout << " S_minusx = " << S_minusx << endl; cout << " S_minusx = " << S_minusx << endl;
cout << " S_minusy = " << S_minusy << endl; cout << " S_minusy = " << S_minusy << endl;
cout << " S_minusz = " << S_minusz << endl; cout << " S_minusz = " << S_minusz << endl;
cout << " Mp = " << Mp << endl; cout << " Mp = " << Mp << endl;
cout << " Mm = " << Mm << endl; cout << " Mm = " << Mm << endl;
cout << " admtol = " << admtol << endl; cout << " admtol = " << admtol << endl;
cout << " Newtontol = " << Newtontol << endl; cout << " Newtontol = " << Newtontol << endl;
cout << " nA = " << nA << endl; cout << " nA = " << nA << endl;
cout << " nB = " << nB << endl; cout << " nB = " << nB << endl;
cout << " nphi = " << nphi << endl; cout << " nphi = " << nphi << endl;
cout << "Newtonmaxit = " << Newtonmaxit << endl; cout << "Newtonmaxit = " << Newtonmaxit << endl;
cout << "///////////////////////////////////////////////////////////////" << endl; cout << "///////////////////////////////////////////////////////////////" << endl;
} }
//===========================the computation body==================================================== //===========================the computation body====================================================
TwoPunctures *ADM; TwoPunctures *ADM;
ADM = new TwoPunctures(mp, mm, b, P_plusx, P_plusy, P_plusz, S_plusx, S_plusy, S_plusz, ADM = new TwoPunctures(mp, mm, b, P_plusx, P_plusy, P_plusz, S_plusx, S_plusy, S_plusz,
P_minusx, P_minusy, P_minusz, S_minusx, S_minusy, S_minusz, P_minusx, P_minusy, P_minusz, S_minusx, S_minusy, S_minusz,
nA, nB, nphi, Mp, Mm, admtol, Newtontol, Newtonmaxit); nA, nB, nphi, Mp, Mm, admtol, Newtontol, Newtonmaxit);
ADM->Solve(); ADM->Solve();
ADM->Save("Ansorg.psid"); ADM->Save("Ansorg.psid");
delete ADM; delete ADM;
//=======================caculation done============================================================= //=======================caculation done=============================================================
cout << "===============================================================" << endl; cout << "===============================================================" << endl;
cout << "Initial data is successfully producede!!" << endl; cout << "Initial data is successfully producede!!" << endl;
exit(0); exit(0);
} }

View File

@@ -1,167 +1,167 @@
#ifndef TWO_PUNCTURES_H #ifndef TWO_PUNCTURES_H
#define TWO_PUNCTURES_H #define TWO_PUNCTURES_H
#include <omp.h> #include <omp.h>
#define StencilSize 19 #define StencilSize 19
#define N_PlaneRelax 1 #define N_PlaneRelax 1
#define NRELAX 200 #define NRELAX 200
#define Step_Relax 1 #define Step_Relax 1
#define Pi 3.14159265358979323846264338328 #define Pi 3.14159265358979323846264338328
#define Pih 1.57079632679489661923132169164 /* Pi/2*/ #define Pih 1.57079632679489661923132169164 /* Pi/2*/
#define Piq 0.78539816339744830961566084582 /* Pi/4*/ #define Piq 0.78539816339744830961566084582 /* Pi/4*/
#define TINY 1.0e-20 #define TINY 1.0e-20
class TwoPunctures class TwoPunctures
{ {
public: public:
typedef struct DERIVS typedef struct DERIVS
{ {
double *d0, *d1, *d2, *d3, *d11, *d12, *d13, *d22, *d23, *d33; double *d0, *d1, *d2, *d3, *d11, *d12, *d13, *d22, *d23, *d33;
} derivs; } derivs;
double *F; double *F;
derivs u, v; derivs u, v;
private: private:
double par_m_plus, par_m_minus, par_b; double par_m_plus, par_m_minus, par_b;
double par_P_plus[3], par_P_minus[3]; double par_P_plus[3], par_P_minus[3];
double par_S_plus[3], par_S_minus[3]; double par_S_plus[3], par_S_minus[3];
int npoints_A, npoints_B, npoints_phi; int npoints_A, npoints_B, npoints_phi;
double target_M_plus, target_M_minus; double target_M_plus, target_M_minus;
double admMass; double admMass;
double adm_tol; double adm_tol;
double Newton_tol; double Newton_tol;
int Newton_maxit; int Newton_maxit;
int ntotal; int ntotal;
// ===== Precomputed spectral derivative matrices ===== // ===== Precomputed spectral derivative matrices =====
double *D1_A, *D2_A; double *D1_A, *D2_A;
double *D1_B, *D2_B; double *D1_B, *D2_B;
double *DF1_phi, *DF2_phi; double *DF1_phi, *DF2_phi;
// ===== Pre-allocated workspace for LineRelax (per-thread) ===== // ===== Pre-allocated workspace for LineRelax (per-thread) =====
int max_threads; int max_threads;
double **ws_diag_be, **ws_e_be, **ws_f_be, **ws_b_be, **ws_x_be; double **ws_diag_be, **ws_e_be, **ws_f_be, **ws_b_be, **ws_x_be;
double **ws_l_be, **ws_u_be, **ws_d_be, **ws_y_be; double **ws_l_be, **ws_u_be, **ws_d_be, **ws_y_be;
double **ws_diag_al, **ws_e_al, **ws_f_al, **ws_b_al, **ws_x_al; double **ws_diag_al, **ws_e_al, **ws_f_al, **ws_b_al, **ws_x_al;
double **ws_l_al, **ws_u_al, **ws_d_al, **ws_y_al; double **ws_l_al, **ws_u_al, **ws_d_al, **ws_y_al;
struct parameters struct parameters
{ {
int nvar, n1, n2, n3; int nvar, n1, n2, n3;
double b; double b;
}; };
public: public:
TwoPunctures(double mp, double mm, double b, double P_plusx, double P_plusy, double P_plusz, TwoPunctures(double mp, double mm, double b, double P_plusx, double P_plusy, double P_plusz,
double S_plusx, double S_plusy, double S_plusz, double S_plusx, double S_plusy, double S_plusz,
double P_minusx, double P_minusy, double P_minusz, double P_minusx, double P_minusy, double P_minusz,
double S_minusx, double S_minusy, double S_minusz, double S_minusx, double S_minusy, double S_minusz,
int nA, int nB, int nphi, int nA, int nB, int nphi,
double Mp, double Mm, double admtol, double Newtontol, double Mp, double Mm, double admtol, double Newtontol,
int Newtonmaxit); int Newtonmaxit);
~TwoPunctures(); ~TwoPunctures();
// 02/07: New/modified methods // 02/07: New/modified methods
void allocate_workspace(); void allocate_workspace();
void free_workspace(); void free_workspace();
void precompute_derivative_matrices(); void precompute_derivative_matrices();
void build_cheb_deriv_matrices(int n, double *D1, double *D2); void build_cheb_deriv_matrices(int n, double *D1, double *D2);
void build_fourier_deriv_matrices(int N, double *DF1, double *DF2); void build_fourier_deriv_matrices(int N, double *DF1, double *DF2);
void Derivatives_AB3_MatMul(int nvar, int n1, int n2, int n3, derivs v); void Derivatives_AB3_MatMul(int nvar, int n1, int n2, int n3, derivs v);
void ThomasAlgorithm_ws(int N, double *b, double *a, double *c, double *x, double *q, void ThomasAlgorithm_ws(int N, double *b, double *a, double *c, double *x, double *q,
double *l, double *u_ws, double *d, double *y); double *l, double *u_ws, double *d, double *y);
void LineRelax_be_omp(double *dv, void LineRelax_be_omp(double *dv,
int const i, int const k, int const nvar, int const i, int const k, int const nvar,
int const n1, int const n2, int const n3, int const n1, int const n2, int const n3,
double const *rhs, int const *ncols, int **cols, double const *rhs, int const *ncols, int **cols,
double **JFD, int tid); double **JFD, int tid);
void LineRelax_al_omp(double *dv, void LineRelax_al_omp(double *dv,
int const j, int const k, int const nvar, int const j, int const k, int const nvar,
int const n1, int const n2, int const n3, int const n1, int const n2, int const n3,
double const *rhs, int const *ncols, double const *rhs, int const *ncols,
int **cols, double **JFD, int tid); int **cols, double **JFD, int tid);
void relax_omp(double *dv, int const nvar, int const n1, int const n2, int const n3, void relax_omp(double *dv, int const nvar, int const n1, int const n2, int const n3,
double const *rhs, int const *ncols, int **cols, double **JFD); double const *rhs, int const *ncols, int **cols, double **JFD);
void Solve(); void Solve();
void set_initial_guess(derivs v); void set_initial_guess(derivs v);
int index(int i, int j, int k, int l, int a, int b, int c, int d); int index(int i, int j, int k, int l, int a, int b, int c, int d);
int *ivector(long nl, long nh); int *ivector(long nl, long nh);
double *dvector(long nl, long nh); double *dvector(long nl, long nh);
int **imatrix(long nrl, long nrh, long ncl, long nch); int **imatrix(long nrl, long nrh, long ncl, long nch);
double **dmatrix(long nrl, long nrh, long ncl, long nch); double **dmatrix(long nrl, long nrh, long ncl, long nch);
double ***d3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh); double ***d3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
void free_ivector(int *v, long nl, long nh); void free_ivector(int *v, long nl, long nh);
void free_dvector(double *v, long nl, long nh); void free_dvector(double *v, long nl, long nh);
void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch); void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch); void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
void free_d3tensor(double ***t, long nrl, long nrh, long ncl, long nch, void free_d3tensor(double ***t, long nrl, long nrh, long ncl, long nch,
long ndl, long ndh); long ndl, long ndh);
int minimum2(int i, int j); int minimum2(int i, int j);
int minimum3(int i, int j, int k); int minimum3(int i, int j, int k);
int maximum2(int i, int j); int maximum2(int i, int j);
int maximum3(int i, int j, int k); int maximum3(int i, int j, int k);
int pow_int(int mantisse, int exponent); int pow_int(int mantisse, int exponent);
void chebft_Zeros(double u[], int n, int inv); void chebft_Zeros(double u[], int n, int inv);
void chebft_Extremes(double u[], int n, int inv); void chebft_Extremes(double u[], int n, int inv);
void chder(double *c, double *cder, int n); void chder(double *c, double *cder, int n);
double chebev(double a, double b, double c[], int m, double x); double chebev(double a, double b, double c[], int m, double x);
void fourft(double *u, int N, int inv); void fourft(double *u, int N, int inv);
void fourder(double u[], double du[], int N); void fourder(double u[], double du[], int N);
void fourder2(double u[], double d2u[], int N); void fourder2(double u[], double d2u[], int N);
double fourev(double *u, int N, double x); double fourev(double *u, int N, double x);
double norm1(double *v, int n); double norm1(double *v, int n);
double norm2(double *v, int n); double norm2(double *v, int n);
double scalarproduct(double *v, double *w, int n); double scalarproduct(double *v, double *w, int n);
double PunctIntPolAtArbitPosition(int ivar, int nvar, int n1, double PunctIntPolAtArbitPosition(int ivar, int nvar, int n1,
int n2, int n3, derivs v, double x, double y, int n2, int n3, derivs v, double x, double y,
double z); double z);
double PunctEvalAtArbitPosition(double *v, int ivar, double A, double B, double phi, double PunctEvalAtArbitPosition(double *v, int ivar, double A, double B, double phi,
int nvar, int n1, int n2, int n3); int nvar, int n1, int n2, int n3);
void AB_To_XR(int nvar, double A, double B, double *X, double *R, void AB_To_XR(int nvar, double A, double B, double *X, double *R,
derivs U); derivs U);
void C_To_c(int nvar, double X, double R, double *x, double *r, void C_To_c(int nvar, double X, double R, double *x, double *r,
derivs U); derivs U);
void rx3_To_xyz(int nvar, double x, double r, double phi, void rx3_To_xyz(int nvar, double x, double r, double phi,
double *y, double *z, derivs U); double *y, double *z, derivs U);
void Derivatives_AB3(int nvar, int n1, int n2, int n3, derivs v); void Derivatives_AB3(int nvar, int n1, int n2, int n3, derivs v);
void Newton(int const nvar, int const n1, int const n2, int const n3, void Newton(int const nvar, int const n1, int const n2, int const n3,
derivs v, double const tol, int const itmax); derivs v, double const tol, int const itmax);
void F_of_v(int nvar, int n1, int n2, int n3, derivs v, double *F, void F_of_v(int nvar, int n1, int n2, int n3, derivs v, double *F,
derivs u); derivs u);
double norm_inf(double const *F, int const ntotal); double norm_inf(double const *F, int const ntotal);
int bicgstab(int const nvar, int const n1, int const n2, int const n3, int bicgstab(int const nvar, int const n1, int const n2, int const n3,
derivs v, derivs dv, int const itmax, double const tol, derivs v, derivs dv, int const itmax, double const tol,
double *normres); double *normres);
void allocate_derivs(derivs *v, int n); void allocate_derivs(derivs *v, int n);
void free_derivs(derivs *v, int n); void free_derivs(derivs *v, int n);
int Index(int ivar, int i, int j, int k, int nvar, int n1, int n2, int n3); int Index(int ivar, int i, int j, int k, int nvar, int n1, int n2, int n3);
void NonLinEquations(double rho_adm, double A, double B, double X, double R, double x, double r, double phi, void NonLinEquations(double rho_adm, double A, double B, double X, double R, double x, double r, double phi,
double y, double z, derivs U, double *values); double y, double z, derivs U, double *values);
double BY_KKofxyz(double x, double y, double z); double BY_KKofxyz(double x, double y, double z);
void SetMatrix_JFD(int nvar, int n1, int n2, int n3, derivs u, int *ncols, int **cols, double **Matrix); void SetMatrix_JFD(int nvar, int n1, int n2, int n3, derivs u, int *ncols, int **cols, double **Matrix);
void J_times_dv(int nvar, int n1, int n2, int n3, derivs dv, double *Jdv, derivs u); void J_times_dv(int nvar, int n1, int n2, int n3, derivs dv, double *Jdv, derivs u);
void JFD_times_dv(int i, int j, int k, int nvar, int n1, int n2, void JFD_times_dv(int i, int j, int k, int nvar, int n1, int n2,
int n3, derivs dv, derivs u, double *values); int n3, derivs dv, derivs u, double *values);
void LinEquations(double A, double B, double X, double R, void LinEquations(double A, double B, double X, double R,
double x, double r, double phi, double x, double r, double phi,
double y, double z, derivs dU, derivs U, double *values); double y, double z, derivs dU, derivs U, double *values);
void ThomasAlgorithm(int N, double *b, double *a, double *c, double *x, double *q); void ThomasAlgorithm(int N, double *b, double *a, double *c, double *x, double *q);
void Save(char *fname); void Save(char *fname);
// provided by Vasileios Paschalidis (vpaschal@illinois.edu) // provided by Vasileios Paschalidis (vpaschal@illinois.edu)
double Spec_IntPolABphiFast(parameters par, double *v, int ivar, double A, double B, double phi); double Spec_IntPolABphiFast(parameters par, double *v, int ivar, double A, double B, double phi);
double Spec_IntPolFast(parameters par, int ivar, double *v, double x, double y, double z); double Spec_IntPolFast(parameters par, int ivar, double *v, double x, double y, double z);
void SpecCoef(parameters par, int ivar, double *v, double *cf); void SpecCoef(parameters par, int ivar, double *v, double *cf);
}; };
#endif /* TWO_PUNCTURES_H */ #endif /* TWO_PUNCTURES_H */

View File

@@ -1,64 +1,64 @@
#ifndef Z4c_CLASS_H #ifndef Z4c_CLASS_H
#define Z4c_CLASS_H #define Z4c_CLASS_H
#ifdef newc #ifdef newc
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <cmath> #include <cmath>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <fstream.h> #include <fstream.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#endif #endif
#include <mpi.h> #include <mpi.h>
#include "cgh.h" #include "cgh.h"
#include "ShellPatch.h" #include "ShellPatch.h"
#include "misc.h" #include "misc.h"
#include "var.h" #include "var.h"
#include "MyList.h" #include "MyList.h"
#include "monitor.h" #include "monitor.h"
#include "surface_integral.h" #include "surface_integral.h"
#include "macrodef.h" #include "macrodef.h"
#ifdef USE_GPU #ifdef USE_GPU
#include "bssn_gpu_class.h" #include "bssn_gpu_class.h"
#else #else
#include "bssn_class.h" #include "bssn_class.h"
#endif #endif
class Z4c_class : public bssn_class class Z4c_class : public bssn_class
{ {
public: public:
Z4c_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei, Z4c_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei,
int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi, int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi,
int a_levi, int maxli, int decni, double maxrexi, double drexi); int a_levi, int maxli, int decni, double maxrexi, double drexi);
~Z4c_class(); ~Z4c_class();
void Initialize(); void Initialize();
void Check_extrop(); void Check_extrop();
// Since we have set zero to variables at very begining // Since we have set zero to variables at very begining
// we can neglect TZ for initial data setting // we can neglect TZ for initial data setting
void Step(int lev, int YN); void Step(int lev, int YN);
void Interp_Constraint(); void Interp_Constraint();
void Constraint_Out(); void Constraint_Out();
void Compute_Constraint(); void Compute_Constraint();
protected: protected:
var *TZo; var *TZo;
var *TZ0; var *TZ0;
var *TZ; var *TZ;
var *TZ1; var *TZ1;
var *TZ_rhs; var *TZ_rhs;
}; };
#endif /* Z4c_CLASS_H */ #endif /* Z4c_CLASS_H */

View File

@@ -1,382 +1,382 @@
!-------------------------------------------------------------------------------! !-------------------------------------------------------------------------------!
! computed constraint for ADM formalism ! ! computed constraint for ADM formalism !
!-------------------------------------------------------------------------------! !-------------------------------------------------------------------------------!
subroutine constraint_adm(ex, X, Y, Z,& subroutine constraint_adm(ex, X, Y, Z,&
dxx,gxy,gxz,dyy,gyz,dzz, & dxx,gxy,gxz,dyy,gyz,dzz, &
Kxx,Kxy,Kxz,Kyy,Kyz,Kzz, & Kxx,Kxy,Kxz,Kyy,Kyz,Kzz, &
Lap,Sfx,Sfy,Sfz,rho,Sx,Sy,Sz,& Lap,Sfx,Sfy,Sfz,rho,Sx,Sy,Sz,&
ham_Res, movx_Res, movy_Res, movz_Res, & ham_Res, movx_Res, movy_Res, movz_Res, &
Symmetry) Symmetry)
implicit none implicit none
!~~~~~~> Input parameters: !~~~~~~> Input parameters:
integer,intent(in ):: ex(1:3),symmetry integer,intent(in ):: ex(1:3),symmetry
real*8, intent(in ):: X(1:ex(1)),Y(1:ex(2)),Z(1:ex(3)) real*8, intent(in ):: X(1:ex(1)),Y(1:ex(2)),Z(1:ex(3))
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: dxx,gxy,gxz,dyy,gyz,dzz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: dxx,gxy,gxz,dyy,gyz,dzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Kxx,Kxy,Kxz,Kyy,Kyz,Kzz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Kxx,Kxy,Kxz,Kyy,Kyz,Kzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Lap,Sfx,Sfy,Sfz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Lap,Sfx,Sfy,Sfz
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: rho,Sx,Sy,Sz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: rho,Sx,Sy,Sz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: ham_Res, movx_Res, movy_Res, movz_Res real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: ham_Res, movx_Res, movy_Res, movz_Res
!~~~~~~> Other variables: !~~~~~~> Other variables:
! inverse metric ! inverse metric
real*8, dimension(ex(1),ex(2),ex(3)) :: gupxx,gupxy,gupxz real*8, dimension(ex(1),ex(2),ex(3)) :: gupxx,gupxy,gupxz
real*8, dimension(ex(1),ex(2),ex(3)) :: gupyy,gupyz,gupzz real*8, dimension(ex(1),ex(2),ex(3)) :: gupyy,gupyz,gupzz
! first order derivative of metric, @_k g_ij ! first order derivative of metric, @_k g_ij
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxx,gxyx,gxzx real*8, dimension(ex(1),ex(2),ex(3)) :: gxxx,gxyx,gxzx
real*8, dimension(ex(1),ex(2),ex(3)) :: gyyx,gyzx,gzzx real*8, dimension(ex(1),ex(2),ex(3)) :: gyyx,gyzx,gzzx
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxy,gxyy,gxzy real*8, dimension(ex(1),ex(2),ex(3)) :: gxxy,gxyy,gxzy
real*8, dimension(ex(1),ex(2),ex(3)) :: gyyy,gyzy,gzzy real*8, dimension(ex(1),ex(2),ex(3)) :: gyyy,gyzy,gzzy
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxz,gxyz,gxzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxxz,gxyz,gxzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gyyz,gyzz,gzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gyyz,gyzz,gzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz,trK,fx,fy,fz real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz,trK,fx,fy,fz
real*8, dimension(ex(1),ex(2),ex(3)) :: Rxx,Rxy,Rxz,Ryy,Ryz,Rzz real*8, dimension(ex(1),ex(2),ex(3)) :: Rxx,Rxy,Rxz,Ryy,Ryz,Rzz
real*8, dimension(ex(1),ex(2),ex(3)) :: Gamxxx, Gamxxy, Gamxxz real*8, dimension(ex(1),ex(2),ex(3)) :: Gamxxx, Gamxxy, Gamxxz
real*8, dimension(ex(1),ex(2),ex(3)) :: Gamxyy, Gamxyz, Gamxzz real*8, dimension(ex(1),ex(2),ex(3)) :: Gamxyy, Gamxyz, Gamxzz
real*8, dimension(ex(1),ex(2),ex(3)) :: Gamyxx, Gamyxy, Gamyxz real*8, dimension(ex(1),ex(2),ex(3)) :: Gamyxx, Gamyxy, Gamyxz
real*8, dimension(ex(1),ex(2),ex(3)) :: Gamyyy, Gamyyz, Gamyzz real*8, dimension(ex(1),ex(2),ex(3)) :: Gamyyy, Gamyyz, Gamyzz
real*8, dimension(ex(1),ex(2),ex(3)) :: Gamzxx, Gamzxy, Gamzxz real*8, dimension(ex(1),ex(2),ex(3)) :: Gamzxx, Gamzxy, Gamzxz
real*8, dimension(ex(1),ex(2),ex(3)) :: Gamzyy, Gamzyz, Gamzzz real*8, dimension(ex(1),ex(2),ex(3)) :: Gamzyy, Gamzyz, Gamzzz
integer, parameter :: NO_SYMM = 0, EQUATORIAL = 1, OCTANT = 2 integer, parameter :: NO_SYMM = 0, EQUATORIAL = 1, OCTANT = 2
real*8, parameter :: ZERO = 0.D0, HALF = 0.5d0, ONE = 1.d0, TWO = 2.d0, FOUR = 4.d0 real*8, parameter :: ZERO = 0.D0, HALF = 0.5d0, ONE = 1.d0, TWO = 2.d0, FOUR = 4.d0
real*8, parameter :: F2o3 = 2.d0/3.d0, F8 = 8.d0, F16 = 1.6d1, SIX = 6.d0 real*8, parameter :: F2o3 = 2.d0/3.d0, F8 = 8.d0, F16 = 1.6d1, SIX = 6.d0
real*8, parameter :: SYM = 1.D0, ANTI= - 1.D0 real*8, parameter :: SYM = 1.D0, ANTI= - 1.D0
real*8 :: PI real*8 :: PI
call adm_ricci_gamma(ex, X, Y, Z, & call adm_ricci_gamma(ex, X, Y, Z, &
dxx , gxy , gxz , dyy , gyz , dzz,& dxx , gxy , gxz , dyy , gyz , dzz,&
Gamxxx,Gamxxy,Gamxxz,Gamxyy,Gamxyz,Gamxzz,& Gamxxx,Gamxxy,Gamxxz,Gamxyy,Gamxyz,Gamxzz,&
Gamyxx,Gamyxy,Gamyxz,Gamyyy,Gamyyz,Gamyzz,& Gamyxx,Gamyxy,Gamyxz,Gamyyy,Gamyyz,Gamyzz,&
Gamzxx,Gamzxy,Gamzxz,Gamzyy,Gamzyz,Gamzzz,& Gamzxx,Gamzxy,Gamzxz,Gamzyy,Gamzyz,Gamzzz,&
Rxx,Rxy,Rxz,Ryy,Ryz,Rzz,& Rxx,Rxy,Rxz,Ryy,Ryz,Rzz,&
Symmetry) Symmetry)
PI = dacos(-ONE) PI = dacos(-ONE)
gxx = dxx + ONE gxx = dxx + ONE
gyy = dyy + ONE gyy = dyy + ONE
gzz = dzz + ONE gzz = dzz + ONE
! invert metric ! invert metric
gupzz = gxx * gyy * gzz + gxy * gyz * gxz + gxz * gxy * gyz - & gupzz = gxx * gyy * gzz + gxy * gyz * gxz + gxz * gxy * gyz - &
gxz * gyy * gxz - gxy * gxy * gzz - gxx * gyz * gyz gxz * gyy * gxz - gxy * gxy * gzz - gxx * gyz * gyz
gupxx = ( gyy * gzz - gyz * gyz ) / gupzz gupxx = ( gyy * gzz - gyz * gyz ) / gupzz
gupxy = - ( gxy * gzz - gyz * gxz ) / gupzz gupxy = - ( gxy * gzz - gyz * gxz ) / gupzz
gupxz = ( gxy * gyz - gyy * gxz ) / gupzz gupxz = ( gxy * gyz - gyy * gxz ) / gupzz
gupyy = ( gxx * gzz - gxz * gxz ) / gupzz gupyy = ( gxx * gzz - gxz * gxz ) / gupzz
gupyz = - ( gxx * gyz - gxy * gxz ) / gupzz gupyz = - ( gxx * gyz - gxy * gxz ) / gupzz
gupzz = ( gxx * gyy - gxy * gxy ) / gupzz gupzz = ( gxx * gyy - gxy * gxy ) / gupzz
trK = gupxx * Kxx + gupyy * Kyy + gupzz * Kzz & trK = gupxx * Kxx + gupyy * Kyy + gupzz * Kzz &
+ TWO * (gupxy * Kxy + gupxz * Kxz + gupyz * Kyz) + TWO * (gupxy * Kxy + gupxz * Kxz + gupyz * Kyz)
! ham_Res = trR + K^2 - K_ij * K^ij - 16 * PI * rho ! ham_Res = trR + K^2 - K_ij * K^ij - 16 * PI * rho
ham_Res = gupxx * Rxx + gupyy * Ryy + gupzz * Rzz + & ham_Res = gupxx * Rxx + gupyy * Ryy + gupzz * Rzz + &
TWO* ( gupxy * Rxy + gupxz * Rxz + gupyz * Ryz ) TWO* ( gupxy * Rxy + gupxz * Rxz + gupyz * Ryz )
ham_Res = ham_Res + trK * trK -(& ham_Res = ham_Res + trK * trK -(&
gupxx * ( & gupxx * ( &
gupxx * Kxx * Kxx + gupyy * Kxy * Kxy + gupzz * Kxz * Kxz + & gupxx * Kxx * Kxx + gupyy * Kxy * Kxy + gupzz * Kxz * Kxz + &
TWO * (gupxy * Kxx * Kxy + gupxz * Kxx * Kxz + gupyz * Kxy * Kxz) ) + & TWO * (gupxy * Kxx * Kxy + gupxz * Kxx * Kxz + gupyz * Kxy * Kxz) ) + &
gupyy * ( & gupyy * ( &
gupxx * Kxy * Kxy + gupyy * Kyy * Kyy + gupzz * Kyz * Kyz + & gupxx * Kxy * Kxy + gupyy * Kyy * Kyy + gupzz * Kyz * Kyz + &
TWO * (gupxy * Kxy * Kyy + gupxz * Kxy * Kyz + gupyz * Kyy * Kyz) ) + & TWO * (gupxy * Kxy * Kyy + gupxz * Kxy * Kyz + gupyz * Kyy * Kyz) ) + &
gupzz * ( & gupzz * ( &
gupxx * Kxz * Kxz + gupyy * Kyz * Kyz + gupzz * Kzz * Kzz + & gupxx * Kxz * Kxz + gupyy * Kyz * Kyz + gupzz * Kzz * Kzz + &
TWO * (gupxy * Kxz * Kyz + gupxz * Kxz * Kzz + gupyz * Kyz * Kzz) ) + & TWO * (gupxy * Kxz * Kyz + gupxz * Kxz * Kzz + gupyz * Kyz * Kzz) ) + &
TWO * ( & TWO * ( &
gupxy * ( & gupxy * ( &
gupxx * Kxx * Kxy + gupyy * Kxy * Kyy + gupzz * Kxz * Kyz + & gupxx * Kxx * Kxy + gupyy * Kxy * Kyy + gupzz * Kxz * Kyz + &
gupxy * (Kxx * Kyy + Kxy * Kxy) + & gupxy * (Kxx * Kyy + Kxy * Kxy) + &
gupxz * (Kxx * Kyz + Kxz * Kxy) + & gupxz * (Kxx * Kyz + Kxz * Kxy) + &
gupyz * (Kxy * Kyz + Kxz * Kyy) ) + & gupyz * (Kxy * Kyz + Kxz * Kyy) ) + &
gupxz * ( & gupxz * ( &
gupxx * Kxx * Kxz + gupyy * Kxy * Kyz + gupzz * Kxz * Kzz + & gupxx * Kxx * Kxz + gupyy * Kxy * Kyz + gupzz * Kxz * Kzz + &
gupxy * (Kxx * Kyz + Kxy * Kxz) + & gupxy * (Kxx * Kyz + Kxy * Kxz) + &
gupxz * (Kxx * Kzz + Kxz * Kxz) + & gupxz * (Kxx * Kzz + Kxz * Kxz) + &
gupyz * (Kxy * Kzz + Kxz * Kyz) ) + & gupyz * (Kxy * Kzz + Kxz * Kyz) ) + &
gupyz * ( & gupyz * ( &
gupxx * Kxy * Kxz + gupyy * Kyy * Kyz + gupzz * Kyz * Kzz + & gupxx * Kxy * Kxz + gupyy * Kyy * Kyz + gupzz * Kyz * Kzz + &
gupxy * (Kxy * Kyz + Kyy * Kxz) + & gupxy * (Kxy * Kyz + Kyy * Kxz) + &
gupxz * (Kxy * Kzz + Kyz * Kxz) + & gupxz * (Kxy * Kzz + Kyz * Kxz) + &
gupyz * (Kyy * Kzz + Kyz * Kyz) ) ))- F16 * PI * rho gupyz * (Kyy * Kzz + Kyz * Kyz) ) ))- F16 * PI * rho
! mov_Res_j = gupkj*D_k K_ij - d_j trK - 8 PI s_j where D respect to physical metric ! mov_Res_j = gupkj*D_k K_ij - d_j trK - 8 PI s_j where D respect to physical metric
! store D_i K_jk ! store D_i K_jk
call fderivs(ex,Kxx,gxxx,gxxy,gxxz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0) call fderivs(ex,Kxx,gxxx,gxxy,gxxz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0)
call fderivs(ex,Kxy,gxyx,gxyy,gxyz,X,Y,Z,ANTI,ANTI,SYM ,Symmetry,0) call fderivs(ex,Kxy,gxyx,gxyy,gxyz,X,Y,Z,ANTI,ANTI,SYM ,Symmetry,0)
call fderivs(ex,Kxz,gxzx,gxzy,gxzz,X,Y,Z,ANTI,SYM ,ANTI,Symmetry,0) call fderivs(ex,Kxz,gxzx,gxzy,gxzz,X,Y,Z,ANTI,SYM ,ANTI,Symmetry,0)
call fderivs(ex,Kyy,gyyx,gyyy,gyyz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0) call fderivs(ex,Kyy,gyyx,gyyy,gyyz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0)
call fderivs(ex,Kyz,gyzx,gyzy,gyzz,X,Y,Z,SYM ,ANTI,ANTI,Symmetry,0) call fderivs(ex,Kyz,gyzx,gyzy,gyzz,X,Y,Z,SYM ,ANTI,ANTI,Symmetry,0)
call fderivs(ex,Kzz,gzzx,gzzy,gzzz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0) call fderivs(ex,Kzz,gzzx,gzzy,gzzz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0)
gxxx = gxxx - ( Gamxxx * Kxx + Gamyxx * Kxy + Gamzxx * Kxz & gxxx = gxxx - ( Gamxxx * Kxx + Gamyxx * Kxy + Gamzxx * Kxz &
+ Gamxxx * Kxx + Gamyxx * Kxy + Gamzxx * Kxz) + Gamxxx * Kxx + Gamyxx * Kxy + Gamzxx * Kxz)
gxyx = gxyx - ( Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz & gxyx = gxyx - ( Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz &
+ Gamxxx * Kxy + Gamyxx * Kyy + Gamzxx * Kyz) + Gamxxx * Kxy + Gamyxx * Kyy + Gamzxx * Kyz)
gxzx = gxzx - ( Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz & gxzx = gxzx - ( Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz &
+ Gamxxx * Kxz + Gamyxx * Kyz + Gamzxx * Kzz) + Gamxxx * Kxz + Gamyxx * Kyz + Gamzxx * Kzz)
gyyx = gyyx - ( Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz & gyyx = gyyx - ( Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz &
+ Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz) + Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz)
gyzx = gyzx - ( Gamxxz * Kxy + Gamyxz * Kyy + Gamzxz * Kyz & gyzx = gyzx - ( Gamxxz * Kxy + Gamyxz * Kyy + Gamzxz * Kyz &
+ Gamxxy * Kxz + Gamyxy * Kyz + Gamzxy * Kzz) + Gamxxy * Kxz + Gamyxy * Kyz + Gamzxy * Kzz)
gzzx = gzzx - ( Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz & gzzx = gzzx - ( Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz &
+ Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz) + Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz)
gxxy = gxxy - ( Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz & gxxy = gxxy - ( Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz &
+ Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz) + Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz)
gxyy = gxyy - ( Gamxyy * Kxx + Gamyyy * Kxy + Gamzyy * Kxz & gxyy = gxyy - ( Gamxyy * Kxx + Gamyyy * Kxy + Gamzyy * Kxz &
+ Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz) + Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz)
gxzy = gxzy - ( Gamxyz * Kxx + Gamyyz * Kxy + Gamzyz * Kxz & gxzy = gxzy - ( Gamxyz * Kxx + Gamyyz * Kxy + Gamzyz * Kxz &
+ Gamxxy * Kxz + Gamyxy * Kyz + Gamzxy * Kzz) + Gamxxy * Kxz + Gamyxy * Kyz + Gamzxy * Kzz)
gyyy = gyyy - ( Gamxyy * Kxy + Gamyyy * Kyy + Gamzyy * Kyz & gyyy = gyyy - ( Gamxyy * Kxy + Gamyyy * Kyy + Gamzyy * Kyz &
+ Gamxyy * Kxy + Gamyyy * Kyy + Gamzyy * Kyz) + Gamxyy * Kxy + Gamyyy * Kyy + Gamzyy * Kyz)
gyzy = gyzy - ( Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz & gyzy = gyzy - ( Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz &
+ Gamxyy * Kxz + Gamyyy * Kyz + Gamzyy * Kzz) + Gamxyy * Kxz + Gamyyy * Kyz + Gamzyy * Kzz)
gzzy = gzzy - ( Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz & gzzy = gzzy - ( Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz &
+ Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz) + Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz)
gxxz = gxxz - ( Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz & gxxz = gxxz - ( Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz &
+ Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz) + Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz)
gxyz = gxyz - ( Gamxyz * Kxx + Gamyyz * Kxy + Gamzyz * Kxz & gxyz = gxyz - ( Gamxyz * Kxx + Gamyyz * Kxy + Gamzyz * Kxz &
+ Gamxxz * Kxy + Gamyxz * Kyy + Gamzxz * Kyz) + Gamxxz * Kxy + Gamyxz * Kyy + Gamzxz * Kyz)
gxzz = gxzz - ( Gamxzz * Kxx + Gamyzz * Kxy + Gamzzz * Kxz & gxzz = gxzz - ( Gamxzz * Kxx + Gamyzz * Kxy + Gamzzz * Kxz &
+ Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz) + Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz)
gyyz = gyyz - ( Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz & gyyz = gyyz - ( Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz &
+ Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz) + Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz)
gyzz = gyzz - ( Gamxzz * Kxy + Gamyzz * Kyy + Gamzzz * Kyz & gyzz = gyzz - ( Gamxzz * Kxy + Gamyzz * Kyy + Gamzzz * Kyz &
+ Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz) + Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz)
gzzz = gzzz - ( Gamxzz * Kxz + Gamyzz * Kyz + Gamzzz * Kzz & gzzz = gzzz - ( Gamxzz * Kxz + Gamyzz * Kyz + Gamzzz * Kzz &
+ Gamxzz * Kxz + Gamyzz * Kyz + Gamzzz * Kzz) + Gamxzz * Kxz + Gamyzz * Kyz + Gamzzz * Kzz)
movx_Res = gupxx*gxxx + gupyy*gxyy + gupzz*gxzz & movx_Res = gupxx*gxxx + gupyy*gxyy + gupzz*gxzz &
+gupxy*gxyx + gupxz*gxzx + gupyz*gxzy & +gupxy*gxyx + gupxz*gxzx + gupyz*gxzy &
+gupxy*gxxy + gupxz*gxxz + gupyz*gxyz +gupxy*gxxy + gupxz*gxxz + gupyz*gxyz
movy_Res = gupxx*gxyx + gupyy*gyyy + gupzz*gyzz & movy_Res = gupxx*gxyx + gupyy*gyyy + gupzz*gyzz &
+gupxy*gyyx + gupxz*gyzx + gupyz*gyzy & +gupxy*gyyx + gupxz*gyzx + gupyz*gyzy &
+gupxy*gxyy + gupxz*gxyz + gupyz*gyyz +gupxy*gxyy + gupxz*gxyz + gupyz*gyyz
movz_Res = gupxx*gxzx + gupyy*gyzy + gupzz*gzzz & movz_Res = gupxx*gxzx + gupyy*gyzy + gupzz*gzzz &
+gupxy*gyzx + gupxz*gzzx + gupyz*gzzy & +gupxy*gyzx + gupxz*gzzx + gupyz*gzzy &
+gupxy*gxzy + gupxz*gxzz + gupyz*gyzz +gupxy*gxzy + gupxz*gxzz + gupyz*gyzz
call fderivs(ex,trK,fx,fy,fz,X,Y,Z,SYM,SYM,SYM,Symmetry,0) call fderivs(ex,trK,fx,fy,fz,X,Y,Z,SYM,SYM,SYM,Symmetry,0)
movx_Res = movx_Res - fx - F8*PI*sx movx_Res = movx_Res - fx - F8*PI*sx
movy_Res = movy_Res - fy - F8*PI*sy movy_Res = movy_Res - fy - F8*PI*sy
movz_Res = movz_Res - fz - F8*PI*sz movz_Res = movz_Res - fz - F8*PI*sz
return return
end subroutine constraint_adm end subroutine constraint_adm
!-------------------------------------------------------------------------------! !-------------------------------------------------------------------------------!
! computed constraint for ADM formalism for shell ! ! computed constraint for ADM formalism for shell !
!-------------------------------------------------------------------------------! !-------------------------------------------------------------------------------!
subroutine constraint_adm_ss(ex,crho,sigma,R, X, Y, Z,& subroutine constraint_adm_ss(ex,crho,sigma,R, X, Y, Z,&
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz, & dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz, &
dxx,gxy,gxz,dyy,gyz,dzz, & dxx,gxy,gxz,dyy,gyz,dzz, &
Kxx,Kxy,Kxz,Kyy,Kyz,Kzz, & Kxx,Kxy,Kxz,Kyy,Kyz,Kzz, &
Lap,Sfx,Sfy,Sfz,rho,Sx,Sy,Sz,& Lap,Sfx,Sfy,Sfz,rho,Sx,Sy,Sz,&
Gamxxx, Gamxxy, Gamxxz,Gamxyy, Gamxyz, Gamxzz, & Gamxxx, Gamxxy, Gamxxz,Gamxyy, Gamxyz, Gamxzz, &
Gamyxx, Gamyxy, Gamyxz,Gamyyy, Gamyyz, Gamyzz, & Gamyxx, Gamyxy, Gamyxz,Gamyyy, Gamyyz, Gamyzz, &
Gamzxx, Gamzxy, Gamzxz,Gamzyy, Gamzyz, Gamzzz, & Gamzxx, Gamzxy, Gamzxz,Gamzyy, Gamzyz, Gamzzz, &
Rxx,Rxy,Rxz,Ryy,Ryz,Rzz, & Rxx,Rxy,Rxz,Ryy,Ryz,Rzz, &
ham_Res, movx_Res, movy_Res, movz_Res, & ham_Res, movx_Res, movy_Res, movz_Res, &
Symmetry,Lev,sst) Symmetry,Lev,sst)
implicit none implicit none
!~~~~~~> Input parameters: !~~~~~~> Input parameters:
integer,intent(in ):: ex(1:3),symmetry,Lev,sst integer,intent(in ):: ex(1:3),symmetry,Lev,sst
double precision,intent(in),dimension(ex(1))::crho double precision,intent(in),dimension(ex(1))::crho
double precision,intent(in),dimension(ex(2))::sigma double precision,intent(in),dimension(ex(2))::sigma
double precision,intent(in),dimension(ex(3))::R double precision,intent(in),dimension(ex(3))::R
real*8, intent(in ),dimension(ex(1),ex(2),ex(3)):: X,Y,Z real*8, intent(in ),dimension(ex(1),ex(2),ex(3)):: X,Y,Z
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::drhodx, drhody, drhodz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::drhodx, drhody, drhodz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dsigmadx,dsigmady,dsigmadz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dsigmadx,dsigmady,dsigmadz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dRdx,dRdy,dRdz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dRdx,dRdy,dRdz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: dxx,gxy,gxz,dyy,gyz,dzz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: dxx,gxy,gxz,dyy,gyz,dzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Kxx,Kxy,Kxz,Kyy,Kyz,Kzz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Kxx,Kxy,Kxz,Kyy,Kyz,Kzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Lap,Sfx,Sfy,Sfz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: Lap,Sfx,Sfy,Sfz
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: rho,Sx,Sy,Sz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: rho,Sx,Sy,Sz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Rxx,Rxy,Rxz,Ryy,Ryz,Rzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Rxx,Rxy,Rxz,Ryy,Ryz,Rzz
! second kind of Christofel symble Gamma^i_jk respect to physical metric ! second kind of Christofel symble Gamma^i_jk respect to physical metric
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxxx, Gamxxy, Gamxxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxxx, Gamxxy, Gamxxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxyy, Gamxyz, Gamxzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxyy, Gamxyz, Gamxzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyxx, Gamyxy, Gamyxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyxx, Gamyxy, Gamyxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyyy, Gamyyz, Gamyzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyyy, Gamyyz, Gamyzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzxx, Gamzxy, Gamzxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzxx, Gamzxy, Gamzxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzyy, Gamzyz, Gamzzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzyy, Gamzyz, Gamzzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: ham_Res, movx_Res, movy_Res, movz_Res real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: ham_Res, movx_Res, movy_Res, movz_Res
!~~~~~~> Other variables: !~~~~~~> Other variables:
! inverse metric ! inverse metric
real*8, dimension(ex(1),ex(2),ex(3)) :: gupxx,gupxy,gupxz real*8, dimension(ex(1),ex(2),ex(3)) :: gupxx,gupxy,gupxz
real*8, dimension(ex(1),ex(2),ex(3)) :: gupyy,gupyz,gupzz real*8, dimension(ex(1),ex(2),ex(3)) :: gupyy,gupyz,gupzz
! first order derivative of metric, @_k g_ij ! first order derivative of metric, @_k g_ij
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxx,gxyx,gxzx real*8, dimension(ex(1),ex(2),ex(3)) :: gxxx,gxyx,gxzx
real*8, dimension(ex(1),ex(2),ex(3)) :: gyyx,gyzx,gzzx real*8, dimension(ex(1),ex(2),ex(3)) :: gyyx,gyzx,gzzx
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxy,gxyy,gxzy real*8, dimension(ex(1),ex(2),ex(3)) :: gxxy,gxyy,gxzy
real*8, dimension(ex(1),ex(2),ex(3)) :: gyyy,gyzy,gzzy real*8, dimension(ex(1),ex(2),ex(3)) :: gyyy,gyzy,gzzy
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxz,gxyz,gxzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxxz,gxyz,gxzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gyyz,gyzz,gzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gyyz,gyzz,gzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz,trK,fx,fy,fz real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz,trK,fx,fy,fz
integer, parameter :: NO_SYMM = 0, EQUATORIAL = 1, OCTANT = 2 integer, parameter :: NO_SYMM = 0, EQUATORIAL = 1, OCTANT = 2
real*8, parameter :: ZERO = 0.D0, HALF = 0.5d0, ONE = 1.d0, TWO = 2.d0, FOUR = 4.d0 real*8, parameter :: ZERO = 0.D0, HALF = 0.5d0, ONE = 1.d0, TWO = 2.d0, FOUR = 4.d0
real*8, parameter :: F2o3 = 2.d0/3.d0, F8 = 8.d0, F16 = 1.6d1, SIX = 6.d0 real*8, parameter :: F2o3 = 2.d0/3.d0, F8 = 8.d0, F16 = 1.6d1, SIX = 6.d0
real*8, parameter :: SYM = 1.D0, ANTI= - 1.D0 real*8, parameter :: SYM = 1.D0, ANTI= - 1.D0
real*8 :: PI real*8 :: PI
call adm_ricci_gamma_ss(ex,crho,sigma,R,X, Y, Z, & call adm_ricci_gamma_ss(ex,crho,sigma,R,X, Y, Z, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz, & dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz, &
dxx , gxy , gxz , dyy , gyz , dzz,& dxx , gxy , gxz , dyy , gyz , dzz,&
Gamxxx,Gamxxy,Gamxxz,Gamxyy,Gamxyz,Gamxzz,& Gamxxx,Gamxxy,Gamxxz,Gamxyy,Gamxyz,Gamxzz,&
Gamyxx,Gamyxy,Gamyxz,Gamyyy,Gamyyz,Gamyzz,& Gamyxx,Gamyxy,Gamyxz,Gamyyy,Gamyyz,Gamyzz,&
Gamzxx,Gamzxy,Gamzxz,Gamzyy,Gamzyz,Gamzzz,& Gamzxx,Gamzxy,Gamzxz,Gamzyy,Gamzyz,Gamzzz,&
Rxx,Rxy,Rxz,Ryy,Ryz,Rzz,& Rxx,Rxy,Rxz,Ryy,Ryz,Rzz,&
Symmetry,Lev,sst) Symmetry,Lev,sst)
PI = dacos(-ONE) PI = dacos(-ONE)
gxx = dxx + ONE gxx = dxx + ONE
gyy = dyy + ONE gyy = dyy + ONE
gzz = dzz + ONE gzz = dzz + ONE
! invert metric ! invert metric
gupzz = gxx * gyy * gzz + gxy * gyz * gxz + gxz * gxy * gyz - & gupzz = gxx * gyy * gzz + gxy * gyz * gxz + gxz * gxy * gyz - &
gxz * gyy * gxz - gxy * gxy * gzz - gxx * gyz * gyz gxz * gyy * gxz - gxy * gxy * gzz - gxx * gyz * gyz
gupxx = ( gyy * gzz - gyz * gyz ) / gupzz gupxx = ( gyy * gzz - gyz * gyz ) / gupzz
gupxy = - ( gxy * gzz - gyz * gxz ) / gupzz gupxy = - ( gxy * gzz - gyz * gxz ) / gupzz
gupxz = ( gxy * gyz - gyy * gxz ) / gupzz gupxz = ( gxy * gyz - gyy * gxz ) / gupzz
gupyy = ( gxx * gzz - gxz * gxz ) / gupzz gupyy = ( gxx * gzz - gxz * gxz ) / gupzz
gupyz = - ( gxx * gyz - gxy * gxz ) / gupzz gupyz = - ( gxx * gyz - gxy * gxz ) / gupzz
gupzz = ( gxx * gyy - gxy * gxy ) / gupzz gupzz = ( gxx * gyy - gxy * gxy ) / gupzz
trK = gupxx * Kxx + gupyy * Kyy + gupzz * Kzz & trK = gupxx * Kxx + gupyy * Kyy + gupzz * Kzz &
+ TWO * (gupxy * Kxy + gupxz * Kxz + gupyz * Kyz) + TWO * (gupxy * Kxy + gupxz * Kxz + gupyz * Kyz)
! ham_Res = trR + K^2 - K_ij * K^ij - 16 * PI * rho ! ham_Res = trR + K^2 - K_ij * K^ij - 16 * PI * rho
ham_Res = gupxx * Rxx + gupyy * Ryy + gupzz * Rzz + & ham_Res = gupxx * Rxx + gupyy * Ryy + gupzz * Rzz + &
TWO* ( gupxy * Rxy + gupxz * Rxz + gupyz * Ryz ) TWO* ( gupxy * Rxy + gupxz * Rxz + gupyz * Ryz )
ham_Res = ham_Res + trK * trK -(& ham_Res = ham_Res + trK * trK -(&
gupxx * ( & gupxx * ( &
gupxx * Kxx * Kxx + gupyy * Kxy * Kxy + gupzz * Kxz * Kxz + & gupxx * Kxx * Kxx + gupyy * Kxy * Kxy + gupzz * Kxz * Kxz + &
TWO * (gupxy * Kxx * Kxy + gupxz * Kxx * Kxz + gupyz * Kxy * Kxz) ) + & TWO * (gupxy * Kxx * Kxy + gupxz * Kxx * Kxz + gupyz * Kxy * Kxz) ) + &
gupyy * ( & gupyy * ( &
gupxx * Kxy * Kxy + gupyy * Kyy * Kyy + gupzz * Kyz * Kyz + & gupxx * Kxy * Kxy + gupyy * Kyy * Kyy + gupzz * Kyz * Kyz + &
TWO * (gupxy * Kxy * Kyy + gupxz * Kxy * Kyz + gupyz * Kyy * Kyz) ) + & TWO * (gupxy * Kxy * Kyy + gupxz * Kxy * Kyz + gupyz * Kyy * Kyz) ) + &
gupzz * ( & gupzz * ( &
gupxx * Kxz * Kxz + gupyy * Kyz * Kyz + gupzz * Kzz * Kzz + & gupxx * Kxz * Kxz + gupyy * Kyz * Kyz + gupzz * Kzz * Kzz + &
TWO * (gupxy * Kxz * Kyz + gupxz * Kxz * Kzz + gupyz * Kyz * Kzz) ) + & TWO * (gupxy * Kxz * Kyz + gupxz * Kxz * Kzz + gupyz * Kyz * Kzz) ) + &
TWO * ( & TWO * ( &
gupxy * ( & gupxy * ( &
gupxx * Kxx * Kxy + gupyy * Kxy * Kyy + gupzz * Kxz * Kyz + & gupxx * Kxx * Kxy + gupyy * Kxy * Kyy + gupzz * Kxz * Kyz + &
gupxy * (Kxx * Kyy + Kxy * Kxy) + & gupxy * (Kxx * Kyy + Kxy * Kxy) + &
gupxz * (Kxx * Kyz + Kxz * Kxy) + & gupxz * (Kxx * Kyz + Kxz * Kxy) + &
gupyz * (Kxy * Kyz + Kxz * Kyy) ) + & gupyz * (Kxy * Kyz + Kxz * Kyy) ) + &
gupxz * ( & gupxz * ( &
gupxx * Kxx * Kxz + gupyy * Kxy * Kyz + gupzz * Kxz * Kzz + & gupxx * Kxx * Kxz + gupyy * Kxy * Kyz + gupzz * Kxz * Kzz + &
gupxy * (Kxx * Kyz + Kxy * Kxz) + & gupxy * (Kxx * Kyz + Kxy * Kxz) + &
gupxz * (Kxx * Kzz + Kxz * Kxz) + & gupxz * (Kxx * Kzz + Kxz * Kxz) + &
gupyz * (Kxy * Kzz + Kxz * Kyz) ) + & gupyz * (Kxy * Kzz + Kxz * Kyz) ) + &
gupyz * ( & gupyz * ( &
gupxx * Kxy * Kxz + gupyy * Kyy * Kyz + gupzz * Kyz * Kzz + & gupxx * Kxy * Kxz + gupyy * Kyy * Kyz + gupzz * Kyz * Kzz + &
gupxy * (Kxy * Kyz + Kyy * Kxz) + & gupxy * (Kxy * Kyz + Kyy * Kxz) + &
gupxz * (Kxy * Kzz + Kyz * Kxz) + & gupxz * (Kxy * Kzz + Kyz * Kxz) + &
gupyz * (Kyy * Kzz + Kyz * Kyz) ) ))- F16 * PI * rho gupyz * (Kyy * Kzz + Kyz * Kyz) ) ))- F16 * PI * rho
! mov_Res_j = gupkj*D_k K_ij - d_j trK - 8 PI s_j where D respect to physical metric ! mov_Res_j = gupkj*D_k K_ij - d_j trK - 8 PI s_j where D respect to physical metric
! store D_i K_jk ! store D_i K_jk
call fderivs_shc(ex,Kxx,gxxx,gxxy,gxxz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,Kxx,gxxx,gxxy,gxxz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,Kxy,gxyx,gxyy,gxyz,crho,sigma,R,ANTI,ANTI,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,Kxy,gxyx,gxyy,gxyz,crho,sigma,R,ANTI,ANTI,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,Kxz,gxzx,gxzy,gxzz,crho,sigma,R,ANTI,SYM ,ANTI,Symmetry,Lev,sst, & call fderivs_shc(ex,Kxz,gxzx,gxzy,gxzz,crho,sigma,R,ANTI,SYM ,ANTI,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,Kyy,gyyx,gyyy,gyyz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,Kyy,gyyx,gyyy,gyyz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,Kyz,gyzx,gyzy,gyzz,crho,sigma,R,SYM ,ANTI,ANTI,Symmetry,Lev,sst, & call fderivs_shc(ex,Kyz,gyzx,gyzy,gyzz,crho,sigma,R,SYM ,ANTI,ANTI,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,Kzz,gzzx,gzzy,gzzz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,Kzz,gzzx,gzzy,gzzz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
gxxx = gxxx - ( Gamxxx * Kxx + Gamyxx * Kxy + Gamzxx * Kxz & gxxx = gxxx - ( Gamxxx * Kxx + Gamyxx * Kxy + Gamzxx * Kxz &
+ Gamxxx * Kxx + Gamyxx * Kxy + Gamzxx * Kxz) + Gamxxx * Kxx + Gamyxx * Kxy + Gamzxx * Kxz)
gxyx = gxyx - ( Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz & gxyx = gxyx - ( Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz &
+ Gamxxx * Kxy + Gamyxx * Kyy + Gamzxx * Kyz) + Gamxxx * Kxy + Gamyxx * Kyy + Gamzxx * Kyz)
gxzx = gxzx - ( Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz & gxzx = gxzx - ( Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz &
+ Gamxxx * Kxz + Gamyxx * Kyz + Gamzxx * Kzz) + Gamxxx * Kxz + Gamyxx * Kyz + Gamzxx * Kzz)
gyyx = gyyx - ( Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz & gyyx = gyyx - ( Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz &
+ Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz) + Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz)
gyzx = gyzx - ( Gamxxz * Kxy + Gamyxz * Kyy + Gamzxz * Kyz & gyzx = gyzx - ( Gamxxz * Kxy + Gamyxz * Kyy + Gamzxz * Kyz &
+ Gamxxy * Kxz + Gamyxy * Kyz + Gamzxy * Kzz) + Gamxxy * Kxz + Gamyxy * Kyz + Gamzxy * Kzz)
gzzx = gzzx - ( Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz & gzzx = gzzx - ( Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz &
+ Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz) + Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz)
gxxy = gxxy - ( Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz & gxxy = gxxy - ( Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz &
+ Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz) + Gamxxy * Kxx + Gamyxy * Kxy + Gamzxy * Kxz)
gxyy = gxyy - ( Gamxyy * Kxx + Gamyyy * Kxy + Gamzyy * Kxz & gxyy = gxyy - ( Gamxyy * Kxx + Gamyyy * Kxy + Gamzyy * Kxz &
+ Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz) + Gamxxy * Kxy + Gamyxy * Kyy + Gamzxy * Kyz)
gxzy = gxzy - ( Gamxyz * Kxx + Gamyyz * Kxy + Gamzyz * Kxz & gxzy = gxzy - ( Gamxyz * Kxx + Gamyyz * Kxy + Gamzyz * Kxz &
+ Gamxxy * Kxz + Gamyxy * Kyz + Gamzxy * Kzz) + Gamxxy * Kxz + Gamyxy * Kyz + Gamzxy * Kzz)
gyyy = gyyy - ( Gamxyy * Kxy + Gamyyy * Kyy + Gamzyy * Kyz & gyyy = gyyy - ( Gamxyy * Kxy + Gamyyy * Kyy + Gamzyy * Kyz &
+ Gamxyy * Kxy + Gamyyy * Kyy + Gamzyy * Kyz) + Gamxyy * Kxy + Gamyyy * Kyy + Gamzyy * Kyz)
gyzy = gyzy - ( Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz & gyzy = gyzy - ( Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz &
+ Gamxyy * Kxz + Gamyyy * Kyz + Gamzyy * Kzz) + Gamxyy * Kxz + Gamyyy * Kyz + Gamzyy * Kzz)
gzzy = gzzy - ( Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz & gzzy = gzzy - ( Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz &
+ Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz) + Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz)
gxxz = gxxz - ( Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz & gxxz = gxxz - ( Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz &
+ Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz) + Gamxxz * Kxx + Gamyxz * Kxy + Gamzxz * Kxz)
gxyz = gxyz - ( Gamxyz * Kxx + Gamyyz * Kxy + Gamzyz * Kxz & gxyz = gxyz - ( Gamxyz * Kxx + Gamyyz * Kxy + Gamzyz * Kxz &
+ Gamxxz * Kxy + Gamyxz * Kyy + Gamzxz * Kyz) + Gamxxz * Kxy + Gamyxz * Kyy + Gamzxz * Kyz)
gxzz = gxzz - ( Gamxzz * Kxx + Gamyzz * Kxy + Gamzzz * Kxz & gxzz = gxzz - ( Gamxzz * Kxx + Gamyzz * Kxy + Gamzzz * Kxz &
+ Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz) + Gamxxz * Kxz + Gamyxz * Kyz + Gamzxz * Kzz)
gyyz = gyyz - ( Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz & gyyz = gyyz - ( Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz &
+ Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz) + Gamxyz * Kxy + Gamyyz * Kyy + Gamzyz * Kyz)
gyzz = gyzz - ( Gamxzz * Kxy + Gamyzz * Kyy + Gamzzz * Kyz & gyzz = gyzz - ( Gamxzz * Kxy + Gamyzz * Kyy + Gamzzz * Kyz &
+ Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz) + Gamxyz * Kxz + Gamyyz * Kyz + Gamzyz * Kzz)
gzzz = gzzz - ( Gamxzz * Kxz + Gamyzz * Kyz + Gamzzz * Kzz & gzzz = gzzz - ( Gamxzz * Kxz + Gamyzz * Kyz + Gamzzz * Kzz &
+ Gamxzz * Kxz + Gamyzz * Kyz + Gamzzz * Kzz) + Gamxzz * Kxz + Gamyzz * Kyz + Gamzzz * Kzz)
movx_Res = gupxx*gxxx + gupyy*gxyy + gupzz*gxzz & movx_Res = gupxx*gxxx + gupyy*gxyy + gupzz*gxzz &
+gupxy*gxyx + gupxz*gxzx + gupyz*gxzy & +gupxy*gxyx + gupxz*gxzx + gupyz*gxzy &
+gupxy*gxxy + gupxz*gxxz + gupyz*gxyz +gupxy*gxxy + gupxz*gxxz + gupyz*gxyz
movy_Res = gupxx*gxyx + gupyy*gyyy + gupzz*gyzz & movy_Res = gupxx*gxyx + gupyy*gyyy + gupzz*gyzz &
+gupxy*gyyx + gupxz*gyzx + gupyz*gyzy & +gupxy*gyyx + gupxz*gyzx + gupyz*gyzy &
+gupxy*gxyy + gupxz*gxyz + gupyz*gyyz +gupxy*gxyy + gupxz*gxyz + gupyz*gyyz
movz_Res = gupxx*gxzx + gupyy*gyzy + gupzz*gzzz & movz_Res = gupxx*gxzx + gupyy*gyzy + gupzz*gzzz &
+gupxy*gyzx + gupxz*gzzx + gupyz*gzzy & +gupxy*gyzx + gupxz*gzzx + gupyz*gzzy &
+gupxy*gxzy + gupxz*gxzz + gupyz*gyzz +gupxy*gxzy + gupxz*gxzz + gupyz*gyzz
call fderivs_shc(ex,trK,fx,fy,fz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,trK,fx,fy,fz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
movx_Res = movx_Res - fx - F8*PI*sx movx_Res = movx_Res - fx - F8*PI*sx
movy_Res = movy_Res - fy - F8*PI*sy movy_Res = movy_Res - fy - F8*PI*sy
movz_Res = movz_Res - fz - F8*PI*sz movz_Res = movz_Res - fz - F8*PI*sz
return return
end subroutine constraint_adm_ss end subroutine constraint_adm_ss

View File

@@ -1,306 +1,306 @@
! for ADM variables ! for ADM variables
subroutine adm_ricci_gamma(ex, X, Y, Z, & subroutine adm_ricci_gamma(ex, X, Y, Z, &
dxx , gxy , gxz , dyy , gyz , dzz,& dxx , gxy , gxz , dyy , gyz , dzz,&
Gamxxx,Gamxxy,Gamxxz,Gamxyy,Gamxyz,Gamxzz,& Gamxxx,Gamxxy,Gamxxz,Gamxyy,Gamxyz,Gamxzz,&
Gamyxx,Gamyxy,Gamyxz,Gamyyy,Gamyyz,Gamyzz,& Gamyxx,Gamyxy,Gamyxz,Gamyyy,Gamyyz,Gamyzz,&
Gamzxx,Gamzxy,Gamzxz,Gamzyy,Gamzyz,Gamzzz,& Gamzxx,Gamzxy,Gamzxz,Gamzyy,Gamzyz,Gamzzz,&
Rxx,Rxy,Rxz,Ryy,Ryz,Rzz,& Rxx,Rxy,Rxz,Ryy,Ryz,Rzz,&
Symmetry) Symmetry)
implicit none implicit none
!~~~~~~> Input parameters: !~~~~~~> Input parameters:
integer,intent(in ):: ex(1:3), Symmetry integer,intent(in ):: ex(1:3), Symmetry
real*8, intent(in ):: X(1:ex(1)),Y(1:ex(2)),Z(1:ex(3)) real*8, intent(in ):: X(1:ex(1)),Y(1:ex(2)),Z(1:ex(3))
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: dxx,gxy,gxz,dyy,gyz,dzz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: dxx,gxy,gxz,dyy,gyz,dzz
! when out, physical second kind of connection ! when out, physical second kind of connection
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxxx, Gamxxy, Gamxxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxxx, Gamxxy, Gamxxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxyy, Gamxyz, Gamxzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxyy, Gamxyz, Gamxzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyxx, Gamyxy, Gamyxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyxx, Gamyxy, Gamyxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyyy, Gamyyz, Gamyzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyyy, Gamyyz, Gamyzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzxx, Gamzxy, Gamzxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzxx, Gamzxy, Gamzxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzyy, Gamzyz, Gamzzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzyy, Gamzyz, Gamzzz
! when out, physical Ricci tensor ! when out, physical Ricci tensor
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Rxx,Rxy,Rxz,Ryy,Ryz,Rzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Rxx,Rxy,Rxz,Ryy,Ryz,Rzz
!~~~~~~> Other variables: !~~~~~~> Other variables:
real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxx,gxyx,gxzx,gyyx,gyzx,gzzx real*8, dimension(ex(1),ex(2),ex(3)) :: gxxx,gxyx,gxzx,gyyx,gyzx,gzzx
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxy,gxyy,gxzy,gyyy,gyzy,gzzy real*8, dimension(ex(1),ex(2),ex(3)) :: gxxy,gxyy,gxzy,gyyy,gyzy,gzzy
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxz,gxyz,gxzz,gyyz,gyzz,gzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxxz,gxyz,gxzz,gyyz,gyzz,gzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamxxx,ass_Gamxxy,ass_Gamxxz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamxxx,ass_Gamxxy,ass_Gamxxz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamxyy,ass_Gamxyz,ass_Gamxzz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamxyy,ass_Gamxyz,ass_Gamxzz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamyxx,ass_Gamyxy,ass_Gamyxz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamyxx,ass_Gamyxy,ass_Gamyxz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamyyy,ass_Gamyyz,ass_Gamyzz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamyyy,ass_Gamyyz,ass_Gamyzz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamzxx,ass_Gamzxy,ass_Gamzxz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamzxx,ass_Gamzxy,ass_Gamzxz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamzyy,ass_Gamzyz,ass_Gamzzz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamzyy,ass_Gamzyz,ass_Gamzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gupxx,gupxy,gupxz real*8, dimension(ex(1),ex(2),ex(3)) :: gupxx,gupxy,gupxz
real*8, dimension(ex(1),ex(2),ex(3)) :: gupyy,gupyz,gupzz real*8, dimension(ex(1),ex(2),ex(3)) :: gupyy,gupyz,gupzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz real*8, dimension(ex(1),ex(2),ex(3)) :: gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz real*8, dimension(ex(1),ex(2),ex(3)) :: Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz
real*8, parameter :: ONE = 1.D0, TWO = 2.D0, FOUR = 4.D0 real*8, parameter :: ONE = 1.D0, TWO = 2.D0, FOUR = 4.D0
real*8, parameter :: HALF = 0.5D0, F2o3 = 2.d0/3.d0, F3o2 = 1.5d0 real*8, parameter :: HALF = 0.5D0, F2o3 = 2.d0/3.d0, F3o2 = 1.5d0
real*8, parameter :: SYM = 1.D0, ANTI= - 1.D0 real*8, parameter :: SYM = 1.D0, ANTI= - 1.D0
gxx = dxx + ONE gxx = dxx + ONE
gyy = dyy + ONE gyy = dyy + ONE
gzz = dzz + ONE gzz = dzz + ONE
call fderivs(ex,dxx,gxxx,gxxy,gxxz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0) call fderivs(ex,dxx,gxxx,gxxy,gxxz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0)
call fderivs(ex,gxy,gxyx,gxyy,gxyz,X,Y,Z,ANTI,ANTI,SYM ,Symmetry,0) call fderivs(ex,gxy,gxyx,gxyy,gxyz,X,Y,Z,ANTI,ANTI,SYM ,Symmetry,0)
call fderivs(ex,gxz,gxzx,gxzy,gxzz,X,Y,Z,ANTI,SYM ,ANTI,Symmetry,0) call fderivs(ex,gxz,gxzx,gxzy,gxzz,X,Y,Z,ANTI,SYM ,ANTI,Symmetry,0)
call fderivs(ex,dyy,gyyx,gyyy,gyyz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0) call fderivs(ex,dyy,gyyx,gyyy,gyyz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0)
call fderivs(ex,gyz,gyzx,gyzy,gyzz,X,Y,Z,SYM ,ANTI,ANTI,Symmetry,0) call fderivs(ex,gyz,gyzx,gyzy,gyzz,X,Y,Z,SYM ,ANTI,ANTI,Symmetry,0)
call fderivs(ex,dzz,gzzx,gzzy,gzzz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0) call fderivs(ex,dzz,gzzx,gzzy,gzzz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0)
call kind1_connection(ex, & call kind1_connection(ex, &
gxxx,gxyx,gxzx,gyyx,gyzx,gzzx, & gxxx,gxyx,gxzx,gyyx,gyzx,gzzx, &
gxxy,gxyy,gxzy,gyyy,gyzy,gzzy, & gxxy,gxyy,gxzy,gyyy,gyzy,gzzy, &
gxxz,gxyz,gxzz,gyyz,gyzz,gzzz, & gxxz,gxyz,gxzz,gyyz,gyzz,gzzz, &
ass_Gamxxx, ass_Gamxxy, ass_Gamxxz, ass_Gamxyy, ass_Gamxyz, ass_Gamxzz, & ass_Gamxxx, ass_Gamxxy, ass_Gamxxz, ass_Gamxyy, ass_Gamxyz, ass_Gamxzz, &
ass_Gamyxx, ass_Gamyxy, ass_Gamyxz, ass_Gamyyy, ass_Gamyyz, ass_Gamyzz, & ass_Gamyxx, ass_Gamyxy, ass_Gamyxz, ass_Gamyyy, ass_Gamyyz, ass_Gamyzz, &
ass_Gamzxx, ass_Gamzxy, ass_Gamzxz, ass_Gamzyy, ass_Gamzyz, ass_Gamzzz) ass_Gamzxx, ass_Gamzxy, ass_Gamzxz, ass_Gamzyy, ass_Gamzyz, ass_Gamzzz)
! invert metric ! invert metric
gupzz = gxx * gyy * gzz + gxy * gyz * gxz + gxz * gxy * gyz - & gupzz = gxx * gyy * gzz + gxy * gyz * gxz + gxz * gxy * gyz - &
gxz * gyy * gxz - gxy * gxy * gzz - gxx * gyz * gyz gxz * gyy * gxz - gxy * gxy * gzz - gxx * gyz * gyz
gupxx = ( gyy * gzz - gyz * gyz ) / gupzz gupxx = ( gyy * gzz - gyz * gyz ) / gupzz
gupxy = - ( gxy * gzz - gyz * gxz ) / gupzz gupxy = - ( gxy * gzz - gyz * gxz ) / gupzz
gupxz = ( gxy * gyz - gyy * gxz ) / gupzz gupxz = ( gxy * gyz - gyy * gxz ) / gupzz
gupyy = ( gxx * gzz - gxz * gxz ) / gupzz gupyy = ( gxx * gzz - gxz * gxz ) / gupzz
gupyz = - ( gxx * gyz - gxy * gxz ) / gupzz gupyz = - ( gxx * gyz - gxy * gxz ) / gupzz
gupzz = ( gxx * gyy - gxy * gxy ) / gupzz gupzz = ( gxx * gyy - gxy * gxy ) / gupzz
call kind2_connection(ex, & call kind2_connection(ex, &
gupxx,gupxy,gupxz,gupyy,gupyz,gupzz, & gupxx,gupxy,gupxz,gupyy,gupyz,gupzz, &
ass_Gamxxx, ass_Gamxxy, ass_Gamxxz, ass_Gamxyy, ass_Gamxyz, ass_Gamxzz, & ass_Gamxxx, ass_Gamxxy, ass_Gamxxz, ass_Gamxyy, ass_Gamxyz, ass_Gamxzz, &
ass_Gamyxx, ass_Gamyxy, ass_Gamyxz, ass_Gamyyy, ass_Gamyyz, ass_Gamyzz, & ass_Gamyxx, ass_Gamyxy, ass_Gamyxz, ass_Gamyyy, ass_Gamyyz, ass_Gamyzz, &
ass_Gamzxx, ass_Gamzxy, ass_Gamzxz, ass_Gamzyy, ass_Gamzyz, ass_Gamzzz, & ass_Gamzxx, ass_Gamzxy, ass_Gamzxz, ass_Gamzyy, ass_Gamzyz, ass_Gamzzz, &
Gamxxx, Gamxxy, Gamxxz, Gamxyy, Gamxyz, Gamxzz, & Gamxxx, Gamxxy, Gamxxz, Gamxyy, Gamxyz, Gamxzz, &
Gamyxx, Gamyxy, Gamyxz, Gamyyy, Gamyyz, Gamyzz, & Gamyxx, Gamyxy, Gamyxz, Gamyyy, Gamyyz, Gamyzz, &
Gamzxx, Gamzxy, Gamzxz, Gamzyy, Gamzyz, Gamzzz) Gamzxx, Gamzxy, Gamzxz, Gamzyy, Gamzyz, Gamzzz)
call fdderivs(ex,dxx,gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0) call fdderivs(ex,dxx,gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0)
call fdderivs(ex,gxy,gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz,X,Y,Z,ANTI,ANTI,SYM ,Symmetry,0) call fdderivs(ex,gxy,gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz,X,Y,Z,ANTI,ANTI,SYM ,Symmetry,0)
call fdderivs(ex,gxz,gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz,X,Y,Z,ANTI,SYM ,ANTI,Symmetry,0) call fdderivs(ex,gxz,gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz,X,Y,Z,ANTI,SYM ,ANTI,Symmetry,0)
call fdderivs(ex,dyy,gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz,X,Y,Z,SYM, SYM ,SYM ,Symmetry,0) call fdderivs(ex,dyy,gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz,X,Y,Z,SYM, SYM ,SYM ,Symmetry,0)
call fdderivs(ex,gyz,gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz,X,Y,Z,SYM ,ANTI,ANTI,Symmetry,0) call fdderivs(ex,gyz,gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz,X,Y,Z,SYM ,ANTI,ANTI,Symmetry,0)
call fdderivs(ex,dzz,gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0) call fdderivs(ex,dzz,gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz,X,Y,Z,SYM ,SYM ,SYM ,Symmetry,0)
call adm_riemann(ex, & call adm_riemann(ex, &
gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz, & gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz, &
gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz, & gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz, &
gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz, & gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz, &
gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz, & gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz, &
gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz, & gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz, &
gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz, & gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz, &
Gamxxx, Gamxxy, Gamxxz, Gamxyy, Gamxyz, Gamxzz, & Gamxxx, Gamxxy, Gamxxz, Gamxyy, Gamxyz, Gamxzz, &
Gamyxx, Gamyxy, Gamyxz, Gamyyy, Gamyyz, Gamyzz, & Gamyxx, Gamyxy, Gamyxz, Gamyyy, Gamyyz, Gamyzz, &
Gamzxx, Gamzxy, Gamzxz, Gamzyy, Gamzyz, Gamzzz, & Gamzxx, Gamzxy, Gamzxz, Gamzyy, Gamzyz, Gamzzz, &
ass_Gamxxx,ass_Gamxxy,ass_Gamxxz, ass_Gamxyy,ass_Gamxyz,ass_Gamxzz, & ass_Gamxxx,ass_Gamxxy,ass_Gamxxz, ass_Gamxyy,ass_Gamxyz,ass_Gamxzz, &
ass_Gamyxx,ass_Gamyxy,ass_Gamyxz, ass_Gamyyy,ass_Gamyyz,ass_Gamyzz, & ass_Gamyxx,ass_Gamyxy,ass_Gamyxz, ass_Gamyyy,ass_Gamyyz,ass_Gamyzz, &
ass_Gamzxx,ass_Gamzxy,ass_Gamzxz, ass_Gamzyy,ass_Gamzyz,ass_Gamzzz, & ass_Gamzxx,ass_Gamzxy,ass_Gamzxz, ass_Gamzyy,ass_Gamzyz,ass_Gamzzz, &
Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz) Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz)
call adm_ricci(ex, & call adm_ricci(ex, &
gupxx , gupxy , gupxz , gupyy , gupyz , gupzz , & gupxx , gupxy , gupxz , gupyy , gupyz , gupzz , &
Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz, & Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz, &
Rxx , Rxy , Rxz , Ryy , Ryz , Rzz) Rxx , Rxy , Rxz , Ryy , Ryz , Rzz)
return return
end subroutine adm_ricci_gamma end subroutine adm_ricci_gamma
!---------------------------------------------------------------------------- !----------------------------------------------------------------------------
subroutine adm_ricci_gamma_ss(ex,crho,sigma,R,X, Y, Z, & subroutine adm_ricci_gamma_ss(ex,crho,sigma,R,X, Y, Z, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz, & dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz, &
dxx , gxy , gxz , dyy , gyz , dzz,& dxx , gxy , gxz , dyy , gyz , dzz,&
Gamxxx,Gamxxy,Gamxxz,Gamxyy,Gamxyz,Gamxzz,& Gamxxx,Gamxxy,Gamxxz,Gamxyy,Gamxyz,Gamxzz,&
Gamyxx,Gamyxy,Gamyxz,Gamyyy,Gamyyz,Gamyzz,& Gamyxx,Gamyxy,Gamyxz,Gamyyy,Gamyyz,Gamyzz,&
Gamzxx,Gamzxy,Gamzxz,Gamzyy,Gamzyz,Gamzzz,& Gamzxx,Gamzxy,Gamzxz,Gamzyy,Gamzyz,Gamzzz,&
Rxx,Rxy,Rxz,Ryy,Ryz,Rzz,& Rxx,Rxy,Rxz,Ryy,Ryz,Rzz,&
Symmetry,Lev,sst) Symmetry,Lev,sst)
implicit none implicit none
!~~~~~~> Input parameters: !~~~~~~> Input parameters:
integer,intent(in ):: ex(1:3), Symmetry,Lev,sst integer,intent(in ):: ex(1:3), Symmetry,Lev,sst
double precision,intent(in),dimension(ex(1))::crho double precision,intent(in),dimension(ex(1))::crho
double precision,intent(in),dimension(ex(2))::sigma double precision,intent(in),dimension(ex(2))::sigma
double precision,intent(in),dimension(ex(3))::R double precision,intent(in),dimension(ex(3))::R
real*8, intent(in ),dimension(ex(1),ex(2),ex(3)):: X,Y,Z real*8, intent(in ),dimension(ex(1),ex(2),ex(3)):: X,Y,Z
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::drhodx, drhody, drhodz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::drhodx, drhody, drhodz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dsigmadx,dsigmady,dsigmadz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dsigmadx,dsigmady,dsigmadz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dRdx,dRdy,dRdz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dRdx,dRdy,dRdz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: dxx,gxy,gxz,dyy,gyz,dzz real*8, dimension(ex(1),ex(2),ex(3)),intent(in ) :: dxx,gxy,gxz,dyy,gyz,dzz
! when out, physical second kind of connection ! when out, physical second kind of connection
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxxx, Gamxxy, Gamxxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxxx, Gamxxy, Gamxxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxyy, Gamxyz, Gamxzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamxyy, Gamxyz, Gamxzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyxx, Gamyxy, Gamyxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyxx, Gamyxy, Gamyxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyyy, Gamyyz, Gamyzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamyyy, Gamyyz, Gamyzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzxx, Gamzxy, Gamzxz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzxx, Gamzxy, Gamzxz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzyy, Gamzyz, Gamzzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Gamzyy, Gamzyz, Gamzzz
! when out, physical Ricci tensor ! when out, physical Ricci tensor
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Rxx,Rxy,Rxz,Ryy,Ryz,Rzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Rxx,Rxy,Rxz,Ryy,Ryz,Rzz
!~~~~~~> Other variables: !~~~~~~> Other variables:
real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxx,gxyx,gxzx,gyyx,gyzx,gzzx real*8, dimension(ex(1),ex(2),ex(3)) :: gxxx,gxyx,gxzx,gyyx,gyzx,gzzx
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxy,gxyy,gxzy,gyyy,gyzy,gzzy real*8, dimension(ex(1),ex(2),ex(3)) :: gxxy,gxyy,gxzy,gyyy,gyzy,gzzy
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxz,gxyz,gxzz,gyyz,gyzz,gzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxxz,gxyz,gxzz,gyyz,gyzz,gzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamxxx,ass_Gamxxy,ass_Gamxxz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamxxx,ass_Gamxxy,ass_Gamxxz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamxyy,ass_Gamxyz,ass_Gamxzz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamxyy,ass_Gamxyz,ass_Gamxzz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamyxx,ass_Gamyxy,ass_Gamyxz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamyxx,ass_Gamyxy,ass_Gamyxz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamyyy,ass_Gamyyz,ass_Gamyzz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamyyy,ass_Gamyyz,ass_Gamyzz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamzxx,ass_Gamzxy,ass_Gamzxz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamzxx,ass_Gamzxy,ass_Gamzxz
real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamzyy,ass_Gamzyz,ass_Gamzzz real*8, dimension(ex(1),ex(2),ex(3)) :: ass_Gamzyy,ass_Gamzyz,ass_Gamzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gupxx,gupxy,gupxz real*8, dimension(ex(1),ex(2),ex(3)) :: gupxx,gupxy,gupxz
real*8, dimension(ex(1),ex(2),ex(3)) :: gupyy,gupyz,gupzz real*8, dimension(ex(1),ex(2),ex(3)) :: gupyy,gupyz,gupzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz real*8, dimension(ex(1),ex(2),ex(3)) :: gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz real*8, dimension(ex(1),ex(2),ex(3)) :: gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz
real*8, dimension(ex(1),ex(2),ex(3)) :: Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz real*8, dimension(ex(1),ex(2),ex(3)) :: Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz
real*8, parameter :: ONE = 1.D0, TWO = 2.D0, FOUR = 4.D0 real*8, parameter :: ONE = 1.D0, TWO = 2.D0, FOUR = 4.D0
real*8, parameter :: HALF = 0.5D0, F2o3 = 2.d0/3.d0, F3o2 = 1.5d0 real*8, parameter :: HALF = 0.5D0, F2o3 = 2.d0/3.d0, F3o2 = 1.5d0
real*8, parameter :: SYM = 1.D0, ANTI= - 1.D0 real*8, parameter :: SYM = 1.D0, ANTI= - 1.D0
gxx = dxx + ONE gxx = dxx + ONE
gyy = dyy + ONE gyy = dyy + ONE
gzz = dzz + ONE gzz = dzz + ONE
call fderivs_shc(ex,dxx,gxxx,gxxy,gxxz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,dxx,gxxx,gxxy,gxxz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,gxy,gxyx,gxyy,gxyz,crho,sigma,R,ANTI,ANTI,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,gxy,gxyx,gxyy,gxyz,crho,sigma,R,ANTI,ANTI,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,gxz,gxzx,gxzy,gxzz,crho,sigma,R,ANTI,SYM ,ANTI,Symmetry,Lev,sst, & call fderivs_shc(ex,gxz,gxzx,gxzy,gxzz,crho,sigma,R,ANTI,SYM ,ANTI,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,dyy,gyyx,gyyy,gyyz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,dyy,gyyx,gyyy,gyyz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,gyz,gyzx,gyzy,gyzz,crho,sigma,R,SYM ,ANTI,ANTI,Symmetry,Lev,sst, & call fderivs_shc(ex,gyz,gyzx,gyzy,gyzz,crho,sigma,R,SYM ,ANTI,ANTI,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call fderivs_shc(ex,dzz,gzzx,gzzy,gzzz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, & call fderivs_shc(ex,dzz,gzzx,gzzy,gzzz,crho,sigma,R, SYM, SYM,SYM,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz) dRdx,dRdy,dRdz)
call kind1_connection(ex, & call kind1_connection(ex, &
gxxx,gxyx,gxzx,gyyx,gyzx,gzzx, & gxxx,gxyx,gxzx,gyyx,gyzx,gzzx, &
gxxy,gxyy,gxzy,gyyy,gyzy,gzzy, & gxxy,gxyy,gxzy,gyyy,gyzy,gzzy, &
gxxz,gxyz,gxzz,gyyz,gyzz,gzzz, & gxxz,gxyz,gxzz,gyyz,gyzz,gzzz, &
ass_Gamxxx, ass_Gamxxy, ass_Gamxxz, ass_Gamxyy, ass_Gamxyz, ass_Gamxzz, & ass_Gamxxx, ass_Gamxxy, ass_Gamxxz, ass_Gamxyy, ass_Gamxyz, ass_Gamxzz, &
ass_Gamyxx, ass_Gamyxy, ass_Gamyxz, ass_Gamyyy, ass_Gamyyz, ass_Gamyzz, & ass_Gamyxx, ass_Gamyxy, ass_Gamyxz, ass_Gamyyy, ass_Gamyyz, ass_Gamyzz, &
ass_Gamzxx, ass_Gamzxy, ass_Gamzxz, ass_Gamzyy, ass_Gamzyz, ass_Gamzzz) ass_Gamzxx, ass_Gamzxy, ass_Gamzxz, ass_Gamzyy, ass_Gamzyz, ass_Gamzzz)
! invert metric ! invert metric
gupzz = gxx * gyy * gzz + gxy * gyz * gxz + gxz * gxy * gyz - & gupzz = gxx * gyy * gzz + gxy * gyz * gxz + gxz * gxy * gyz - &
gxz * gyy * gxz - gxy * gxy * gzz - gxx * gyz * gyz gxz * gyy * gxz - gxy * gxy * gzz - gxx * gyz * gyz
gupxx = ( gyy * gzz - gyz * gyz ) / gupzz gupxx = ( gyy * gzz - gyz * gyz ) / gupzz
gupxy = - ( gxy * gzz - gyz * gxz ) / gupzz gupxy = - ( gxy * gzz - gyz * gxz ) / gupzz
gupxz = ( gxy * gyz - gyy * gxz ) / gupzz gupxz = ( gxy * gyz - gyy * gxz ) / gupzz
gupyy = ( gxx * gzz - gxz * gxz ) / gupzz gupyy = ( gxx * gzz - gxz * gxz ) / gupzz
gupyz = - ( gxx * gyz - gxy * gxz ) / gupzz gupyz = - ( gxx * gyz - gxy * gxz ) / gupzz
gupzz = ( gxx * gyy - gxy * gxy ) / gupzz gupzz = ( gxx * gyy - gxy * gxy ) / gupzz
call kind2_connection(ex, & call kind2_connection(ex, &
gupxx,gupxy,gupxz,gupyy,gupyz,gupzz, & gupxx,gupxy,gupxz,gupyy,gupyz,gupzz, &
ass_Gamxxx, ass_Gamxxy, ass_Gamxxz, ass_Gamxyy, ass_Gamxyz, ass_Gamxzz, & ass_Gamxxx, ass_Gamxxy, ass_Gamxxz, ass_Gamxyy, ass_Gamxyz, ass_Gamxzz, &
ass_Gamyxx, ass_Gamyxy, ass_Gamyxz, ass_Gamyyy, ass_Gamyyz, ass_Gamyzz, & ass_Gamyxx, ass_Gamyxy, ass_Gamyxz, ass_Gamyyy, ass_Gamyyz, ass_Gamyzz, &
ass_Gamzxx, ass_Gamzxy, ass_Gamzxz, ass_Gamzyy, ass_Gamzyz, ass_Gamzzz, & ass_Gamzxx, ass_Gamzxy, ass_Gamzxz, ass_Gamzyy, ass_Gamzyz, ass_Gamzzz, &
Gamxxx, Gamxxy, Gamxxz, Gamxyy, Gamxyz, Gamxzz, & Gamxxx, Gamxxy, Gamxxz, Gamxyy, Gamxyz, Gamxzz, &
Gamyxx, Gamyxy, Gamyxz, Gamyyy, Gamyyz, Gamyzz, & Gamyxx, Gamyxy, Gamyxz, Gamyyy, Gamyyz, Gamyzz, &
Gamzxx, Gamzxy, Gamzxz, Gamzyy, Gamzyz, Gamzzz) Gamzxx, Gamzxy, Gamzxz, Gamzyy, Gamzyz, Gamzzz)
call fdderivs_shc(ex,dxx,gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz,crho,sigma,R, SYM, SYM,SYM ,Symmetry,Lev,sst, & call fdderivs_shc(ex,dxx,gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz,crho,sigma,R, SYM, SYM,SYM ,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz) dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz)
call fdderivs_shc(ex,dyy,gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz,crho,sigma,R, SYM, SYM,SYM ,Symmetry,Lev,sst, & call fdderivs_shc(ex,dyy,gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz,crho,sigma,R, SYM, SYM,SYM ,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz) dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz)
call fdderivs_shc(ex,dzz,gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz,crho,sigma,R, SYM, SYM,SYM ,Symmetry,Lev,sst, & call fdderivs_shc(ex,dzz,gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz,crho,sigma,R, SYM, SYM,SYM ,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz) dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz)
call fdderivs_shc(ex,gxy,gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz,crho,sigma,R,ANTI,ANTI,SYM ,Symmetry,Lev,sst, & call fdderivs_shc(ex,gxy,gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz,crho,sigma,R,ANTI,ANTI,SYM ,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz) dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz)
call fdderivs_shc(ex,gxz,gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz,crho,sigma,R,ANTI,SYM ,ANTI,Symmetry,Lev,sst, & call fdderivs_shc(ex,gxz,gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz,crho,sigma,R,ANTI,SYM ,ANTI,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz) dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz)
call fdderivs_shc(ex,gyz,gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz,crho,sigma,R,SYM ,ANTI,ANTI,Symmetry,Lev,sst, & call fdderivs_shc(ex,gyz,gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz,crho,sigma,R,SYM ,ANTI,ANTI,Symmetry,Lev,sst, &
drhodx, drhody, drhodz, & drhodx, drhody, drhodz, &
dsigmadx,dsigmady,dsigmadz, & dsigmadx,dsigmady,dsigmadz, &
dRdx,dRdy,dRdz, & dRdx,dRdy,dRdz, &
drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, & drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz, &
dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, & dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz, &
dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz) dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz)
call adm_riemann(ex, & call adm_riemann(ex, &
gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz, & gxxxx,gxxxy,gxxxz,gxxyy,gxxyz,gxxzz, &
gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz, & gxyxx,gxyxy,gxyxz,gxyyy,gxyyz,gxyzz, &
gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz, & gxzxx,gxzxy,gxzxz,gxzyy,gxzyz,gxzzz, &
gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz, & gyyxx,gyyxy,gyyxz,gyyyy,gyyyz,gyyzz, &
gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz, & gyzxx,gyzxy,gyzxz,gyzyy,gyzyz,gyzzz, &
gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz, & gzzxx,gzzxy,gzzxz,gzzyy,gzzyz,gzzzz, &
Gamxxx, Gamxxy, Gamxxz, Gamxyy, Gamxyz, Gamxzz, & Gamxxx, Gamxxy, Gamxxz, Gamxyy, Gamxyz, Gamxzz, &
Gamyxx, Gamyxy, Gamyxz, Gamyyy, Gamyyz, Gamyzz, & Gamyxx, Gamyxy, Gamyxz, Gamyyy, Gamyyz, Gamyzz, &
Gamzxx, Gamzxy, Gamzxz, Gamzyy, Gamzyz, Gamzzz, & Gamzxx, Gamzxy, Gamzxz, Gamzyy, Gamzyz, Gamzzz, &
ass_Gamxxx,ass_Gamxxy,ass_Gamxxz, ass_Gamxyy,ass_Gamxyz,ass_Gamxzz, & ass_Gamxxx,ass_Gamxxy,ass_Gamxxz, ass_Gamxyy,ass_Gamxyz,ass_Gamxzz, &
ass_Gamyxx,ass_Gamyxy,ass_Gamyxz, ass_Gamyyy,ass_Gamyyz,ass_Gamyzz, & ass_Gamyxx,ass_Gamyxy,ass_Gamyxz, ass_Gamyyy,ass_Gamyyz,ass_Gamyzz, &
ass_Gamzxx,ass_Gamzxy,ass_Gamzxz, ass_Gamzyy,ass_Gamzyz,ass_Gamzzz, & ass_Gamzxx,ass_Gamzxy,ass_Gamzxz, ass_Gamzyy,ass_Gamzyz,ass_Gamzzz, &
Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz) Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz)
call adm_ricci(ex, & call adm_ricci(ex, &
gupxx , gupxy , gupxz , gupyy , gupyz , gupzz , & gupxx , gupxy , gupxz , gupyy , gupyz , gupzz , &
Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz, & Rxyxy, Rxyxz, Rxyyz, Rxzxz, Rxzyz, Ryzyz, &
Rxx , Rxy , Rxz , Ryy , Ryz , Rzz) Rxx , Rxy , Rxz , Ryy , Ryz , Rzz)
return return
end subroutine adm_ricci_gamma_ss end subroutine adm_ricci_gamma_ss

View File

@@ -1,186 +1,186 @@
#include <assert.h> #include <assert.h>
#include <stddef.h> // NULL #include <stddef.h> // NULL
#include <stdlib.h> // size_t #include <stdlib.h> // size_t
#include "cctk.h" #include "cctk.h"
#include "stdc.h" #include "stdc.h"
#include "util.h" #include "util.h"
#include "array.h" #include "array.h"
namespace AHFinderDirect namespace AHFinderDirect
{ {
namespace jtutil namespace jtutil
{ {
template <typename T> template <typename T>
array1d<T>::array1d(int min_i_in, int max_i_in, array1d<T>::array1d(int min_i_in, int max_i_in,
T *array_in /* = NULL */, T *array_in /* = NULL */,
int stride_i_in /* = 0 */) int stride_i_in /* = 0 */)
: array_(array_in), : array_(array_in),
offset_(0), // temp value, changed below offset_(0), // temp value, changed below
stride_i_(stride_i_in), stride_i_(stride_i_in),
min_i_(min_i_in), max_i_(max_i_in), min_i_(min_i_in), max_i_(max_i_in),
we_own_array_(array_in == NULL) we_own_array_(array_in == NULL)
{ {
if (stride_i_ == 0) if (stride_i_ == 0)
then stride_i_ = 1; then stride_i_ = 1;
// must use unchecked subscripting here since setup isn't done yet // must use unchecked subscripting here since setup isn't done yet
offset_ = -subscript_unchecked(min_i_); // RHS uses offset_ = 0 offset_ = -subscript_unchecked(min_i_); // RHS uses offset_ = 0
assert(subscript_unchecked(min_i_) == 0); assert(subscript_unchecked(min_i_) == 0);
max_subscript_ = subscript_unchecked(max_i_); max_subscript_ = subscript_unchecked(max_i_);
if (we_own_array_) if (we_own_array_)
then then
{ {
// allocate it // allocate it
const int N_allocate = N_i(); const int N_allocate = N_i();
array_ = new T[N_allocate]; array_ = new T[N_allocate];
} }
// explicitly initialize array (new[] *doesn't* do this automagically) // explicitly initialize array (new[] *doesn't* do this automagically)
for (int i = min_i(); i <= max_i(); ++i) for (int i = min_i(); i <= max_i(); ++i)
{ {
operator()(i) = T(0); operator()(i) = T(0);
} }
} }
// //
// This function destroys an array1d object. // This function destroys an array1d object.
// //
template <typename T> template <typename T>
array1d<T>::~array1d() array1d<T>::~array1d()
{ {
if (we_own_array_) if (we_own_array_)
then delete[] array_; then delete[] array_;
} }
// //
// This function constructs an array2d object. // This function constructs an array2d object.
// //
template <typename T> template <typename T>
array2d<T>::array2d(int min_i_in, int max_i_in, array2d<T>::array2d(int min_i_in, int max_i_in,
int min_j_in, int max_j_in, int min_j_in, int max_j_in,
T *array_in /* = NULL */, T *array_in /* = NULL */,
int stride_i_in /* = 0 */, int stride_j_in /* = 0 */) int stride_i_in /* = 0 */, int stride_j_in /* = 0 */)
: array_(array_in), : array_(array_in),
offset_(0), // temp value, changed below offset_(0), // temp value, changed below
stride_i_(stride_i_in), stride_j_(stride_j_in), stride_i_(stride_i_in), stride_j_(stride_j_in),
min_i_(min_i_in), max_i_(max_i_in), min_i_(min_i_in), max_i_(max_i_in),
min_j_(min_j_in), max_j_(max_j_in), min_j_(min_j_in), max_j_(max_j_in),
we_own_array_(array_in == NULL) we_own_array_(array_in == NULL)
{ {
if (stride_j_ == 0) if (stride_j_ == 0)
then stride_j_ = 1; then stride_j_ = 1;
if (stride_i_ == 0) if (stride_i_ == 0)
then stride_i_ = N_j(); then stride_i_ = N_j();
// must use unchecked subscripting here since setup isn't done yet // must use unchecked subscripting here since setup isn't done yet
offset_ = -subscript_unchecked(min_i_, min_j_); // RHS uses offset_ = 0 offset_ = -subscript_unchecked(min_i_, min_j_); // RHS uses offset_ = 0
assert(subscript_unchecked(min_i_, min_j_) == 0); assert(subscript_unchecked(min_i_, min_j_) == 0);
max_subscript_ = subscript_unchecked(max_i_, max_j_); max_subscript_ = subscript_unchecked(max_i_, max_j_);
if (we_own_array_) if (we_own_array_)
then then
{ {
// allocate it // allocate it
const int N_allocate = N_i() * N_j(); const int N_allocate = N_i() * N_j();
array_ = new T[N_allocate]; array_ = new T[N_allocate];
} }
// explicitly initialize array (new[] *doesn't* do this automagically) // explicitly initialize array (new[] *doesn't* do this automagically)
for (int i = min_i(); i <= max_i(); ++i) for (int i = min_i(); i <= max_i(); ++i)
{ {
for (int j = min_j(); j <= max_j(); ++j) for (int j = min_j(); j <= max_j(); ++j)
{ {
operator()(i, j) = T(0); operator()(i, j) = T(0);
} }
} }
} }
// //
// This function destroys an array2d object. // This function destroys an array2d object.
// //
template <typename T> template <typename T>
array2d<T>::~array2d() array2d<T>::~array2d()
{ {
if (we_own_array_) if (we_own_array_)
then delete[] array_; then delete[] array_;
} }
// //
// This function constructs an array3d object. // This function constructs an array3d object.
// //
template <typename T> template <typename T>
array3d<T>::array3d(int min_i_in, int max_i_in, array3d<T>::array3d(int min_i_in, int max_i_in,
int min_j_in, int max_j_in, int min_j_in, int max_j_in,
int min_k_in, int max_k_in, int min_k_in, int max_k_in,
T *array_in /* = NULL */, T *array_in /* = NULL */,
int stride_i_in /* = 0 */, int stride_j_in /* = 0 */, int stride_i_in /* = 0 */, int stride_j_in /* = 0 */,
int stride_k_in /* = 0 */) int stride_k_in /* = 0 */)
: array_(array_in), : array_(array_in),
offset_(0), // temp value, changed below offset_(0), // temp value, changed below
stride_i_(stride_i_in), stride_j_(stride_j_in), stride_i_(stride_i_in), stride_j_(stride_j_in),
stride_k_(stride_k_in), stride_k_(stride_k_in),
min_i_(min_i_in), max_i_(max_i_in), min_i_(min_i_in), max_i_(max_i_in),
min_j_(min_j_in), max_j_(max_j_in), min_j_(min_j_in), max_j_(max_j_in),
min_k_(min_k_in), max_k_(max_k_in), min_k_(min_k_in), max_k_(max_k_in),
we_own_array_(array_in == NULL) we_own_array_(array_in == NULL)
{ {
if (stride_k_ == 0) if (stride_k_ == 0)
then stride_k_ = 1; then stride_k_ = 1;
if (stride_j_ == 0) if (stride_j_ == 0)
then stride_j_ = N_k(); then stride_j_ = N_k();
if (stride_i_ == 0) if (stride_i_ == 0)
then stride_i_ = N_j() * N_k(); then stride_i_ = N_j() * N_k();
// must use unchecked subscripting here since setup isn't done yet // must use unchecked subscripting here since setup isn't done yet
offset_ = -subscript_unchecked(min_i_, min_j_, min_k_); // RHS uses offset_ = 0 offset_ = -subscript_unchecked(min_i_, min_j_, min_k_); // RHS uses offset_ = 0
assert(subscript_unchecked(min_i_, min_j_, min_k_) == 0); assert(subscript_unchecked(min_i_, min_j_, min_k_) == 0);
max_subscript_ = subscript_unchecked(max_i_, max_j_, max_k_); max_subscript_ = subscript_unchecked(max_i_, max_j_, max_k_);
if (we_own_array_) if (we_own_array_)
then then
{ {
// allocate it // allocate it
const int N_allocate = N_i() * N_j() * N_k(); const int N_allocate = N_i() * N_j() * N_k();
array_ = new T[N_allocate]; array_ = new T[N_allocate];
} }
// explicitly initialize array (new[] *doesn't* do this automagically) // explicitly initialize array (new[] *doesn't* do this automagically)
for (int i = min_i(); i <= max_i(); ++i) for (int i = min_i(); i <= max_i(); ++i)
{ {
for (int j = min_j(); j <= max_j(); ++j) for (int j = min_j(); j <= max_j(); ++j)
{ {
for (int k = min_k(); k <= max_k(); ++k) for (int k = min_k(); k <= max_k(); ++k)
{ {
operator()(i, j, k) = T(0); operator()(i, j, k) = T(0);
} }
} }
} }
} }
// //
// This function destroys an array3d object. // This function destroys an array3d object.
// //
template <typename T> template <typename T>
array3d<T>::~array3d() array3d<T>::~array3d()
{ {
if (we_own_array_) if (we_own_array_)
then delete[] array_; then delete[] array_;
} }
template class array1d<int>; template class array1d<int>;
// FIXME: we shouldn't have to instantiate these both, the const one // FIXME: we shouldn't have to instantiate these both, the const one
// is actually trivially derivable from the non-const one. :( // is actually trivially derivable from the non-const one. :(
template class array1d<void *>; template class array1d<void *>;
template class array1d<const void *>; template class array1d<const void *>;
template class array1d<CCTK_REAL>; template class array1d<CCTK_REAL>;
template class array2d<CCTK_INT>; template class array2d<CCTK_INT>;
template class array2d<CCTK_REAL>; template class array2d<CCTK_REAL>;
template class array3d<CCTK_REAL>; template class array3d<CCTK_REAL>;
} // namespace jtutil } // namespace jtutil
} // namespace AHFinderDirect } // namespace AHFinderDirect

View File

@@ -1,292 +1,292 @@
#ifndef AHFINDERDIRECT__ARRAY_HH #ifndef AHFINDERDIRECT__ARRAY_HH
#define AHFINDERDIRECT__ARRAY_HH #define AHFINDERDIRECT__ARRAY_HH
namespace AHFinderDirect namespace AHFinderDirect
{ {
namespace jtutil namespace jtutil
{ {
//****************************************************************************** //******************************************************************************
template <typename T> template <typename T>
class array1d class array1d
{ {
public: public:
int min_i() const { return min_i_; } int min_i() const { return min_i_; }
int max_i() const { return max_i_; } int max_i() const { return max_i_; }
int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); } int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); } bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
int subscript_unchecked(int i) const int subscript_unchecked(int i) const
{ {
return offset_ + stride_i_ * i; return offset_ + stride_i_ * i;
} }
int subscript(int i) const int subscript(int i) const
{ {
assert(is_valid_i(i)); assert(is_valid_i(i));
const int posn = subscript_unchecked(i); const int posn = subscript_unchecked(i);
assert(posn >= 0); assert(posn >= 0);
assert(posn <= max_subscript_); assert(posn <= max_subscript_);
return posn; return posn;
} }
int subscript_offset() const { return offset_; } int subscript_offset() const { return offset_; }
int subscript_stride_i() const { return stride_i_; } int subscript_stride_i() const { return stride_i_; }
// normal-use access functions // normal-use access functions
// ... rvalue // ... rvalue
const T &operator()(int i) const { return array_[subscript(i)]; } const T &operator()(int i) const { return array_[subscript(i)]; }
// ... lvalue // ... lvalue
T &operator()(int i) { return array_[subscript(i)]; } T &operator()(int i) { return array_[subscript(i)]; }
// get access to internal 0-origin 1D storage array // get access to internal 0-origin 1D storage array
// (low-level, dangerous, use with caution!) // (low-level, dangerous, use with caution!)
// ... semantics of N_array() may not be what you want // ... semantics of N_array() may not be what you want
// if strides specify noncontiguous storage // if strides specify noncontiguous storage
int N_array() const { return max_subscript_ + stride_i_; } int N_array() const { return max_subscript_ + stride_i_; }
const T *data_array() const { return const_cast<const T *>(array_); } const T *data_array() const { return const_cast<const T *>(array_); }
T *data_array() { return array_; } T *data_array() { return array_; }
// constructor, destructor // constructor, destructor
// ... constructor initializes all array elements to T(0.0) // ... constructor initializes all array elements to T(0.0)
// ... omitted strides default to C storage order // ... omitted strides default to C storage order
array1d(int min_i_in, int max_i_in, array1d(int min_i_in, int max_i_in,
T *array_in = NULL, // caller-provided storage array T *array_in = NULL, // caller-provided storage array
// if non-NULL // if non-NULL
int stride_i_in = 0); int stride_i_in = 0);
~array1d(); ~array1d();
private: private:
// we forbid copying and passing by value // we forbid copying and passing by value
// by declaring the copy constructor and assignment operator // by declaring the copy constructor and assignment operator
// private, but never defining them // private, but never defining them
array1d(const array1d<T> &rhs); array1d(const array1d<T> &rhs);
array1d<T> &operator=(const array1d<T> &rhs); array1d<T> &operator=(const array1d<T> &rhs);
private: private:
// n.b. we declare the array pointer first in the class // n.b. we declare the array pointer first in the class
// ==> it's probably at 0 offset // ==> it's probably at 0 offset
// ==> we may get slightly faster array access // ==> we may get slightly faster array access
T *array_; // --> new-allocated 1D storage array T *array_; // --> new-allocated 1D storage array
// subscripting info // subscripting info
// n.b. put this next in class so it should be in the same // n.b. put this next in class so it should be in the same
// cpu cache line as array_ ==> faster array access // cpu cache line as array_ ==> faster array access
int offset_, stride_i_; int offset_, stride_i_;
// min/max array bounds // min/max array bounds
const int min_i_, max_i_; const int min_i_, max_i_;
int max_subscript_; int max_subscript_;
// n.b. put this at end of class since performance doesn't matter // n.b. put this at end of class since performance doesn't matter
bool we_own_array_; // true ==> array_ --> new[] array which we own bool we_own_array_; // true ==> array_ --> new[] array which we own
// false ==> array_ --> client-owned storage // false ==> array_ --> client-owned storage
}; };
//****************************************************************************** //******************************************************************************
template <typename T> template <typename T>
class array2d class array2d
{ {
public: public:
// array info // array info
int min_i() const { return min_i_; } int min_i() const { return min_i_; }
int max_i() const { return max_i_; } int max_i() const { return max_i_; }
int min_j() const { return min_j_; } int min_j() const { return min_j_; }
int max_j() const { return max_j_; } int max_j() const { return max_j_; }
int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); } int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); } int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); }
bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); } bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); } bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); }
bool is_valid_ij(int i, int j) const bool is_valid_ij(int i, int j) const
{ {
return is_valid_i(i) && is_valid_j(j); return is_valid_i(i) && is_valid_j(j);
} }
int subscript_unchecked(int i, int j) const int subscript_unchecked(int i, int j) const
{ {
return offset_ + stride_i_ * i + stride_j_ * j; return offset_ + stride_i_ * i + stride_j_ * j;
} }
int subscript(int i, int j) const int subscript(int i, int j) const
{ {
// n.b. we want each assert() here to be on a separate // n.b. we want each assert() here to be on a separate
// source line, so an assert() failure message can // source line, so an assert() failure message can
// pinpoint *which* index is bad // pinpoint *which* index is bad
assert(is_valid_i(i)); assert(is_valid_i(i));
assert(is_valid_j(j)); assert(is_valid_j(j));
const int posn = subscript_unchecked(i, j); const int posn = subscript_unchecked(i, j);
assert(posn >= 0); assert(posn >= 0);
assert(posn <= max_subscript_); assert(posn <= max_subscript_);
return posn; return posn;
} }
int subscript_offset() const { return offset_; } int subscript_offset() const { return offset_; }
int subscript_stride_i() const { return stride_i_; } int subscript_stride_i() const { return stride_i_; }
int subscript_stride_j() const { return stride_j_; } int subscript_stride_j() const { return stride_j_; }
// normal-use access functions // normal-use access functions
// ... rvalue // ... rvalue
const T &operator()(int i, int j) const const T &operator()(int i, int j) const
{ {
return array_[subscript(i, j)]; return array_[subscript(i, j)];
} }
// ... lvalue // ... lvalue
T &operator()(int i, int j) T &operator()(int i, int j)
{ {
return array_[subscript(i, j)]; return array_[subscript(i, j)];
} }
// get access to internal 0-origin 1D storage array // get access to internal 0-origin 1D storage array
// (low-level, dangerous, use with caution!) // (low-level, dangerous, use with caution!)
// ... semantics of N_array() may not be what you want // ... semantics of N_array() may not be what you want
// if strides specify noncontiguous storage // if strides specify noncontiguous storage
int N_array() const { return max_subscript_ + stride_j_; } int N_array() const { return max_subscript_ + stride_j_; }
const T *data_array() const { return const_cast<const T *>(array_); } const T *data_array() const { return const_cast<const T *>(array_); }
T *data_array() { return array_; } T *data_array() { return array_; }
// constructor, destructor // constructor, destructor
// ... constructor initializes all array elements to T(0.0) // ... constructor initializes all array elements to T(0.0)
// ... omitted strides default to C storage order // ... omitted strides default to C storage order
array2d(int min_i_in, int max_i_in, array2d(int min_i_in, int max_i_in,
int min_j_in, int max_j_in, int min_j_in, int max_j_in,
T *array_in = NULL, // caller-provided storage array T *array_in = NULL, // caller-provided storage array
// if non-NULL // if non-NULL
int stride_i_in = 0, int stride_j_in = 0); int stride_i_in = 0, int stride_j_in = 0);
~array2d(); ~array2d();
private: private:
// we forbid copying and passing by value // we forbid copying and passing by value
// by declaring the copy constructor and assignment operator // by declaring the copy constructor and assignment operator
// private, but never defining them // private, but never defining them
array2d(const array2d<T> &rhs); array2d(const array2d<T> &rhs);
array2d<T> &operator=(const array2d<T> &rhs); array2d<T> &operator=(const array2d<T> &rhs);
private: private:
// n.b. we declare the array pointer first in the class // n.b. we declare the array pointer first in the class
// ==> it's probably at 0 offset // ==> it's probably at 0 offset
// ==> we may get slightly faster array access // ==> we may get slightly faster array access
T *array_; // --> new-allocated 1D storage array T *array_; // --> new-allocated 1D storage array
// subscripting info // subscripting info
// n.b. put this next in class so it should be in the same // n.b. put this next in class so it should be in the same
// cpu cache line as array_ ==> faster array access // cpu cache line as array_ ==> faster array access
int offset_, stride_i_, stride_j_; int offset_, stride_i_, stride_j_;
// min/max array bounds // min/max array bounds
const int min_i_, max_i_; const int min_i_, max_i_;
const int min_j_, max_j_; const int min_j_, max_j_;
int max_subscript_; int max_subscript_;
// n.b. put this at end of class since performance doesn't matter // n.b. put this at end of class since performance doesn't matter
bool we_own_array_; // true ==> array_ --> new[] array which we own bool we_own_array_; // true ==> array_ --> new[] array which we own
// false ==> array_ --> client-owned storage // false ==> array_ --> client-owned storage
}; };
//****************************************************************************** //******************************************************************************
template <typename T> template <typename T>
class array3d class array3d
{ {
public: public:
// array info // array info
int min_i() const { return min_i_; } int min_i() const { return min_i_; }
int max_i() const { return max_i_; } int max_i() const { return max_i_; }
int min_j() const { return min_j_; } int min_j() const { return min_j_; }
int max_j() const { return max_j_; } int max_j() const { return max_j_; }
int min_k() const { return min_k_; } int min_k() const { return min_k_; }
int max_k() const { return max_k_; } int max_k() const { return max_k_; }
int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); } int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); } int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); }
int N_k() const { return jtutil::how_many_in_range(min_k_, max_k_); } int N_k() const { return jtutil::how_many_in_range(min_k_, max_k_); }
bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); } bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); } bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); }
bool is_valid_k(int k) const { return (k >= min_k_) && (k <= max_k_); } bool is_valid_k(int k) const { return (k >= min_k_) && (k <= max_k_); }
bool is_valid_ijk(int i, int j, int k) const bool is_valid_ijk(int i, int j, int k) const
{ {
return is_valid_i(i) && is_valid_j(j) && is_valid_k(k); return is_valid_i(i) && is_valid_j(j) && is_valid_k(k);
} }
int subscript_unchecked(int i, int j, int k) const int subscript_unchecked(int i, int j, int k) const
{ {
return offset_ + stride_i_ * i + stride_j_ * j + stride_k_ * k; return offset_ + stride_i_ * i + stride_j_ * j + stride_k_ * k;
} }
int subscript(int i, int j, int k) const int subscript(int i, int j, int k) const
{ {
// n.b. we want each assert() here to be on a separate // n.b. we want each assert() here to be on a separate
// source line, so an assert() failure message can // source line, so an assert() failure message can
// pinpoint *which* index is bad // pinpoint *which* index is bad
assert(is_valid_i(i)); assert(is_valid_i(i));
assert(is_valid_j(j)); assert(is_valid_j(j));
assert(is_valid_k(k)); assert(is_valid_k(k));
const int posn = subscript_unchecked(i, j, k); const int posn = subscript_unchecked(i, j, k);
assert(posn >= 0); assert(posn >= 0);
assert(posn <= max_subscript_); assert(posn <= max_subscript_);
return posn; return posn;
} }
int subscript_offset() const { return offset_; } int subscript_offset() const { return offset_; }
int subscript_stride_i() const { return stride_i_; } int subscript_stride_i() const { return stride_i_; }
int subscript_stride_j() const { return stride_j_; } int subscript_stride_j() const { return stride_j_; }
int subscript_stride_k() const { return stride_k_; } int subscript_stride_k() const { return stride_k_; }
// normal-use access functions // normal-use access functions
// ... rvalue // ... rvalue
const T &operator()(int i, int j, int k) const const T &operator()(int i, int j, int k) const
{ {
return array_[subscript(i, j, k)]; return array_[subscript(i, j, k)];
} }
// ... lvalue // ... lvalue
T &operator()(int i, int j, int k) T &operator()(int i, int j, int k)
{ {
return array_[subscript(i, j, k)]; return array_[subscript(i, j, k)];
} }
// get access to internal 0-origin 1D storage array // get access to internal 0-origin 1D storage array
// (low-level, dangerous, use with caution!) // (low-level, dangerous, use with caution!)
// ... semantics of N_array() may not be what you want // ... semantics of N_array() may not be what you want
// if strides specify noncontiguous storage // if strides specify noncontiguous storage
int N_array() const { return max_subscript_ + stride_k_; } int N_array() const { return max_subscript_ + stride_k_; }
const T *data_array() const { return const_cast<const T *>(array_); } const T *data_array() const { return const_cast<const T *>(array_); }
T *data_array() { return array_; } T *data_array() { return array_; }
// constructor, destructor // constructor, destructor
// ... constructor initializes all array elements to T(0.0) // ... constructor initializes all array elements to T(0.0)
// ... omitted strides default to C storage order // ... omitted strides default to C storage order
array3d(int min_i_in, int max_i_in, array3d(int min_i_in, int max_i_in,
int min_j_in, int max_j_in, int min_j_in, int max_j_in,
int min_k_in, int max_k_in, int min_k_in, int max_k_in,
T *array_in = NULL, // caller-provided storage array T *array_in = NULL, // caller-provided storage array
// if non-NULL // if non-NULL
int stride_i_in = 0, int stride_j_in = 0, int stride_k_in = 0); int stride_i_in = 0, int stride_j_in = 0, int stride_k_in = 0);
~array3d(); ~array3d();
private: private:
// we forbid copying and passing by value // we forbid copying and passing by value
// by declaring the copy constructor and assignment operator // by declaring the copy constructor and assignment operator
// private, but never defining them // private, but never defining them
array3d(const array3d<T> &rhs); array3d(const array3d<T> &rhs);
array3d<T> &operator=(const array3d<T> &rhs); array3d<T> &operator=(const array3d<T> &rhs);
private: private:
// n.b. we declare the array pointer first in the class // n.b. we declare the array pointer first in the class
// ==> it's probably at 0 offset // ==> it's probably at 0 offset
// ==> we may get slightly faster array access // ==> we may get slightly faster array access
T *array_; // --> new-allocated 1D storage array T *array_; // --> new-allocated 1D storage array
// subscripting info // subscripting info
// n.b. put this next in class so it should be in the same // n.b. put this next in class so it should be in the same
// cpu cache line as array_ ==> faster array access // cpu cache line as array_ ==> faster array access
int offset_, stride_i_, stride_j_, stride_k_; int offset_, stride_i_, stride_j_, stride_k_;
// min/max array bounds // min/max array bounds
const int min_i_, max_i_; const int min_i_, max_i_;
const int min_j_, max_j_; const int min_j_, max_j_;
const int min_k_, max_k_; const int min_k_, max_k_;
int max_subscript_; int max_subscript_;
// n.b. put this at end of class since performance doesn't matter // n.b. put this at end of class since performance doesn't matter
bool we_own_array_; // true ==> array_ --> new[] array which we own bool we_own_array_; // true ==> array_ --> new[] array which we own
// false ==> array_ --> client-owned storage // false ==> array_ --> client-owned storage
}; };
} // namespace jtutil } // namespace jtutil
} // namespace AHFinderDirect } // namespace AHFinderDirect
#endif /* AHFINDERDIRECT__ARRAY_HH */ #endif /* AHFINDERDIRECT__ARRAY_HH */

View File

@@ -1,40 +1,40 @@
!-------------------------------------------------------------------------------! !-------------------------------------------------------------------------------!
! convert bssn variables to ADM variables ! ! convert bssn variables to ADM variables !
!-------------------------------------------------------------------------------! !-------------------------------------------------------------------------------!
subroutine bssn2adm(ex,chi,trK, & subroutine bssn2adm(ex,chi,trK, &
gxx,gxy,gxz,gyy,gyz,gzz, & gxx,gxy,gxz,gyy,gyz,gzz, &
Axx,Axy,Axz,Ayy,Ayz,Azz, & Axx,Axy,Axz,Ayy,Ayz,Azz, &
adm_gxx,adm_gxy,adm_gxz,adm_gyy,adm_gyz,adm_gzz, & adm_gxx,adm_gxy,adm_gxz,adm_gyy,adm_gyz,adm_gzz, &
Kxx,Kxy,Kxz,Kyy,Kyz,Kzz) Kxx,Kxy,Kxz,Kyy,Kyz,Kzz)
implicit none implicit none
!~~~~~~> Input parameters: !~~~~~~> Input parameters:
integer,intent(in ):: ex(1:3) integer,intent(in ):: ex(1:3)
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::chi,trK double precision,intent(in),dimension(ex(1),ex(2),ex(3))::chi,trK
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::gxx,gxy,gxz,gyy,gyz,gzz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::gxx,gxy,gxz,gyy,gyz,gzz
double precision,intent(in),dimension(ex(1),ex(2),ex(3))::Axx,Axy,Axz,Ayy,Ayz,Azz double precision,intent(in),dimension(ex(1),ex(2),ex(3))::Axx,Axy,Axz,Ayy,Ayz,Azz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: adm_gxx,adm_gxy,adm_gxz,adm_gyy,adm_gyz,adm_gzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: adm_gxx,adm_gxy,adm_gxz,adm_gyy,adm_gyz,adm_gzz
real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Kxx,Kxy,Kxz,Kyy,Kyz,Kzz real*8, dimension(ex(1),ex(2),ex(3)),intent(out) :: Kxx,Kxy,Kxz,Kyy,Kyz,Kzz
real*8, parameter :: F1o3=1.d0/3.d0 real*8, parameter :: F1o3=1.d0/3.d0
adm_gxx = gxx/chi adm_gxx = gxx/chi
adm_gxy = gxy/chi adm_gxy = gxy/chi
adm_gxz = gxz/chi adm_gxz = gxz/chi
adm_gyy = gyy/chi adm_gyy = gyy/chi
adm_gyz = gyz/chi adm_gyz = gyz/chi
adm_gzz = gzz/chi adm_gzz = gzz/chi
Kxx = Axx/chi+F1o3*trK*adm_gxx Kxx = Axx/chi+F1o3*trK*adm_gxx
Kxy = Axy/chi+F1o3*trK*adm_gxy Kxy = Axy/chi+F1o3*trK*adm_gxy
Kxz = Axz/chi+F1o3*trK*adm_gxz Kxz = Axz/chi+F1o3*trK*adm_gxz
Kyy = Ayy/chi+F1o3*trK*adm_gyy Kyy = Ayy/chi+F1o3*trK*adm_gyy
Kyz = Ayz/chi+F1o3*trK*adm_gyz Kyz = Ayz/chi+F1o3*trK*adm_gyz
Kzz = Azz/chi+F1o3*trK*adm_gzz Kzz = Azz/chi+F1o3*trK*adm_gzz
return return
end subroutine bssn2adm end subroutine bssn2adm

View File

@@ -1,69 +1,69 @@
#ifndef BSSNEM_CLASS_H #ifndef BSSNEM_CLASS_H
#define BSSNEM_CLASS_H #define BSSNEM_CLASS_H
#ifdef newc #ifdef newc
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <cmath> #include <cmath>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <fstream.h> #include <fstream.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#endif #endif
#include <mpi.h> #include <mpi.h>
#include "cgh.h" #include "cgh.h"
#include "ShellPatch.h" #include "ShellPatch.h"
#include "misc.h" #include "misc.h"
#include "var.h" #include "var.h"
#include "MyList.h" #include "MyList.h"
#include "monitor.h" #include "monitor.h"
#include "surface_integral.h" #include "surface_integral.h"
#include "macrodef.h" #include "macrodef.h"
#ifdef USE_GPU #ifdef USE_GPU
#include "bssn_gpu_class.h" #include "bssn_gpu_class.h"
#else #else
#include "bssn_class.h" #include "bssn_class.h"
#endif #endif
class bssnEM_class : public bssn_class class bssnEM_class : public bssn_class
{ {
public: public:
bssnEM_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei, bssnEM_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei,
int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi, int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi,
int a_levi, int maxli, int decni, double maxrexi, double drexi); int a_levi, int maxli, int decni, double maxrexi, double drexi);
~bssnEM_class(); ~bssnEM_class();
void Initialize(); void Initialize();
void Read_Ansorg(); void Read_Ansorg();
void Setup_Initial_Data(); void Setup_Initial_Data();
void Step(int lev, int YN); void Step(int lev, int YN);
void Compute_Phi2(int lev); void Compute_Phi2(int lev);
void AnalysisStuff_EM(int lev, double dT_lev); void AnalysisStuff_EM(int lev, double dT_lev);
void Interp_Constraint(); void Interp_Constraint();
protected: protected:
var *Exo, *Eyo, *Ezo, *Bxo, *Byo, *Bzo, *Kpsio, *Kphio; var *Exo, *Eyo, *Ezo, *Bxo, *Byo, *Bzo, *Kpsio, *Kphio;
var *Ex0, *Ey0, *Ez0, *Bx0, *By0, *Bz0, *Kpsi0, *Kphi0; var *Ex0, *Ey0, *Ez0, *Bx0, *By0, *Bz0, *Kpsi0, *Kphi0;
var *Ex, *Ey, *Ez, *Bx, *By, *Bz, *Kpsi, *Kphi; var *Ex, *Ey, *Ez, *Bx, *By, *Bz, *Kpsi, *Kphi;
var *Ex1, *Ey1, *Ez1, *Bx1, *By1, *Bz1, *Kpsi1, *Kphi1; var *Ex1, *Ey1, *Ez1, *Bx1, *By1, *Bz1, *Kpsi1, *Kphi1;
var *Ex_rhs, *Ey_rhs, *Ez_rhs, *Bx_rhs, *By_rhs, *Bz_rhs, *Kpsi_rhs, *Kphi_rhs; var *Ex_rhs, *Ey_rhs, *Ez_rhs, *Bx_rhs, *By_rhs, *Bz_rhs, *Kpsi_rhs, *Kphi_rhs;
var *Jx, *Jy, *Jz, *qchar; var *Jx, *Jy, *Jz, *qchar;
var *Rphi2, *Iphi2; var *Rphi2, *Iphi2;
var *Rphi1, *Iphi1; var *Rphi1, *Iphi1;
monitor *Phi2Monitor; monitor *Phi2Monitor;
monitor *Phi1Monitor; monitor *Phi1Monitor;
}; };
#endif /* BSSNEM_CLASS_H */ #endif /* BSSNEM_CLASS_H */

View File

@@ -1,70 +1,70 @@
#ifndef BSSNESCALAR_CLASS_H #ifndef BSSNESCALAR_CLASS_H
#define BSSNESCALAR_CLASS_H #define BSSNESCALAR_CLASS_H
#ifdef newc #ifdef newc
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <cmath> #include <cmath>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <fstream.h> #include <fstream.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#endif #endif
#include <mpi.h> #include <mpi.h>
#include "cgh.h" #include "cgh.h"
#include "ShellPatch.h" #include "ShellPatch.h"
#include "misc.h" #include "misc.h"
#include "var.h" #include "var.h"
#include "MyList.h" #include "MyList.h"
#include "monitor.h" #include "monitor.h"
#include "surface_integral.h" #include "surface_integral.h"
#include "macrodef.h" #include "macrodef.h"
#ifdef USE_GPU #ifdef USE_GPU
#include "bssn_gpu_class.h" #include "bssn_gpu_class.h"
#else #else
#include "bssn_class.h" #include "bssn_class.h"
#endif #endif
class bssnEScalar_class : public bssn_class class bssnEScalar_class : public bssn_class
{ {
public: public:
bssnEScalar_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei, bssnEScalar_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei,
int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi, int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi,
int a_levi, int maxli, int decni, double maxrexi, double drexi); int a_levi, int maxli, int decni, double maxrexi, double drexi);
~bssnEScalar_class(); ~bssnEScalar_class();
void Initialize(); void Initialize();
void Read_Ansorg(); void Read_Ansorg();
void Read_Pablo(); void Read_Pablo();
void Compute_Psi4(int lev); void Compute_Psi4(int lev);
void Step(int lev, int YN); void Step(int lev, int YN);
void AnalysisStuff_EScalar(int lev, double dT_lev); void AnalysisStuff_EScalar(int lev, double dT_lev);
void Interp_Constraint(); void Interp_Constraint();
void Constraint_Out(); void Constraint_Out();
protected: protected:
var *Sphio, *Spio; var *Sphio, *Spio;
var *Sphi0, *Spi0; var *Sphi0, *Spi0;
var *Sphi, *Spi; var *Sphi, *Spi;
var *Sphi1, *Spi1; var *Sphi1, *Spi1;
var *Sphi_rhs, *Spi_rhs; var *Sphi_rhs, *Spi_rhs;
var *Cons_fR; var *Cons_fR;
monitor *MaxScalar_Monitor; monitor *MaxScalar_Monitor;
}; };
#endif /* BSSNESCALAR_CLASS_H */ #endif /* BSSNESCALAR_CLASS_H */

View File

@@ -1,206 +1,207 @@
#ifndef BSSN_CLASS_H #ifndef BSSN_CLASS_H
#define BSSN_CLASS_H #define BSSN_CLASS_H
#ifdef newc #ifdef newc
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <cmath> #include <cmath>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <fstream.h> #include <fstream.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#endif #endif
#include <mpi.h> #include <mpi.h>
#include "macrodef.h" #include "macrodef.h"
#include "cgh.h" #include "cgh.h"
#include "ShellPatch.h" #include "ShellPatch.h"
#include "misc.h" #include "misc.h"
#include "var.h" #include "var.h"
#include "MyList.h" #include "MyList.h"
#include "monitor.h" #include "monitor.h"
#include "surface_integral.h" #include "surface_integral.h"
#include "checkpoint.h" #include "checkpoint.h"
extern void setpbh(int iBHN, double **iPBH, double *iMass, int rBHN); extern void setpbh(int iBHN, double **iPBH, double *iMass, int rBHN);
class bssn_class class bssn_class
{ {
public: public:
int ngfs; int ngfs;
int nprocs, myrank; int nprocs, myrank;
cgh *GH; cgh *GH;
ShellPatch *SH; ShellPatch *SH;
double PhysTime; double PhysTime;
int checkrun; int checkrun;
char checkfilename[50]; char checkfilename[50];
int Steps; int Steps;
double StartTime, TotalTime; double StartTime, TotalTime;
double AnasTime, DumpTime, d2DumpTime, CheckTime; double AnasTime, DumpTime, d2DumpTime, CheckTime;
double LastAnas, LastConsOut; double LastAnas, LastConsOut;
bool cuda_level0_constraint_cache_valid;
int *ConstraintRefreshLevels; int *ConstraintRefreshLevels;
double Courant; double Courant;
double numepss, numepsb, numepsh; double numepss, numepsb, numepsh;
int Symmetry; int Symmetry;
int maxl, decn; int maxl, decn;
double maxrex, drex; double maxrex, drex;
int trfls, a_lev; int trfls, a_lev;
double dT; double dT;
double chitiny; double chitiny;
double **Porg0, **Porgbr, **Porg, **Porg1, **Porg_rhs; double **Porg0, **Porgbr, **Porg, **Porg1, **Porg_rhs;
int BH_num, BH_num_input; int BH_num, BH_num_input;
double *Mass, *Pmom, *Spin; double *Mass, *Pmom, *Spin;
double ADMMass; double ADMMass;
var *phio, *trKo; var *phio, *trKo;
var *gxxo, *gxyo, *gxzo, *gyyo, *gyzo, *gzzo; var *gxxo, *gxyo, *gxzo, *gyyo, *gyzo, *gzzo;
var *Axxo, *Axyo, *Axzo, *Ayyo, *Ayzo, *Azzo; var *Axxo, *Axyo, *Axzo, *Ayyo, *Ayzo, *Azzo;
var *Gmxo, *Gmyo, *Gmzo; var *Gmxo, *Gmyo, *Gmzo;
var *Lapo, *Sfxo, *Sfyo, *Sfzo; var *Lapo, *Sfxo, *Sfyo, *Sfzo;
var *dtSfxo, *dtSfyo, *dtSfzo; var *dtSfxo, *dtSfyo, *dtSfzo;
var *phi0, *trK0; var *phi0, *trK0;
var *gxx0, *gxy0, *gxz0, *gyy0, *gyz0, *gzz0; var *gxx0, *gxy0, *gxz0, *gyy0, *gyz0, *gzz0;
var *Axx0, *Axy0, *Axz0, *Ayy0, *Ayz0, *Azz0; var *Axx0, *Axy0, *Axz0, *Ayy0, *Ayz0, *Azz0;
var *Gmx0, *Gmy0, *Gmz0; var *Gmx0, *Gmy0, *Gmz0;
var *Lap0, *Sfx0, *Sfy0, *Sfz0; var *Lap0, *Sfx0, *Sfy0, *Sfz0;
var *dtSfx0, *dtSfy0, *dtSfz0; var *dtSfx0, *dtSfy0, *dtSfz0;
var *phi, *trK; var *phi, *trK;
var *gxx, *gxy, *gxz, *gyy, *gyz, *gzz; var *gxx, *gxy, *gxz, *gyy, *gyz, *gzz;
var *Axx, *Axy, *Axz, *Ayy, *Ayz, *Azz; var *Axx, *Axy, *Axz, *Ayy, *Ayz, *Azz;
var *Gmx, *Gmy, *Gmz; var *Gmx, *Gmy, *Gmz;
var *Lap, *Sfx, *Sfy, *Sfz; var *Lap, *Sfx, *Sfy, *Sfz;
var *dtSfx, *dtSfy, *dtSfz; var *dtSfx, *dtSfy, *dtSfz;
var *phi1, *trK1; var *phi1, *trK1;
var *gxx1, *gxy1, *gxz1, *gyy1, *gyz1, *gzz1; var *gxx1, *gxy1, *gxz1, *gyy1, *gyz1, *gzz1;
var *Axx1, *Axy1, *Axz1, *Ayy1, *Ayz1, *Azz1; var *Axx1, *Axy1, *Axz1, *Ayy1, *Ayz1, *Azz1;
var *Gmx1, *Gmy1, *Gmz1; var *Gmx1, *Gmy1, *Gmz1;
var *Lap1, *Sfx1, *Sfy1, *Sfz1; var *Lap1, *Sfx1, *Sfy1, *Sfz1;
var *dtSfx1, *dtSfy1, *dtSfz1; var *dtSfx1, *dtSfy1, *dtSfz1;
var *phi_rhs, *trK_rhs; var *phi_rhs, *trK_rhs;
var *gxx_rhs, *gxy_rhs, *gxz_rhs, *gyy_rhs, *gyz_rhs, *gzz_rhs; var *gxx_rhs, *gxy_rhs, *gxz_rhs, *gyy_rhs, *gyz_rhs, *gzz_rhs;
var *Axx_rhs, *Axy_rhs, *Axz_rhs, *Ayy_rhs, *Ayz_rhs, *Azz_rhs; var *Axx_rhs, *Axy_rhs, *Axz_rhs, *Ayy_rhs, *Ayz_rhs, *Azz_rhs;
var *Gmx_rhs, *Gmy_rhs, *Gmz_rhs; var *Gmx_rhs, *Gmy_rhs, *Gmz_rhs;
var *Lap_rhs, *Sfx_rhs, *Sfy_rhs, *Sfz_rhs; var *Lap_rhs, *Sfx_rhs, *Sfy_rhs, *Sfz_rhs;
var *dtSfx_rhs, *dtSfy_rhs, *dtSfz_rhs; var *dtSfx_rhs, *dtSfy_rhs, *dtSfz_rhs;
var *rho, *Sx, *Sy, *Sz, *Sxx, *Sxy, *Sxz, *Syy, *Syz, *Szz; var *rho, *Sx, *Sy, *Sz, *Sxx, *Sxy, *Sxz, *Syy, *Syz, *Szz;
var *Gamxxx, *Gamxxy, *Gamxxz, *Gamxyy, *Gamxyz, *Gamxzz; var *Gamxxx, *Gamxxy, *Gamxxz, *Gamxyy, *Gamxyz, *Gamxzz;
var *Gamyxx, *Gamyxy, *Gamyxz, *Gamyyy, *Gamyyz, *Gamyzz; var *Gamyxx, *Gamyxy, *Gamyxz, *Gamyyy, *Gamyyz, *Gamyzz;
var *Gamzxx, *Gamzxy, *Gamzxz, *Gamzyy, *Gamzyz, *Gamzzz; var *Gamzxx, *Gamzxy, *Gamzxz, *Gamzyy, *Gamzyz, *Gamzzz;
var *Rxx, *Rxy, *Rxz, *Ryy, *Ryz, *Rzz; var *Rxx, *Rxy, *Rxz, *Ryy, *Ryz, *Rzz;
var *Rpsi4, *Ipsi4; var *Rpsi4, *Ipsi4;
var *t1Rpsi4, *t1Ipsi4, *t2Rpsi4, *t2Ipsi4; var *t1Rpsi4, *t1Ipsi4, *t2Rpsi4, *t2Ipsi4;
var *Cons_Ham, *Cons_Px, *Cons_Py, *Cons_Pz, *Cons_Gx, *Cons_Gy, *Cons_Gz; var *Cons_Ham, *Cons_Px, *Cons_Py, *Cons_Pz, *Cons_Gx, *Cons_Gy, *Cons_Gz;
#ifdef Point_Psi4 #ifdef Point_Psi4
var *phix, *phiy, *phiz; var *phix, *phiy, *phiz;
var *trKx, *trKy, *trKz; var *trKx, *trKy, *trKz;
var *Axxx, *Axxy, *Axxz; var *Axxx, *Axxy, *Axxz;
var *Axyx, *Axyy, *Axyz; var *Axyx, *Axyy, *Axyz;
var *Axzx, *Axzy, *Axzz; var *Axzx, *Axzy, *Axzz;
var *Ayyx, *Ayyy, *Ayyz; var *Ayyx, *Ayyy, *Ayyz;
var *Ayzx, *Ayzy, *Ayzz; var *Ayzx, *Ayzy, *Ayzz;
var *Azzx, *Azzy, *Azzz; var *Azzx, *Azzy, *Azzz;
#endif #endif
// FIXME: uc = StateList, up = OldStateList, upp = SynchList_cor; so never touch these three data // FIXME: uc = StateList, up = OldStateList, upp = SynchList_cor; so never touch these three data
MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList; MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList;
MyList<var> *OldStateList, *DumpList; MyList<var> *OldStateList, *DumpList;
MyList<var> *ConstraintList; MyList<var> *ConstraintList;
Parallel::SyncCache *sync_cache_pre; // per-level cache for predictor sync Parallel::SyncCache *sync_cache_pre; // per-level cache for predictor sync
Parallel::SyncCache *sync_cache_cor; // per-level cache for corrector sync Parallel::SyncCache *sync_cache_cor; // per-level cache for corrector sync
Parallel::SyncCache *sync_cache_rp_coarse; // RestrictProlong sync on PatL[lev-1] Parallel::SyncCache *sync_cache_rp_coarse; // RestrictProlong sync on PatL[lev-1]
Parallel::SyncCache *sync_cache_rp_fine; // RestrictProlong sync on PatL[lev] Parallel::SyncCache *sync_cache_rp_fine; // RestrictProlong sync on PatL[lev]
Parallel::SyncCache *sync_cache_restrict; // cached Restrict in RestrictProlong Parallel::SyncCache *sync_cache_restrict; // cached Restrict in RestrictProlong
Parallel::SyncCache *sync_cache_outbd; // cached OutBdLow2Hi in RestrictProlong Parallel::SyncCache *sync_cache_outbd; // cached OutBdLow2Hi in RestrictProlong
monitor *ErrorMonitor, *Psi4Monitor, *BHMonitor, *MAPMonitor; monitor *ErrorMonitor, *Psi4Monitor, *BHMonitor, *MAPMonitor;
monitor *ConVMonitor, *TimingMonitor; monitor *ConVMonitor, *TimingMonitor;
surface_integral *Waveshell; surface_integral *Waveshell;
checkpoint *CheckPoint; checkpoint *CheckPoint;
public: public:
bssn_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei, bssn_class(double Couranti, double StartTimei, double TotalTimei, double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei,
int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi, int Symmetryi, int checkruni, char *checkfilenamei, double numepssi, double numepsbi, double numepshi,
int a_levi, int maxli, int decni, double maxrexi, double drexi); int a_levi, int maxli, int decni, double maxrexi, double drexi);
~bssn_class(); virtual ~bssn_class();
void Evolve(int Steps); void Evolve(int Steps);
void RecursiveStep(int lev); void RecursiveStep(int lev);
#if (PSTR == 3) #if (PSTR == 3)
void RecursiveStep(int lev, int num); void RecursiveStep(int lev, int num);
#endif #endif
#if (PSTR == 1 || PSTR == 2 || PSTR == 3) #if (PSTR == 1 || PSTR == 2 || PSTR == 3)
void ParallelStep(); void ParallelStep();
void SHStep(); void SHStep();
#endif #endif
void RestrictProlong(int lev, int YN, bool BB, MyList<var> *SL, MyList<var> *OL, MyList<var> *corL); void RestrictProlong(int lev, int YN, bool BB, MyList<var> *SL, MyList<var> *OL, MyList<var> *corL);
void RestrictProlong_aux(int lev, int YN, bool BB, MyList<var> *SL, MyList<var> *OL, MyList<var> *corL); void RestrictProlong_aux(int lev, int YN, bool BB, MyList<var> *SL, MyList<var> *OL, MyList<var> *corL);
void RestrictProlong(int lev, int YN, bool BB); void RestrictProlong(int lev, int YN, bool BB);
void ProlongRestrict(int lev, int YN, bool BB); void ProlongRestrict(int lev, int YN, bool BB);
void Setup_Black_Hole_position(); void Setup_Black_Hole_position();
void compute_Porg_rhs(double **BH_PS, double **BH_RHS, var *forx, var *fory, var *forz, int lev); void compute_Porg_rhs(double **BH_PS, double **BH_RHS, var *forx, var *fory, var *forz, int lev);
bool read_Pablo_file(int *ext, double *datain, char *filename); bool read_Pablo_file(int *ext, double *datain, char *filename);
void write_Pablo_file(int *ext, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, void write_Pablo_file(int *ext, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax,
char *filename); char *filename);
void AnalysisStuff(int lev, double dT_lev); void AnalysisStuff(int lev, double dT_lev);
void Setup_KerrSchild(); void Setup_KerrSchild();
void Enforce_algcon(int lev, int fg); void Enforce_algcon(int lev, int fg);
void testRestrict(); void testRestrict();
void testOutBd(); void testOutBd();
bool check_Stdin_Abort(); bool check_Stdin_Abort();
virtual void Setup_Initial_Data_Cao(); virtual void Setup_Initial_Data_Cao();
virtual void Setup_Initial_Data_Lousto(); virtual void Setup_Initial_Data_Lousto();
virtual void Initialize(); virtual void Initialize();
virtual void Read_Ansorg(); virtual void Read_Ansorg();
virtual void Read_Pablo() {}; virtual void Read_Pablo() {};
virtual void Compute_Psi4(int lev); virtual void Compute_Psi4(int lev);
virtual void Step(int lev, int YN); virtual void Step(int lev, int YN);
virtual void Interp_Constraint(bool infg); virtual void Interp_Constraint(bool infg);
virtual void Constraint_Out(); virtual void Constraint_Out();
virtual void Compute_Constraint(); virtual void Compute_Constraint();
#ifdef With_AHF #ifdef With_AHF
protected: protected:
MyList<var> *AHList, *AHDList, *GaugeList; MyList<var> *AHList, *AHDList, *GaugeList;
int AHfindevery; int AHfindevery;
double AHdumptime; double AHdumptime;
int *lastahdumpid, HN_num; // number of possible horizons int *lastahdumpid, HN_num; // number of possible horizons
int *findeveryl; int *findeveryl;
double *xc, *yc, *zc, *xr, *yr, *zr; double *xc, *yc, *zc, *xr, *yr, *zr;
bool *trigger; bool *trigger;
double *dTT; double *dTT;
int *dumpid; int *dumpid;
public: public:
void AH_Prepare_derivatives(); void AH_Prepare_derivatives();
bool AH_Interp_Points(MyList<var> *VarList, bool AH_Interp_Points(MyList<var> *VarList,
int NN, double **XX, int NN, double **XX,
double *Shellf, int Symmetryi); double *Shellf, int Symmetryi);
void AH_Step_Find(int lev, double dT_lev); void AH_Step_Find(int lev, double dT_lev);
#endif #endif
}; };
#endif /* BSSN_CLASS_H */ #endif /* BSSN_CLASS_H */

View File

@@ -2,7 +2,7 @@
#ifndef BSSN_GPU_H_ #ifndef BSSN_GPU_H_
#define BSSN_GPU_H_ #define BSSN_GPU_H_
#include "bssn_macro.h" #include "bssn_macro.h"
#include "macrodef.fh" #include "macrodef.h"
#define DEVICE_ID 0 #define DEVICE_ID 0
// #define DEVICE_ID_BY_MPI_RANK // #define DEVICE_ID_BY_MPI_RANK
@@ -25,49 +25,32 @@
/** main function */ /** main function */
int gpu_rhs(int calledby, int mpi_rank, int *ex, double &T, int gpu_rhs(int calledby, int mpi_rank, int *ex, double &T,
double *X, double *Y, double *Z, double *X, double *Y, double *Z,
double *chi, double *trK, double *chi, double *trK,
double *dxx, double *gxy, double *gxz, double *dyy, double *gyz, double *dzz, double *dxx, double *gxy, double *gxz, double *dyy, double *gyz, double *dzz,
double *Axx, double *Axy, double *Axz, double *Ayy, double *Ayz, double *Azz, double *Axx, double *Axy, double *Axz, double *Ayy, double *Ayz, double *Azz,
double *Gamx, double *Gamy, double *Gamz, double *Gamx, double *Gamy, double *Gamz,
double *Lap, double *betax, double *betay, double *betaz, double *Lap, double *betax, double *betay, double *betaz,
double *dtSfx, double *dtSfy, double *dtSfz, double *dtSfx, double *dtSfy, double *dtSfz,
double *chi_rhs, double *trK_rhs, double *chi_rhs, double *trK_rhs,
double *gxx_rhs, double *gxy_rhs, double *gxz_rhs, double *gyy_rhs, double *gyz_rhs, double *gzz_rhs, double *gxx_rhs, double *gxy_rhs, double *gxz_rhs, double *gyy_rhs, double *gyz_rhs, double *gzz_rhs,
double *Axx_rhs, double *Axy_rhs, double *Axz_rhs, double *Ayy_rhs, double *Ayz_rhs, double *Azz_rhs, double *Axx_rhs, double *Axy_rhs, double *Axz_rhs, double *Ayy_rhs, double *Ayz_rhs, double *Azz_rhs,
double *Gamx_rhs, double *Gamy_rhs, double *Gamz_rhs, double *Gamx_rhs, double *Gamy_rhs, double *Gamz_rhs,
double *Lap_rhs, double *betax_rhs, double *betay_rhs, double *betaz_rhs, double *Lap_rhs, double *betax_rhs, double *betay_rhs, double *betaz_rhs,
double *dtSfx_rhs, double *dtSfy_rhs, double *dtSfz_rhs, double *dtSfx_rhs, double *dtSfy_rhs, double *dtSfz_rhs,
double *rho, double *Sx, double *Sy, double *Sz, double *Sxx, double *rho, double *Sx, double *Sy, double *Sz, double *Sxx,
double *Sxy, double *Sxz, double *Syy, double *Syz, double *Szz, double *Sxy, double *Sxz, double *Syy, double *Syz, double *Szz,
double *Gamxxx, double *Gamxxy, double *Gamxxz, double *Gamxyy, double *Gamxyz, double *Gamxzz, double *Gamxxx, double *Gamxxy, double *Gamxxz, double *Gamxyy, double *Gamxyz, double *Gamxzz,
double *Gamyxx, double *Gamyxy, double *Gamyxz, double *Gamyyy, double *Gamyyz, double *Gamyzz, double *Gamyxx, double *Gamyxy, double *Gamyxz, double *Gamyyy, double *Gamyyz, double *Gamyzz,
double *Gamzxx, double *Gamzxy, double *Gamzxz, double *Gamzyy, double *Gamzyz, double *Gamzzz, double *Gamzxx, double *Gamzxy, double *Gamzxz, double *Gamzyy, double *Gamzyz, double *Gamzzz,
double *Rxx, double *Rxy, double *Rxz, double *Ryy, double *Ryz, double *Rzz, double *Rxx, double *Rxy, double *Rxz, double *Ryy, double *Ryz, double *Rzz,
double *ham_Res, double *movx_Res, double *movy_Res, double *movz_Res, double *ham_Res, double *movx_Res, double *movy_Res, double *movz_Res,
double *Gmx_Res, double *Gmy_Res, double *Gmz_Res, double *Gmx_Res, double *Gmy_Res, double *Gmz_Res,
int &Symmetry, int &Lev, double &eps, int &co); int &Symmetry, int &Lev, double &eps, int &co);
int gpu_rhs_ss(RHS_SS_PARA); int gpu_rhs_ss(RHS_SS_PARA);
/** Init GPU side data in GPUMeta. */ #define Z4C_SS_PARA int calledby, int mpi_rank, int *ex, double &T, double *crho, double *sigma, double *R, double *X, double *Y, double *Z, double *drhodx, double *drhody, double *drhodz, double *dsigmadx, double *dsigmady, double *dsigmadz, double *dRdx, double *dRdy, double *dRdz, double *drhodxx, double *drhodxy, double *drhodxz, double *drhodyy, double *drhodyz, double *drhodzz, double *dsigmadxx, double *dsigmadxy, double *dsigmadxz, double *dsigmadyy, double *dsigmadyz, double *dsigmadzz, double *dRdxx, double *dRdxy, double *dRdxz, double *dRdyy, double *dRdyz, double *dRdzz, double *chi, double *trK, double *dxx, double *gxy, double *gxz, double *dyy, double *gyz, double *dzz, double *Axx, double *Axy, double *Axz, double *Ayy, double *Ayz, double *Azz, double *Gamx, double *Gamy, double *Gamz, double *Lap, double *betax, double *betay, double *betaz, double *dtSfx, double *dtSfy, double *dtSfz, double *TZ, double *chi_rhs, double *trK_rhs, double *gxx_rhs, double *gxy_rhs, double *gxz_rhs, double *gyy_rhs, double *gyz_rhs, double *gzz_rhs, double *Axx_rhs, double *Axy_rhs, double *Axz_rhs, double *Ayy_rhs, double *Ayz_rhs, double *Azz_rhs, double *Gamx_rhs, double *Gamy_rhs, double *Gamz_rhs, double *Lap_rhs, double *betax_rhs, double *betay_rhs, double *betaz_rhs, double *dtSfx_rhs, double *dtSfy_rhs, double *dtSfz_rhs, double *TZ_rhs, double *rho, double *Sx, double *Sy, double *Sz, double *Sxx, double *Sxy, double *Sxz, double *Syy, double *Syz, double *Szz, double *Gamxxx, double *Gamxxy, double *Gamxxz, double *Gamxyy, double *Gamxyz, double *Gamxzz, double *Gamyxx, double *Gamyxy, double *Gamyxz, double *Gamyyy, double *Gamyyz, double *Gamyzz, double *Gamzxx, double *Gamzxy, double *Gamzxz, double *Gamzyy, double *Gamzyz, double *Gamzzz, double *Rxx, double *Rxy, double *Rxz, double *Ryy, double *Ryz, double *Rzz, double *ham_Res, double *movx_Res, double *movy_Res, double *movz_Res, double *Gmx_Res, double *Gmy_Res, double *Gmz_Res, int &Symmetry, int &Lev, double &eps, int &sst, int &co
// void init_fluid_meta_gpu(GPUMeta *gpu_meta);
int gpu_rhs_z4c_ss(Z4C_SS_PARA);
#endif #endif

View File

@@ -1,124 +1,124 @@
#include "bssn_macro.h" #include "bssn_macro.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <cstring> #include <cstring>
using namespace std; using namespace std;
int compare_two_file(char *fname1, char *fname2, int data_num) int compare_two_file(char *fname1, char *fname2, int data_num)
{ {
// read file // read file
fstream file1(fname1, ios_base::in); fstream file1(fname1, ios_base::in);
fstream file2(fname2, ios_base::in); fstream file2(fname2, ios_base::in);
double *d1, *d2; double *d1, *d2;
d1 = (double *)malloc(sizeof(double) * data_num); d1 = (double *)malloc(sizeof(double) * data_num);
d2 = (double *)malloc(sizeof(double) * data_num); d2 = (double *)malloc(sizeof(double) * data_num);
for (int i = 0; i < data_num; ++i) for (int i = 0; i < data_num; ++i)
{ {
file1.read((char *)(d1 + i), sizeof(double)); file1.read((char *)(d1 + i), sizeof(double));
file2.read((char *)(d2 + i), sizeof(double)); file2.read((char *)(d2 + i), sizeof(double));
} }
// compare data // compare data
bool is_match = true; bool is_match = true;
for (int i = 0; i < data_num; ++i) for (int i = 0; i < data_num; ++i)
{ {
if (d1[i] != d2[i]) if (d1[i] != d2[i])
{ {
is_match = false; is_match = false;
cout << "miss match at position " << i << endl; cout << "miss match at position " << i << endl;
break; break;
} }
} }
if (is_match) if (is_match)
cout << "Result is right." << endl; cout << "Result is right." << endl;
free(d1); free(d1);
free(d2); free(d2);
file1.close(); file1.close();
file2.close(); file2.close();
return 0; return 0;
} }
void printMatrix(int ftag1, int ftag2, double *d1, double *d2, int ord) void printMatrix(int ftag1, int ftag2, double *d1, double *d2, int ord)
{ {
char fname1[32]; char fname1[32];
char fname2[32]; char fname2[32];
// char ftag1[32]; char ftag2[32]; // char ftag1[32]; char ftag2[32];
// sprintf(ftag1,"%d",ftag1); // sprintf(ftag1,"%d",ftag1);
strcpy(fname1, "matrix_f.show"); strcpy(fname1, "matrix_f.show");
// strcat(fname1,ftag1); // strcat(fname1,ftag1);
// sprintf(ftag2,"%d",ftag2); // sprintf(ftag2,"%d",ftag2);
strcpy(fname2, "matrix_g.show"); strcpy(fname2, "matrix_g.show");
// strcat(fname2,ftag2); // strcat(fname2,ftag2);
ofstream fout0, fout1, fout2; ofstream fout0, fout1, fout2;
fout1.open(fname1); fout1.open(fname1);
fout2.open(fname2); fout2.open(fname2);
for (int k = 0; k < 65; k++) for (int k = 0; k < 65; k++)
{ {
fout1 << "---------square " << k << " ----------" << endl; fout1 << "---------square " << k << " ----------" << endl;
fout2 << "---------square " << k << " ----------" << endl; fout2 << "---------square " << k << " ----------" << endl;
for (int j = 0; j < 67 + ord * 2; j++) for (int j = 0; j < 67 + ord * 2; j++)
{ {
for (int i = 0; i < 67 + ord * 2; i++) for (int i = 0; i < 67 + ord * 2; i++)
{ {
fout1 << d1[i + j * (67 + ord * 2) + k * ((67 + ord * 2) * (67 + ord * 2))] << ' '; fout1 << d1[i + j * (67 + ord * 2) + k * ((67 + ord * 2) * (67 + ord * 2))] << ' ';
fout2 << d2[i + j * (67 + ord * 2) + k * ((67 + ord * 2) * (67 + ord * 2))] << ' '; fout2 << d2[i + j * (67 + ord * 2) + k * ((67 + ord * 2) * (67 + ord * 2))] << ' ';
// fout1<<test_output_g[i+j*(cg->shape[0]) + k*(_2d_size)] <<' '; // fout1<<test_output_g[i+j*(cg->shape[0]) + k*(_2d_size)] <<' ';
// fout2<<test_fh_f [i+j*(cg->shape[0]) + k*(_2d_size)] <<' '; // fout2<<test_fh_f [i+j*(cg->shape[0]) + k*(_2d_size)] <<' ';
} }
fout1 << endl; fout1 << endl;
fout2 << endl; fout2 << endl;
} }
} }
} }
int compare_result(int ftag1, double *d2, int data_num) int compare_result(int ftag1, double *d2, int data_num)
{ {
// read file // read file
char fname1[32]; char fname1[32];
char ftag[32]; char ftag[32];
// itoa(filetag,ftag,10); // itoa(filetag,ftag,10);
sprintf(ftag, "%d", ftag1); sprintf(ftag, "%d", ftag1);
strcpy(fname1, "matrix_f.out"); strcpy(fname1, "matrix_f.out");
strcat(fname1, ftag); strcat(fname1, ftag);
fstream file1(fname1, ios_base::in); fstream file1(fname1, ios_base::in);
double *d1; double *d1;
d1 = (double *)malloc(sizeof(double) * data_num); d1 = (double *)malloc(sizeof(double) * data_num);
for (int i = 0; i < data_num; ++i) for (int i = 0; i < data_num; ++i)
{ {
file1.read((char *)(d1 + i), sizeof(double)); file1.read((char *)(d1 + i), sizeof(double));
} }
// compare data // compare data
bool is_match = true; bool is_match = true;
double delta; double delta;
for (int i = 0; i < data_num; ++i) for (int i = 0; i < data_num; ++i)
{ {
delta = d1[i] - d2[i]; delta = d1[i] - d2[i];
if (delta < 0) if (delta < 0)
delta = -delta; delta = -delta;
if (delta > 1e-14) if (delta > 1e-14)
{ {
is_match = false; is_match = false;
cout << fname1 << "::miss match at position " << i << endl; cout << fname1 << "::miss match at position " << i << endl;
break; break;
} }
// if(i<100 && i>50) // if(i<100 && i>50)
// cout<<d1[i]<<" "<<d2[i]<<endl; // cout<<d1[i]<<" "<<d2[i]<<endl;
} }
if (is_match) if (is_match)
cout << ftag1 << "::matched." << endl; cout << ftag1 << "::matched." << endl;
if (ftag1 == 0) if (ftag1 == 0)
{ {
printMatrix(1, 2, d1, d2, 3); printMatrix(1, 2, d1, d2, 3);
} }
free(d1); free(d1);
file1.close(); file1.close();
return 0; return 0;
} }

View File

@@ -1,94 +1,94 @@
#ifndef BSSN_STEP_H #ifndef BSSN_STEP_H
#define BSSN_STEP_H #define BSSN_STEP_H
//1---------------------FLAGS--------------------- //1---------------------FLAGS---------------------
#define USE_GPU #define USE_GPU
#define MAX_GPU_PROCESS_NUM 1 #define MAX_GPU_PROCESS_NUM 1
#define COUNT_CPU_RHS_TIME #define COUNT_CPU_RHS_TIME
//2---------------------TIMER--------------------- //2---------------------TIMER---------------------
//2.1 TIMER_INIT //2.1 TIMER_INIT
//2.2 TIMER_TIC_WITHOUT_OUTPUT //2.2 TIMER_TIC_WITHOUT_OUTPUT
//2.3 TIMER_TIC(tag,order,label) //2.3 TIMER_TIC(tag,order,label)
//2.4 TIMER_TIC_TAIL_OF_FUNC(tag,label) //2.4 TIMER_TIC_TAIL_OF_FUNC(tag,label)
#define TIME_COUNT_EACH_RANK 0 #define TIME_COUNT_EACH_RANK 0
#define TIMER_INIT \ #define TIMER_INIT \
double clock_prev,clock_curr,step_begin_clock;\ double clock_prev,clock_curr,step_begin_clock;\
if(1 == 1){\ if(1 == 1){\
clock_curr =MPI_Wtime();\ clock_curr =MPI_Wtime();\
step_begin_clock = MPI_Wtime();\ step_begin_clock = MPI_Wtime();\
}else{\ }else{\
if(myrank == 0){\ if(myrank == 0){\
clock_curr= MPI_Wtime();\ clock_curr= MPI_Wtime();\
step_begin_clock = MPI_Wtime();\ step_begin_clock = MPI_Wtime();\
}\ }\
} }
#define TIMER_TIC(tag,order,label) \ #define TIMER_TIC(tag,order,label) \
if(TIME_COUNT_EACH_RANK == 1){\ if(TIME_COUNT_EACH_RANK == 1){\
clock_prev= clock_curr;\ clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\ clock_curr = MPI_Wtime();\
cout<<#tag <<order <<":MPI Rank: "<<myrank<<" "<<#label <<" "<<(clock_curr-clock_prev)<<endl;\ cout<<#tag <<order <<":MPI Rank: "<<myrank<<" "<<#label <<" "<<(clock_curr-clock_prev)<<endl;\
}else{\ }else{\
if(myrank==0){\ if(myrank==0){\
clock_prev= clock_curr;\ clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\ clock_curr = MPI_Wtime();\
cout<<#tag <<order <<" "<<#label " "<<(clock_curr-clock_prev)<<endl;\ cout<<#tag <<order <<" "<<#label " "<<(clock_curr-clock_prev)<<endl;\
}\ }\
} }
#define TIMER_TIC_EACH_PROC(tag,order,label) \ #define TIMER_TIC_EACH_PROC(tag,order,label) \
clock_prev= clock_curr;\ clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\ clock_curr = MPI_Wtime();\
cout<<#tag <<order <<":MPI Rank: "<<myrank<<" "<<#label <<" "<<(clock_curr-clock_prev)<<endl;\ cout<<#tag <<order <<":MPI Rank: "<<myrank<<" "<<#label <<" "<<(clock_curr-clock_prev)<<endl;\
} }
#define TIMER_TIC_WITHOUT_OUTPUT \ #define TIMER_TIC_WITHOUT_OUTPUT \
if(TIME_COUNT_EACH_RANK == 1){\ if(TIME_COUNT_EACH_RANK == 1){\
clock_curr = MPI_Wtime();\ clock_curr = MPI_Wtime();\
}else{\ }else{\
if(myrank==0){\ if(myrank==0){\
clock_curr = MPI_Wtime();\ clock_curr = MPI_Wtime();\
}\ }\
} }
#define TIMER_TIC_TAIL_OF_FUNC(tag,label) \ #define TIMER_TIC_TAIL_OF_FUNC(tag,label) \
if(TIME_COUNT_EACH_RANK == 1){\ if(TIME_COUNT_EACH_RANK == 1){\
cout<<#tag <<"MPI Rank: "<<myrank<<" "<<#label <<" "<<(MPI_Wtime()-step_begin_clock)<<" seconds!"<<endl;\ cout<<#tag <<"MPI Rank: "<<myrank<<" "<<#label <<" "<<(MPI_Wtime()-step_begin_clock)<<" seconds!"<<endl;\
}else{\ }else{\
if(myrank==0)\ if(myrank==0)\
{\ {\
cout<<#tag <<#label <<" "<<(MPI_Wtime()-step_begin_clock)<<" seconds!"<<endl;\ cout<<#tag <<#label <<" "<<(MPI_Wtime()-step_begin_clock)<<" seconds!"<<endl;\
}\ }\
} }
//3---------------------GPU--------------------- //3---------------------GPU---------------------
#define CALLED_BY_STEP 0 #define CALLED_BY_STEP 0
#define CALLED_BY_CONSTRAINT 1 #define CALLED_BY_CONSTRAINT 1
#define RHS_PARA_CALLED_FIRST_TIME cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,ndeps,pre #define RHS_PARA_CALLED_FIRST_TIME cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,ndeps,pre
#define RHS_PARA_CALLED_THEN cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[phi->sgfn],cg->fgfs[trK->sgfn],cg->fgfs[gxx->sgfn],cg->fgfs[gxy->sgfn],cg->fgfs[gxz->sgfn],cg->fgfs[gyy->sgfn],cg->fgfs[gyz->sgfn],cg->fgfs[gzz->sgfn],cg->fgfs[Axx->sgfn],cg->fgfs[Axy->sgfn],cg->fgfs[Axz->sgfn],cg->fgfs[Ayy->sgfn],cg->fgfs[Ayz->sgfn],cg->fgfs[Azz->sgfn],cg->fgfs[Gmx->sgfn],cg->fgfs[Gmy->sgfn],cg->fgfs[Gmz->sgfn],cg->fgfs[Lap->sgfn],cg->fgfs[Sfx->sgfn],cg->fgfs[Sfy->sgfn],cg->fgfs[Sfz->sgfn],cg->fgfs[dtSfx->sgfn],cg->fgfs[dtSfy->sgfn],cg->fgfs[dtSfz->sgfn],cg->fgfs[phi1->sgfn],cg->fgfs[trK1->sgfn],cg->fgfs[gxx1->sgfn],cg->fgfs[gxy1->sgfn],cg->fgfs[gxz1->sgfn],cg->fgfs[gyy1->sgfn],cg->fgfs[gyz1->sgfn],cg->fgfs[gzz1->sgfn],cg->fgfs[Axx1->sgfn],cg->fgfs[Axy1->sgfn],cg->fgfs[Axz1->sgfn],cg->fgfs[Ayy1->sgfn],cg->fgfs[Ayz1->sgfn],cg->fgfs[Azz1->sgfn],cg->fgfs[Gmx1->sgfn],cg->fgfs[Gmy1->sgfn],cg->fgfs[Gmz1->sgfn],cg->fgfs[Lap1->sgfn],cg->fgfs[Sfx1->sgfn],cg->fgfs[Sfy1->sgfn],cg->fgfs[Sfz1->sgfn],cg->fgfs[dtSfx1->sgfn],cg->fgfs[dtSfy1->sgfn],cg->fgfs[dtSfz1->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,ndeps,cor #define RHS_PARA_CALLED_THEN cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[phi->sgfn],cg->fgfs[trK->sgfn],cg->fgfs[gxx->sgfn],cg->fgfs[gxy->sgfn],cg->fgfs[gxz->sgfn],cg->fgfs[gyy->sgfn],cg->fgfs[gyz->sgfn],cg->fgfs[gzz->sgfn],cg->fgfs[Axx->sgfn],cg->fgfs[Axy->sgfn],cg->fgfs[Axz->sgfn],cg->fgfs[Ayy->sgfn],cg->fgfs[Ayz->sgfn],cg->fgfs[Azz->sgfn],cg->fgfs[Gmx->sgfn],cg->fgfs[Gmy->sgfn],cg->fgfs[Gmz->sgfn],cg->fgfs[Lap->sgfn],cg->fgfs[Sfx->sgfn],cg->fgfs[Sfy->sgfn],cg->fgfs[Sfz->sgfn],cg->fgfs[dtSfx->sgfn],cg->fgfs[dtSfy->sgfn],cg->fgfs[dtSfz->sgfn],cg->fgfs[phi1->sgfn],cg->fgfs[trK1->sgfn],cg->fgfs[gxx1->sgfn],cg->fgfs[gxy1->sgfn],cg->fgfs[gxz1->sgfn],cg->fgfs[gyy1->sgfn],cg->fgfs[gyz1->sgfn],cg->fgfs[gzz1->sgfn],cg->fgfs[Axx1->sgfn],cg->fgfs[Axy1->sgfn],cg->fgfs[Axz1->sgfn],cg->fgfs[Ayy1->sgfn],cg->fgfs[Ayz1->sgfn],cg->fgfs[Azz1->sgfn],cg->fgfs[Gmx1->sgfn],cg->fgfs[Gmy1->sgfn],cg->fgfs[Gmz1->sgfn],cg->fgfs[Lap1->sgfn],cg->fgfs[Sfx1->sgfn],cg->fgfs[Sfy1->sgfn],cg->fgfs[Sfz1->sgfn],cg->fgfs[dtSfx1->sgfn],cg->fgfs[dtSfy1->sgfn],cg->fgfs[dtSfz1->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,ndeps,cor
#define RHS_PARA_CALLED_Constraint_Out cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,ndeps,pre #define RHS_PARA_CALLED_Constraint_Out cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,ndeps,pre
#define RHS_PARA_CALLED_Interp_Constraint cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,ndeps,pre #define RHS_PARA_CALLED_Interp_Constraint cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,ndeps,pre
#define RHS_SS_PARA_CALLED_FIRST_TIME cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[fngfs+ShellPatch::gx],cg->fgfs[fngfs+ShellPatch::gy],cg->fgfs[fngfs+ShellPatch::gz],cg->fgfs[fngfs+ShellPatch::drhodx],cg->fgfs[fngfs+ShellPatch::drhody],cg->fgfs[fngfs+ShellPatch::drhodz],cg->fgfs[fngfs+ShellPatch::dsigmadx],cg->fgfs[fngfs+ShellPatch::dsigmady],cg->fgfs[fngfs+ShellPatch::dsigmadz],cg->fgfs[fngfs+ShellPatch::dRdx],cg->fgfs[fngfs+ShellPatch::dRdy],cg->fgfs[fngfs+ShellPatch::dRdz],cg->fgfs[fngfs+ShellPatch::drhodxx],cg->fgfs[fngfs+ShellPatch::drhodxy],cg->fgfs[fngfs+ShellPatch::drhodxz],cg->fgfs[fngfs+ShellPatch::drhodyy],cg->fgfs[fngfs+ShellPatch::drhodyz],cg->fgfs[fngfs+ShellPatch::drhodzz],cg->fgfs[fngfs+ShellPatch::dsigmadxx],cg->fgfs[fngfs+ShellPatch::dsigmadxy],cg->fgfs[fngfs+ShellPatch::dsigmadxz],cg->fgfs[fngfs+ShellPatch::dsigmadyy],cg->fgfs[fngfs+ShellPatch::dsigmadyz],cg->fgfs[fngfs+ShellPatch::dsigmadzz],cg->fgfs[fngfs+ShellPatch::dRdxx],cg->fgfs[fngfs+ShellPatch::dRdxy],cg->fgfs[fngfs+ShellPatch::dRdxz],cg->fgfs[fngfs+ShellPatch::dRdyy],cg->fgfs[fngfs+ShellPatch::dRdyz],cg->fgfs[fngfs+ShellPatch::dRdzz],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,numepsh,sPp->data->sst,pre #define RHS_SS_PARA_CALLED_FIRST_TIME cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[fngfs+ShellPatch::gx],cg->fgfs[fngfs+ShellPatch::gy],cg->fgfs[fngfs+ShellPatch::gz],cg->fgfs[fngfs+ShellPatch::drhodx],cg->fgfs[fngfs+ShellPatch::drhody],cg->fgfs[fngfs+ShellPatch::drhodz],cg->fgfs[fngfs+ShellPatch::dsigmadx],cg->fgfs[fngfs+ShellPatch::dsigmady],cg->fgfs[fngfs+ShellPatch::dsigmadz],cg->fgfs[fngfs+ShellPatch::dRdx],cg->fgfs[fngfs+ShellPatch::dRdy],cg->fgfs[fngfs+ShellPatch::dRdz],cg->fgfs[fngfs+ShellPatch::drhodxx],cg->fgfs[fngfs+ShellPatch::drhodxy],cg->fgfs[fngfs+ShellPatch::drhodxz],cg->fgfs[fngfs+ShellPatch::drhodyy],cg->fgfs[fngfs+ShellPatch::drhodyz],cg->fgfs[fngfs+ShellPatch::drhodzz],cg->fgfs[fngfs+ShellPatch::dsigmadxx],cg->fgfs[fngfs+ShellPatch::dsigmadxy],cg->fgfs[fngfs+ShellPatch::dsigmadxz],cg->fgfs[fngfs+ShellPatch::dsigmadyy],cg->fgfs[fngfs+ShellPatch::dsigmadyz],cg->fgfs[fngfs+ShellPatch::dsigmadzz],cg->fgfs[fngfs+ShellPatch::dRdxx],cg->fgfs[fngfs+ShellPatch::dRdxy],cg->fgfs[fngfs+ShellPatch::dRdxz],cg->fgfs[fngfs+ShellPatch::dRdyy],cg->fgfs[fngfs+ShellPatch::dRdyz],cg->fgfs[fngfs+ShellPatch::dRdzz],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,numepsh,sPp->data->sst,pre
#define RHS_SS_PARA_CALLED_THEN cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[fngfs+ShellPatch::gx],cg->fgfs[fngfs+ShellPatch::gy],cg->fgfs[fngfs+ShellPatch::gz],cg->fgfs[fngfs+ShellPatch::drhodx],cg->fgfs[fngfs+ShellPatch::drhody],cg->fgfs[fngfs+ShellPatch::drhodz],cg->fgfs[fngfs+ShellPatch::dsigmadx],cg->fgfs[fngfs+ShellPatch::dsigmady],cg->fgfs[fngfs+ShellPatch::dsigmadz],cg->fgfs[fngfs+ShellPatch::dRdx],cg->fgfs[fngfs+ShellPatch::dRdy],cg->fgfs[fngfs+ShellPatch::dRdz],cg->fgfs[fngfs+ShellPatch::drhodxx],cg->fgfs[fngfs+ShellPatch::drhodxy],cg->fgfs[fngfs+ShellPatch::drhodxz],cg->fgfs[fngfs+ShellPatch::drhodyy],cg->fgfs[fngfs+ShellPatch::drhodyz],cg->fgfs[fngfs+ShellPatch::drhodzz],cg->fgfs[fngfs+ShellPatch::dsigmadxx],cg->fgfs[fngfs+ShellPatch::dsigmadxy],cg->fgfs[fngfs+ShellPatch::dsigmadxz],cg->fgfs[fngfs+ShellPatch::dsigmadyy],cg->fgfs[fngfs+ShellPatch::dsigmadyz],cg->fgfs[fngfs+ShellPatch::dsigmadzz],cg->fgfs[fngfs+ShellPatch::dRdxx],cg->fgfs[fngfs+ShellPatch::dRdxy],cg->fgfs[fngfs+ShellPatch::dRdxz],cg->fgfs[fngfs+ShellPatch::dRdyy],cg->fgfs[fngfs+ShellPatch::dRdyz],cg->fgfs[fngfs+ShellPatch::dRdzz],cg->fgfs[phi->sgfn],cg->fgfs[trK->sgfn],cg->fgfs[gxx->sgfn],cg->fgfs[gxy->sgfn],cg->fgfs[gxz->sgfn],cg->fgfs[gyy->sgfn],cg->fgfs[gyz->sgfn],cg->fgfs[gzz->sgfn],cg->fgfs[Axx->sgfn],cg->fgfs[Axy->sgfn],cg->fgfs[Axz->sgfn],cg->fgfs[Ayy->sgfn],cg->fgfs[Ayz->sgfn],cg->fgfs[Azz->sgfn],cg->fgfs[Gmx->sgfn],cg->fgfs[Gmy->sgfn],cg->fgfs[Gmz->sgfn],cg->fgfs[Lap->sgfn],cg->fgfs[Sfx->sgfn],cg->fgfs[Sfy->sgfn],cg->fgfs[Sfz->sgfn],cg->fgfs[dtSfx->sgfn],cg->fgfs[dtSfy->sgfn],cg->fgfs[dtSfz->sgfn],cg->fgfs[phi1->sgfn],cg->fgfs[trK1->sgfn],cg->fgfs[gxx1->sgfn],cg->fgfs[gxy1->sgfn],cg->fgfs[gxz1->sgfn],cg->fgfs[gyy1->sgfn],cg->fgfs[gyz1->sgfn],cg->fgfs[gzz1->sgfn],cg->fgfs[Axx1->sgfn],cg->fgfs[Axy1->sgfn],cg->fgfs[Axz1->sgfn],cg->fgfs[Ayy1->sgfn],cg->fgfs[Ayz1->sgfn],cg->fgfs[Azz1->sgfn],cg->fgfs[Gmx1->sgfn],cg->fgfs[Gmy1->sgfn],cg->fgfs[Gmz1->sgfn],cg->fgfs[Lap1->sgfn],cg->fgfs[Sfx1->sgfn],cg->fgfs[Sfy1->sgfn],cg->fgfs[Sfz1->sgfn],cg->fgfs[dtSfx1->sgfn],cg->fgfs[dtSfy1->sgfn],cg->fgfs[dtSfz1->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,numepsh,sPp->data->sst,cor #define RHS_SS_PARA_CALLED_THEN cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[fngfs+ShellPatch::gx],cg->fgfs[fngfs+ShellPatch::gy],cg->fgfs[fngfs+ShellPatch::gz],cg->fgfs[fngfs+ShellPatch::drhodx],cg->fgfs[fngfs+ShellPatch::drhody],cg->fgfs[fngfs+ShellPatch::drhodz],cg->fgfs[fngfs+ShellPatch::dsigmadx],cg->fgfs[fngfs+ShellPatch::dsigmady],cg->fgfs[fngfs+ShellPatch::dsigmadz],cg->fgfs[fngfs+ShellPatch::dRdx],cg->fgfs[fngfs+ShellPatch::dRdy],cg->fgfs[fngfs+ShellPatch::dRdz],cg->fgfs[fngfs+ShellPatch::drhodxx],cg->fgfs[fngfs+ShellPatch::drhodxy],cg->fgfs[fngfs+ShellPatch::drhodxz],cg->fgfs[fngfs+ShellPatch::drhodyy],cg->fgfs[fngfs+ShellPatch::drhodyz],cg->fgfs[fngfs+ShellPatch::drhodzz],cg->fgfs[fngfs+ShellPatch::dsigmadxx],cg->fgfs[fngfs+ShellPatch::dsigmadxy],cg->fgfs[fngfs+ShellPatch::dsigmadxz],cg->fgfs[fngfs+ShellPatch::dsigmadyy],cg->fgfs[fngfs+ShellPatch::dsigmadyz],cg->fgfs[fngfs+ShellPatch::dsigmadzz],cg->fgfs[fngfs+ShellPatch::dRdxx],cg->fgfs[fngfs+ShellPatch::dRdxy],cg->fgfs[fngfs+ShellPatch::dRdxz],cg->fgfs[fngfs+ShellPatch::dRdyy],cg->fgfs[fngfs+ShellPatch::dRdyz],cg->fgfs[fngfs+ShellPatch::dRdzz],cg->fgfs[phi->sgfn],cg->fgfs[trK->sgfn],cg->fgfs[gxx->sgfn],cg->fgfs[gxy->sgfn],cg->fgfs[gxz->sgfn],cg->fgfs[gyy->sgfn],cg->fgfs[gyz->sgfn],cg->fgfs[gzz->sgfn],cg->fgfs[Axx->sgfn],cg->fgfs[Axy->sgfn],cg->fgfs[Axz->sgfn],cg->fgfs[Ayy->sgfn],cg->fgfs[Ayz->sgfn],cg->fgfs[Azz->sgfn],cg->fgfs[Gmx->sgfn],cg->fgfs[Gmy->sgfn],cg->fgfs[Gmz->sgfn],cg->fgfs[Lap->sgfn],cg->fgfs[Sfx->sgfn],cg->fgfs[Sfy->sgfn],cg->fgfs[Sfz->sgfn],cg->fgfs[dtSfx->sgfn],cg->fgfs[dtSfy->sgfn],cg->fgfs[dtSfz->sgfn],cg->fgfs[phi1->sgfn],cg->fgfs[trK1->sgfn],cg->fgfs[gxx1->sgfn],cg->fgfs[gxy1->sgfn],cg->fgfs[gxz1->sgfn],cg->fgfs[gyy1->sgfn],cg->fgfs[gyz1->sgfn],cg->fgfs[gzz1->sgfn],cg->fgfs[Axx1->sgfn],cg->fgfs[Axy1->sgfn],cg->fgfs[Axz1->sgfn],cg->fgfs[Ayy1->sgfn],cg->fgfs[Ayz1->sgfn],cg->fgfs[Azz1->sgfn],cg->fgfs[Gmx1->sgfn],cg->fgfs[Gmy1->sgfn],cg->fgfs[Gmz1->sgfn],cg->fgfs[Lap1->sgfn],cg->fgfs[Sfx1->sgfn],cg->fgfs[Sfy1->sgfn],cg->fgfs[Sfz1->sgfn],cg->fgfs[dtSfx1->sgfn],cg->fgfs[dtSfy1->sgfn],cg->fgfs[dtSfz1->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,numepsh,sPp->data->sst,cor
#define RHS_PARA_CALLED_Constraint_Out_SS cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[fngfs+ShellPatch::gx],cg->fgfs[fngfs+ShellPatch::gy],cg->fgfs[fngfs+ShellPatch::gz],cg->fgfs[fngfs+ShellPatch::drhodx],cg->fgfs[fngfs+ShellPatch::drhody],cg->fgfs[fngfs+ShellPatch::drhodz],cg->fgfs[fngfs+ShellPatch::dsigmadx],cg->fgfs[fngfs+ShellPatch::dsigmady],cg->fgfs[fngfs+ShellPatch::dsigmadz],cg->fgfs[fngfs+ShellPatch::dRdx],cg->fgfs[fngfs+ShellPatch::dRdy],cg->fgfs[fngfs+ShellPatch::dRdz],cg->fgfs[fngfs+ShellPatch::drhodxx],cg->fgfs[fngfs+ShellPatch::drhodxy],cg->fgfs[fngfs+ShellPatch::drhodxz],cg->fgfs[fngfs+ShellPatch::drhodyy],cg->fgfs[fngfs+ShellPatch::drhodyz],cg->fgfs[fngfs+ShellPatch::drhodzz],cg->fgfs[fngfs+ShellPatch::dsigmadxx],cg->fgfs[fngfs+ShellPatch::dsigmadxy],cg->fgfs[fngfs+ShellPatch::dsigmadxz],cg->fgfs[fngfs+ShellPatch::dsigmadyy],cg->fgfs[fngfs+ShellPatch::dsigmadyz],cg->fgfs[fngfs+ShellPatch::dsigmadzz],cg->fgfs[fngfs+ShellPatch::dRdxx],cg->fgfs[fngfs+ShellPatch::dRdxy],cg->fgfs[fngfs+ShellPatch::dRdxz],cg->fgfs[fngfs+ShellPatch::dRdyy],cg->fgfs[fngfs+ShellPatch::dRdyz],cg->fgfs[fngfs+ShellPatch::dRdzz],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,numepsh,sPp->data->sst,pre #define RHS_PARA_CALLED_Constraint_Out_SS cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[fngfs+ShellPatch::gx],cg->fgfs[fngfs+ShellPatch::gy],cg->fgfs[fngfs+ShellPatch::gz],cg->fgfs[fngfs+ShellPatch::drhodx],cg->fgfs[fngfs+ShellPatch::drhody],cg->fgfs[fngfs+ShellPatch::drhodz],cg->fgfs[fngfs+ShellPatch::dsigmadx],cg->fgfs[fngfs+ShellPatch::dsigmady],cg->fgfs[fngfs+ShellPatch::dsigmadz],cg->fgfs[fngfs+ShellPatch::dRdx],cg->fgfs[fngfs+ShellPatch::dRdy],cg->fgfs[fngfs+ShellPatch::dRdz],cg->fgfs[fngfs+ShellPatch::drhodxx],cg->fgfs[fngfs+ShellPatch::drhodxy],cg->fgfs[fngfs+ShellPatch::drhodxz],cg->fgfs[fngfs+ShellPatch::drhodyy],cg->fgfs[fngfs+ShellPatch::drhodyz],cg->fgfs[fngfs+ShellPatch::drhodzz],cg->fgfs[fngfs+ShellPatch::dsigmadxx],cg->fgfs[fngfs+ShellPatch::dsigmadxy],cg->fgfs[fngfs+ShellPatch::dsigmadxz],cg->fgfs[fngfs+ShellPatch::dsigmadyy],cg->fgfs[fngfs+ShellPatch::dsigmadyz],cg->fgfs[fngfs+ShellPatch::dsigmadzz],cg->fgfs[fngfs+ShellPatch::dRdxx],cg->fgfs[fngfs+ShellPatch::dRdxy],cg->fgfs[fngfs+ShellPatch::dRdxz],cg->fgfs[fngfs+ShellPatch::dRdyy],cg->fgfs[fngfs+ShellPatch::dRdyz],cg->fgfs[fngfs+ShellPatch::dRdzz],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,numepsh,sPp->data->sst,pre
#define RHS_PARA_CALLED_Intrp_Constraint_Out_SS cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[fngfs+ShellPatch::gx],cg->fgfs[fngfs+ShellPatch::gy],cg->fgfs[fngfs+ShellPatch::gz],cg->fgfs[fngfs+ShellPatch::drhodx],cg->fgfs[fngfs+ShellPatch::drhody],cg->fgfs[fngfs+ShellPatch::drhodz],cg->fgfs[fngfs+ShellPatch::dsigmadx],cg->fgfs[fngfs+ShellPatch::dsigmady],cg->fgfs[fngfs+ShellPatch::dsigmadz],cg->fgfs[fngfs+ShellPatch::dRdx],cg->fgfs[fngfs+ShellPatch::dRdy],cg->fgfs[fngfs+ShellPatch::dRdz],cg->fgfs[fngfs+ShellPatch::drhodxx],cg->fgfs[fngfs+ShellPatch::drhodxy],cg->fgfs[fngfs+ShellPatch::drhodxz],cg->fgfs[fngfs+ShellPatch::drhodyy],cg->fgfs[fngfs+ShellPatch::drhodyz],cg->fgfs[fngfs+ShellPatch::drhodzz],cg->fgfs[fngfs+ShellPatch::dsigmadxx],cg->fgfs[fngfs+ShellPatch::dsigmadxy],cg->fgfs[fngfs+ShellPatch::dsigmadxz],cg->fgfs[fngfs+ShellPatch::dsigmadyy],cg->fgfs[fngfs+ShellPatch::dsigmadyz],cg->fgfs[fngfs+ShellPatch::dsigmadzz],cg->fgfs[fngfs+ShellPatch::dRdxx],cg->fgfs[fngfs+ShellPatch::dRdxy],cg->fgfs[fngfs+ShellPatch::dRdxz],cg->fgfs[fngfs+ShellPatch::dRdyy],cg->fgfs[fngfs+ShellPatch::dRdyz],cg->fgfs[fngfs+ShellPatch::dRdzz],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,numepsh,sPp->data->sst,pre #define RHS_PARA_CALLED_Intrp_Constraint_Out_SS cg->shape,TRK4,cg->X[0],cg->X[1],cg->X[2],cg->fgfs[fngfs+ShellPatch::gx],cg->fgfs[fngfs+ShellPatch::gy],cg->fgfs[fngfs+ShellPatch::gz],cg->fgfs[fngfs+ShellPatch::drhodx],cg->fgfs[fngfs+ShellPatch::drhody],cg->fgfs[fngfs+ShellPatch::drhodz],cg->fgfs[fngfs+ShellPatch::dsigmadx],cg->fgfs[fngfs+ShellPatch::dsigmady],cg->fgfs[fngfs+ShellPatch::dsigmadz],cg->fgfs[fngfs+ShellPatch::dRdx],cg->fgfs[fngfs+ShellPatch::dRdy],cg->fgfs[fngfs+ShellPatch::dRdz],cg->fgfs[fngfs+ShellPatch::drhodxx],cg->fgfs[fngfs+ShellPatch::drhodxy],cg->fgfs[fngfs+ShellPatch::drhodxz],cg->fgfs[fngfs+ShellPatch::drhodyy],cg->fgfs[fngfs+ShellPatch::drhodyz],cg->fgfs[fngfs+ShellPatch::drhodzz],cg->fgfs[fngfs+ShellPatch::dsigmadxx],cg->fgfs[fngfs+ShellPatch::dsigmadxy],cg->fgfs[fngfs+ShellPatch::dsigmadxz],cg->fgfs[fngfs+ShellPatch::dsigmadyy],cg->fgfs[fngfs+ShellPatch::dsigmadyz],cg->fgfs[fngfs+ShellPatch::dsigmadzz],cg->fgfs[fngfs+ShellPatch::dRdxx],cg->fgfs[fngfs+ShellPatch::dRdxy],cg->fgfs[fngfs+ShellPatch::dRdxz],cg->fgfs[fngfs+ShellPatch::dRdyy],cg->fgfs[fngfs+ShellPatch::dRdyz],cg->fgfs[fngfs+ShellPatch::dRdzz],cg->fgfs[phi0->sgfn],cg->fgfs[trK0->sgfn],cg->fgfs[gxx0->sgfn],cg->fgfs[gxy0->sgfn],cg->fgfs[gxz0->sgfn],cg->fgfs[gyy0->sgfn],cg->fgfs[gyz0->sgfn],cg->fgfs[gzz0->sgfn],cg->fgfs[Axx0->sgfn],cg->fgfs[Axy0->sgfn],cg->fgfs[Axz0->sgfn],cg->fgfs[Ayy0->sgfn],cg->fgfs[Ayz0->sgfn],cg->fgfs[Azz0->sgfn],cg->fgfs[Gmx0->sgfn],cg->fgfs[Gmy0->sgfn],cg->fgfs[Gmz0->sgfn],cg->fgfs[Lap0->sgfn],cg->fgfs[Sfx0->sgfn],cg->fgfs[Sfy0->sgfn],cg->fgfs[Sfz0->sgfn],cg->fgfs[dtSfx0->sgfn],cg->fgfs[dtSfy0->sgfn],cg->fgfs[dtSfz0->sgfn],cg->fgfs[phi_rhs->sgfn],cg->fgfs[trK_rhs->sgfn],cg->fgfs[gxx_rhs->sgfn],cg->fgfs[gxy_rhs->sgfn],cg->fgfs[gxz_rhs->sgfn],cg->fgfs[gyy_rhs->sgfn],cg->fgfs[gyz_rhs->sgfn],cg->fgfs[gzz_rhs->sgfn],cg->fgfs[Axx_rhs->sgfn],cg->fgfs[Axy_rhs->sgfn],cg->fgfs[Axz_rhs->sgfn],cg->fgfs[Ayy_rhs->sgfn],cg->fgfs[Ayz_rhs->sgfn],cg->fgfs[Azz_rhs->sgfn],cg->fgfs[Gmx_rhs->sgfn],cg->fgfs[Gmy_rhs->sgfn],cg->fgfs[Gmz_rhs->sgfn],cg->fgfs[Lap_rhs->sgfn],cg->fgfs[Sfx_rhs->sgfn],cg->fgfs[Sfy_rhs->sgfn],cg->fgfs[Sfz_rhs->sgfn],cg->fgfs[dtSfx_rhs->sgfn],cg->fgfs[dtSfy_rhs->sgfn],cg->fgfs[dtSfz_rhs->sgfn],cg->fgfs[rho->sgfn],cg->fgfs[Sx->sgfn],cg->fgfs[Sy->sgfn],cg->fgfs[Sz->sgfn],cg->fgfs[Sxx->sgfn],cg->fgfs[Sxy->sgfn],cg->fgfs[Sxz->sgfn],cg->fgfs[Syy->sgfn],cg->fgfs[Syz->sgfn],cg->fgfs[Szz->sgfn],cg->fgfs[Gamxxx->sgfn],cg->fgfs[Gamxxy->sgfn],cg->fgfs[Gamxxz->sgfn],cg->fgfs[Gamxyy->sgfn],cg->fgfs[Gamxyz->sgfn],cg->fgfs[Gamxzz->sgfn],cg->fgfs[Gamyxx->sgfn],cg->fgfs[Gamyxy->sgfn],cg->fgfs[Gamyxz->sgfn],cg->fgfs[Gamyyy->sgfn],cg->fgfs[Gamyyz->sgfn],cg->fgfs[Gamyzz->sgfn],cg->fgfs[Gamzxx->sgfn],cg->fgfs[Gamzxy->sgfn],cg->fgfs[Gamzxz->sgfn],cg->fgfs[Gamzyy->sgfn],cg->fgfs[Gamzyz->sgfn],cg->fgfs[Gamzzz->sgfn],cg->fgfs[Rxx->sgfn],cg->fgfs[Rxy->sgfn],cg->fgfs[Rxz->sgfn],cg->fgfs[Ryy->sgfn],cg->fgfs[Ryz->sgfn],cg->fgfs[Rzz->sgfn],cg->fgfs[Cons_Ham->sgfn],cg->fgfs[Cons_Px->sgfn],cg->fgfs[Cons_Py->sgfn],cg->fgfs[Cons_Pz->sgfn],cg->fgfs[Cons_Gx->sgfn],cg->fgfs[Cons_Gy->sgfn],cg->fgfs[Cons_Gz->sgfn],Symmetry,lev,numepsh,sPp->data->sst,pre
//4------------tool------------------------------ //4------------tool------------------------------
int compare_result(int ftag1,double * d2,int data_num); int compare_result(int ftag1,double * d2,int data_num);
#endif #endif

View File

@@ -1,35 +1,35 @@
#ifndef BSSN_H #ifndef BSSN_H
#define BSSN_H #define BSSN_H
#ifdef fortran1 #ifdef fortran1
#define f_compute_rhs_bssn compute_rhs_bssn #define f_compute_rhs_bssn compute_rhs_bssn
#define f_compute_rhs_bssn_ss compute_rhs_bssn_ss #define f_compute_rhs_bssn_ss compute_rhs_bssn_ss
#define f_compute_rhs_bssn_escalar compute_rhs_bssn_escalar #define f_compute_rhs_bssn_escalar compute_rhs_bssn_escalar
#define f_compute_rhs_bssn_escalar_ss compute_rhs_bssn_escalar_ss #define f_compute_rhs_bssn_escalar_ss compute_rhs_bssn_escalar_ss
#define f_compute_rhs_Z4c compute_rhs_z4c #define f_compute_rhs_Z4c compute_rhs_z4c
#define f_compute_rhs_Z4cnot compute_rhs_z4cnot #define f_compute_rhs_Z4cnot compute_rhs_z4cnot
#define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss #define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss
#define f_compute_constraint_fr compute_constraint_fr #define f_compute_constraint_fr compute_constraint_fr
#endif #endif
#ifdef fortran2 #ifdef fortran2
#define f_compute_rhs_bssn COMPUTE_RHS_BSSN #define f_compute_rhs_bssn COMPUTE_RHS_BSSN
#define f_compute_rhs_bssn_ss COMPUTE_RHS_BSSN_SS #define f_compute_rhs_bssn_ss COMPUTE_RHS_BSSN_SS
#define f_compute_rhs_bssn_escalar COMPUTE_RHS_BSSN_ESCALAR #define f_compute_rhs_bssn_escalar COMPUTE_RHS_BSSN_ESCALAR
#define f_compute_rhs_bssn_escalar_ss COMPUTE_RHS_BSSN_ESCALAR_SS #define f_compute_rhs_bssn_escalar_ss COMPUTE_RHS_BSSN_ESCALAR_SS
#define f_compute_rhs_Z4c COMPUTE_RHS_Z4C #define f_compute_rhs_Z4c COMPUTE_RHS_Z4C
#define f_compute_rhs_Z4cnot COMPUTE_RHS_Z4CNOT #define f_compute_rhs_Z4cnot COMPUTE_RHS_Z4CNOT
#define f_compute_rhs_Z4c_ss COMPUTE_RHS_Z4C_SS #define f_compute_rhs_Z4c_ss COMPUTE_RHS_Z4C_SS
#define f_compute_constraint_fr COMPUTE_CONSTRAINT_FR #define f_compute_constraint_fr COMPUTE_CONSTRAINT_FR
#endif #endif
#ifdef fortran3 #ifdef fortran3
#define f_compute_rhs_bssn compute_rhs_bssn_ #define f_compute_rhs_bssn compute_rhs_bssn_
#define f_compute_rhs_bssn_ss compute_rhs_bssn_ss_ #define f_compute_rhs_bssn_ss compute_rhs_bssn_ss_
#define f_compute_rhs_bssn_escalar compute_rhs_bssn_escalar_ #define f_compute_rhs_bssn_escalar compute_rhs_bssn_escalar_
#define f_compute_rhs_bssn_escalar_ss compute_rhs_bssn_escalar_ss_ #define f_compute_rhs_bssn_escalar_ss compute_rhs_bssn_escalar_ss_
#define f_compute_rhs_Z4c compute_rhs_z4c_ #define f_compute_rhs_Z4c compute_rhs_z4c_
#define f_compute_rhs_Z4cnot compute_rhs_z4cnot_ #define f_compute_rhs_Z4cnot compute_rhs_z4cnot_
#define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss_ #define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss_
#define f_compute_constraint_fr compute_constraint_fr_ #define f_compute_constraint_fr compute_constraint_fr_
#endif #endif
@@ -48,197 +48,197 @@ extern "C"
extern "C" extern "C"
{ {
int f_compute_rhs_bssn(int *, double &, double *, double *, double *, // ex,T,X,Y,Z int f_compute_rhs_bssn(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &); int &, int &, double &, int &);
} }
extern "C" extern "C"
{ {
int f_compute_rhs_bssn_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R int f_compute_rhs_bssn_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R
double *, double *, double *, // X,Y,Z double *, double *, double *, // X,Y,Z
double *, double *, double *, // drhodx,drhody,drhodz double *, double *, double *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz double *, double *, double *, // dRdx,dRdy,dRdz
double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz
double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz
double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &, int &); int &, int &, double &, int &, int &);
} }
extern "C" extern "C"
{ {
int f_compute_rhs_bssn_escalar(int *, double &, double *, double *, double *, // ex,T,X,Y,Z int f_compute_rhs_bssn_escalar(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi, Spi double *, double *, // Sphi, Spi
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi, Spi double *, double *, // Sphi, Spi
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &); int &, int &, double &, int &);
} }
extern "C" extern "C"
{ {
int f_compute_rhs_bssn_escalar_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R int f_compute_rhs_bssn_escalar_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R
double *, double *, double *, // X,Y,Z double *, double *, double *, // X,Y,Z
double *, double *, double *, // drhodx,drhody,drhodz double *, double *, double *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz double *, double *, double *, // dRdx,dRdy,dRdz
double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz
double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz
double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi,Spi double *, double *, // Sphi,Spi
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi,Spi double *, double *, // Sphi,Spi
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &, int &); int &, int &, double &, int &, int &);
} }
extern "C" extern "C"
{ {
int f_compute_rhs_Z4c(int *, double &, double *, double *, double *, // ex,T,X,Y,Z int f_compute_rhs_Z4c(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // Z4 double *, // Z4
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // Z4 double *, // Z4
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
int &, int &, double &, int &); int &, int &, double &, int &);
} }
extern "C" extern "C"
{ {
int f_compute_rhs_Z4c_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R int f_compute_rhs_Z4c_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R
double *, double *, double *, // X,Y,Z double *, double *, double *, // X,Y,Z
double *, double *, double *, // drhodx,drhody,drhodz double *, double *, double *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz double *, double *, double *, // dRdx,dRdy,dRdz
double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz
double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz
double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // TZ double *, // TZ
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // TZ double *, // TZ
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &, int &); int &, int &, double &, int &, int &);
} }
extern "C" extern "C"
{ {
int f_compute_rhs_Z4cnot(int *, double &, double *, double *, double *, // ex,T,X,Y,Z int f_compute_rhs_Z4cnot(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // Z4 double *, // Z4
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // Z4 double *, // Z4
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
int &, int &, double &, int &, double &); int &, int &, double &, int &, double &);
} }
extern "C" extern "C"
{ {
void f_compute_constraint_fr(int *, double *, double *, double *, // ex,X,Y,Z void f_compute_constraint_fr(int *, double *, double *, double *, // ex,X,Y,Z
double *, double *, double *, double *, // chi, trK,rho,Sphi double *, double *, double *, double *, // chi, trK,rho,Sphi
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, double *, double *, double *, // Rij double *, double *, double *, double *, double *, double *, // Rij
double *, double *, double *, double *, double *, double *, // Sij double *, double *, double *, double *, double *, double *, // Sij
double *); double *);
} // FR_cons } // FR_cons
#endif /* BSSN_H */ #endif /* BSSN_H */

View File

@@ -1098,12 +1098,12 @@ int f_compute_rhs_bssn(int *ex, double &T,
betaz_rhs[i] = FF * dtSfz[i]; betaz_rhs[i] = FF * dtSfz[i];
reta[i] = reta[i] =
gupxx[i] * dtSfx_rhs[i] * dtSfx_rhs[i] gupxx[i] * chix[i] * chix[i]
+ gupyy[i] * dtSfy_rhs[i] * dtSfy_rhs[i] + gupyy[i] * chiy[i] * chiy[i]
+ gupzz[i] * dtSfz_rhs[i] * dtSfz_rhs[i] + gupzz[i] * chiz[i] * chiz[i]
+ TWO * ( gupxy[i] * dtSfx_rhs[i] * dtSfy_rhs[i] + TWO * ( gupxy[i] * chix[i] * chiy[i]
+ gupxz[i] * dtSfx_rhs[i] * dtSfz_rhs[i] + gupxz[i] * chix[i] * chiz[i]
+ gupyz[i] * dtSfy_rhs[i] * dtSfz_rhs[i] ); + gupyz[i] * chiy[i] * chiz[i] );
#if (GAUGE == 2) #if (GAUGE == 2)
reta[i] = 1.31 / 2.0 * sqrt( reta[i] / chin1[i] ) / pow( (ONE - sqrt(chin1[i])), 2.0 ); reta[i] = 1.31 / 2.0 * sqrt( reta[i] / chin1[i] ) / pow( (ONE - sqrt(chin1[i])), 2.0 );
@@ -1116,12 +1116,12 @@ int f_compute_rhs_bssn(int *ex, double &T,
dtSfz_rhs[i] = Gamz_rhs[i] - reta[i] * dtSfz[i]; dtSfz_rhs[i] = Gamz_rhs[i] - reta[i] * dtSfz[i];
#elif (GAUGE == 4 || GAUGE == 5) #elif (GAUGE == 4 || GAUGE == 5)
reta[i] = reta[i] =
gupxx[i] * dtSfx_rhs[i] * dtSfx_rhs[i] gupxx[i] * chix[i] * chix[i]
+ gupyy[i] * dtSfy_rhs[i] * dtSfy_rhs[i] + gupyy[i] * chiy[i] * chiy[i]
+ gupzz[i] * dtSfz_rhs[i] * dtSfz_rhs[i] + gupzz[i] * chiz[i] * chiz[i]
+ TWO * ( gupxy[i] * dtSfx_rhs[i] * dtSfy_rhs[i] + TWO * ( gupxy[i] * chix[i] * chiy[i]
+ gupxz[i] * dtSfx_rhs[i] * dtSfz_rhs[i] + gupxz[i] * chix[i] * chiz[i]
+ gupyz[i] * dtSfy_rhs[i] * dtSfz_rhs[i] ); + gupyz[i] * chiy[i] * chiz[i] );
#if (GAUGE == 4) #if (GAUGE == 4)
reta[i] = 1.31 / 2.0 * sqrt( reta[i] / chin1[i] ) / pow( (ONE - sqrt(chin1[i])), 2.0 ); reta[i] = 1.31 / 2.0 * sqrt( reta[i] / chin1[i] ) / pow( (ONE - sqrt(chin1[i])), 2.0 );

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,413 @@
#ifndef BSSN_RHS_CUDA_H
#define BSSN_RHS_CUDA_H
#ifdef __cplusplus
extern "C" {
#endif
enum {
BSSN_CUDA_STATE_COUNT = 24,
BSSN_ESCALAR_CUDA_STATE_COUNT = 26,
BSSN_EM_CUDA_STATE_COUNT = 32,
BSSN_EM_CUDA_SOURCE_COUNT = 4,
BSSN_CUDA_MATTER_COUNT = 10
};
int f_compute_rhs_bssn(int *ex, double &T,
double *X, double *Y, double *Z,
double *chi, double *trK,
double *dxx, double *gxy, double *gxz, double *dyy, double *gyz, double *dzz,
double *Axx, double *Axy, double *Axz, double *Ayy, double *Ayz, double *Azz,
double *Gamx, double *Gamy, double *Gamz,
double *Lap, double *betax, double *betay, double *betaz,
double *dtSfx, double *dtSfy, double *dtSfz,
double *chi_rhs, double *trK_rhs,
double *gxx_rhs, double *gxy_rhs, double *gxz_rhs, double *gyy_rhs, double *gyz_rhs, double *gzz_rhs,
double *Axx_rhs, double *Axy_rhs, double *Axz_rhs, double *Ayy_rhs, double *Ayz_rhs, double *Azz_rhs,
double *Gamx_rhs, double *Gamy_rhs, double *Gamz_rhs,
double *Lap_rhs, double *betax_rhs, double *betay_rhs, double *betaz_rhs,
double *dtSfx_rhs, double *dtSfy_rhs, double *dtSfz_rhs,
double *rho, double *Sx, double *Sy, double *Sz,
double *Sxx, double *Sxy, double *Sxz, double *Syy, double *Syz, double *Szz,
double *Gamxxx, double *Gamxxy, double *Gamxxz, double *Gamxyy, double *Gamxyz, double *Gamxzz,
double *Gamyxx, double *Gamyxy, double *Gamyxz, double *Gamyyy, double *Gamyyz, double *Gamyzz,
double *Gamzxx, double *Gamzxy, double *Gamzxz, double *Gamzyy, double *Gamzyz, double *Gamzzz,
double *Rxx, double *Rxy, double *Rxz, double *Ryy, double *Ryz, double *Rzz,
double *ham_Res, double *movx_Res, double *movy_Res, double *movz_Res,
double *Gmx_Res, double *Gmy_Res, double *Gmz_Res,
int &Symmetry, int &Lev, double &eps, int &co);
int bssn_cuda_rk4_substep(void *block_tag,
int *ex, double *X, double *Y, double *Z,
double **state_host_in,
double **state_host_out,
double **matter_host,
const double *propspeed,
const double *soa_flat,
const double *bbox,
double &dT,
double &T,
int &RK4,
int &apply_bam_bc,
int &Symmetry,
int &Lev,
double &eps,
int &co,
int &use_zero_matter,
int &keep_resident_state,
int &apply_enforce_ga,
double &chitiny);
int bssn_escalar_cuda_rk4_substep(void *block_tag,
int *ex, double *X, double *Y, double *Z,
double **state_host_in,
double **state_host_out,
const double *propspeed,
const double *soa_flat,
const double *bbox,
double &dT,
double &T,
int &RK4,
int &apply_bam_bc,
int &Symmetry,
int &Lev,
double &eps,
int &co,
int &keep_resident_state,
int &apply_enforce_ga,
double &chitiny);
int bssn_escalar_cuda_compute_constraints(int *ex, double *X, double *Y, double *Z,
double **state_host_in,
double **constraint_host_out,
int &Symmetry,
int &Lev,
double &eps);
int bssn_em_cuda_rk4_substep(void *block_tag,
int *ex, double *X, double *Y, double *Z,
double **state_host_in,
double **state_host_out,
double **source_host,
const double *propspeed,
const double *soa_flat,
const double *bbox,
double &dT,
double &T,
int &RK4,
int &apply_bam_bc,
int &Symmetry,
int &Lev,
double &eps,
int &co,
int &keep_resident_state,
int &apply_enforce_ga,
double &chitiny);
int bssn_em_cuda_resident_zero_fast_state(void *block_tag);
int bssn_cuda_copy_state_region_to_host(void *block_tag,
int state_index,
double *host_state,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_copy_state_region_from_host(void *block_tag,
int state_index,
double *host_state,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_download_resident_state(void *block_tag,
int *ex,
double **state_host_out);
int bssn_escalar_cuda_download_resident_state(void *block_tag,
int *ex,
double **state_host_out);
int bssn_cuda_upload_resident_state_count(void *block_tag,
int *ex,
double **state_host_in,
int state_count);
int bssn_escalar_cuda_upload_resident_state(void *block_tag,
int *ex,
double **state_host_in);
int bssn_cuda_keep_only_resident_state_count(void *block_tag,
int *ex,
double **state_host_key,
int state_count);
int bssn_escalar_cuda_keep_only_resident_state(void *block_tag,
int *ex,
double **state_host_key);
int bssn_cuda_download_resident_state_count_if_present(void *block_tag,
int *ex,
double **state_host_out,
int state_count);
int bssn_cuda_download_resident_state_if_present(void *block_tag,
int *ex,
double **state_host_out);
int bssn_cuda_download_constraint_outputs(int *ex,
double **constraint_host_out);
int bssn_cuda_pack_state_region_to_host_buffer(void *block_tag,
int state_index,
double *host_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_interp_state_point3(void *block_tag,
int *ex,
int state0,
int state1,
int state2,
double x0,
double y0,
double z0,
double dx,
double dy,
double dz,
double px,
double py,
double pz,
int ordn,
int symmetry,
double **state_host_key,
const double *soa3,
double *out3);
int bssn_cuda_interp_host_two_fields(void *block_tag,
int *ex,
double *field0,
double *field1,
double x0,
double y0,
double z0,
double dx,
double dy,
double dz,
const double *px,
const double *py,
const double *pz,
int npoints,
int ordn,
int symmetry,
const double *soa6,
double *out_interleaved);
int bssn_cuda_unpack_state_region_from_host_buffer(void *block_tag,
int state_index,
double *host_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_unpack_state_region_from_host_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
int state_index,
double *host_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_pack_state_batch_to_host_buffer(void *block_tag,
int state_count,
double *host_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_pack_state_batch_to_host_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *host_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_unpack_state_batch_from_host_buffer(void *block_tag,
int state_count,
double *host_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_unpack_state_batch_from_host_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *host_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_pack_state_batch_to_device_buffer(void *block_tag,
int state_count,
double *device_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_pack_state_batch_to_device_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *device_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_unpack_state_batch_from_device_buffer(void *block_tag,
int state_count,
double *device_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_unpack_state_batch_from_device_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *device_buffer,
int *ex,
int i0, int j0, int k0,
int sx, int sy, int sz);
int bssn_cuda_pack_state_segments_to_device_buffer(void *block_tag,
int state_count,
double *device_buffer,
int *ex,
int segment_count,
const int *segment_meta);
int bssn_cuda_pack_state_segments_to_device_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *device_buffer,
int *ex,
int segment_count,
const int *segment_meta);
int bssn_cuda_unpack_state_segments_from_device_buffer(void *block_tag,
int state_count,
double *device_buffer,
int *ex,
int segment_count,
const int *segment_meta);
int bssn_cuda_unpack_state_segments_from_device_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *device_buffer,
int *ex,
int segment_count,
const int *segment_meta);
int bssn_cuda_restrict_state_segments_to_device_buffer(void *block_tag,
int state_count,
double *device_buffer,
int *ex,
int segment_count,
const int *segment_meta);
int bssn_cuda_restrict_state_segments_to_device_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *device_buffer,
int *ex,
int segment_count,
const int *segment_meta,
const double *state_soa);
int bssn_cuda_prolong_state_segments_to_device_buffer(void *block_tag,
int state_count,
double *device_buffer,
int *ex,
int segment_count,
const int *segment_meta);
int bssn_cuda_prolong_state_segments_to_device_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *device_buffer,
int *ex,
int segment_count,
const int *segment_meta,
const double *state_soa);
int bssn_cuda_restrict_state_batch_to_device_buffer(void *block_tag,
int state_count,
double *device_buffer,
int *ex,
int sx, int sy, int sz,
int fi0, int fj0, int fk0);
int bssn_cuda_restrict_state_batch_to_device_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *device_buffer,
int *ex,
int sx, int sy, int sz,
int fi0, int fj0, int fk0,
const double *state_soa);
int bssn_cuda_prolong_state_batch_to_device_buffer(void *block_tag,
int state_count,
double *device_buffer,
int *ex,
int sx, int sy, int sz,
int ii0, int jj0, int kk0,
int lbc_i, int lbc_j, int lbc_k);
int bssn_cuda_prolong_state_batch_to_device_buffer_for_host_views(void *block_tag,
double **state_host_key,
int state_count,
double *device_buffer,
int *ex,
int sx, int sy, int sz,
int ii0, int jj0, int kk0,
int lbc_i, int lbc_j, int lbc_k,
const double *state_soa);
int bssn_cuda_download_state_subset(void *block_tag,
int *ex,
int subset_count,
const int *state_indices,
double **state_host_out);
int bssn_cuda_upload_state_subset(void *block_tag,
int *ex,
int subset_count,
const int *state_indices,
double **state_host_in);
int bssn_cuda_prepare_inter_time_level(void *block_tag,
int *ex,
int state_count,
double **src1_host_key,
double **src2_host_key,
double **src3_host_key,
double **dst_host_key,
int source_count,
int tindex);
int bssn_cuda_has_resident_state(void *block_tag);
void bssn_cuda_release_step_ctx(void *block_tag);
#ifdef __cplusplus
}
// C++-only helpers declared for derived equation classes (Z4C, etc.)
// Defined in bssn_class.C. Requires MyList, Patch, var from including TU.
bool bssn_cuda_use_resident_sync(int lev);
void bssn_cuda_download_level_state_if_present(MyList<Patch> *PatL, MyList<var> *vars, int myrank);
#endif
#endif

View File

@@ -1,58 +1,58 @@
#ifndef _CCTK_H_ #ifndef _CCTK_H_
#define _CCTK_H_ 1 #define _CCTK_H_ 1
/* Grab the main configuration info. */ /* Grab the main configuration info. */
#include "cctk_Config.h" #include "cctk_Config.h"
#define CCTK_THORNSTRING "AHFinderDirect" #define CCTK_THORNSTRING "AHFinderDirect"
/* Include the constants */ /* Include the constants */
#include "cctk_Constants.h" #include "cctk_Constants.h"
/* get the definition of ptrdiff_t */ /* get the definition of ptrdiff_t */
#include <stddef.h> #include <stddef.h>
int CCTK_VInfo(const char *thorn, const char *format, ...); int CCTK_VInfo(const char *thorn, const char *format, ...);
int CCTK_VWarn(int level, int CCTK_VWarn(int level,
int line, int line,
const char *file, const char *file,
const char *thorn, const char *thorn,
const char *format, const char *format,
...); ...);
#define CCTK_ERROR_INTERP_GHOST_SIZE_TOO_SMALL (-1001) #define CCTK_ERROR_INTERP_GHOST_SIZE_TOO_SMALL (-1001)
#ifdef __cplusplus #ifdef __cplusplus
#define HAVE_INLINE #define HAVE_INLINE
#else #else
#ifndef inline #ifndef inline
#define HAVE_INLINE #define HAVE_INLINE
#endif #endif
#endif #endif
#define CCTK_PRINTSEPARATOR \ #define CCTK_PRINTSEPARATOR \
printf("--------------------------------------------------------------------------------\n"); printf("--------------------------------------------------------------------------------\n");
#define _DECLARE_CCTK_ARGUMENTS _DECLARE_CCTK_CARGUMENTS #define _DECLARE_CCTK_ARGUMENTS _DECLARE_CCTK_CARGUMENTS
#define _DECLARE_CCTK_CARGUMENTS \ #define _DECLARE_CCTK_CARGUMENTS \
ptrdiff_t cctki_dummy_int; \ ptrdiff_t cctki_dummy_int; \
CCTK_REAL cctk_time = cctkGH->PhysTime; \ CCTK_REAL cctk_time = cctkGH->PhysTime; \
int cctk_iteration = 1; \ int cctk_iteration = 1; \
int cctk_dim = 3; int cctk_dim = 3;
#define CCTK_EQUALS(a, b) (CCTK_Equals((a), (b))) #define CCTK_EQUALS(a, b) (CCTK_Equals((a), (b)))
#define CCTK_PASS_CTOC cctkGH #define CCTK_PASS_CTOC cctkGH
#define CCTK_ORIGIN_SPACE(x) (cctk_origin_space[x] + cctk_delta_space[x] / cctk_levfac[x] * cctk_levoff[x] / cctk_levoffdenom[x]) #define CCTK_ORIGIN_SPACE(x) (cctk_origin_space[x] + cctk_delta_space[x] / cctk_levfac[x] * cctk_levoff[x] / cctk_levoffdenom[x])
#define CCTK_DELTA_SPACE(x) (cctk_delta_space[x] / cctk_levfac[x]) #define CCTK_DELTA_SPACE(x) (cctk_delta_space[x] / cctk_levfac[x])
#define CCTK_DELTA_TIME (cctk_delta_time / cctk_timefac) #define CCTK_DELTA_TIME (cctk_delta_time / cctk_timefac)
#define CCTK_LSSH(stag, dim) cctk_lssh[(stag) + CCTK_NSTAGGER * (dim)] #define CCTK_LSSH(stag, dim) cctk_lssh[(stag) + CCTK_NSTAGGER * (dim)]
#define CCTK_LSSH_IDX(stag, dim) ((stag) + CCTK_NSTAGGER * (dim)) #define CCTK_LSSH_IDX(stag, dim) ((stag) + CCTK_NSTAGGER * (dim))
#define CCTK_WARN(a, b) CCTK_Warn(a, __LINE__, __FILE__, CCTK_THORNSTRING, b) #define CCTK_WARN(a, b) CCTK_Warn(a, __LINE__, __FILE__, CCTK_THORNSTRING, b)
#define CCTK_MALLOC(s) CCTKi_Malloc(s, __LINE__, __FILE__) #define CCTK_MALLOC(s) CCTKi_Malloc(s, __LINE__, __FILE__)
#define CCTK_FREE(p) CCTKi_Free(p) #define CCTK_FREE(p) CCTKi_Free(p)
#define CCTK_INFO(a) CCTK_Info(CCTK_THORNSTRING, (a)) #define CCTK_INFO(a) CCTK_Info(CCTK_THORNSTRING, (a))
#define CCTK_PARAMWARN(a) CCTK_ParamWarn(CCTK_THORNSTRING, (a)) #define CCTK_PARAMWARN(a) CCTK_ParamWarn(CCTK_THORNSTRING, (a))
#endif #endif

View File

@@ -1,168 +1,168 @@
#ifndef _CCTK_CONFIG_H_ #ifndef _CCTK_CONFIG_H_
#define _CCTK_CONFIG_H_ #define _CCTK_CONFIG_H_
#define STDC_HEADERS 1 #define STDC_HEADERS 1
#define CCTK_FCALL #define CCTK_FCALL
#define HAVE_GETHOSTBYNAME 1 #define HAVE_GETHOSTBYNAME 1
#define HAVE_GETOPT_LONG_ONLY 1 #define HAVE_GETOPT_LONG_ONLY 1
#define HAVE_CRYPT 1 #define HAVE_CRYPT 1
#define HAVE_FINITE 1 #define HAVE_FINITE 1
#define HAVE_ISNAN 1 #define HAVE_ISNAN 1
#define HAVE_ISINF 1 #define HAVE_ISINF 1
#define HAVE_MKSTEMP 1 #define HAVE_MKSTEMP 1
#define HAVE_VA_COPY 1 #define HAVE_VA_COPY 1
/* Do we have mode_t ? */ /* Do we have mode_t ? */
#define HAVE_MODE_T 1 #define HAVE_MODE_T 1
#define HAVE_SOCKLEN_T 1 #define HAVE_SOCKLEN_T 1
#ifdef HAVE_SOCKLEN_T #ifdef HAVE_SOCKLEN_T
# define CCTK_SOCKLEN_T socklen_t # define CCTK_SOCKLEN_T socklen_t
#else #else
# define CCTK_SOCKLEN_T int # define CCTK_SOCKLEN_T int
#endif #endif
#define HAVE_TIME_H 1 #define HAVE_TIME_H 1
#define HAVE_SYS_IOCTL_H 1 #define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_SOCKET_H 1 #define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1 #define HAVE_UNISTD_H 1
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
#define HAVE_ASSERT_H 1 #define HAVE_ASSERT_H 1
#define HAVE_TGMATH_H 1 #define HAVE_TGMATH_H 1
#define HAVE_SYS_STAT_H 1 #define HAVE_SYS_STAT_H 1
#define HAVE_GETOPT_H 1 #define HAVE_GETOPT_H 1
#define HAVE_REGEX_H 1 #define HAVE_REGEX_H 1
#define HAVE_NETINET_IN_H 1 #define HAVE_NETINET_IN_H 1
#define HAVE_NETDB_H 1 #define HAVE_NETDB_H 1
#define HAVE_ARPA_INET_H 1 #define HAVE_ARPA_INET_H 1
#define HAVE_CRYPT_H 1 #define HAVE_CRYPT_H 1
#define HAVE_DIRENT_H 1 #define HAVE_DIRENT_H 1
#define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL_H 1
#define HAVE_MALLOC_H 1 #define HAVE_MALLOC_H 1
#define HAVE_MALLINFO 1 #define HAVE_MALLINFO 1
#define HAVE_MALLOPT 1 #define HAVE_MALLOPT 1
#define HAVE_M_MMAP_THRESHOLD_VALUE 1 #define HAVE_M_MMAP_THRESHOLD_VALUE 1
#define TIME_WITH_SYS_TIME 1 #define TIME_WITH_SYS_TIME 1
#define HAVE_VECTOR 1 #define HAVE_VECTOR 1
#define HAVE_VECTOR_H 1 #define HAVE_VECTOR_H 1
#define GETTIMEOFDAY_NEEDS_TIMEZONE 1 #define GETTIMEOFDAY_NEEDS_TIMEZONE 1
#define CCTK_CACHELINE_BYTES 64 #define CCTK_CACHELINE_BYTES 64
#define CCTK_CACHE_SIZE 1024*1024 #define CCTK_CACHE_SIZE 1024*1024
#define NULL_DEVICE "/dev/null" #define NULL_DEVICE "/dev/null"
#define CCTK_BUILD_OS "linux-gnu" #define CCTK_BUILD_OS "linux-gnu"
#define CCTK_BUILD_CPU "x86_64" #define CCTK_BUILD_CPU "x86_64"
#define CCTK_BUILD_VENDOR "unknown" #define CCTK_BUILD_VENDOR "unknown"
#define SIZEOF_SHORT_INT 2 #define SIZEOF_SHORT_INT 2
#define SIZEOF_INT 4 #define SIZEOF_INT 4
#define SIZEOF_LONG_INT 8 #define SIZEOF_LONG_INT 8
#define SIZEOF_LONG_LONG 8 #define SIZEOF_LONG_LONG 8
#define SIZEOF_LONG_DOUBLE 16 #define SIZEOF_LONG_DOUBLE 16
#define SIZEOF_DOUBLE 8 #define SIZEOF_DOUBLE 8
#define SIZEOF_FLOAT 4 #define SIZEOF_FLOAT 4
#define SIZEOF_CHAR_P 8 #define SIZEOF_CHAR_P 8
#define CCTK_REAL_PRECISION_8 1 #define CCTK_REAL_PRECISION_8 1
#define CCTK_INTEGER_PRECISION_4 1 #define CCTK_INTEGER_PRECISION_4 1
#define HAVE_CCTK_INT8 1 #define HAVE_CCTK_INT8 1
#define HAVE_CCTK_INT4 1 #define HAVE_CCTK_INT4 1
#define HAVE_CCTK_INT2 1 #define HAVE_CCTK_INT2 1
#define HAVE_CCTK_INT1 1 #define HAVE_CCTK_INT1 1
#define HAVE_CCTK_REAL16 1 #define HAVE_CCTK_REAL16 1
#define HAVE_CCTK_REAL8 1 #define HAVE_CCTK_REAL8 1
#define HAVE_CCTK_REAL4 1 #define HAVE_CCTK_REAL4 1
#define CCTK_INT8 long int #define CCTK_INT8 long int
#define CCTK_INT4 int #define CCTK_INT4 int
#define CCTK_INT2 short int #define CCTK_INT2 short int
#define CCTK_INT1 signed char #define CCTK_INT1 signed char
#define CCTK_REAL16 long double #define CCTK_REAL16 long double
#define CCTK_REAL8 double #define CCTK_REAL8 double
#define CCTK_REAL4 float #define CCTK_REAL4 float
#ifndef __cplusplus #ifndef __cplusplus
#ifdef CCTK_C_RESTRICT #ifdef CCTK_C_RESTRICT
#define restrict CCTK_C_RESTRICT #define restrict CCTK_C_RESTRICT
#endif #endif
/* Allow the use of CCTK_RESTRICT as a qualifier always. */ /* Allow the use of CCTK_RESTRICT as a qualifier always. */
#ifdef CCTK_C_RESTRICT #ifdef CCTK_C_RESTRICT
#define CCTK_RESTRICT CCTK_C_RESTRICT #define CCTK_RESTRICT CCTK_C_RESTRICT
#else #else
#define CCTK_RESTRICT restrict #define CCTK_RESTRICT restrict
#endif #endif
#ifdef HAVE_CCTK_C_BOOL #ifdef HAVE_CCTK_C_BOOL
#define CCTK_HAVE_C_BOOL #define CCTK_HAVE_C_BOOL
#endif #endif
#endif /* ! defined __cplusplus */ #endif /* ! defined __cplusplus */
/****************************************************************************/ /****************************************************************************/
/****************************************************************************/ /****************************************************************************/
/* C++ specific stuff */ /* C++ specific stuff */
/****************************************************************************/ /****************************************************************************/
#ifdef __cplusplus #ifdef __cplusplus
/* Some C++ compilers don't have bool ! */ /* Some C++ compilers don't have bool ! */
#define HAVE_CCTK_CXX_BOOL 1 #define HAVE_CCTK_CXX_BOOL 1
#ifndef HAVE_CCTK_CXX_BOOL #ifndef HAVE_CCTK_CXX_BOOL
typedef enum {false, true} bool; typedef enum {false, true} bool;
#else #else
/* deprecated in beta15 */ /* deprecated in beta15 */
#define CCTK_HAVE_CXX_BOOL #define CCTK_HAVE_CXX_BOOL
#endif #endif
/* Some C++ compilers recognise the restrict keyword */ /* Some C++ compilers recognise the restrict keyword */
#define CCTK_CXX_RESTRICT __restrict__ #define CCTK_CXX_RESTRICT __restrict__
/* Since this is non-standard leave commented out for the moment */ /* Since this is non-standard leave commented out for the moment */
#if 0 #if 0
/* Define to empty if the keyword does not work. */ /* Define to empty if the keyword does not work. */
#ifdef CCTK_CXX_RESTRICT #ifdef CCTK_CXX_RESTRICT
#define restrict CCTK_CXX_RESTRICT #define restrict CCTK_CXX_RESTRICT
#endif #endif
#endif #endif
/* Allow the use of CCTK_RESTRICT as a qualifier always. */ /* Allow the use of CCTK_RESTRICT as a qualifier always. */
#ifdef CCTK_CXX_RESTRICT #ifdef CCTK_CXX_RESTRICT
#define CCTK_RESTRICT CCTK_CXX_RESTRICT #define CCTK_RESTRICT CCTK_CXX_RESTRICT
#else #else
#define CCTK_RESTRICT restrict #define CCTK_RESTRICT restrict
#endif #endif
#endif /* __cplusplus */ #endif /* __cplusplus */
/****************************************************************************/ /****************************************************************************/
#ifdef FCODE #ifdef FCODE
#define HAVE_CCTK_FORTRAN_REAL4 1 #define HAVE_CCTK_FORTRAN_REAL4 1
#define HAVE_CCTK_FORTRAN_REAL8 1 #define HAVE_CCTK_FORTRAN_REAL8 1
#define HAVE_CCTK_FORTRAN_REAL16 1 #define HAVE_CCTK_FORTRAN_REAL16 1
#define HAVE_CCTK_FORTRAN_COMPLEX8 1 #define HAVE_CCTK_FORTRAN_COMPLEX8 1
#define HAVE_CCTK_FORTRAN_COMPLEX16 1 #define HAVE_CCTK_FORTRAN_COMPLEX16 1
#define HAVE_CCTK_FORTRAN_COMPLEX32 1 #define HAVE_CCTK_FORTRAN_COMPLEX32 1
#endif /* FCODE */ #endif /* FCODE */
/* Now include the code to pick an appropriate precison for reals and ints */ /* Now include the code to pick an appropriate precison for reals and ints */
#include "cctk_Types.h" #include "cctk_Types.h"
#endif /* _CCTK_CONFIG_H_ */ #endif /* _CCTK_CONFIG_H_ */

View File

@@ -1,57 +1,57 @@
#ifndef _CCTK_CONSTANTS_H_ #ifndef _CCTK_CONSTANTS_H_
#define _CCTK_CONSTANTS_H_ #define _CCTK_CONSTANTS_H_
#define CCTK_VARIABLE_VOID 100 #define CCTK_VARIABLE_VOID 100
#define CCTK_VARIABLE_BYTE 101 #define CCTK_VARIABLE_BYTE 101
#define CCTK_VARIABLE_INT 102 #define CCTK_VARIABLE_INT 102
#define CCTK_VARIABLE_INT1 103 #define CCTK_VARIABLE_INT1 103
#define CCTK_VARIABLE_INT2 104 #define CCTK_VARIABLE_INT2 104
#define CCTK_VARIABLE_INT4 105 #define CCTK_VARIABLE_INT4 105
#define CCTK_VARIABLE_INT8 106 #define CCTK_VARIABLE_INT8 106
#define CCTK_VARIABLE_REAL 107 #define CCTK_VARIABLE_REAL 107
#define CCTK_VARIABLE_REAL4 108 #define CCTK_VARIABLE_REAL4 108
#define CCTK_VARIABLE_REAL8 109 #define CCTK_VARIABLE_REAL8 109
#define CCTK_VARIABLE_REAL16 110 #define CCTK_VARIABLE_REAL16 110
#define CCTK_VARIABLE_COMPLEX 111 #define CCTK_VARIABLE_COMPLEX 111
#define CCTK_VARIABLE_COMPLEX8 112 #define CCTK_VARIABLE_COMPLEX8 112
#define CCTK_VARIABLE_COMPLEX16 113 #define CCTK_VARIABLE_COMPLEX16 113
#define CCTK_VARIABLE_COMPLEX32 114 #define CCTK_VARIABLE_COMPLEX32 114
#define CCTK_VARIABLE_CHAR 115 #define CCTK_VARIABLE_CHAR 115
#define CCTK_VARIABLE_STRING 116 #define CCTK_VARIABLE_STRING 116
#define CCTK_VARIABLE_POINTER 117 #define CCTK_VARIABLE_POINTER 117
#define CCTK_VARIABLE_POINTER_TO_CONST 118 #define CCTK_VARIABLE_POINTER_TO_CONST 118
#define CCTK_VARIABLE_FPOINTER 119 #define CCTK_VARIABLE_FPOINTER 119
/* DEPRECATED IN BETA 12 */ /* DEPRECATED IN BETA 12 */
#define CCTK_VARIABLE_FN_POINTER CCTK_VARIABLE_FPOINTER #define CCTK_VARIABLE_FN_POINTER CCTK_VARIABLE_FPOINTER
/* steerable status of parameters */ /* steerable status of parameters */
#define CCTK_STEERABLE_NEVER 200 #define CCTK_STEERABLE_NEVER 200
#define CCTK_STEERABLE_ALWAYS 201 #define CCTK_STEERABLE_ALWAYS 201
#define CCTK_STEERABLE_RECOVER 202 #define CCTK_STEERABLE_RECOVER 202
/* number of staggerings */ /* number of staggerings */
#define CCTK_NSTAGGER 3 #define CCTK_NSTAGGER 3
/* group distributions */ /* group distributions */
#define CCTK_DISTRIB_CONSTANT 301 #define CCTK_DISTRIB_CONSTANT 301
#define CCTK_DISTRIB_DEFAULT 302 #define CCTK_DISTRIB_DEFAULT 302
/* group types */ /* group types */
#define CCTK_SCALAR 401 #define CCTK_SCALAR 401
#define CCTK_GF 402 #define CCTK_GF 402
#define CCTK_ARRAY 403 #define CCTK_ARRAY 403
/* group scopes */ /* group scopes */
#define CCTK_PRIVATE 501 #define CCTK_PRIVATE 501
#define CCTK_PROTECTED 502 #define CCTK_PROTECTED 502
#define CCTK_PUBLIC 503 #define CCTK_PUBLIC 503
/* constants for CCTK_TraverseString() */ /* constants for CCTK_TraverseString() */
#define CCTK_VAR 601 #define CCTK_VAR 601
#define CCTK_GROUP 602 #define CCTK_GROUP 602
#define CCTK_GROUP_OR_VAR 603 #define CCTK_GROUP_OR_VAR 603
#endif /* _CCTK_CONSTANTS_ */ #endif /* _CCTK_CONSTANTS_ */

View File

@@ -1,180 +1,180 @@
#ifndef _CCTK_TYPES_H_ #ifndef _CCTK_TYPES_H_
#define _CCTK_TYPES_H_ #define _CCTK_TYPES_H_
#ifndef _CCTK_CONFIG_H_ #ifndef _CCTK_CONFIG_H_
#include "cctk_Config.h" #include "cctk_Config.h"
#endif #endif
typedef void *CCTK_POINTER; typedef void *CCTK_POINTER;
typedef const void *CCTK_POINTER_TO_CONST; typedef const void *CCTK_POINTER_TO_CONST;
typedef void (*CCTK_FPOINTER)(void); typedef void (*CCTK_FPOINTER)(void);
#define HAVE_CCTK_POINTER 1 #define HAVE_CCTK_POINTER 1
#define HAVE_CCTK_POINTER_TO_CONST 1 #define HAVE_CCTK_POINTER_TO_CONST 1
#define HAVE_CCTK_FPOINTER 1 #define HAVE_CCTK_FPOINTER 1
/* Character types */ /* Character types */
typedef char CCTK_CHAR; typedef char CCTK_CHAR;
typedef const char * CCTK_STRING; typedef const char * CCTK_STRING;
#define HAVE_CCTK_CHAR 1 #define HAVE_CCTK_CHAR 1
#define HAVE_CCTK_STRING 1 #define HAVE_CCTK_STRING 1
/* Structures for complex types */ /* Structures for complex types */
#ifdef HAVE_CCTK_REAL16 #ifdef HAVE_CCTK_REAL16
#define HAVE_CCTK_COMPLEX32 1 #define HAVE_CCTK_COMPLEX32 1
typedef struct CCTK_COMPLEX32 typedef struct CCTK_COMPLEX32
{ {
CCTK_REAL16 Re; CCTK_REAL16 Re;
CCTK_REAL16 Im; CCTK_REAL16 Im;
#ifdef __cplusplus #ifdef __cplusplus
CCTK_REAL16 real() const { return Re; } CCTK_REAL16 real() const { return Re; }
CCTK_REAL16 imag() const { return Im; } CCTK_REAL16 imag() const { return Im; }
#endif #endif
} CCTK_COMPLEX32; } CCTK_COMPLEX32;
#endif #endif
#ifdef HAVE_CCTK_REAL8 #ifdef HAVE_CCTK_REAL8
#define HAVE_CCTK_COMPLEX16 1 #define HAVE_CCTK_COMPLEX16 1
typedef struct CCTK_COMPLEX16 typedef struct CCTK_COMPLEX16
{ {
CCTK_REAL8 Re; CCTK_REAL8 Re;
CCTK_REAL8 Im; CCTK_REAL8 Im;
#ifdef __cplusplus #ifdef __cplusplus
CCTK_REAL8 real() const { return Re; } CCTK_REAL8 real() const { return Re; }
CCTK_REAL8 imag() const { return Im; } CCTK_REAL8 imag() const { return Im; }
#endif #endif
} CCTK_COMPLEX16; } CCTK_COMPLEX16;
#endif #endif
#ifdef HAVE_CCTK_REAL4 #ifdef HAVE_CCTK_REAL4
#define HAVE_CCTK_COMPLEX8 1 #define HAVE_CCTK_COMPLEX8 1
typedef struct CCTK_COMPLEX8 typedef struct CCTK_COMPLEX8
{ {
CCTK_REAL4 Re; CCTK_REAL4 Re;
CCTK_REAL4 Im; CCTK_REAL4 Im;
#ifdef __cplusplus #ifdef __cplusplus
CCTK_REAL4 real() const { return Re; } CCTK_REAL4 real() const { return Re; }
CCTK_REAL4 imag() const { return Im; } CCTK_REAL4 imag() const { return Im; }
#endif #endif
} CCTK_COMPLEX8; } CCTK_COMPLEX8;
#endif #endif
/* Small positive integer type */ /* Small positive integer type */
typedef unsigned char CCTK_BYTE; typedef unsigned char CCTK_BYTE;
#define HAVE_CCTK_BYTE 1 #define HAVE_CCTK_BYTE 1
/* Define stuff for fortran. */ /* Define stuff for fortran. */
#ifdef FCODE #ifdef FCODE
#define CCTK_POINTER integer*SIZEOF_CHAR_P #define CCTK_POINTER integer*SIZEOF_CHAR_P
#define CCTK_POINTER_TO_CONST integer*SIZEOF_CHAR_P #define CCTK_POINTER_TO_CONST integer*SIZEOF_CHAR_P
/* TODO: add autoconf for determining the size of function pointers */ /* TODO: add autoconf for determining the size of function pointers */
#define CCTK_FPOINTER integer*SIZEOF_CHAR_P #define CCTK_FPOINTER integer*SIZEOF_CHAR_P
#define HAVE_CCTK_POINTER 1 #define HAVE_CCTK_POINTER 1
#define HAVE_CCTK_POINTER_TO_CONST 1 #define HAVE_CCTK_POINTER_TO_CONST 1
#define HAVE_CCTK_FPOINTER 1 #define HAVE_CCTK_FPOINTER 1
/* Character types */ /* Character types */
/* A single character does not exist in Fortran; in Fortran, all /* A single character does not exist in Fortran; in Fortran, all
character types are strings. Hence we do not define CCTK_CHAR. */ character types are strings. Hence we do not define CCTK_CHAR. */
/* #define CCTK_CHAR CHARACTER */ /* #define CCTK_CHAR CHARACTER */
/* #define HAVE_CCTK_CHAR 1 */ /* #define HAVE_CCTK_CHAR 1 */
/* This is a C-string, i.e., only a pointer */ /* This is a C-string, i.e., only a pointer */
#define CCTK_STRING CCTK_POINTER_TO_CONST #define CCTK_STRING CCTK_POINTER_TO_CONST
#define HAVE_CCTK_STRING 1 #define HAVE_CCTK_STRING 1
#ifdef HAVE_CCTK_INT8 #ifdef HAVE_CCTK_INT8
#define CCTK_INT8 INTEGER*8 #define CCTK_INT8 INTEGER*8
#endif #endif
#ifdef HAVE_CCTK_INT4 #ifdef HAVE_CCTK_INT4
#define CCTK_INT4 INTEGER*4 #define CCTK_INT4 INTEGER*4
#endif #endif
#ifdef HAVE_CCTK_INT2 #ifdef HAVE_CCTK_INT2
#define CCTK_INT2 INTEGER*2 #define CCTK_INT2 INTEGER*2
#endif #endif
#ifdef HAVE_CCTK_INT1 #ifdef HAVE_CCTK_INT1
#define CCTK_INT1 INTEGER*1 #define CCTK_INT1 INTEGER*1
#endif #endif
#ifdef HAVE_CCTK_REAL16 #ifdef HAVE_CCTK_REAL16
#define CCTK_REAL16 REAL*16 #define CCTK_REAL16 REAL*16
#define HAVE_CCTK_COMPLEX32 1 #define HAVE_CCTK_COMPLEX32 1
#define CCTK_COMPLEX32 COMPLEX*32 #define CCTK_COMPLEX32 COMPLEX*32
#endif #endif
#ifdef HAVE_CCTK_REAL8 #ifdef HAVE_CCTK_REAL8
#define CCTK_REAL8 REAL*8 #define CCTK_REAL8 REAL*8
#define HAVE_CCTK_COMPLEX16 1 #define HAVE_CCTK_COMPLEX16 1
#define CCTK_COMPLEX16 COMPLEX*16 #define CCTK_COMPLEX16 COMPLEX*16
#endif #endif
#ifdef HAVE_CCTK_REAL4 #ifdef HAVE_CCTK_REAL4
#define CCTK_REAL4 REAL*4 #define CCTK_REAL4 REAL*4
#define HAVE_CCTK_COMPLEX8 1 #define HAVE_CCTK_COMPLEX8 1
#define CCTK_COMPLEX8 COMPLEX*8 #define CCTK_COMPLEX8 COMPLEX*8
#endif #endif
/* Should be unsigned, but Fortran doesn't have that */ /* Should be unsigned, but Fortran doesn't have that */
#define CCTK_BYTE INTEGER*1 #define CCTK_BYTE INTEGER*1
#define HAVE_CCTK_BYTE 1 #define HAVE_CCTK_BYTE 1
#endif /*FCODE */ #endif /*FCODE */
/* Now pick the types based upon the precision variable. */ /* Now pick the types based upon the precision variable. */
/* Floating point precision */ /* Floating point precision */
#ifdef CCTK_REAL_PRECISION_16 #ifdef CCTK_REAL_PRECISION_16
#define CCTK_REAL_PRECISION 16 #define CCTK_REAL_PRECISION 16
#define CCTK_REAL CCTK_REAL16 #define CCTK_REAL CCTK_REAL16
#endif #endif
#ifdef CCTK_REAL_PRECISION_8 #ifdef CCTK_REAL_PRECISION_8
#define CCTK_REAL_PRECISION 8 #define CCTK_REAL_PRECISION 8
#define CCTK_REAL CCTK_REAL8 #define CCTK_REAL CCTK_REAL8
#endif #endif
#ifdef CCTK_REAL_PRECISION_4 #ifdef CCTK_REAL_PRECISION_4
#define CCTK_REAL_PRECISION 4 #define CCTK_REAL_PRECISION 4
#define CCTK_REAL CCTK_REAL4 #define CCTK_REAL CCTK_REAL4
#endif #endif
/* Integer precision */ /* Integer precision */
#ifdef CCTK_INTEGER_PRECISION_8 #ifdef CCTK_INTEGER_PRECISION_8
#define CCTK_INTEGER_PRECISION 8 #define CCTK_INTEGER_PRECISION 8
#define CCTK_INT CCTK_INT8 #define CCTK_INT CCTK_INT8
#endif #endif
#ifdef CCTK_INTEGER_PRECISION_4 #ifdef CCTK_INTEGER_PRECISION_4
#define CCTK_INTEGER_PRECISION 4 #define CCTK_INTEGER_PRECISION 4
#define CCTK_INT CCTK_INT4 #define CCTK_INT CCTK_INT4
#endif #endif
#ifdef CCTK_INTEGER_PRECISION_2 #ifdef CCTK_INTEGER_PRECISION_2
#define CCTK_INTEGER_PRECISION 2 #define CCTK_INTEGER_PRECISION 2
#define CCTK_INT CCTK_INT2 #define CCTK_INT CCTK_INT2
#endif #endif
#ifdef CCTK_INTEGER_PRECISION_1 #ifdef CCTK_INTEGER_PRECISION_1
#define CCTK_INTEGER_PRECISION 1 #define CCTK_INTEGER_PRECISION 1
#define CCTK_INT CCTK_INT1 #define CCTK_INT CCTK_INT1
#endif #endif
/* Complex precision */ /* Complex precision */
#ifdef CCTK_REAL_PRECISION_16 #ifdef CCTK_REAL_PRECISION_16
#define CCTK_COMPLEX_PRECISION 32 #define CCTK_COMPLEX_PRECISION 32
#define CCTK_COMPLEX CCTK_COMPLEX32 #define CCTK_COMPLEX CCTK_COMPLEX32
#endif #endif
#ifdef CCTK_REAL_PRECISION_8 #ifdef CCTK_REAL_PRECISION_8
#define CCTK_COMPLEX_PRECISION 16 #define CCTK_COMPLEX_PRECISION 16
#define CCTK_COMPLEX CCTK_COMPLEX16 #define CCTK_COMPLEX CCTK_COMPLEX16
#endif #endif
#ifdef CCTK_REAL_PRECISION_4 #ifdef CCTK_REAL_PRECISION_4
#define CCTK_COMPLEX_PRECISION 8 #define CCTK_COMPLEX_PRECISION 8
#define CCTK_COMPLEX CCTK_COMPLEX8 #define CCTK_COMPLEX CCTK_COMPLEX8
#endif #endif
#endif /*_CCTK_TYPES_H_ */ #endif /*_CCTK_TYPES_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,92 +1,92 @@
#ifndef CGH_H #ifndef CGH_H
#define CGH_H #define CGH_H
#include <mpi.h> #include <mpi.h>
#include "MyList.h" #include "MyList.h"
#include "MPatch.h" #include "MPatch.h"
#include "macrodef.h" #include "macrodef.h"
#include "monitor.h" #include "monitor.h"
#include "Parallel.h" #include "Parallel.h"
class cgh class cgh
{ {
public: public:
int levels, movls, BH_num_in; int levels, movls, BH_num_in;
// information of boxes // information of boxes
int *grids; int *grids;
double ***bbox; double ***bbox;
int ***shape; int ***shape;
double ***handle; double ***handle;
double ***Porgls; double ***Porgls;
double *Lt; double *Lt;
// information of Patch list // information of Patch list
MyList<Patch> **PatL; MyList<Patch> **PatL;
// information of OutBdLow2Hi point list and Restrict point list // information of OutBdLow2Hi point list and Restrict point list
#if (RPB == 1) #if (RPB == 1)
MyList<Parallel::pointstru_bam> **bdsul, **rsul; MyList<Parallel::pointstru_bam> **bdsul, **rsul;
#endif #endif
#if (PSTR == 1 || PSTR == 2 || PSTR == 3) #if (PSTR == 1 || PSTR == 2 || PSTR == 3)
int mylev; int mylev;
int *start_rank, *end_rank; int *start_rank, *end_rank;
MPI_Comm *Commlev; MPI_Comm *Commlev;
#endif #endif
protected: protected:
int ingfs, fngfs; int ingfs, fngfs;
static constexpr double ratio = 0.75; static constexpr double ratio = 0.75;
int trfls; int trfls;
public: public:
cgh(int ingfsi, int fngfsi, int Symmetry, char *filename, int checkrun, monitor *ErrorMonitor); cgh(int ingfsi, int fngfsi, int Symmetry, char *filename, int checkrun, monitor *ErrorMonitor);
~cgh(); ~cgh();
void compose_cgh(int nprocs); void compose_cgh(int nprocs);
void sethandle(monitor *ErrorMonitor); void sethandle(monitor *ErrorMonitor);
void checkPatchList(MyList<Patch> *PatL, bool buflog); void checkPatchList(MyList<Patch> *PatL, bool buflog);
void Regrid(int Symmetry, int BH_num, double **Porgbr, double **Porg0, void Regrid(int Symmetry, int BH_num, double **Porgbr, double **Porg0,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *OldList, MyList<var> *StateList,
MyList<var> *FutureList, MyList<var> *tmList, bool BB, MyList<var> *FutureList, MyList<var> *tmList, bool BB,
monitor *ErrorMonitor); monitor *ErrorMonitor);
void Regrid_fake(int Symmetry, int BH_num, double **Porgbr, double **Porg0, void Regrid_fake(int Symmetry, int BH_num, double **Porgbr, double **Porg0,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *OldList, MyList<var> *StateList,
MyList<var> *FutureList, MyList<var> *tmList, bool BB, MyList<var> *FutureList, MyList<var> *tmList, bool BB,
monitor *ErrorMonitor); monitor *ErrorMonitor);
void recompose_cgh(int nprocs, bool *lev_flag, void recompose_cgh(int nprocs, bool *lev_flag,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *OldList, MyList<var> *StateList,
MyList<var> *FutureList, MyList<var> *tmList, MyList<var> *FutureList, MyList<var> *tmList,
int Symmetry, bool BB); int Symmetry, bool BB);
void recompose_cgh_fake(int nprocs, bool *lev_flag, void recompose_cgh_fake(int nprocs, bool *lev_flag,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *OldList, MyList<var> *StateList,
MyList<var> *FutureList, MyList<var> *tmList, MyList<var> *FutureList, MyList<var> *tmList,
int Symmetry, bool BB); int Symmetry, bool BB);
void read_bbox(int Symmetry, char *filename); void read_bbox(int Symmetry, char *filename);
MyList<Patch> *construct_patchlist(int lev, int Symmetry); MyList<Patch> *construct_patchlist(int lev, int Symmetry);
bool Interp_One_Point(MyList<var> *VarList, bool Interp_One_Point(MyList<var> *VarList,
double *XX, /*input global Cartesian coordinate*/ double *XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry); double *Shellf, int Symmetry);
void recompose_cgh_Onelevel(int nprocs, int lev, void recompose_cgh_Onelevel(int nprocs, int lev,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *OldList, MyList<var> *StateList,
MyList<var> *FutureList, MyList<var> *tmList, MyList<var> *FutureList, MyList<var> *tmList,
int Symmetry, bool BB); int Symmetry, bool BB);
bool Regrid_Onelevel(int lev, int Symmetry, int BH_num, double **Porgbr, double **Porg0, bool Regrid_Onelevel(int lev, int Symmetry, int BH_num, double **Porgbr, double **Porg0,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *OldList, MyList<var> *StateList,
MyList<var> *FutureList, MyList<var> *tmList, bool BB, MyList<var> *FutureList, MyList<var> *tmList, bool BB,
monitor *ErrorMonitor); monitor *ErrorMonitor);
void Regrid_Onelevel_aux(int lev, int Symmetry, int BH_num, double **Porgbr, double **Porg0, void Regrid_Onelevel_aux(int lev, int Symmetry, int BH_num, double **Porgbr, double **Porg0,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *OldList, MyList<var> *StateList,
MyList<var> *FutureList, MyList<var> *tmList, bool BB, MyList<var> *FutureList, MyList<var> *tmList, bool BB,
monitor *ErrorMonitor); monitor *ErrorMonitor);
void settrfls(const int lev); void settrfls(const int lev);
#if (PSTR == 1 || PSTR == 2 || PSTR == 3) #if (PSTR == 1 || PSTR == 2 || PSTR == 3)
void construct_mylev(int nprocs); void construct_mylev(int nprocs);
#endif #endif
}; };
#endif /* CGH_H */ #endif /* CGH_H */

View File

@@ -1,60 +1,60 @@
#ifndef CHECKPOINT_H #ifndef CHECKPOINT_H
#define CHECKPOINT_H #define CHECKPOINT_H
#ifdef newc #ifdef newc
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <strstream> #include <strstream>
#include <fstream> #include <fstream>
#include <string> #include <string>
using namespace std; using namespace std;
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#include <strstream> #include <strstream>
#include <fstream.h> #include <fstream.h>
#include <string.h> #include <string.h>
#endif #endif
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <mpi.h> #include <mpi.h>
#include "var.h" #include "var.h"
#include "MyList.h" #include "MyList.h"
#include "cgh.h" #include "cgh.h"
#include "macrodef.h" #include "macrodef.h"
#include "ShellPatch.h" #include "ShellPatch.h"
class checkpoint class checkpoint
{ {
public: public:
bool checkedrun; bool checkedrun;
bool I_Print; bool I_Print;
char *filename; char *filename;
MyList<var> *CheckList; MyList<var> *CheckList;
string out_dir; string out_dir;
public: public:
checkpoint(bool checked, const char fname[], int myrank); checkpoint(bool checked, const char fname[], int myrank);
// checkpoint(bool checked, char fname[50], int myrank); // checkpoint(bool checked, char fname[50], int myrank);
~checkpoint(); ~checkpoint();
void addvariable(var *VV); void addvariable(var *VV);
void addvariablelist(MyList<var> *VL); void addvariablelist(MyList<var> *VL);
void write_Black_Hole_position(int BH_num_input, int BH_num, double **Porg0, double **Porgbr, double *Mass); void write_Black_Hole_position(int BH_num_input, int BH_num, double **Porg0, double **Porgbr, double *Mass);
void read_Black_Hole_position(int &BH_num_input, int &BH_num, double **&Porg0, double *&Pmom, void read_Black_Hole_position(int &BH_num_input, int &BH_num, double **&Porg0, double *&Pmom,
double *&Spin, double *&Mass, double **&Porgbr, double **&Porg, double *&Spin, double *&Mass, double **&Porgbr, double **&Porg,
double **&Porg1, double **&Porg_rhs); double **&Porg1, double **&Porg_rhs);
void writecheck_cgh(double time, cgh *GH); void writecheck_cgh(double time, cgh *GH);
void readcheck_cgh(double &time, cgh *GH, int myrank, int nprocs, int Symmetry); void readcheck_cgh(double &time, cgh *GH, int myrank, int nprocs, int Symmetry);
void writecheck_sh(double time, ShellPatch *SH); void writecheck_sh(double time, ShellPatch *SH);
void readcheck_sh(ShellPatch *SH, int myrank); void readcheck_sh(ShellPatch *SH, int myrank);
void write_bssn(double LastDump, double Last2dDump, double LastAnas); void write_bssn(double LastDump, double Last2dDump, double LastAnas);
void read_bssn(double &LastDump, double &Last2dDump, double &LastAnas); void read_bssn(double &LastDump, double &Last2dDump, double &LastAnas);
}; };
#endif /* CHECKPOINT */ #endif /* CHECKPOINT */

View File

@@ -1,16 +1,16 @@
#ifndef AHFINDERDIRECT__CONFIG_H #ifndef AHFINDERDIRECT__CONFIG_H
#define AHFINDERDIRECT__CONFIG_H #define AHFINDERDIRECT__CONFIG_H
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
size_t Util_Strlcat(char* dst, const char* src, size_t dst_size); size_t Util_Strlcat(char* dst, const char* src, size_t dst_size);
size_t Util_Strlcpy(char* dst, const char* src, size_t dst_size); size_t Util_Strlcpy(char* dst, const char* src, size_t dst_size);
typedef CCTK_REAL fp; typedef CCTK_REAL fp;
typedef CCTK_INT integer; typedef CCTK_INT integer;
#endif /* AHFINDERDIRECT__CONFIG_H */ #endif /* AHFINDERDIRECT__CONFIG_H */

View File

@@ -1,173 +1,173 @@
#ifndef COORDS_H #ifndef COORDS_H
#define COORDS_H #define COORDS_H
namespace AHFinderDirect namespace AHFinderDirect
{ {
namespace local_coords namespace local_coords
{ {
// compare if two angles are fuzzily equal mod 2*pi radians (360 degrees) // compare if two angles are fuzzily equal mod 2*pi radians (360 degrees)
bool fuzzy_EQ_ang(fp ang1, fp ang2); // radians bool fuzzy_EQ_ang(fp ang1, fp ang2); // radians
bool fuzzy_EQ_dang(fp dang1, fp dang2); // degrees bool fuzzy_EQ_dang(fp dang1, fp dang2); // degrees
// modulo-reduce {ang,dang} to be (fuzzily) within the range // modulo-reduce {ang,dang} to be (fuzzily) within the range
// [min,max]_{ang,dang}, or error_exit() if no such value exists // [min,max]_{ang,dang}, or error_exit() if no such value exists
fp modulo_reduce_ang(fp ang, fp min_ang, fp max_ang); fp modulo_reduce_ang(fp ang, fp min_ang, fp max_ang);
fp modulo_reduce_dang(fp dang, fp min_dang, fp max_dang); fp modulo_reduce_dang(fp dang, fp min_dang, fp max_dang);
} // close namespace local_coords:: } // close namespace local_coords::
namespace local_coords namespace local_coords
{ {
// (r,(mu,nu,phi)) <--> (x,y,z) // (r,(mu,nu,phi)) <--> (x,y,z)
void xyz_of_r_mu_nu(fp r, fp mu, fp nu, fp &x, fp &y, fp &z); void xyz_of_r_mu_nu(fp r, fp mu, fp nu, fp &x, fp &y, fp &z);
void xyz_of_r_mu_phi(fp r, fp mu, fp phi, fp &x, fp &y, fp &z); void xyz_of_r_mu_phi(fp r, fp mu, fp phi, fp &x, fp &y, fp &z);
void xyz_of_r_nu_phi(fp r, fp nu, fp phi, fp &x, fp &y, fp &z); void xyz_of_r_nu_phi(fp r, fp nu, fp phi, fp &x, fp &y, fp &z);
fp r_of_xyz(fp x, fp y, fp z); fp r_of_xyz(fp x, fp y, fp z);
fp mu_of_yz(fp y, fp z); fp mu_of_yz(fp y, fp z);
fp nu_of_xz(fp x, fp z); fp nu_of_xz(fp x, fp z);
fp phi_of_xy(fp x, fp y); fp phi_of_xy(fp x, fp y);
// ((mu,nu,phi)) --> the 3rd // ((mu,nu,phi)) --> the 3rd
fp phi_of_mu_nu(fp mu, fp nu); fp phi_of_mu_nu(fp mu, fp nu);
fp nu_of_mu_phi(fp mu, fp phi); fp nu_of_mu_phi(fp mu, fp phi);
fp mu_of_nu_phi(fp nu, fp phi); fp mu_of_nu_phi(fp nu, fp phi);
// partial {x,y,z} / partial {mu,nu,phi} // partial {x,y,z} / partial {mu,nu,phi}
void partial_xyz_wrt_r_mu_nu(fp r, fp mu, fp nu, void partial_xyz_wrt_r_mu_nu(fp r, fp mu, fp nu,
fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_nu, fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_nu,
fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_nu, fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_nu,
fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_nu); fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_nu);
void partial_xyz_wrt_r_mu_phi(fp r, fp mu, fp phi, void partial_xyz_wrt_r_mu_phi(fp r, fp mu, fp phi,
fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_phi, fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_phi,
fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_phi, fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_phi,
fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_phi); fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_phi);
void partial_xyz_wrt_r_nu_phi(fp r, fp nu, fp phi, void partial_xyz_wrt_r_nu_phi(fp r, fp nu, fp phi,
fp &partial_x_wrt_r, fp &partial_x_wrt_nu, fp &partial_x_wrt_phi, fp &partial_x_wrt_r, fp &partial_x_wrt_nu, fp &partial_x_wrt_phi,
fp &partial_y_wrt_r, fp &partial_y_wrt_nu, fp &partial_y_wrt_phi, fp &partial_y_wrt_r, fp &partial_y_wrt_nu, fp &partial_y_wrt_phi,
fp &partial_z_wrt_r, fp &partial_z_wrt_nu, fp &partial_z_wrt_phi); fp &partial_z_wrt_r, fp &partial_z_wrt_nu, fp &partial_z_wrt_phi);
// partial {mu,nu,phi} / partial {x,y,z} // partial {mu,nu,phi} / partial {x,y,z}
fp partial_mu_wrt_y(fp y, fp z); fp partial_mu_wrt_y(fp y, fp z);
fp partial_mu_wrt_z(fp y, fp z); fp partial_mu_wrt_z(fp y, fp z);
fp partial_nu_wrt_x(fp x, fp z); fp partial_nu_wrt_x(fp x, fp z);
fp partial_nu_wrt_z(fp x, fp z); fp partial_nu_wrt_z(fp x, fp z);
fp partial_phi_wrt_x(fp x, fp y); fp partial_phi_wrt_x(fp x, fp y);
fp partial_phi_wrt_y(fp x, fp y); fp partial_phi_wrt_y(fp x, fp y);
// partial^2 {mu,nu,phi} / partial {x,y,z}{x,y,z} // partial^2 {mu,nu,phi} / partial {x,y,z}{x,y,z}
fp partial2_mu_wrt_yy(fp y, fp z); fp partial2_mu_wrt_yy(fp y, fp z);
fp partial2_mu_wrt_yz(fp y, fp z); fp partial2_mu_wrt_yz(fp y, fp z);
fp partial2_mu_wrt_zz(fp y, fp z); fp partial2_mu_wrt_zz(fp y, fp z);
fp partial2_nu_wrt_xx(fp x, fp z); fp partial2_nu_wrt_xx(fp x, fp z);
fp partial2_nu_wrt_xz(fp x, fp z); fp partial2_nu_wrt_xz(fp x, fp z);
fp partial2_nu_wrt_zz(fp x, fp z); fp partial2_nu_wrt_zz(fp x, fp z);
fp partial2_phi_wrt_xx(fp x, fp y); fp partial2_phi_wrt_xx(fp x, fp y);
fp partial2_phi_wrt_xy(fp x, fp y); fp partial2_phi_wrt_xy(fp x, fp y);
fp partial2_phi_wrt_yy(fp x, fp y); fp partial2_phi_wrt_yy(fp x, fp y);
// usual polar spherical (r,theta,phi) <--> (x,y,z) // usual polar spherical (r,theta,phi) <--> (x,y,z)
void xyz_of_r_theta_phi(fp r, fp theta, fp phi, fp &x, fp &y, fp &z); void xyz_of_r_theta_phi(fp r, fp theta, fp phi, fp &x, fp &y, fp &z);
void r_theta_phi_of_xyz(fp x, fp y, fp z, fp &r, fp &theta, fp &phi); void r_theta_phi_of_xyz(fp x, fp y, fp z, fp &r, fp &theta, fp &phi);
// ... already have r_of_xyz() // ... already have r_of_xyz()
// ... already have phi_of_xy() // ... already have phi_of_xy()
fp theta_of_xyz(fp x, fp y, fp z); fp theta_of_xyz(fp x, fp y, fp z);
// ((mu,nu,phi)) <--> usual polar spherical (theta,phi) // ((mu,nu,phi)) <--> usual polar spherical (theta,phi)
// ... note phi is the same coordinate in both systems // ... note phi is the same coordinate in both systems
void theta_phi_of_mu_nu(fp mu, fp nu, fp &ps_theta, fp &ps_phi); void theta_phi_of_mu_nu(fp mu, fp nu, fp &ps_theta, fp &ps_phi);
void theta_phi_of_mu_phi(fp mu, fp phi, fp &ps_theta, fp &ps_phi); void theta_phi_of_mu_phi(fp mu, fp phi, fp &ps_theta, fp &ps_phi);
void theta_phi_of_nu_phi(fp nu, fp phi, fp &ps_theta, fp &ps_phi); void theta_phi_of_nu_phi(fp nu, fp phi, fp &ps_theta, fp &ps_phi);
void mu_nu_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &nu); void mu_nu_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &nu);
void mu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &phi); void mu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &phi);
void nu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &nu, fp &phi); void nu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &nu, fp &phi);
// ((mu,nu,phi)) --> direction cosines (xcos,ycos,zcos) // ((mu,nu,phi)) --> direction cosines (xcos,ycos,zcos)
void xyzcos_of_mu_nu(fp mu, fp nu, fp &xcos, fp &ycos, fp &zcos); void xyzcos_of_mu_nu(fp mu, fp nu, fp &xcos, fp &ycos, fp &zcos);
void xyzcos_of_mu_phi(fp mu, fp phi, fp &xcos, fp &ycos, fp &zcos); void xyzcos_of_mu_phi(fp mu, fp phi, fp &xcos, fp &ycos, fp &zcos);
void xyzcos_of_nu_phi(fp nu, fp phi, fp &xcos, fp &ycos, fp &zcos); void xyzcos_of_nu_phi(fp nu, fp phi, fp &xcos, fp &ycos, fp &zcos);
} // close namespace local_coords:: } // close namespace local_coords::
//***************************************************************************** //*****************************************************************************
// //
// ***** bit masks for coordinates **** // ***** bit masks for coordinates ****
// //
// //
// We need to manipulate coordinates to do calculations like "which // We need to manipulate coordinates to do calculations like "which
// coordinate do these two patches have in common". We do these by // coordinate do these two patches have in common". We do these by
// Boolean operations on integers using the following bit masks: // Boolean operations on integers using the following bit masks:
// //
namespace local_coords namespace local_coords
{ {
typedef int coords_set; typedef int coords_set;
enum enum
{ {
coords_set_mu = 0x1, coords_set_mu = 0x1,
coords_set_nu = 0x2, coords_set_nu = 0x2,
coords_set_phi = 0x4, coords_set_phi = 0x4,
coords_set_empty = 0x0, coords_set_empty = 0x0,
coords_set_all = coords_set_mu | coords_set_nu | coords_set_phi // no comma coords_set_all = coords_set_mu | coords_set_nu | coords_set_phi // no comma
}; };
// human-readable coordinate names for debugging etc // human-readable coordinate names for debugging etc
const char *name_of_coords_set(coords_set S); const char *name_of_coords_set(coords_set S);
// set complement of coordinates // set complement of coordinates
inline coords_set coords_set_not(coords_set S) inline coords_set coords_set_not(coords_set S)
{ {
return coords_set_all & ~S; return coords_set_all & ~S;
} }
} // close namespace local_coords:: } // close namespace local_coords::
//****************************************************************************** //******************************************************************************
// //
// This class stores the origin point of our local coordinates, and // This class stores the origin point of our local coordinates, and
// provides conversions between local and global coordinates. // provides conversions between local and global coordinates.
// //
class global_coords class global_coords
{ {
public: public:
// get global (x,y,z) coordinates of local origin point // get global (x,y,z) coordinates of local origin point
fp origin_x() const { return origin_x_; } fp origin_x() const { return origin_x_; }
fp origin_y() const { return origin_y_; } fp origin_y() const { return origin_y_; }
fp origin_z() const { return origin_z_; } fp origin_z() const { return origin_z_; }
// constructor: specify global (x,y,z) coordinates of local origin point // constructor: specify global (x,y,z) coordinates of local origin point
global_coords(fp origin_x_in, fp origin_y_in, fp origin_z_in) global_coords(fp origin_x_in, fp origin_y_in, fp origin_z_in)
: origin_x_(origin_x_in), : origin_x_(origin_x_in),
origin_y_(origin_y_in), origin_y_(origin_y_in),
origin_z_(origin_z_in) origin_z_(origin_z_in)
{ {
} }
// destructor: compiler-generated no-op is ok // destructor: compiler-generated no-op is ok
void recentering(fp x, fp y, fp z) void recentering(fp x, fp y, fp z)
{ {
origin_x_ = x; origin_x_ = x;
origin_y_ = y; origin_y_ = y;
origin_z_ = z; origin_z_ = z;
} }
private: private:
// we forbid copying and passing by value // we forbid copying and passing by value
// by declaring the copy constructor and assignment operator // by declaring the copy constructor and assignment operator
// private, but never defining them // private, but never defining them
global_coords(const global_coords &rhs); global_coords(const global_coords &rhs);
global_coords &operator=(const global_coords &rhs); global_coords &operator=(const global_coords &rhs);
private: private:
// global (x,y,z) coordinates of local origin point // global (x,y,z) coordinates of local origin point
fp origin_x_, origin_y_, origin_z_; fp origin_x_, origin_y_, origin_z_;
}; };
//****************************************************************************** //******************************************************************************
} // namespace AHFinderDirect } // namespace AHFinderDirect
#endif /* COORDS_H */ #endif /* COORDS_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,56 +1,56 @@
#ifndef CPBC_H #ifndef CPBC_H
#define CPBC_H #define CPBC_H
#ifdef fortran1 #ifdef fortran1
#define f_david_milton_extroplate_ss david_milton_extroplate_ss #define f_david_milton_extroplate_ss david_milton_extroplate_ss
#define f_david_milton_cpbc_ss david_milton_cpbc_ss #define f_david_milton_cpbc_ss david_milton_cpbc_ss
#endif #endif
#ifdef fortran2 #ifdef fortran2
#define f_david_milton_extroplate_ss DAVID_MILTON_EXTROPLATE_SS #define f_david_milton_extroplate_ss DAVID_MILTON_EXTROPLATE_SS
#define f_david_milton_cpbc_ss DAVID_MILTON_CPBC_SS #define f_david_milton_cpbc_ss DAVID_MILTON_CPBC_SS
#endif #endif
#ifdef fortran3 #ifdef fortran3
#define f_david_milton_extroplate_ss david_milton_extroplate_ss_ #define f_david_milton_extroplate_ss david_milton_extroplate_ss_
#define f_david_milton_cpbc_ss david_milton_cpbc_ss_ #define f_david_milton_cpbc_ss david_milton_cpbc_ss_
#endif #endif
extern "C" extern "C"
{ {
int f_david_milton_extroplate_ss(int *, double *, double *, double *, // ex,crho,sigma,R int f_david_milton_extroplate_ss(int *, double *, double *, double *, // ex,crho,sigma,R
double *, double *, double *, // TZ, chi, trK double *, double *, double *, // TZ, chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double &, double &); double &, double &);
} // zmin,zmax } // zmin,zmax
extern "C" extern "C"
{ {
int f_david_milton_cpbc_ss(int *, double *, double *, double *, // ex,crho,sigma,R int f_david_milton_cpbc_ss(int *, double *, double *, double *, // ex,crho,sigma,R
double *, double *, double *, // x,y,z double *, double *, double *, // x,y,z
double *, double *, double *, // drhodx,drhody,drhodz double *, double *, double *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz double *, double *, double *, // dRdx,dRdy,dRdz
double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz
double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz
double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double &, double &, double &, double &, double &, double &, // xmin,ymin,zmin,xmax,ymax,zmax double &, double &, double &, double &, double &, double &, // xmin,ymin,zmin,xmax,ymax,zmax
double *, double *, double *, // TZ,chi, trK double *, double *, double *, // TZ,chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, // TZ, chi, trK double *, double *, double *, // TZ, chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, // Gama constraint double *, double *, double *, // Gama constraint
int &, double &, int &); int &, double &, int &);
} // Symmetry, eps, sst } // Symmetry, eps, sst
#endif /* CPBC_H */ #endif /* CPBC_H */

View File

@@ -1,93 +1,93 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "stdc.h" #include "stdc.h"
#include "util.h" #include "util.h"
#include "cpm_map.h" #include "cpm_map.h"
namespace AHFinderDirect namespace AHFinderDirect
{ {
namespace jtutil namespace jtutil
{ {
template <typename fp_t> template <typename fp_t>
cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in, cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in,
fp_t fixed_point) fp_t fixed_point)
: min_i_(min_i_in), max_i_(max_i_in), : min_i_(min_i_in), max_i_(max_i_in),
map_is_plus_(false) map_is_plus_(false)
{ {
const fp_t d_offset = 2.0 * fixed_point; const fp_t d_offset = 2.0 * fixed_point;
if (!fuzzy<fp_t>::is_integer(d_offset)) if (!fuzzy<fp_t>::is_integer(d_offset))
then error_exit(ERROR_EXIT, then error_exit(ERROR_EXIT,
"***** cpm_map::cpm_map (mirror):\n" "***** cpm_map::cpm_map (mirror):\n"
" fixed_point=%g isn't (fuzzily) integral or half-integral!\n", " fixed_point=%g isn't (fuzzily) integral or half-integral!\n",
double(fixed_point)); /*NOTREACHED*/ double(fixed_point)); /*NOTREACHED*/
offset_ = round<fp_t>::to_integer(d_offset); offset_ = round<fp_t>::to_integer(d_offset);
assert( assert(
map_unchecked(fuzzy<fp_t>::floor(fixed_point)) == map_unchecked(fuzzy<fp_t>::floor(fixed_point)) ==
fuzzy<fp_t>::ceiling(fixed_point)); fuzzy<fp_t>::ceiling(fixed_point));
} }
//****************************************************************************** //******************************************************************************
// //
// This function constructs a generic cpm_map object, with the mapping // This function constructs a generic cpm_map object, with the mapping
// specified by a sample point sample_i --> sample_j and by sign. // specified by a sample point sample_i --> sample_j and by sign.
// The sample point need not be in the map's domain/range. // The sample point need not be in the map's domain/range.
// //
template <typename fp_t> template <typename fp_t>
cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in, cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in,
int sample_i, int sample_j, int sample_i, int sample_j,
bool map_is_plus_in) bool map_is_plus_in)
: min_i_(min_i_in), max_i_(max_i_in), : min_i_(min_i_in), max_i_(max_i_in),
offset_(map_is_plus_in ? sample_j - sample_i offset_(map_is_plus_in ? sample_j - sample_i
: sample_j + sample_i), : sample_j + sample_i),
map_is_plus_(map_is_plus_in) map_is_plus_(map_is_plus_in)
{ {
assert(map_unchecked(sample_i) == sample_j); assert(map_unchecked(sample_i) == sample_j);
} }
//****************************************************************************** //******************************************************************************
// //
// This function constructs a generic cpm_map object, with the mapping // This function constructs a generic cpm_map object, with the mapping
// specified by a *fp* sample point sample_i --> sample_j (which // specified by a *fp* sample point sample_i --> sample_j (which
// must specify an integer --> integer mapping, i.e. 4.2 --> 4.2 is // must specify an integer --> integer mapping, i.e. 4.2 --> 4.2 is
// ok for a + map, and 4.5 --> 4.5 is ok for a minus map, but 4.2 --> 4.7 // ok for a + map, and 4.5 --> 4.5 is ok for a minus map, but 4.2 --> 4.7
// is never ok) and by sign. The sample point need not be in the map's // is never ok) and by sign. The sample point need not be in the map's
// domain/range. // domain/range.
// //
template <typename fp_t> template <typename fp_t>
cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in, cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in,
fp_t sample_i, fp_t sample_j, fp_t sample_i, fp_t sample_j,
bool map_is_plus_in) bool map_is_plus_in)
: min_i_(min_i_in), max_i_(max_i_in), : min_i_(min_i_in), max_i_(max_i_in),
map_is_plus_(map_is_plus_in) map_is_plus_(map_is_plus_in)
{ {
const fp_t fp_offset = map_is_plus_in ? sample_j - sample_i const fp_t fp_offset = map_is_plus_in ? sample_j - sample_i
: sample_j + sample_i; : sample_j + sample_i;
if (!fuzzy<fp_t>::is_integer(fp_offset)) if (!fuzzy<fp_t>::is_integer(fp_offset))
then error_exit(ERROR_EXIT, then error_exit(ERROR_EXIT,
"***** cpm_map::cpm_map (generic via fp sample point):\n" "***** cpm_map::cpm_map (generic via fp sample point):\n"
" fp_offset=%g isn't fuzzily integral!\n" " fp_offset=%g isn't fuzzily integral!\n"
" ==> sample_i=%g --> sample_j=%g\n" " ==> sample_i=%g --> sample_j=%g\n"
" doesn't fuzzily specify an integer --> integer mapping!\n", " doesn't fuzzily specify an integer --> integer mapping!\n",
double(fp_offset), double(fp_offset),
double(sample_i), double(sample_j)); /*NOTREACHED*/ double(sample_i), double(sample_j)); /*NOTREACHED*/
offset_ = round<fp_t>::to_integer(fp_offset); offset_ = round<fp_t>::to_integer(fp_offset);
// verify that we have setup correct // verify that we have setup correct
assert( assert(
map_unchecked(fuzzy<fp_t>::floor(sample_i)) == map_unchecked(fuzzy<fp_t>::floor(sample_i)) ==
(map_is_plus_in ? fuzzy<fp_t>::floor(sample_j) (map_is_plus_in ? fuzzy<fp_t>::floor(sample_j)
: fuzzy<fp_t>::ceiling(sample_j))); : fuzzy<fp_t>::ceiling(sample_j)));
} }
template class cpm_map<float>; template class cpm_map<float>;
template class cpm_map<double>; template class cpm_map<double>;
} // namespace jtutil } // namespace jtutil
} // namespace AHFinderDirect } // namespace AHFinderDirect

View File

@@ -1,120 +1,120 @@
#ifndef AHFINDERDIRECT__CPM_MAP_HH #ifndef AHFINDERDIRECT__CPM_MAP_HH
#define AHFINDERDIRECT__CPM_MAP_HH #define AHFINDERDIRECT__CPM_MAP_HH
namespace AHFinderDirect namespace AHFinderDirect
{ {
namespace jtutil namespace jtutil
{ {
template <typename fp_t> template <typename fp_t>
class cpm_map class cpm_map
{ {
public: public:
// bounds info -- domain // bounds info -- domain
int min_i() const { return min_i_; } int min_i() const { return min_i_; }
int max_i() const { return max_i_; } int max_i() const { return max_i_; }
int N_points() const int N_points() const
{ {
return jtutil::how_many_in_range(min_i_, max_i_); return jtutil::how_many_in_range(min_i_, max_i_);
} }
bool in_domain(int i) const { return (i >= min_i_) && (i <= max_i_); } bool in_domain(int i) const { return (i >= min_i_) && (i <= max_i_); }
// is the mapping + or - ? // is the mapping + or - ?
bool is_plus() const { return map_is_plus_; } bool is_plus() const { return map_is_plus_; }
bool is_minus() const { return !map_is_plus_; } bool is_minus() const { return !map_is_plus_; }
int sign() const { return map_is_plus_ ? +1 : -1; } int sign() const { return map_is_plus_ ? +1 : -1; }
fp_t fp_sign() const { return map_is_plus_ ? +1.0 : -1.0; } fp_t fp_sign() const { return map_is_plus_ ? +1.0 : -1.0; }
// the mapping itself // the mapping itself
int map_unchecked(int i) const int map_unchecked(int i) const
{ {
return map_is_plus_ ? offset_ + i return map_is_plus_ ? offset_ + i
: offset_ - i; : offset_ - i;
} }
int inv_map_unchecked(int j) const int inv_map_unchecked(int j) const
{ {
return map_is_plus_ ? j - offset_ return map_is_plus_ ? j - offset_
: offset_ - j; : offset_ - j;
} }
int map(int i) const int map(int i) const
{ {
assert(in_domain(i)); assert(in_domain(i));
return map_unchecked(i); return map_unchecked(i);
} }
int inv_map(int j) const int inv_map(int j) const
{ {
int i = inv_map_unchecked(j); int i = inv_map_unchecked(j);
assert(in_domain(i)); assert(in_domain(i));
return i; return i;
} }
// bounds info -- range // bounds info -- range
// ... we use the unchecked map here in case the domain is empty // ... we use the unchecked map here in case the domain is empty
int min_j() const int min_j() const
{ {
return map_is_plus_ ? map_unchecked(min_i_) return map_is_plus_ ? map_unchecked(min_i_)
: map_unchecked(max_i_); : map_unchecked(max_i_);
} }
int max_j() const int max_j() const
{ {
return map_is_plus_ ? map_unchecked(max_i_) return map_is_plus_ ? map_unchecked(max_i_)
: map_unchecked(min_i_); : map_unchecked(min_i_);
} }
bool in_range(int j) const { return in_domain(inv_map_unchecked(j)); } bool in_range(int j) const { return in_domain(inv_map_unchecked(j)); }
// //
// constructors // constructors
// //
// "mirror" map: i --> const - i // "mirror" map: i --> const - i
// ... map specified by fixed point (must be integer or half-integer) // ... map specified by fixed point (must be integer or half-integer)
// ... fixed point need not be in domain/range // ... fixed point need not be in domain/range
cpm_map(int min_i_in, int max_i_in, cpm_map(int min_i_in, int max_i_in,
fp_t fixed_point); fp_t fixed_point);
// "shift" map: i --> const + i // "shift" map: i --> const + i
// ... map specified by shift amount // ... map specified by shift amount
// ... default is identity map // ... default is identity map
cpm_map(int min_i_in, int max_i_in, cpm_map(int min_i_in, int max_i_in,
int shift_amount = 0) int shift_amount = 0)
: min_i_(min_i_in), max_i_(max_i_in), : min_i_(min_i_in), max_i_(max_i_in),
offset_(shift_amount), map_is_plus_(true) offset_(shift_amount), map_is_plus_(true)
{ {
} }
// generic map: i --> const +/- i // generic map: i --> const +/- i
// ... map specified by sample point sample_i --> sample_j // ... map specified by sample point sample_i --> sample_j
// and by sign (one of {plus,minus}_map ) // and by sign (one of {plus,minus}_map )
// ... sample point need not be in domain/range // ... sample point need not be in domain/range
cpm_map(int min_i_in, int max_i_in, cpm_map(int min_i_in, int max_i_in,
int sample_i, int sample_j, int sample_i, int sample_j,
bool map_is_plus_in); bool map_is_plus_in);
// generic map: i --> const +/- i // generic map: i --> const +/- i
// ... map specified by *fp* sample point sample_i --> sample_j // ... map specified by *fp* sample point sample_i --> sample_j
// (must specify an integer --> integer mapping) // (must specify an integer --> integer mapping)
// and by sign (one of {plus,minus}_map ) // and by sign (one of {plus,minus}_map )
// ... hence if sign is -1, then sample_i and sample_j // ... hence if sign is -1, then sample_i and sample_j
// must both be half-integral // must both be half-integral
// ... sample point need *not* be in domain/range // ... sample point need *not* be in domain/range
cpm_map(int min_i_in, int max_i_in, cpm_map(int min_i_in, int max_i_in,
fp_t sample_i, fp_t sample_j, fp_t sample_i, fp_t sample_j,
bool map_is_plus_in); bool map_is_plus_in);
// no need for explicit destructor, compiler-generated no-op is ok // no need for explicit destructor, compiler-generated no-op is ok
// ditto for copy constructor and assignment operator // ditto for copy constructor and assignment operator
private: private:
// bounds (inclusive) // bounds (inclusive)
int min_i_, max_i_; int min_i_, max_i_;
// these define the actual mapping // these define the actual mapping
int offset_; int offset_;
bool map_is_plus_; bool map_is_plus_;
}; };
//****************************************************************************** //******************************************************************************
} // namespace jtutil } // namespace jtutil
} // namespace AHFinderDirect } // namespace AHFinderDirect
#endif /* AHFINDERDIRECT__CPM_MAP_HH */ #endif /* AHFINDERDIRECT__CPM_MAP_HH */

View File

@@ -1,76 +1,76 @@
#ifndef DERIVATIVES #ifndef DERIVATIVES
#define DERIVATIVES #define DERIVATIVES
#ifdef fortran1 #ifdef fortran1
#define f_fderivs fderivs #define f_fderivs fderivs
#define f_fderivs_sh fderivs_sh #define f_fderivs_sh fderivs_sh
#define f_fderivs_shc fderivs_shc #define f_fderivs_shc fderivs_shc
#define f_fdderivs_shc fdderivs_shc #define f_fdderivs_shc fdderivs_shc
#define f_fdderivs fdderivs #define f_fdderivs fdderivs
#endif #endif
#ifdef fortran2 #ifdef fortran2
#define f_fderivs FDERIVS #define f_fderivs FDERIVS
#define f_fderivs_sh FDERIVS_SH #define f_fderivs_sh FDERIVS_SH
#define f_fderivs_shc FDERIVS_SHC #define f_fderivs_shc FDERIVS_SHC
#define f_fdderivs_shc FDDERIVS_SHC #define f_fdderivs_shc FDDERIVS_SHC
#define f_fdderivs FDDERIVS #define f_fdderivs FDDERIVS
#endif #endif
#ifdef fortran3 #ifdef fortran3
#define f_fderivs fderivs_ #define f_fderivs fderivs_
#define f_fderivs_sh fderivs_sh_ #define f_fderivs_sh fderivs_sh_
#define f_fderivs_shc fderivs_shc_ #define f_fderivs_shc fderivs_shc_
#define f_fdderivs_shc fdderivs_shc_ #define f_fdderivs_shc fdderivs_shc_
#define f_fdderivs fdderivs_ #define f_fdderivs fdderivs_
#endif #endif
extern "C" extern "C"
{ {
void f_fderivs(int *, double *, void f_fderivs(int *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double &, double &, double &, int &, int &); double &, double &, double &, int &, int &);
} }
extern "C" extern "C"
{ {
void f_fderivs_sh(int *, double *, void f_fderivs_sh(int *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double &, double &, double &, int &, int &, int &); double &, double &, double &, int &, int &, int &);
} }
extern "C" extern "C"
{ {
void f_fderivs_shc(int *, double *, void f_fderivs_shc(int *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double &, double &, double &, int &, int &, int &, double &, double &, double &, int &, int &, int &,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *); double *, double *, double *);
} }
extern "C" extern "C"
{ {
void f_fdderivs_shc(int *, double *, void f_fdderivs_shc(int *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double &, double &, double &, int &, int &, int &, double &, double &, double &, int &, int &, int &,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *); double *, double *, double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
void f_fdderivs(int *, double *, void f_fdderivs(int *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double &, double &, double &, int &, int &); double &, double &, double &, int &, int &);
} }
#endif /* DERIVATIVES */ #endif /* DERIVATIVES */

View File

@@ -1,108 +1,108 @@
#ifndef DRIVER_H #ifndef DRIVER_H
#define DRIVER_H #define DRIVER_H
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include "util_Table.h" #include "util_Table.h"
#include "cctk.h" #include "cctk.h"
#include "config.h" #include "config.h"
#include "stdc.h" #include "stdc.h"
#include "util.h" #include "util.h"
#include "array.h" #include "array.h"
#include "cpm_map.h" #include "cpm_map.h"
#include "linear_map.h" #include "linear_map.h"
#include "coords.h" #include "coords.h"
#include "tgrid.h" #include "tgrid.h"
#include "fd_grid.h" #include "fd_grid.h"
#include "patch.h" #include "patch.h"
#include "patch_edge.h" #include "patch_edge.h"
#include "patch_interp.h" #include "patch_interp.h"
#include "ghost_zone.h" #include "ghost_zone.h"
#include "patch_system.h" #include "patch_system.h"
#include "Jacobian.h" #include "Jacobian.h"
#include "gfns.h" #include "gfns.h"
#include "gr.h" #include "gr.h"
#include "horizon_sequence.h" #include "horizon_sequence.h"
#include "BH_diagnostics.h" #include "BH_diagnostics.h"
namespace AHFinderDirect namespace AHFinderDirect
{ {
struct iteration_status_buffers struct iteration_status_buffers
{ {
int *hn_buffer; int *hn_buffer;
int *iteration_buffer; int *iteration_buffer;
enum expansion_status *expansion_status_buffer; enum expansion_status *expansion_status_buffer;
fp *mean_horizon_radius_buffer; fp *mean_horizon_radius_buffer;
fp *Theta_infinity_norm_buffer; fp *Theta_infinity_norm_buffer;
bool *found_horizon_buffer; bool *found_horizon_buffer;
jtutil::array2d<CCTK_REAL> *send_buffer_ptr; jtutil::array2d<CCTK_REAL> *send_buffer_ptr;
jtutil::array2d<CCTK_REAL> *receive_buffer_ptr; jtutil::array2d<CCTK_REAL> *receive_buffer_ptr;
iteration_status_buffers() iteration_status_buffers()
: hn_buffer(NULL), iteration_buffer(NULL), : hn_buffer(NULL), iteration_buffer(NULL),
expansion_status_buffer(NULL), expansion_status_buffer(NULL),
mean_horizon_radius_buffer(NULL), mean_horizon_radius_buffer(NULL),
Theta_infinity_norm_buffer(NULL), Theta_infinity_norm_buffer(NULL),
found_horizon_buffer(NULL), found_horizon_buffer(NULL),
send_buffer_ptr(NULL), receive_buffer_ptr(NULL) send_buffer_ptr(NULL), receive_buffer_ptr(NULL)
{ {
} }
}; };
// //
// This struct holds interprocessor-communication buffers for broadcasting // This struct holds interprocessor-communication buffers for broadcasting
// the BH diagnostics and horizon shape from the processor which finds a // the BH diagnostics and horizon shape from the processor which finds a
// given horizon, to all processors. // given horizon, to all processors.
// //
struct horizon_buffers struct horizon_buffers
{ {
int N_buffer; int N_buffer;
double *send_buffer; double *send_buffer;
double *receive_buffer; double *receive_buffer;
horizon_buffers() horizon_buffers()
: N_buffer(0), : N_buffer(0),
send_buffer(NULL), send_buffer(NULL),
receive_buffer(NULL) receive_buffer(NULL)
{ {
} }
}; };
// //
struct AH_data struct AH_data
{ {
patch_system *ps_ptr; patch_system *ps_ptr;
Jacobian *Jac_ptr; Jacobian *Jac_ptr;
double surface_expansion; double surface_expansion;
bool initial_find_flag; bool initial_find_flag;
bool recentering_flag, stop_finding, find_trigger; bool recentering_flag, stop_finding, find_trigger;
bool found_flag; // did we find this horizon (successfully) bool found_flag; // did we find this horizon (successfully)
struct BH_diagnostics BH_diagnostics; struct BH_diagnostics BH_diagnostics;
FILE *BH_diagnostics_fileptr; FILE *BH_diagnostics_fileptr;
// interprocessor-communication buffers // interprocessor-communication buffers
// for this horizon's BH diagnostics and (optionally) horizon shape // for this horizon's BH diagnostics and (optionally) horizon shape
struct horizon_buffers horizon_buffers; struct horizon_buffers horizon_buffers;
}; };
// initial_guess.cc // initial_guess.cc
void setup_initial_guess(patch_system &ps, void setup_initial_guess(patch_system &ps,
fp x_center, fp y_center, fp z_center, fp x_center, fp y_center, fp z_center,
fp x_radius, fp y_radius, fp z_radius); fp x_radius, fp y_radius, fp z_radius);
// Newton.cc // Newton.cc
void Newton(int N_procs, int N_active_procs, int my_proc, void Newton(int N_procs, int N_active_procs, int my_proc,
horizon_sequence &hs, struct AH_data *const AH_data_array[], horizon_sequence &hs, struct AH_data *const AH_data_array[],
struct iteration_status_buffers &isb, int *dumpid, double *); struct iteration_status_buffers &isb, int *dumpid, double *);
} // namespace AHFinderDirect } // namespace AHFinderDirect
#endif /* DRIVER_H */ #endif /* DRIVER_H */

View File

@@ -1,45 +1,45 @@
#ifndef EMPART_H #ifndef EMPART_H
#define EMPART_H #define EMPART_H
#ifdef fortran1 #ifdef fortran1
#define f_compute_rhs_empart compute_rhs_empart #define f_compute_rhs_empart compute_rhs_empart
#define f_compute_rhs_empart_ss compute_rhs_empart_ss #define f_compute_rhs_empart_ss compute_rhs_empart_ss
#endif #endif
#ifdef fortran2 #ifdef fortran2
#define f_compute_rhs_empart COMPUTE_RHS_EMPART #define f_compute_rhs_empart COMPUTE_RHS_EMPART
#define f_compute_rhs_empart_ss COMPUTE_RHS_EMPART_SS #define f_compute_rhs_empart_ss COMPUTE_RHS_EMPART_SS
#endif #endif
#ifdef fortran3 #ifdef fortran3
#define f_compute_rhs_empart compute_rhs_empart_ #define f_compute_rhs_empart compute_rhs_empart_
#define f_compute_rhs_empart_ss compute_rhs_empart_ss_ #define f_compute_rhs_empart_ss compute_rhs_empart_ss_
#endif #endif
extern "C" extern "C"
{ {
int f_compute_rhs_empart(int *, double *, double *, double *, int f_compute_rhs_empart(int *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
int &, int &, double &); int &, int &, double &);
} }
extern "C" extern "C"
{ {
int f_compute_rhs_empart_ss(int *, double *, double *, double *, double *, double *, double *, int f_compute_rhs_empart_ss(int *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
int &, int &, double &, int &); int &, int &, double &, int &);
} }
#endif /* EMPART_H */ #endif /* EMPART_H */

View File

@@ -1,230 +1,230 @@
!----------------------------------------------------------------------------- !-----------------------------------------------------------------------------
! !
! remove the trace of Aij ! remove the trace of Aij
! trace-free Aij and enforce the determinant of bssn metric to one ! trace-free Aij and enforce the determinant of bssn metric to one
!----------------------------------------------------------------------------- !-----------------------------------------------------------------------------
subroutine enforce_ag(ex, dxx, gxy, gxz, dyy, gyz, dzz, & subroutine enforce_ag(ex, dxx, gxy, gxz, dyy, gyz, dzz, &
Axx, Axy, Axz, Ayy, Ayz, Azz) Axx, Axy, Axz, Ayy, Ayz, Azz)
implicit none implicit none
!~~~~~~> Input parameters: !~~~~~~> Input parameters:
integer, intent(in) :: ex(1:3) integer, intent(in) :: ex(1:3)
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: dxx,dyy,dzz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: dxx,dyy,dzz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: gxy,gxz,gyz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: gxy,gxz,gyz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Axx,Axy,Axz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Axx,Axy,Axz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Ayy,Ayz,Azz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Ayy,Ayz,Azz
!~~~~~~~> Local variable: !~~~~~~~> Local variable:
integer :: i,j,k integer :: i,j,k
real*8 :: lgxx,lgyy,lgzz,ldetg real*8 :: lgxx,lgyy,lgzz,ldetg
real*8 :: lgupxx,lgupxy,lgupxz,lgupyy,lgupyz,lgupzz real*8 :: lgupxx,lgupxy,lgupxz,lgupyy,lgupyz,lgupzz
real*8 :: ltrA,lscale real*8 :: ltrA,lscale
real*8, parameter :: F1o3 = 1.D0 / 3.D0, ONE = 1.D0, TWO = 2.D0 real*8, parameter :: F1o3 = 1.D0 / 3.D0, ONE = 1.D0, TWO = 2.D0
!~~~~~~> !~~~~~~>
do k=1,ex(3) do k=1,ex(3)
do j=1,ex(2) do j=1,ex(2)
do i=1,ex(1) do i=1,ex(1)
lgxx = dxx(i,j,k) + ONE lgxx = dxx(i,j,k) + ONE
lgyy = dyy(i,j,k) + ONE lgyy = dyy(i,j,k) + ONE
lgzz = dzz(i,j,k) + ONE lgzz = dzz(i,j,k) + ONE
ldetg = lgxx * lgyy * lgzz & ldetg = lgxx * lgyy * lgzz &
+ gxy(i,j,k) * gyz(i,j,k) * gxz(i,j,k) & + gxy(i,j,k) * gyz(i,j,k) * gxz(i,j,k) &
+ gxz(i,j,k) * gxy(i,j,k) * gyz(i,j,k) & + gxz(i,j,k) * gxy(i,j,k) * gyz(i,j,k) &
- gxz(i,j,k) * lgyy * gxz(i,j,k) & - gxz(i,j,k) * lgyy * gxz(i,j,k) &
- gxy(i,j,k) * gxy(i,j,k) * lgzz & - gxy(i,j,k) * gxy(i,j,k) * lgzz &
- lgxx * gyz(i,j,k) * gyz(i,j,k) - lgxx * gyz(i,j,k) * gyz(i,j,k)
lgupxx = ( lgyy * lgzz - gyz(i,j,k) * gyz(i,j,k) ) / ldetg lgupxx = ( lgyy * lgzz - gyz(i,j,k) * gyz(i,j,k) ) / ldetg
lgupxy = - ( gxy(i,j,k) * lgzz - gyz(i,j,k) * gxz(i,j,k) ) / ldetg lgupxy = - ( gxy(i,j,k) * lgzz - gyz(i,j,k) * gxz(i,j,k) ) / ldetg
lgupxz = ( gxy(i,j,k) * gyz(i,j,k) - lgyy * gxz(i,j,k) ) / ldetg lgupxz = ( gxy(i,j,k) * gyz(i,j,k) - lgyy * gxz(i,j,k) ) / ldetg
lgupyy = ( lgxx * lgzz - gxz(i,j,k) * gxz(i,j,k) ) / ldetg lgupyy = ( lgxx * lgzz - gxz(i,j,k) * gxz(i,j,k) ) / ldetg
lgupyz = - ( lgxx * gyz(i,j,k) - gxy(i,j,k) * gxz(i,j,k) ) / ldetg lgupyz = - ( lgxx * gyz(i,j,k) - gxy(i,j,k) * gxz(i,j,k) ) / ldetg
lgupzz = ( lgxx * lgyy - gxy(i,j,k) * gxy(i,j,k) ) / ldetg lgupzz = ( lgxx * lgyy - gxy(i,j,k) * gxy(i,j,k) ) / ldetg
ltrA = lgupxx * Axx(i,j,k) + lgupyy * Ayy(i,j,k) & ltrA = lgupxx * Axx(i,j,k) + lgupyy * Ayy(i,j,k) &
+ lgupzz * Azz(i,j,k) & + lgupzz * Azz(i,j,k) &
+ TWO * (lgupxy * Axy(i,j,k) + lgupxz * Axz(i,j,k) & + TWO * (lgupxy * Axy(i,j,k) + lgupxz * Axz(i,j,k) &
+ lgupyz * Ayz(i,j,k)) + lgupyz * Ayz(i,j,k))
Axx(i,j,k) = Axx(i,j,k) - F1o3 * lgxx * ltrA Axx(i,j,k) = Axx(i,j,k) - F1o3 * lgxx * ltrA
Axy(i,j,k) = Axy(i,j,k) - F1o3 * gxy(i,j,k) * ltrA Axy(i,j,k) = Axy(i,j,k) - F1o3 * gxy(i,j,k) * ltrA
Axz(i,j,k) = Axz(i,j,k) - F1o3 * gxz(i,j,k) * ltrA Axz(i,j,k) = Axz(i,j,k) - F1o3 * gxz(i,j,k) * ltrA
Ayy(i,j,k) = Ayy(i,j,k) - F1o3 * lgyy * ltrA Ayy(i,j,k) = Ayy(i,j,k) - F1o3 * lgyy * ltrA
Ayz(i,j,k) = Ayz(i,j,k) - F1o3 * gyz(i,j,k) * ltrA Ayz(i,j,k) = Ayz(i,j,k) - F1o3 * gyz(i,j,k) * ltrA
Azz(i,j,k) = Azz(i,j,k) - F1o3 * lgzz * ltrA Azz(i,j,k) = Azz(i,j,k) - F1o3 * lgzz * ltrA
lscale = ONE / ( ldetg ** F1o3 ) lscale = ONE / ( ldetg ** F1o3 )
dxx(i,j,k) = lgxx * lscale - ONE dxx(i,j,k) = lgxx * lscale - ONE
gxy(i,j,k) = gxy(i,j,k) * lscale gxy(i,j,k) = gxy(i,j,k) * lscale
gxz(i,j,k) = gxz(i,j,k) * lscale gxz(i,j,k) = gxz(i,j,k) * lscale
dyy(i,j,k) = lgyy * lscale - ONE dyy(i,j,k) = lgyy * lscale - ONE
gyz(i,j,k) = gyz(i,j,k) * lscale gyz(i,j,k) = gyz(i,j,k) * lscale
dzz(i,j,k) = lgzz * lscale - ONE dzz(i,j,k) = lgzz * lscale - ONE
enddo enddo
enddo enddo
enddo enddo
return return
end subroutine enforce_ag end subroutine enforce_ag
#if 1 #if 1
!---------------------------------------------------------------------------------- !----------------------------------------------------------------------------------
! swap the turn of a and g ! swap the turn of a and g
!---------------------------------------------------------------------------------- !----------------------------------------------------------------------------------
subroutine enforce_ga(ex, dxx, gxy, gxz, dyy, gyz, dzz, & subroutine enforce_ga(ex, dxx, gxy, gxz, dyy, gyz, dzz, &
Axx, Axy, Axz, Ayy, Ayz, Azz) Axx, Axy, Axz, Ayy, Ayz, Azz)
implicit none implicit none
!~~~~~~> Input parameters: !~~~~~~> Input parameters:
integer, intent(in) :: ex(1:3) integer, intent(in) :: ex(1:3)
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: dxx,dyy,dzz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: dxx,dyy,dzz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: gxy,gxz,gyz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: gxy,gxz,gyz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Axx,Axy,Axz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Axx,Axy,Axz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Ayy,Ayz,Azz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Ayy,Ayz,Azz
!~~~~~~~> Local variable: !~~~~~~~> Local variable:
integer :: i,j,k integer :: i,j,k
real*8 :: lgxx,lgyy,lgzz,lscale real*8 :: lgxx,lgyy,lgzz,lscale
real*8 :: lgxy,lgxz,lgyz real*8 :: lgxy,lgxz,lgyz
real*8 :: lgupxx,lgupxy,lgupxz,lgupyy,lgupyz,lgupzz real*8 :: lgupxx,lgupxy,lgupxz,lgupyy,lgupyz,lgupzz
real*8 :: ltrA real*8 :: ltrA
real*8, parameter :: F1o3 = 1.D0 / 3.D0, ONE = 1.D0, TWO = 2.D0 real*8, parameter :: F1o3 = 1.D0 / 3.D0, ONE = 1.D0, TWO = 2.D0
!~~~~~~> !~~~~~~>
do k=1,ex(3) do k=1,ex(3)
do j=1,ex(2) do j=1,ex(2)
do i=1,ex(1) do i=1,ex(1)
! for g: normalize determinant first ! for g: normalize determinant first
lgxx = dxx(i,j,k) + ONE lgxx = dxx(i,j,k) + ONE
lgyy = dyy(i,j,k) + ONE lgyy = dyy(i,j,k) + ONE
lgzz = dzz(i,j,k) + ONE lgzz = dzz(i,j,k) + ONE
lgxy = gxy(i,j,k) lgxy = gxy(i,j,k)
lgxz = gxz(i,j,k) lgxz = gxz(i,j,k)
lgyz = gyz(i,j,k) lgyz = gyz(i,j,k)
lscale = lgxx * lgyy * lgzz + lgxy * lgyz * lgxz & lscale = lgxx * lgyy * lgzz + lgxy * lgyz * lgxz &
+ lgxz * lgxy * lgyz - lgxz * lgyy * lgxz & + lgxz * lgxy * lgyz - lgxz * lgyy * lgxz &
- lgxy * lgxy * lgzz - lgxx * lgyz * lgyz - lgxy * lgxy * lgzz - lgxx * lgyz * lgyz
lscale = ONE / ( lscale ** F1o3 ) lscale = ONE / ( lscale ** F1o3 )
lgxx = lgxx * lscale lgxx = lgxx * lscale
lgxy = lgxy * lscale lgxy = lgxy * lscale
lgxz = lgxz * lscale lgxz = lgxz * lscale
lgyy = lgyy * lscale lgyy = lgyy * lscale
lgyz = lgyz * lscale lgyz = lgyz * lscale
lgzz = lgzz * lscale lgzz = lgzz * lscale
dxx(i,j,k) = lgxx - ONE dxx(i,j,k) = lgxx - ONE
gxy(i,j,k) = lgxy gxy(i,j,k) = lgxy
gxz(i,j,k) = lgxz gxz(i,j,k) = lgxz
dyy(i,j,k) = lgyy - ONE dyy(i,j,k) = lgyy - ONE
gyz(i,j,k) = lgyz gyz(i,j,k) = lgyz
dzz(i,j,k) = lgzz - ONE dzz(i,j,k) = lgzz - ONE
! for A: trace-free using normalized metric (det=1, no division needed) ! for A: trace-free using normalized metric (det=1, no division needed)
lgupxx = ( lgyy * lgzz - lgyz * lgyz ) lgupxx = ( lgyy * lgzz - lgyz * lgyz )
lgupxy = - ( lgxy * lgzz - lgyz * lgxz ) lgupxy = - ( lgxy * lgzz - lgyz * lgxz )
lgupxz = ( lgxy * lgyz - lgyy * lgxz ) lgupxz = ( lgxy * lgyz - lgyy * lgxz )
lgupyy = ( lgxx * lgzz - lgxz * lgxz ) lgupyy = ( lgxx * lgzz - lgxz * lgxz )
lgupyz = - ( lgxx * lgyz - lgxy * lgxz ) lgupyz = - ( lgxx * lgyz - lgxy * lgxz )
lgupzz = ( lgxx * lgyy - lgxy * lgxy ) lgupzz = ( lgxx * lgyy - lgxy * lgxy )
ltrA = lgupxx * Axx(i,j,k) + lgupyy * Ayy(i,j,k) & ltrA = lgupxx * Axx(i,j,k) + lgupyy * Ayy(i,j,k) &
+ lgupzz * Azz(i,j,k) & + lgupzz * Azz(i,j,k) &
+ TWO * (lgupxy * Axy(i,j,k) + lgupxz * Axz(i,j,k) & + TWO * (lgupxy * Axy(i,j,k) + lgupxz * Axz(i,j,k) &
+ lgupyz * Ayz(i,j,k)) + lgupyz * Ayz(i,j,k))
Axx(i,j,k) = Axx(i,j,k) - F1o3 * lgxx * ltrA Axx(i,j,k) = Axx(i,j,k) - F1o3 * lgxx * ltrA
Axy(i,j,k) = Axy(i,j,k) - F1o3 * lgxy * ltrA Axy(i,j,k) = Axy(i,j,k) - F1o3 * lgxy * ltrA
Axz(i,j,k) = Axz(i,j,k) - F1o3 * lgxz * ltrA Axz(i,j,k) = Axz(i,j,k) - F1o3 * lgxz * ltrA
Ayy(i,j,k) = Ayy(i,j,k) - F1o3 * lgyy * ltrA Ayy(i,j,k) = Ayy(i,j,k) - F1o3 * lgyy * ltrA
Ayz(i,j,k) = Ayz(i,j,k) - F1o3 * lgyz * ltrA Ayz(i,j,k) = Ayz(i,j,k) - F1o3 * lgyz * ltrA
Azz(i,j,k) = Azz(i,j,k) - F1o3 * lgzz * ltrA Azz(i,j,k) = Azz(i,j,k) - F1o3 * lgzz * ltrA
enddo enddo
enddo enddo
enddo enddo
return return
end subroutine enforce_ga end subroutine enforce_ga
#else #else
!---------------------------------------------------------------------------------- !----------------------------------------------------------------------------------
! duplicate bam ! duplicate bam
!---------------------------------------------------------------------------------- !----------------------------------------------------------------------------------
subroutine enforce_ga(ex, dxx, gxy, gxz, dyy, gyz, dzz, & subroutine enforce_ga(ex, dxx, gxy, gxz, dyy, gyz, dzz, &
Axx, Axy, Axz, Ayy, Ayz, Azz) Axx, Axy, Axz, Ayy, Ayz, Azz)
implicit none implicit none
!~~~~~~> Input parameters: !~~~~~~> Input parameters:
integer, intent(in) :: ex(1:3) integer, intent(in) :: ex(1:3)
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: dxx,dyy,dzz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: dxx,dyy,dzz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: gxy,gxz,gyz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: gxy,gxz,gyz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Axx,Axy,Axz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Axx,Axy,Axz
real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Ayy,Ayz,Azz real*8, dimension(ex(1),ex(2),ex(3)), intent(inout) :: Ayy,Ayz,Azz
!~~~~~~~> Local variable: !~~~~~~~> Local variable:
real*8, dimension(ex(1),ex(2),ex(3)) :: trA real*8, dimension(ex(1),ex(2),ex(3)) :: trA
real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz real*8, dimension(ex(1),ex(2),ex(3)) :: gxx,gyy,gzz
real*8, dimension(ex(1),ex(2),ex(3)) :: aux,detginv real*8, dimension(ex(1),ex(2),ex(3)) :: aux,detginv
real*8, parameter :: oot = 1.D0 / 3.D0, ONE = 1.D0, TWO = 2.D0 real*8, parameter :: oot = 1.D0 / 3.D0, ONE = 1.D0, TWO = 2.D0
!~~~~~~> !~~~~~~>
gxx = dxx + ONE gxx = dxx + ONE
gyy = dyy + ONE gyy = dyy + ONE
gzz = dzz + ONE gzz = dzz + ONE
! for g ! for g
aux = (2.d0*gxy*gxz*gyz + gxx*gyy*gzz & aux = (2.d0*gxy*gxz*gyz + gxx*gyy*gzz &
- gzz*gxy**2 - gyy*gxz**2 - gxx*gyz**2)**(-oot) - gzz*gxy**2 - gyy*gxz**2 - gxx*gyz**2)**(-oot)
gxx = gxx * aux gxx = gxx * aux
gxy = gxy * aux gxy = gxy * aux
gxz = gxz * aux gxz = gxz * aux
gyy = gyy * aux gyy = gyy * aux
gyz = gyz * aux gyz = gyz * aux
gzz = gzz * aux gzz = gzz * aux
dxx = gxx - ONE dxx = gxx - ONE
dyy = gyy - ONE dyy = gyy - ONE
dzz = gzz - ONE dzz = gzz - ONE
! for A ! for A
detginv = 1/(2.d0*gxy*gxz*gyz + gxx*gyy*gzz & detginv = 1/(2.d0*gxy*gxz*gyz + gxx*gyy*gzz &
- gzz*gxy**2 - gyy*gxz**2 - gxx*gyz**2) - gzz*gxy**2 - gyy*gxz**2 - gxx*gyz**2)
trA = detginv*(-2.d0*Ayz*gxx*gyz + Axx*gyy*gzz + & trA = detginv*(-2.d0*Ayz*gxx*gyz + Axx*gyy*gzz + &
gxx*(Azz*gyy + Ayy*gzz) + 2.d0*(gxz*(Ayz*gxy - Axz*gyy + & gxx*(Azz*gyy + Ayy*gzz) + 2.d0*(gxz*(Ayz*gxy - Axz*gyy + &
Axy*gyz) + gxy*(Axz*gyz - Axy*gzz)) - Azz*gxy**2 - Ayy*gxz**2 - & Axy*gyz) + gxy*(Axz*gyz - Axy*gzz)) - Azz*gxy**2 - Ayy*gxz**2 - &
Axx*gyz**2) Axx*gyz**2)
aux = -(oot*trA) aux = -(oot*trA)
Axx = Axx + aux * gxx Axx = Axx + aux * gxx
Axy = Axy + aux * gxy Axy = Axy + aux * gxy
Axz = Axz + aux * gxz Axz = Axz + aux * gxz
Ayy = Ayy + aux * gyy Ayy = Ayy + aux * gyy
Ayz = Ayz + aux * gyz Ayz = Ayz + aux * gyz
Azz = Azz + aux * gzz Azz = Azz + aux * gzz
return return
end subroutine enforce_ga end subroutine enforce_ga
#endif #endif

View File

@@ -1,30 +1,30 @@
#ifndef ENFORCE_ALGEBRA_H #ifndef ENFORCE_ALGEBRA_H
#define ENFORCE_ALGEBRA_H #define ENFORCE_ALGEBRA_H
#ifdef fortran1 #ifdef fortran1
#define f_enforce_ag enforce_ag #define f_enforce_ag enforce_ag
#define f_enforce_ga enforce_ga #define f_enforce_ga enforce_ga
#endif #endif
#ifdef fortran2 #ifdef fortran2
#define f_enforce_ag ENFORCE_AG #define f_enforce_ag ENFORCE_AG
#define f_enforce_ga ENFORCE_GA #define f_enforce_ga ENFORCE_GA
#endif #endif
#ifdef fortran3 #ifdef fortran3
#define f_enforce_ag enforce_ag_ #define f_enforce_ag enforce_ag_
#define f_enforce_ga enforce_ga_ #define f_enforce_ga enforce_ga_
#endif #endif
extern "C" extern "C"
{ {
void f_enforce_ag(int *, void f_enforce_ag(int *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *); double *, double *, double *, double *, double *, double *);
} }
extern "C" extern "C"
{ {
void f_enforce_ga(int *, void f_enforce_ga(int *,
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *); double *, double *, double *, double *, double *, double *);
} }
#endif /* ENFORCE_ALGEBRA_H */ #endif /* ENFORCE_ALGEBRA_H */

View File

@@ -1,38 +1,38 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "cctk.h" #include "cctk.h"
#include "config.h" #include "config.h"
#include "stdc.h" #include "stdc.h"
namespace AHFinderDirect namespace AHFinderDirect
{ {
namespace jtutil namespace jtutil
{ {
int error_exit(int msg_level, const char *format, ...) int error_exit(int msg_level, const char *format, ...)
{ {
const int N_buffer = 2000; const int N_buffer = 2000;
char buffer[N_buffer]; char buffer[N_buffer];
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vsnprintf(buffer, N_buffer, format, ap); vsnprintf(buffer, N_buffer, format, ap);
va_end(ap); va_end(ap);
const int len = strlen(buffer); const int len = strlen(buffer);
if ((len > 0) && (buffer[len - 1] == '\n')) if ((len > 0) && (buffer[len - 1] == '\n'))
then buffer[len - 1] = '\0'; then buffer[len - 1] = '\0';
CCTK_VWarn(msg_level, __LINE__, __FILE__, CCTK_THORNSTRING, "%s", buffer); CCTK_VWarn(msg_level, __LINE__, __FILE__, CCTK_THORNSTRING, "%s", buffer);
// if we got here, evidently msg_level wasn't drastic enough // if we got here, evidently msg_level wasn't drastic enough
abort(); /*NOTREACHED*/ abort(); /*NOTREACHED*/
} }
//****************************************************************************** //******************************************************************************
} // namespace jtutil } // namespace jtutil
} // namespace AHFinderDirect } // namespace AHFinderDirect

Some files were not shown because too many files have changed in this diff Show More