Compare commits

..

2 Commits

Author SHA1 Message Date
6796384bf4 taskset setting updated 2026-02-07 22:24:02 +08:00
c974a88d6d Pool fh work arrays in compute_rhs_bssn to eliminate allocation churn
Add _fh variants of fderivs, fdderivs, kodis, and lopsided that accept
a caller-provided fh work array instead of allocating one internally.
Declare two shared work arrays in compute_rhs_bssn (fh_work2 for
symmetry_bd(2) callers, fh_work3 for symmetry_bd(3) callers) and pass
them to all ~84 subroutine calls, eliminating ~77 redundant automatic
array allocations (~591 MB churn per RHS call, ~2.3 GB per timestep).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 21:49:12 +08:00
233 changed files with 189078 additions and 196644 deletions

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

@@ -8,14 +8,6 @@
##
##################################################################
## Guard against re-execution by multiprocessing child processes.
## Without this, using 'spawn' or 'forkserver' context would cause every
## worker to re-run the entire script, spawning exponentially more
## workers (fork bomb).
if __name__ != '__main__':
import sys as _sys
_sys.exit(0)
##################################################################
@@ -126,7 +118,12 @@ setup.generate_AMSSNCKU_input()
#inputvalue = input() ## Wait for user input (press Enter) to proceed
#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( " Generating the AMSS-NCKU input parfile for the ABE executable. " )
@@ -265,12 +262,6 @@ if not os.path.exists( ABE_file ):
## Copy the executable ABE (or ABEGPU) into the run directory
shutil.copy2(ABE_file, output_directory)
## Copy interp load balance profile if present (for optimize pass)
interp_lb_profile = os.path.join(AMSS_NCKU_source_copy, "interp_lb_profile.bin")
if os.path.exists(interp_lb_profile):
shutil.copy2(interp_lb_profile, output_directory)
print( " Copied interp_lb_profile.bin to run directory " )
###########################
## If the initial-data method is TwoPuncture, copy the TwoPunctureABE executable to the run directory
@@ -307,7 +298,7 @@ if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
import generate_TwoPuncture_input
generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input(numerical_grid.puncture_data)
generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input()
print( )
print( " The input parfile for the TwoPunctureABE executable has been generated. " )
@@ -349,7 +340,7 @@ if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
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
@@ -433,31 +424,26 @@ print(
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_xiaoqu.generate_puncture_orbit_plot( binary_results_directory, figure_directory )
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_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_xiaoqu.generate_gravitational_wave_psi4_plot( binary_results_directory, figure_directory, i )
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_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_xiaoqu.generate_constraint_check_plot( binary_results_directory, figure_directory, i )
## Plot stored binary data
plot_xiaoqu.generate_binary_data_plot( binary_results_directory, figure_directory )

View File

@@ -1,19 +1,10 @@
#!/usr/bin/env python3
"""
AMSS-NCKU GW150914 Simulation Regression Test Script (Comprehensive Version)
AMSS-NCKU GW150914 Simulation Regression Test Script
Verification Requirements:
1. RMS errors < 1% for:
- 3D Vector Total RMS
- X Component RMS
- Y Component RMS
- Z Component RMS
2. ADM constraint violation < 2 (Grid Level 0)
3. The following figure PDFs must match GW150914-origin exactly after rasterization:
- ADM_Constraint_Grid_Level_0.pdf
- BH_Trajectory_21_XY.pdf
- BH_Trajectory_XY.pdf
The script also reports the percentage of differing pixels for each figure.
Verification Requirements:
1. XY-plane trajectory RMS error < 1% (Optimized vs. baseline, max of BH1 and BH2)
2. ADM constraint violation < 2 (Grid Level 0)
RMS Calculation Method:
- Computes trajectory deviation on the XY plane independently for BH1 and BH2
@@ -25,13 +16,9 @@ Default: output_dir = GW150914/AMSS_NCKU_output
Reference: GW150914-origin (baseline simulation)
"""
import numpy as np
import sys
import os
import shutil
import subprocess
import tempfile
from PIL import Image
import numpy as np
import sys
import os
# ANSI Color Codes
class Color:
@@ -58,200 +45,91 @@ def load_bh_trajectory(filepath):
}
def load_constraint_data(filepath):
"""Load constraint violation data"""
data = []
def load_constraint_data(filepath):
"""Load constraint violation data"""
data = []
with open(filepath, 'r') as f:
for line in f:
if line.startswith('#'):
continue
parts = line.split()
if len(parts) >= 8:
data.append([float(x) for x in parts[:8]])
return np.array(data)
def resolve_figure_dir(path):
"""Resolve the sibling figure directory from an output or figure path."""
normalized = os.path.normpath(path)
if os.path.basename(normalized) == "figure":
return normalized
return os.path.join(os.path.dirname(normalized), "figure")
def render_pdf_to_images(pdf_path, dpi=150):
"""Render a PDF to RGB images using Ghostscript."""
gs_path = shutil.which("gs")
if gs_path is None:
raise RuntimeError("Ghostscript executable 'gs' was not found in PATH")
with tempfile.TemporaryDirectory(prefix="amss_verify_pdf_") as temp_dir:
output_pattern = os.path.join(temp_dir, "page-%03d.ppm")
cmd = [
gs_path,
"-q",
"-dSAFER",
"-dBATCH",
"-dNOPAUSE",
"-sDEVICE=ppmraw",
f"-r{dpi}",
f"-o{output_pattern}",
pdf_path
]
try:
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, text=True)
except subprocess.CalledProcessError as exc:
message = exc.stderr.strip() or str(exc)
raise RuntimeError(f"Failed to render PDF '{pdf_path}': {message}") from exc
ppm_files = sorted(
os.path.join(temp_dir, filename)
for filename in os.listdir(temp_dir)
if filename.endswith(".ppm")
)
if not ppm_files:
raise RuntimeError(f"No rendered pages were produced for '{pdf_path}'")
images = []
for ppm_file in ppm_files:
with Image.open(ppm_file) as img:
images.append(np.array(img.convert("RGB"), dtype=np.uint8))
return images
def compare_rendered_pages(ref_img, target_img):
"""Return (different_pixels, total_pixels) for two rendered RGB pages."""
ref_h, ref_w = ref_img.shape[:2]
tgt_h, tgt_w = target_img.shape[:2]
total_pixels = max(ref_h, tgt_h) * max(ref_w, tgt_w)
if ref_h == tgt_h and ref_w == tgt_w:
different_pixels = int(np.count_nonzero(np.any(ref_img != target_img, axis=2)))
return different_pixels, total_pixels
diff_mask = np.ones((max(ref_h, tgt_h), max(ref_w, tgt_w)), dtype=bool)
overlap_h = min(ref_h, tgt_h)
overlap_w = min(ref_w, tgt_w)
overlap_diff = np.any(ref_img[:overlap_h, :overlap_w] != target_img[:overlap_h, :overlap_w], axis=2)
diff_mask[:overlap_h, :overlap_w] = overlap_diff
different_pixels = int(np.count_nonzero(diff_mask))
return different_pixels, total_pixels
def compare_pdf_images(ref_pdf, target_pdf, dpi=150, threshold_percent=0.001):
"""Compare two PDFs by rasterizing them and counting differing pixels."""
ref_pages = render_pdf_to_images(ref_pdf, dpi=dpi)
target_pages = render_pdf_to_images(target_pdf, dpi=dpi)
total_pixels = 0
different_pixels = 0
max_pages = max(len(ref_pages), len(target_pages))
for page_idx in range(max_pages):
if page_idx < len(ref_pages) and page_idx < len(target_pages):
page_diff, page_total = compare_rendered_pages(ref_pages[page_idx], target_pages[page_idx])
else:
existing_page = ref_pages[page_idx] if page_idx < len(ref_pages) else target_pages[page_idx]
page_total = existing_page.shape[0] * existing_page.shape[1]
page_diff = page_total
total_pixels += page_total
different_pixels += page_diff
diff_percent = (different_pixels / total_pixels * 100.0) if total_pixels else 0.0
return {
"different_pixels": different_pixels,
"total_pixels": total_pixels,
"diff_percent": diff_percent,
"pages_ref": len(ref_pages),
"pages_target": len(target_pages),
"passed": diff_percent < threshold_percent
}
def compare_required_figures(reference_figure_dir, target_figure_dir):
"""Compare the required GW150914 figure PDFs."""
figure_names = [
"ADM_Constraint_Grid_Level_0.pdf",
"BH_Trajectory_21_XY.pdf",
"BH_Trajectory_XY.pdf"
]
results = []
for figure_name in figure_names:
ref_pdf = os.path.join(reference_figure_dir, figure_name)
target_pdf = os.path.join(target_figure_dir, figure_name)
if not os.path.exists(ref_pdf):
raise FileNotFoundError(f"Reference figure not found: {ref_pdf}")
if not os.path.exists(target_pdf):
raise FileNotFoundError(f"Target figure not found: {target_pdf}")
comparison = compare_pdf_images(ref_pdf, target_pdf)
comparison["name"] = figure_name
results.append(comparison)
return results
data.append([float(x) for x in parts[:8]])
return np.array(data)
def calculate_all_rms_errors(bh_data_ref, bh_data_target):
def calculate_rms_error(bh_data_ref, bh_data_target):
"""
Calculate 3D Vector RMS and component-wise RMS (X, Y, Z) independently.
Uses r = sqrt(x^2 + y^2) as the denominator for all error normalizations.
Returns the maximum error between BH1 and BH2 for each category.
Calculate trajectory-based RMS error on the XY plane between baseline and optimized simulations.
This function computes the RMS error independently for BH1 and BH2 trajectories,
then returns the maximum of the two as the final RMS error metric.
For each black hole, the RMS is calculated as:
RMS = sqrt( (1/M) * sum( (Δr_i / r_i^max)^2 ) ) × 100%
where:
Δr_i = sqrt((x_ref,i - x_new,i)^2 + (y_ref,i - y_new,i)^2)
r_i^max = max(sqrt(x_ref,i^2 + y_ref,i^2), sqrt(x_new,i^2 + y_new,i^2))
Args:
bh_data_ref: Reference (baseline) trajectory data
bh_data_target: Target (optimized) trajectory data
Returns:
rms_value: Final RMS error as a percentage (max of BH1 and BH2)
error: Error message if any
"""
# Align data: truncate to the length of the shorter dataset
M = min(len(bh_data_ref['time']), len(bh_data_target['time']))
if M < 10:
return None, "Insufficient data points for comparison"
results = {}
# Extract XY coordinates for both black holes
x1_ref = bh_data_ref['x1'][:M]
y1_ref = bh_data_ref['y1'][:M]
x2_ref = bh_data_ref['x2'][:M]
y2_ref = bh_data_ref['y2'][:M]
for bh in ['1', '2']:
x_r, y_r, z_r = bh_data_ref[f'x{bh}'][:M], bh_data_ref[f'y{bh}'][:M], bh_data_ref[f'z{bh}'][:M]
x_n, y_n, z_n = bh_data_target[f'x{bh}'][:M], bh_data_target[f'y{bh}'][:M], bh_data_target[f'z{bh}'][:M]
x1_new = bh_data_target['x1'][:M]
y1_new = bh_data_target['y1'][:M]
x2_new = bh_data_target['x2'][:M]
y2_new = bh_data_target['y2'][:M]
# 核心修改:根据组委会的邮件指示,分母统一使用 r = sqrt(x^2 + y^2)
r_ref = np.sqrt(x_r**2 + y_r**2)
r_new = np.sqrt(x_n**2 + y_n**2)
denom_max = np.maximum(r_ref, r_new)
# Calculate RMS for BH1
delta_r1 = np.sqrt((x1_ref - x1_new)**2 + (y1_ref - y1_new)**2)
r1_ref = np.sqrt(x1_ref**2 + y1_ref**2)
r1_new = np.sqrt(x1_new**2 + y1_new**2)
r1_max = np.maximum(r1_ref, r1_new)
valid = denom_max > 1e-15
if np.sum(valid) < 10:
results[f'BH{bh}'] = { '3D_Vector': 0.0, 'X_Component': 0.0, 'Y_Component': 0.0, 'Z_Component': 0.0 }
continue
# Calculate RMS for BH2
delta_r2 = np.sqrt((x2_ref - x2_new)**2 + (y2_ref - y2_new)**2)
r2_ref = np.sqrt(x2_ref**2 + y2_ref**2)
r2_new = np.sqrt(x2_new**2 + y2_new**2)
r2_max = np.maximum(r2_ref, r2_new)
def calc_rms(delta):
# 将对应分量的偏差除以统一的轨道半径分母 denom_max
return np.sqrt(np.mean((delta[valid] / denom_max[valid])**2)) * 100
# Avoid division by zero for BH1
valid_mask1 = r1_max > 1e-15
if np.sum(valid_mask1) < 10:
return None, "Insufficient valid data points for BH1"
# 1. Total 3D Vector RMS
delta_vec = np.sqrt((x_r - x_n)**2 + (y_r - y_n)**2 + (z_r - z_n)**2)
rms_3d = calc_rms(delta_vec)
terms1 = (delta_r1[valid_mask1] / r1_max[valid_mask1])**2
rms_bh1 = np.sqrt(np.mean(terms1)) * 100
# 2. Component-wise RMS (分离计算各轴,但共用半径分母)
rms_x = calc_rms(np.abs(x_r - x_n))
rms_y = calc_rms(np.abs(y_r - y_n))
rms_z = calc_rms(np.abs(z_r - z_n))
# Avoid division by zero for BH2
valid_mask2 = r2_max > 1e-15
if np.sum(valid_mask2) < 10:
return None, "Insufficient valid data points for BH2"
results[f'BH{bh}'] = {
'3D_Vector': rms_3d,
'X_Component': rms_x,
'Y_Component': rms_y,
'Z_Component': rms_z
}
terms2 = (delta_r2[valid_mask2] / r2_max[valid_mask2])**2
rms_bh2 = np.sqrt(np.mean(terms2)) * 100
# 获取 BH1 BH2 中的最大误差
max_rms = {
'3D_Vector': max(results['BH1']['3D_Vector'], results['BH2']['3D_Vector']),
'X_Component': max(results['BH1']['X_Component'], results['BH2']['X_Component']),
'Y_Component': max(results['BH1']['Y_Component'], results['BH2']['Y_Component']),
'Z_Component': max(results['BH1']['Z_Component'], results['BH2']['Z_Component'])
}
# Final RMS is the maximum of BH1 and BH2
rms_final = max(rms_bh1, rms_bh2)
return rms_final, None
return max_rms, None
def analyze_constraint_violation(constraint_data, n_levels=9):
"""
@@ -277,32 +155,34 @@ def analyze_constraint_violation(constraint_data, n_levels=9):
def print_header():
"""Print report header"""
print("\n" + Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
print(Color.BOLD + " AMSS-NCKU GW150914 Comprehensive Regression Test" + Color.RESET)
print(Color.BOLD + " AMSS-NCKU GW150914 Simulation Regression Test Report" + Color.RESET)
print(Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
def print_rms_results(rms_dict, error, threshold=1.0):
print(f"\n{Color.BOLD}1. RMS Error Analysis (Maximums of BH1 & BH2){Color.RESET}")
print("-" * 65)
def print_rms_results(rms_rel, error, threshold=1.0):
"""Print RMS error results"""
print(f"\n{Color.BOLD}1. RMS Error Analysis (Baseline vs Optimized){Color.RESET}")
print("-" * 45)
if error:
print(f" {Color.RED}Error: {error}{Color.RESET}")
return False
all_passed = True
print(f" Requirement: < {threshold}%\n")
passed = rms_rel < threshold
for key, val in rms_dict.items():
passed = val < threshold
all_passed = all_passed and passed
status = get_status_text(passed)
print(f" {key:15}: {val:8.4f}% | Status: {status}")
print(f" RMS relative error: {rms_rel:.4f}%")
print(f" Requirement: < {threshold}%")
print(f" Status: {get_status_text(passed)}")
return all_passed
return passed
def print_constraint_results(results, threshold=2.0):
def print_constraint_results(results, threshold=2.0):
"""Print constraint violation results"""
print(f"\n{Color.BOLD}2. ADM Constraint Violation Analysis (Grid Level 0){Color.RESET}")
print("-" * 65)
print("-" * 45)
names = ['Ham', 'Px', 'Py', 'Pz', 'Gx', 'Gy', 'Gz']
for i, name in enumerate(names):
@@ -315,49 +195,23 @@ def print_constraint_results(results, threshold=2.0):
print(f"\n Maximum violation: {results['max_violation']:.6f}")
print(f" Requirement: < {threshold}")
print(f" Status: {get_status_text(passed)}")
return passed
def print_figure_results(results, threshold_percent=0.001):
print(f"\n{Color.BOLD}3. Figure Pixel Comparison (PDF Rasterization){Color.RESET}")
print("-" * 65)
print(f" Requirement: < {threshold_percent:.3f}% differing pixels\n")
all_passed = True
for result in results:
passed = result["passed"]
all_passed = all_passed and passed
status = get_status_text(passed)
print(f" {result['name']:32}: {result['diff_percent']:10.6f}% | Status: {status}")
if result["pages_ref"] != result["pages_target"]:
print(f" {'':32} pages(ref/target): {result['pages_ref']}/{result['pages_target']}")
return all_passed
def print_figure_error(error_message):
print(f"\n{Color.BOLD}3. Figure Pixel Comparison (PDF Rasterization){Color.RESET}")
print("-" * 65)
print(f" {Color.RED}Error: {error_message}{Color.RESET}")
return False
def print_summary(rms_passed, constraint_passed, figure_passed):
print("\n" + Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
print(Color.BOLD + "Verification Summary" + Color.RESET)
print(Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
all_passed = rms_passed and constraint_passed and figure_passed
res_rms = get_status_text(rms_passed)
res_con = get_status_text(constraint_passed)
res_fig = get_status_text(figure_passed)
print(f" [1] Comprehensive RMS check: {res_rms}")
print(f" [2] ADM constraint check: {res_con}")
print(f" [3] Figure pixel comparison: {res_fig}")
return passed
def print_summary(rms_passed, constraint_passed):
"""Print summary"""
print("\n" + Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
print(Color.BOLD + "Verification Summary" + Color.RESET)
print(Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
all_passed = rms_passed and constraint_passed
res_rms = get_status_text(rms_passed)
res_con = get_status_text(constraint_passed)
print(f" [1] RMS trajectory check: {res_rms}")
print(f" [2] ADM constraint check: {res_con}")
final_status = f"{Color.GREEN}{Color.BOLD}ALL CHECKS PASSED{Color.RESET}" if all_passed else f"{Color.RED}{Color.BOLD}SOME CHECKS FAILED{Color.RESET}"
print(f"\n Overall result: {final_status}")
@@ -365,58 +219,61 @@ def print_summary(rms_passed, constraint_passed, figure_passed):
return all_passed
def main():
# Determine target (optimized) output directory
if len(sys.argv) > 1:
target_dir = sys.argv[1]
else:
script_dir = os.path.dirname(os.path.abspath(__file__))
target_dir = os.path.join(script_dir, "GW150914/AMSS_NCKU_output")
script_dir = os.path.dirname(os.path.abspath(__file__))
reference_dir = os.path.join(script_dir, "GW150914-origin/AMSS_NCKU_output")
target_figure_dir = resolve_figure_dir(target_dir)
reference_figure_dir = os.path.join(script_dir, "GW150914-origin/figure")
bh_file_ref = os.path.join(reference_dir, "bssn_BH.dat")
bh_file_target = os.path.join(target_dir, "bssn_BH.dat")
constraint_file = os.path.join(target_dir, "bssn_constraint.dat")
# Determine reference (baseline) directory
script_dir = os.path.dirname(os.path.abspath(__file__))
reference_dir = os.path.join(script_dir, "GW150914-origin/AMSS_NCKU_output")
# Data file paths
bh_file_ref = os.path.join(reference_dir, "bssn_BH.dat")
bh_file_target = os.path.join(target_dir, "bssn_BH.dat")
constraint_file = os.path.join(target_dir, "bssn_constraint.dat")
# Check if files exist
if not os.path.exists(bh_file_ref):
print(f"{Color.RED}{Color.BOLD}Error:{Color.RESET} Baseline trajectory file not found: {bh_file_ref}")
sys.exit(1)
if not os.path.exists(bh_file_target):
print(f"{Color.RED}{Color.BOLD}Error:{Color.RESET} Target trajectory file not found: {bh_file_target}")
sys.exit(1)
if not os.path.exists(constraint_file):
print(f"{Color.RED}{Color.BOLD}Error:{Color.RESET} Constraint data file not found: {constraint_file}")
sys.exit(1)
print_header()
print(f"\n{Color.BOLD}Reference (Baseline):{Color.RESET} {Color.BLUE}{reference_dir}{Color.RESET}")
print(f"{Color.BOLD}Target (Optimized): {Color.RESET} {Color.BLUE}{target_dir}{Color.RESET}")
print(f"{Color.BOLD}Reference Figures: {Color.RESET} {Color.BLUE}{reference_figure_dir}{Color.RESET}")
print(f"{Color.BOLD}Target Figures: {Color.RESET} {Color.BLUE}{target_figure_dir}{Color.RESET}")
# Print header
print_header()
print(f"\n{Color.BOLD}Reference (Baseline):{Color.RESET} {Color.BLUE}{reference_dir}{Color.RESET}")
print(f"{Color.BOLD}Target (Optimized): {Color.RESET} {Color.BLUE}{target_dir}{Color.RESET}")
# Load data
bh_data_ref = load_bh_trajectory(bh_file_ref)
bh_data_target = load_bh_trajectory(bh_file_target)
constraint_data = load_constraint_data(constraint_file)
# Output modified RMS results
rms_dict, error = calculate_all_rms_errors(bh_data_ref, bh_data_target)
rms_passed = print_rms_results(rms_dict, error)
# Calculate RMS error
rms_rel, error = calculate_rms_error(bh_data_ref, bh_data_target)
rms_passed = print_rms_results(rms_rel, error)
# Analyze constraint violation
constraint_results = analyze_constraint_violation(constraint_data)
constraint_passed = print_constraint_results(constraint_results)
# Print summary
all_passed = print_summary(rms_passed, constraint_passed)
# Return exit code
sys.exit(0 if all_passed else 1)
# Output constraint results
constraint_results = analyze_constraint_violation(constraint_data)
constraint_passed = print_constraint_results(constraint_results)
try:
figure_results = compare_required_figures(reference_figure_dir, target_figure_dir)
figure_passed = print_figure_results(figure_results)
except (FileNotFoundError, RuntimeError) as exc:
figure_passed = print_figure_error(str(exc))
all_passed = print_summary(rms_passed, constraint_passed, figure_passed)
sys.exit(0 if all_passed else 1)
if __name__ == "__main__":
main()

View File

@@ -1,53 +1,53 @@
#ifndef Ansorg_H
#define Ansorg_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>
#define PI M_PI
class Ansorg
{
protected:
int n1, n2, n3, ntotal;
int order;
double *coordA, *coordB, *coordphi;
int ps_rxx, ps_rxy, ps_ryx, ps_ryy;
double ps_b, ps_dx;
double PIh;
double *pu_ps;
int myrank;
public:
Ansorg(char *filename, int orderi);
~Ansorg();
double ps_u_at_xyz(double x, double y, double z);
void set_ABp();
void xyz_to_ABp(double x, double y, double z,
double *A, double *B, double *phi);
double interpolate_tri_bar(double x, double y, double z,
int n1, int n2, int n3,
double *x1, double *x2, double *x3, double *yp);
int find_point_bisection(double x, int n, double *xp, int o);
void barycentric_omega(int n, int s, double *x, double *omega);
double barycentric(double x0, int n, int s, double *x, double *y,
double *omega);
};
#endif /* Ansorg_H */
#ifndef Ansorg_H
#define Ansorg_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>
#define PI M_PI
class Ansorg
{
protected:
int n1, n2, n3, ntotal;
int order;
double *coordA, *coordB, *coordphi;
int ps_rxx, ps_rxy, ps_ryx, ps_ryy;
double ps_b, ps_dx;
double PIh;
double *pu_ps;
int myrank;
public:
Ansorg(char *filename, int orderi);
~Ansorg();
double ps_u_at_xyz(double x, double y, double z);
void set_ABp();
void xyz_to_ABp(double x, double y, double z,
double *A, double *B, double *phi);
double interpolate_tri_bar(double x, double y, double z,
int n1, int n2, int n3,
double *x1, double *x2, double *x3, double *yp);
int find_point_bisection(double x, int n, double *xp, int o);
void barycentric_omega(int n, int s, double *x, double *omega);
double barycentric(double x0, int n, int s, double *x, double *y,
double *omega);
};
#endif /* Ansorg_H */

View File

@@ -1,101 +1,101 @@
#ifndef BH_DIAGNOSTICS_H
#define BH_DIAGNOSTICS_H
namespace AHFinderDirect
{
struct BH_diagnostics
{
public:
// mean x,y,z
fp centroid_x, centroid_y, centroid_z;
// these are quadrupole moments about the centroid, i.e.
// mean(xi*xj) - centroid_i*centroid_j
fp quadrupole_xx, quadrupole_xy, quadrupole_xz,
quadrupole_yy, quadrupole_yz,
quadrupole_zz;
// min,max,mean surface radius about local coordinate origin
fp min_radius, max_radius, mean_radius;
// xyz bounding box
fp min_x, max_x,
min_y, max_y,
min_z, max_z;
// proper circumference
// (computed using induced metric along these local-coordinate planes)
fp circumference_xy,
circumference_xz,
circumference_yz;
// surface area (computed using induced metric)
// and quantities derived from it
fp area, irreducible_mass, areal_radius;
double Px, Py, Pz, Sx, Sy, Sz;
public:
// position of diagnostics in buffer and number of diagnostics
enum
{
posn__centroid_x = 0,
posn__centroid_y,
posn__centroid_z,
posn__quadrupole_xx,
posn__quadrupole_xy,
posn__quadrupole_xz,
posn__quadrupole_yy,
posn__quadrupole_yz,
posn__quadrupole_zz,
posn__min_radius,
posn__max_radius,
posn__mean_radius,
posn__min_x,
posn__max_x,
posn__min_y,
posn__max_y,
posn__min_z,
posn__max_z,
posn__circumference_xy,
posn__circumference_xz,
posn__circumference_yz,
posn__area,
posn__irreducible_mass,
posn__areal_radius,
N_buffer // no comma // size of buffer
};
// copy diagnostics to/from buffer
void copy_to_buffer(double buffer[N_buffer]) const;
void copy_from_buffer(const double buffer[N_buffer]);
public:
void compute(patch_system &ps);
void compute_signature(patch_system &ps, const double dT);
FILE *setup_output_file(int N_horizons, int hn)
const;
void output(FILE *fileptr, double time)
const;
BH_diagnostics();
private:
static double surface_integral(const patch_system &ps,
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_yz_plane,
enum patch::integration_method method);
};
//******************************************************************************
} // namespace AHFinderDirect
#endif /* BH_DIAGNOSTICS_H */
#ifndef BH_DIAGNOSTICS_H
#define BH_DIAGNOSTICS_H
namespace AHFinderDirect
{
struct BH_diagnostics
{
public:
// mean x,y,z
fp centroid_x, centroid_y, centroid_z;
// these are quadrupole moments about the centroid, i.e.
// mean(xi*xj) - centroid_i*centroid_j
fp quadrupole_xx, quadrupole_xy, quadrupole_xz,
quadrupole_yy, quadrupole_yz,
quadrupole_zz;
// min,max,mean surface radius about local coordinate origin
fp min_radius, max_radius, mean_radius;
// xyz bounding box
fp min_x, max_x,
min_y, max_y,
min_z, max_z;
// proper circumference
// (computed using induced metric along these local-coordinate planes)
fp circumference_xy,
circumference_xz,
circumference_yz;
// surface area (computed using induced metric)
// and quantities derived from it
fp area, irreducible_mass, areal_radius;
double Px, Py, Pz, Sx, Sy, Sz;
public:
// position of diagnostics in buffer and number of diagnostics
enum
{
posn__centroid_x = 0,
posn__centroid_y,
posn__centroid_z,
posn__quadrupole_xx,
posn__quadrupole_xy,
posn__quadrupole_xz,
posn__quadrupole_yy,
posn__quadrupole_yz,
posn__quadrupole_zz,
posn__min_radius,
posn__max_radius,
posn__mean_radius,
posn__min_x,
posn__max_x,
posn__min_y,
posn__max_y,
posn__min_z,
posn__max_z,
posn__circumference_xy,
posn__circumference_xz,
posn__circumference_yz,
posn__area,
posn__irreducible_mass,
posn__areal_radius,
N_buffer // no comma // size of buffer
};
// copy diagnostics to/from buffer
void copy_to_buffer(double buffer[N_buffer]) const;
void copy_from_buffer(const double buffer[N_buffer]);
public:
void compute(patch_system &ps);
void compute_signature(patch_system &ps, const double dT);
FILE *setup_output_file(int N_horizons, int hn)
const;
void output(FILE *fileptr, double time)
const;
BH_diagnostics();
private:
static double surface_integral(const patch_system &ps,
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_yz_plane,
enum patch::integration_method method);
};
//******************************************************************************
} // namespace AHFinderDirect
#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,255 +0,0 @@
#include "tool.h"
/*
* 你需要提供 symmetry_bd 的 C 版本(或 Fortran 绑到 C 的接口)。
* Fortran: call symmetry_bd(3,ex,f,fh,SoA)
*
* 约定:
* nghost = 3
* ex[3] = {ex1,ex2,ex3}
* f = 原始网格 (ex1*ex2*ex3)
* fh = 扩展网格 ((ex1+3)*(ex2+3)*(ex3+3)),对应 Fortran 的 (-2:ex1, ...)
* SoA[3] = 输入参数
*/
void lopsided(const int ex[3],
const double *X, const double *Y, const double *Z,
const double *f, double *f_rhs,
const double *Sfx, const double *Sfy, const double *Sfz,
int Symmetry, const double SoA[3])
{
const double ZEO = 0.0, ONE = 1.0, F3 = 3.0;
const double TWO = 2.0, F6 = 6.0, F18 = 18.0;
const double F12 = 12.0, F10 = 10.0, EIT = 8.0;
const int NO_SYMM = 0, EQ_SYMM = 1, OCTANT = 2;
(void)OCTANT; // 这里和 Fortran 一样只是定义了不用也没关系
const int ex1 = ex[0], ex2 = ex[1], ex3 = ex[2];
// 对应 Fortran: dX = X(2)-X(1) Fortran 1-based
// C: X[1]-X[0]
const double dX = X[1] - X[0];
const double dY = Y[1] - Y[0];
const double dZ = Z[1] - Z[0];
const double d12dx = ONE / F12 / dX;
const double d12dy = ONE / F12 / dY;
const double d12dz = ONE / F12 / dZ;
// Fortran 里算了 d2dx/d2dy/d2dz 但本 subroutine 里没用到(保持一致也算出来)
const double d2dx = ONE / TWO / dX;
const double d2dy = ONE / TWO / dY;
const double d2dz = ONE / TWO / dZ;
(void)d2dx; (void)d2dy; (void)d2dz;
// Fortran:
// imax = ex(1); jmax = ex(2); kmax = ex(3)
const int imaxF = ex1;
const int jmaxF = ex2;
const int kmaxF = ex3;
// Fortran:
// imin=jmin=kmin=1; 若满足对称条件则设为 -2
int iminF = 1, jminF = 1, kminF = 1;
if (Symmetry > NO_SYMM && fabs(Z[0]) < dZ) kminF = -2;
if (Symmetry > EQ_SYMM && fabs(X[0]) < dX) iminF = -2;
if (Symmetry > EQ_SYMM && fabs(Y[0]) < dY) jminF = -2;
// 分配 fh大小 (ex1+3)*(ex2+3)*(ex3+3)
const size_t nx = (size_t)ex1 + 3;
const size_t ny = (size_t)ex2 + 3;
const size_t nz = (size_t)ex3 + 3;
const size_t fh_size = nx * ny * nz;
double *fh = (double*)malloc(fh_size * sizeof(double));
if (!fh) return; // 内存不足:直接返回(你也可以改成 abort/报错)
// Fortran: call symmetry_bd(3,ex,f,fh,SoA)
symmetry_bd(3, ex, f, fh, SoA);
/*
* Fortran 主循环:
* do k=1,ex(3)-1
* do j=1,ex(2)-1
* do i=1,ex(1)-1
*
* 转成 C 0-based
* k0 = 0..ex3-2, j0 = 0..ex2-2, i0 = 0..ex1-2
*
* 并且 Fortran 里的 i/j/k 在 fh 访问时,仍然是 Fortran 索引值:
* iF=i0+1, jF=j0+1, kF=k0+1
*/
for (int k0 = 0; k0 <= ex3 - 2; ++k0) {
const int kF = k0 + 1;
for (int j0 = 0; j0 <= ex2 - 2; ++j0) {
const int jF = j0 + 1;
for (int i0 = 0; i0 <= ex1 - 2; ++i0) {
const int iF = i0 + 1;
const size_t p = idx_ex(i0, j0, k0, ex);
// ---------------- x direction ----------------
const double sfx = Sfx[p];
if (sfx > ZEO) {
// Fortran: if(i+3 <= imax)
// iF+3 <= ex1 <=> i0+4 <= ex1 <=> i0 <= ex1-4
if (i0 <= ex1 - 4) {
f_rhs[p] += sfx * d12dx *
(-F3 * fh[idx_fh_F(iF - 1, jF, kF, ex)]
-F10 * fh[idx_fh_F(iF , jF, kF, ex)]
+F18 * fh[idx_fh_F(iF + 1, jF, kF, ex)]
-F6 * fh[idx_fh_F(iF + 2, jF, kF, ex)]
+ fh[idx_fh_F(iF + 3, jF, kF, ex)]);
}
// elseif(i+2 <= imax) <=> i0 <= ex1-3
else if (i0 <= ex1 - 3) {
f_rhs[p] += sfx * d12dx *
( fh[idx_fh_F(iF - 2, jF, kF, ex)]
-EIT * fh[idx_fh_F(iF - 1, jF, kF, ex)]
+EIT * fh[idx_fh_F(iF + 1, jF, kF, ex)]
- fh[idx_fh_F(iF + 2, jF, kF, ex)]);
}
// elseif(i+1 <= imax) <=> i0 <= ex1-2循环里总成立
else if (i0 <= ex1 - 2) {
f_rhs[p] -= sfx * d12dx *
(-F3 * fh[idx_fh_F(iF + 1, jF, kF, ex)]
-F10 * fh[idx_fh_F(iF , jF, kF, ex)]
+F18 * fh[idx_fh_F(iF - 1, jF, kF, ex)]
-F6 * fh[idx_fh_F(iF - 2, jF, kF, ex)]
+ fh[idx_fh_F(iF - 3, jF, kF, ex)]);
}
} else if (sfx < ZEO) {
// Fortran: if(i-3 >= imin)
// (iF-3) >= iminF <=> (i0-2) >= iminF
if ((i0 - 2) >= iminF) {
f_rhs[p] -= sfx * d12dx *
(-F3 * fh[idx_fh_F(iF + 1, jF, kF, ex)]
-F10 * fh[idx_fh_F(iF , jF, kF, ex)]
+F18 * fh[idx_fh_F(iF - 1, jF, kF, ex)]
-F6 * fh[idx_fh_F(iF - 2, jF, kF, ex)]
+ fh[idx_fh_F(iF - 3, jF, kF, ex)]);
}
// elseif(i-2 >= imin) <=> (i0-1) >= iminF
else if ((i0 - 1) >= iminF) {
f_rhs[p] += sfx * d12dx *
( fh[idx_fh_F(iF - 2, jF, kF, ex)]
-EIT * fh[idx_fh_F(iF - 1, jF, kF, ex)]
+EIT * fh[idx_fh_F(iF + 1, jF, kF, ex)]
- fh[idx_fh_F(iF + 2, jF, kF, ex)]);
}
// elseif(i-1 >= imin) <=> i0 >= iminF
else if (i0 >= iminF) {
f_rhs[p] += sfx * d12dx *
(-F3 * fh[idx_fh_F(iF - 1, jF, kF, ex)]
-F10 * fh[idx_fh_F(iF , jF, kF, ex)]
+F18 * fh[idx_fh_F(iF + 1, jF, kF, ex)]
-F6 * fh[idx_fh_F(iF + 2, jF, kF, ex)]
+ fh[idx_fh_F(iF + 3, jF, kF, ex)]);
}
}
// ---------------- y direction ----------------
const double sfy = Sfy[p];
if (sfy > ZEO) {
// jF+3 <= ex2 <=> j0+4 <= ex2 <=> j0 <= ex2-4
if (j0 <= ex2 - 4) {
f_rhs[p] += sfy * d12dy *
(-F3 * fh[idx_fh_F(iF, jF - 1, kF, ex)]
-F10 * fh[idx_fh_F(iF, jF , kF, ex)]
+F18 * fh[idx_fh_F(iF, jF + 1, kF, ex)]
-F6 * fh[idx_fh_F(iF, jF + 2, kF, ex)]
+ fh[idx_fh_F(iF, jF + 3, kF, ex)]);
} else if (j0 <= ex2 - 3) {
f_rhs[p] += sfy * d12dy *
( fh[idx_fh_F(iF, jF - 2, kF, ex)]
-EIT * fh[idx_fh_F(iF, jF - 1, kF, ex)]
+EIT * fh[idx_fh_F(iF, jF + 1, kF, ex)]
- fh[idx_fh_F(iF, jF + 2, kF, ex)]);
} else if (j0 <= ex2 - 2) {
f_rhs[p] -= sfy * d12dy *
(-F3 * fh[idx_fh_F(iF, jF + 1, kF, ex)]
-F10 * fh[idx_fh_F(iF, jF , kF, ex)]
+F18 * fh[idx_fh_F(iF, jF - 1, kF, ex)]
-F6 * fh[idx_fh_F(iF, jF - 2, kF, ex)]
+ fh[idx_fh_F(iF, jF - 3, kF, ex)]);
}
} else if (sfy < ZEO) {
if ((j0 - 2) >= jminF) {
f_rhs[p] -= sfy * d12dy *
(-F3 * fh[idx_fh_F(iF, jF + 1, kF, ex)]
-F10 * fh[idx_fh_F(iF, jF , kF, ex)]
+F18 * fh[idx_fh_F(iF, jF - 1, kF, ex)]
-F6 * fh[idx_fh_F(iF, jF - 2, kF, ex)]
+ fh[idx_fh_F(iF, jF - 3, kF, ex)]);
} else if ((j0 - 1) >= jminF) {
f_rhs[p] += sfy * d12dy *
( fh[idx_fh_F(iF, jF - 2, kF, ex)]
-EIT * fh[idx_fh_F(iF, jF - 1, kF, ex)]
+EIT * fh[idx_fh_F(iF, jF + 1, kF, ex)]
- fh[idx_fh_F(iF, jF + 2, kF, ex)]);
} else if (j0 >= jminF) {
f_rhs[p] += sfy * d12dy *
(-F3 * fh[idx_fh_F(iF, jF - 1, kF, ex)]
-F10 * fh[idx_fh_F(iF, jF , kF, ex)]
+F18 * fh[idx_fh_F(iF, jF + 1, kF, ex)]
-F6 * fh[idx_fh_F(iF, jF + 2, kF, ex)]
+ fh[idx_fh_F(iF, jF + 3, kF, ex)]);
}
}
// ---------------- z direction ----------------
const double sfz = Sfz[p];
if (sfz > ZEO) {
if (k0 <= ex3 - 4) {
f_rhs[p] += sfz * d12dz *
(-F3 * fh[idx_fh_F(iF, jF, kF - 1, ex)]
-F10 * fh[idx_fh_F(iF, jF, kF , ex)]
+F18 * fh[idx_fh_F(iF, jF, kF + 1, ex)]
-F6 * fh[idx_fh_F(iF, jF, kF + 2, ex)]
+ fh[idx_fh_F(iF, jF, kF + 3, ex)]);
} else if (k0 <= ex3 - 3) {
f_rhs[p] += sfz * d12dz *
( fh[idx_fh_F(iF, jF, kF - 2, ex)]
-EIT * fh[idx_fh_F(iF, jF, kF - 1, ex)]
+EIT * fh[idx_fh_F(iF, jF, kF + 1, ex)]
- fh[idx_fh_F(iF, jF, kF + 2, ex)]);
} else if (k0 <= ex3 - 2) {
f_rhs[p] -= sfz * d12dz *
(-F3 * fh[idx_fh_F(iF, jF, kF + 1, ex)]
-F10 * fh[idx_fh_F(iF, jF, kF , ex)]
+F18 * fh[idx_fh_F(iF, jF, kF - 1, ex)]
-F6 * fh[idx_fh_F(iF, jF, kF - 2, ex)]
+ fh[idx_fh_F(iF, jF, kF - 3, ex)]);
}
} else if (sfz < ZEO) {
if ((k0 - 2) >= kminF) {
f_rhs[p] -= sfz * d12dz *
(-F3 * fh[idx_fh_F(iF, jF, kF + 1, ex)]
-F10 * fh[idx_fh_F(iF, jF, kF , ex)]
+F18 * fh[idx_fh_F(iF, jF, kF - 1, ex)]
-F6 * fh[idx_fh_F(iF, jF, kF - 2, ex)]
+ fh[idx_fh_F(iF, jF, kF - 3, ex)]);
} else if ((k0 - 1) >= kminF) {
f_rhs[p] += sfz * d12dz *
( fh[idx_fh_F(iF, jF, kF - 2, ex)]
-EIT * fh[idx_fh_F(iF, jF, kF - 1, ex)]
+EIT * fh[idx_fh_F(iF, jF, kF + 1, ex)]
- fh[idx_fh_F(iF, jF, kF + 2, ex)]);
} else if (k0 >= kminF) {
f_rhs[p] += sfz * d12dz *
(-F3 * fh[idx_fh_F(iF, jF, kF - 1, ex)]
-F10 * fh[idx_fh_F(iF, jF, kF , ex)]
+F18 * fh[idx_fh_F(iF, jF, kF + 1, ex)]
-F6 * fh[idx_fh_F(iF, jF, kF + 2, ex)]
+ fh[idx_fh_F(iF, jF, kF + 3, ex)]);
}
}
}
}
}
free(fh);
}

View File

@@ -1,248 +0,0 @@
#include "tool.h"
/*
* Combined advection (lopsided) + KO dissipation (kodis).
* Uses one shared symmetry_bd buffer per call.
*/
void lopsided_kodis(const int ex[3],
const double *X, const double *Y, const double *Z,
const double *f, double *f_rhs,
const double *Sfx, const double *Sfy, const double *Sfz,
int Symmetry, const double SoA[3], double eps)
{
const double ZEO = 0.0, ONE = 1.0, F3 = 3.0;
const double F6 = 6.0, F18 = 18.0;
const double F12 = 12.0, F10 = 10.0, EIT = 8.0;
const double SIX = 6.0, FIT = 15.0, TWT = 20.0;
const double cof = 64.0; // 2^6
const int NO_SYMM = 0, EQ_SYMM = 1;
const int ex1 = ex[0], ex2 = ex[1], ex3 = ex[2];
const double dX = X[1] - X[0];
const double dY = Y[1] - Y[0];
const double dZ = Z[1] - Z[0];
const double d12dx = ONE / F12 / dX;
const double d12dy = ONE / F12 / dY;
const double d12dz = ONE / F12 / dZ;
const int imaxF = ex1;
const int jmaxF = ex2;
const int kmaxF = ex3;
int iminF = 1, jminF = 1, kminF = 1;
if (Symmetry > NO_SYMM && fabs(Z[0]) < dZ) kminF = -2;
if (Symmetry > EQ_SYMM && fabs(X[0]) < dX) iminF = -2;
if (Symmetry > EQ_SYMM && fabs(Y[0]) < dY) jminF = -2;
// fh for Fortran-style domain (-2:ex1,-2:ex2,-2:ex3)
const size_t nx = (size_t)ex1 + 3;
const size_t ny = (size_t)ex2 + 3;
const size_t nz = (size_t)ex3 + 3;
const size_t fh_size = nx * ny * nz;
double *fh = (double*)malloc(fh_size * sizeof(double));
if (!fh) return;
symmetry_bd(3, ex, f, fh, SoA);
// Advection (same stencil logic as lopsided_c.C)
for (int k0 = 0; k0 <= ex3 - 2; ++k0) {
const int kF = k0 + 1;
for (int j0 = 0; j0 <= ex2 - 2; ++j0) {
const int jF = j0 + 1;
for (int i0 = 0; i0 <= ex1 - 2; ++i0) {
const int iF = i0 + 1;
const size_t p = idx_ex(i0, j0, k0, ex);
const double sfx = Sfx[p];
if (sfx > ZEO) {
if (i0 <= ex1 - 4) {
f_rhs[p] += sfx * d12dx *
(-F3 * fh[idx_fh_F(iF - 1, jF, kF, ex)]
-F10 * fh[idx_fh_F(iF , jF, kF, ex)]
+F18 * fh[idx_fh_F(iF + 1, jF, kF, ex)]
-F6 * fh[idx_fh_F(iF + 2, jF, kF, ex)]
+ fh[idx_fh_F(iF + 3, jF, kF, ex)]);
} else if (i0 <= ex1 - 3) {
f_rhs[p] += sfx * d12dx *
( fh[idx_fh_F(iF - 2, jF, kF, ex)]
-EIT * fh[idx_fh_F(iF - 1, jF, kF, ex)]
+EIT * fh[idx_fh_F(iF + 1, jF, kF, ex)]
- fh[idx_fh_F(iF + 2, jF, kF, ex)]);
} else if (i0 <= ex1 - 2) {
f_rhs[p] -= sfx * d12dx *
(-F3 * fh[idx_fh_F(iF + 1, jF, kF, ex)]
-F10 * fh[idx_fh_F(iF , jF, kF, ex)]
+F18 * fh[idx_fh_F(iF - 1, jF, kF, ex)]
-F6 * fh[idx_fh_F(iF - 2, jF, kF, ex)]
+ fh[idx_fh_F(iF - 3, jF, kF, ex)]);
}
} else if (sfx < ZEO) {
if ((i0 - 2) >= iminF) {
f_rhs[p] -= sfx * d12dx *
(-F3 * fh[idx_fh_F(iF + 1, jF, kF, ex)]
-F10 * fh[idx_fh_F(iF , jF, kF, ex)]
+F18 * fh[idx_fh_F(iF - 1, jF, kF, ex)]
-F6 * fh[idx_fh_F(iF - 2, jF, kF, ex)]
+ fh[idx_fh_F(iF - 3, jF, kF, ex)]);
} else if ((i0 - 1) >= iminF) {
f_rhs[p] += sfx * d12dx *
( fh[idx_fh_F(iF - 2, jF, kF, ex)]
-EIT * fh[idx_fh_F(iF - 1, jF, kF, ex)]
+EIT * fh[idx_fh_F(iF + 1, jF, kF, ex)]
- fh[idx_fh_F(iF + 2, jF, kF, ex)]);
} else if (i0 >= iminF) {
f_rhs[p] += sfx * d12dx *
(-F3 * fh[idx_fh_F(iF - 1, jF, kF, ex)]
-F10 * fh[idx_fh_F(iF , jF, kF, ex)]
+F18 * fh[idx_fh_F(iF + 1, jF, kF, ex)]
-F6 * fh[idx_fh_F(iF + 2, jF, kF, ex)]
+ fh[idx_fh_F(iF + 3, jF, kF, ex)]);
}
}
const double sfy = Sfy[p];
if (sfy > ZEO) {
if (j0 <= ex2 - 4) {
f_rhs[p] += sfy * d12dy *
(-F3 * fh[idx_fh_F(iF, jF - 1, kF, ex)]
-F10 * fh[idx_fh_F(iF, jF , kF, ex)]
+F18 * fh[idx_fh_F(iF, jF + 1, kF, ex)]
-F6 * fh[idx_fh_F(iF, jF + 2, kF, ex)]
+ fh[idx_fh_F(iF, jF + 3, kF, ex)]);
} else if (j0 <= ex2 - 3) {
f_rhs[p] += sfy * d12dy *
( fh[idx_fh_F(iF, jF - 2, kF, ex)]
-EIT * fh[idx_fh_F(iF, jF - 1, kF, ex)]
+EIT * fh[idx_fh_F(iF, jF + 1, kF, ex)]
- fh[idx_fh_F(iF, jF + 2, kF, ex)]);
} else if (j0 <= ex2 - 2) {
f_rhs[p] -= sfy * d12dy *
(-F3 * fh[idx_fh_F(iF, jF + 1, kF, ex)]
-F10 * fh[idx_fh_F(iF, jF , kF, ex)]
+F18 * fh[idx_fh_F(iF, jF - 1, kF, ex)]
-F6 * fh[idx_fh_F(iF, jF - 2, kF, ex)]
+ fh[idx_fh_F(iF, jF - 3, kF, ex)]);
}
} else if (sfy < ZEO) {
if ((j0 - 2) >= jminF) {
f_rhs[p] -= sfy * d12dy *
(-F3 * fh[idx_fh_F(iF, jF + 1, kF, ex)]
-F10 * fh[idx_fh_F(iF, jF , kF, ex)]
+F18 * fh[idx_fh_F(iF, jF - 1, kF, ex)]
-F6 * fh[idx_fh_F(iF, jF - 2, kF, ex)]
+ fh[idx_fh_F(iF, jF - 3, kF, ex)]);
} else if ((j0 - 1) >= jminF) {
f_rhs[p] += sfy * d12dy *
( fh[idx_fh_F(iF, jF - 2, kF, ex)]
-EIT * fh[idx_fh_F(iF, jF - 1, kF, ex)]
+EIT * fh[idx_fh_F(iF, jF + 1, kF, ex)]
- fh[idx_fh_F(iF, jF + 2, kF, ex)]);
} else if (j0 >= jminF) {
f_rhs[p] += sfy * d12dy *
(-F3 * fh[idx_fh_F(iF, jF - 1, kF, ex)]
-F10 * fh[idx_fh_F(iF, jF , kF, ex)]
+F18 * fh[idx_fh_F(iF, jF + 1, kF, ex)]
-F6 * fh[idx_fh_F(iF, jF + 2, kF, ex)]
+ fh[idx_fh_F(iF, jF + 3, kF, ex)]);
}
}
const double sfz = Sfz[p];
if (sfz > ZEO) {
if (k0 <= ex3 - 4) {
f_rhs[p] += sfz * d12dz *
(-F3 * fh[idx_fh_F(iF, jF, kF - 1, ex)]
-F10 * fh[idx_fh_F(iF, jF, kF , ex)]
+F18 * fh[idx_fh_F(iF, jF, kF + 1, ex)]
-F6 * fh[idx_fh_F(iF, jF, kF + 2, ex)]
+ fh[idx_fh_F(iF, jF, kF + 3, ex)]);
} else if (k0 <= ex3 - 3) {
f_rhs[p] += sfz * d12dz *
( fh[idx_fh_F(iF, jF, kF - 2, ex)]
-EIT * fh[idx_fh_F(iF, jF, kF - 1, ex)]
+EIT * fh[idx_fh_F(iF, jF, kF + 1, ex)]
- fh[idx_fh_F(iF, jF, kF + 2, ex)]);
} else if (k0 <= ex3 - 2) {
f_rhs[p] -= sfz * d12dz *
(-F3 * fh[idx_fh_F(iF, jF, kF + 1, ex)]
-F10 * fh[idx_fh_F(iF, jF, kF , ex)]
+F18 * fh[idx_fh_F(iF, jF, kF - 1, ex)]
-F6 * fh[idx_fh_F(iF, jF, kF - 2, ex)]
+ fh[idx_fh_F(iF, jF, kF - 3, ex)]);
}
} else if (sfz < ZEO) {
if ((k0 - 2) >= kminF) {
f_rhs[p] -= sfz * d12dz *
(-F3 * fh[idx_fh_F(iF, jF, kF + 1, ex)]
-F10 * fh[idx_fh_F(iF, jF, kF , ex)]
+F18 * fh[idx_fh_F(iF, jF, kF - 1, ex)]
-F6 * fh[idx_fh_F(iF, jF, kF - 2, ex)]
+ fh[idx_fh_F(iF, jF, kF - 3, ex)]);
} else if ((k0 - 1) >= kminF) {
f_rhs[p] += sfz * d12dz *
( fh[idx_fh_F(iF, jF, kF - 2, ex)]
-EIT * fh[idx_fh_F(iF, jF, kF - 1, ex)]
+EIT * fh[idx_fh_F(iF, jF, kF + 1, ex)]
- fh[idx_fh_F(iF, jF, kF + 2, ex)]);
} else if (k0 >= kminF) {
f_rhs[p] += sfz * d12dz *
(-F3 * fh[idx_fh_F(iF, jF, kF - 1, ex)]
-F10 * fh[idx_fh_F(iF, jF, kF , ex)]
+F18 * fh[idx_fh_F(iF, jF, kF + 1, ex)]
-F6 * fh[idx_fh_F(iF, jF, kF + 2, ex)]
+ fh[idx_fh_F(iF, jF, kF + 3, ex)]);
}
}
}
}
}
// KO dissipation (same domain restriction as kodiss_c.C)
if (eps > ZEO) {
const int i0_lo = (iminF + 2 > 0) ? iminF + 2 : 0;
const int j0_lo = (jminF + 2 > 0) ? jminF + 2 : 0;
const int k0_lo = (kminF + 2 > 0) ? kminF + 2 : 0;
const int i0_hi = imaxF - 4; // inclusive
const int j0_hi = jmaxF - 4;
const int k0_hi = kmaxF - 4;
if (!(i0_lo > i0_hi || j0_lo > j0_hi || k0_lo > k0_hi)) {
for (int k0 = k0_lo; k0 <= k0_hi; ++k0) {
const int kF = k0 + 1;
for (int j0 = j0_lo; j0 <= j0_hi; ++j0) {
const int jF = j0 + 1;
for (int i0 = i0_lo; i0 <= i0_hi; ++i0) {
const int iF = i0 + 1;
const size_t p = idx_ex(i0, j0, k0, ex);
const double Dx_term =
((fh[idx_fh_F(iF - 3, jF, kF, ex)] + fh[idx_fh_F(iF + 3, jF, kF, ex)]) -
SIX * (fh[idx_fh_F(iF - 2, jF, kF, ex)] + fh[idx_fh_F(iF + 2, jF, kF, ex)]) +
FIT * (fh[idx_fh_F(iF - 1, jF, kF, ex)] + fh[idx_fh_F(iF + 1, jF, kF, ex)]) -
TWT * fh[idx_fh_F(iF, jF, kF, ex)]) / dX;
const double Dy_term =
((fh[idx_fh_F(iF, jF - 3, kF, ex)] + fh[idx_fh_F(iF, jF + 3, kF, ex)]) -
SIX * (fh[idx_fh_F(iF, jF - 2, kF, ex)] + fh[idx_fh_F(iF, jF + 2, kF, ex)]) +
FIT * (fh[idx_fh_F(iF, jF - 1, kF, ex)] + fh[idx_fh_F(iF, jF + 1, kF, ex)]) -
TWT * fh[idx_fh_F(iF, jF, kF, ex)]) / dY;
const double Dz_term =
((fh[idx_fh_F(iF, jF, kF - 3, ex)] + fh[idx_fh_F(iF, jF, kF + 3, ex)]) -
SIX * (fh[idx_fh_F(iF, jF, kF - 2, ex)] + fh[idx_fh_F(iF, jF, kF + 2, ex)]) +
FIT * (fh[idx_fh_F(iF, jF, kF - 1, ex)] + fh[idx_fh_F(iF, jF, kF + 1, ex)]) -
TWT * fh[idx_fh_F(iF, jF, kF, ex)]) / dZ;
f_rhs[p] += (eps / cof) * (Dx_term + Dy_term + Dz_term);
}
}
}
}
}
free(fh);
}

View File

@@ -1,199 +1,199 @@
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <new>
using namespace std;
#include "Block.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)
{
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];
fgfs = new double *[fngfs];
for (int i = 0; i < fngfs; i++)
{
fgfs[i] = (double *)malloc(sizeof(double) * nn);
if (!(fgfs[i]))
{
cout << "on node#" << rank << ", out of memory when constructing Block." << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
memset(fgfs[i], 0, sizeof(double) * nn);
}
igfs = new int *[ingfs];
for (int i = 0; i < ingfs; i++)
{
igfs[i] = (int *)malloc(sizeof(int) * nn);
if (!(igfs[i]))
{
cout << "on node#" << rank << ", out of memory when constructing Block." << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
memset(igfs[i], 0, sizeof(int) * nn);
}
}
#endif
}
Block::~Block()
{
int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == rank)
{
for (int i = 0; i < dim; i++)
delete[] X[i];
for (int i = 0; i < ingfs; i++)
free(igfs[i]);
delete[] igfs;
for (int i = 0; i < fngfs; i++)
free(fgfs[i]);
delete[] fgfs;
X[0] = X[1] = X[2] = 0;
igfs = 0;
fgfs = 0;
}
}
void Block::checkBlock()
{
int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == 0)
{
cout << "belong to level " << lev << endl;
cout << "shape: [";
for (int i = 0; i < dim; i++)
{
cout << shape[i];
if (i < dim - 1)
cout << ",";
else
cout << "]";
}
cout << " resolution: [";
for (int i = 0; i < dim; i++)
{
cout << getdX(i);
if (i < dim - 1)
cout << ",";
else
cout << "]" << endl;
}
cout << "locate on node " << rank << ", at (includes ghost zone):" << endl;
cout << "(";
for (int i = 0; i < dim; i++)
{
cout << bbox[i] << ":" << bbox[dim + i];
if (i < dim - 1)
cout << ",";
else
cout << ")" << endl;
}
cout << "has " << ingfs << " int type grids functions," << fngfs << " double type grids functions" << endl;
}
}
double Block::getdX(int dir)
{
if (dir < 0 || dir >= dim)
{
cout << "Block::getdX: error input dir = " << dir << ", this Block has direction (0," << dim - 1 << ")" << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
double h;
#ifdef Vertex
#ifdef Cell
#error Both Cell and Vertex are defined
#endif
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;
MPI_Abort(MPI_COMM_WORLD, 1);
}
h = (bbox[dim + dir] - bbox[dir]) / (shape[dir] - 1);
#else
#ifdef Cell
h = (bbox[dim + dir] - bbox[dir]) / shape[dir];
#else
#error Not define Vertex nor Cell
#endif
#endif
return h;
}
void Block::swapList(MyList<var> *VarList1, MyList<var> *VarList2, int myrank)
{
if (rank == myrank)
{
MyList<var> *varl1 = VarList1, *varl2 = VarList2;
while (varl1 && varl2)
{
misc::swap<double *>(fgfs[varl1->data->sgfn], fgfs[varl2->data->sgfn]);
varl1 = varl1->next;
varl2 = varl2->next;
}
if (varl1 || varl2)
{
cout << "error in Block::swaplist, var lists does not match." << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
}
}
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <new>
using namespace std;
#include "Block.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)
{
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];
fgfs = new double *[fngfs];
for (int i = 0; i < fngfs; i++)
{
fgfs[i] = (double *)malloc(sizeof(double) * nn);
if (!(fgfs[i]))
{
cout << "on node#" << rank << ", out of memory when constructing Block." << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
memset(fgfs[i], 0, sizeof(double) * nn);
}
igfs = new int *[ingfs];
for (int i = 0; i < ingfs; i++)
{
igfs[i] = (int *)malloc(sizeof(int) * nn);
if (!(igfs[i]))
{
cout << "on node#" << rank << ", out of memory when constructing Block." << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
memset(igfs[i], 0, sizeof(int) * nn);
}
}
#endif
}
Block::~Block()
{
int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == rank)
{
for (int i = 0; i < dim; i++)
delete[] X[i];
for (int i = 0; i < ingfs; i++)
free(igfs[i]);
delete[] igfs;
for (int i = 0; i < fngfs; i++)
free(fgfs[i]);
delete[] fgfs;
X[0] = X[1] = X[2] = 0;
igfs = 0;
fgfs = 0;
}
}
void Block::checkBlock()
{
int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == 0)
{
cout << "belong to level " << lev << endl;
cout << "shape: [";
for (int i = 0; i < dim; i++)
{
cout << shape[i];
if (i < dim - 1)
cout << ",";
else
cout << "]";
}
cout << " resolution: [";
for (int i = 0; i < dim; i++)
{
cout << getdX(i);
if (i < dim - 1)
cout << ",";
else
cout << "]" << endl;
}
cout << "locate on node " << rank << ", at (includes ghost zone):" << endl;
cout << "(";
for (int i = 0; i < dim; i++)
{
cout << bbox[i] << ":" << bbox[dim + i];
if (i < dim - 1)
cout << ",";
else
cout << ")" << endl;
}
cout << "has " << ingfs << " int type grids functions," << fngfs << " double type grids functions" << endl;
}
}
double Block::getdX(int dir)
{
if (dir < 0 || dir >= dim)
{
cout << "Block::getdX: error input dir = " << dir << ", this Block has direction (0," << dim - 1 << ")" << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
double h;
#ifdef Vertex
#ifdef Cell
#error Both Cell and Vertex are defined
#endif
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;
MPI_Abort(MPI_COMM_WORLD, 1);
}
h = (bbox[dim + dir] - bbox[dir]) / (shape[dir] - 1);
#else
#ifdef Cell
h = (bbox[dim + dir] - bbox[dir]) / shape[dir];
#else
#error Not define Vertex nor Cell
#endif
#endif
return h;
}
void Block::swapList(MyList<var> *VarList1, MyList<var> *VarList2, int myrank)
{
if (rank == myrank)
{
MyList<var> *varl1 = VarList1, *varl2 = VarList2;
while (varl1 && varl2)
{
misc::swap<double *>(fgfs[varl1->data->sgfn], fgfs[varl2->data->sgfn]);
varl1 = varl1->next;
varl2 = varl2->next;
}
if (varl1 || varl2)
{
cout << "error in Block::swaplist, var lists does not match." << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
}
}

View File

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

View File

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

View File

@@ -1,332 +0,0 @@
#include "tool.h"
void fdderivs(const int ex[3],
const double *f,
double *fxx, double *fxy, double *fxz,
double *fyy, double *fyz, double *fzz,
const double *X, const double *Y, const double *Z,
double SYM1, double SYM2, double SYM3,
int Symmetry, int onoff)
{
(void)onoff;
const int NO_SYMM = 0, EQ_SYMM = 1;
const double ZEO = 0.0, ONE = 1.0, TWO = 2.0;
const double F1o4 = 2.5e-1; // 1/4
const double F8 = 8.0;
const double F16 = 16.0;
const double F30 = 30.0;
const double F1o12 = ONE / 12.0;
const double F1o144 = ONE / 144.0;
const int ex1 = ex[0], ex2 = ex[1], ex3 = ex[2];
const double dX = X[1] - X[0];
const double dY = Y[1] - Y[0];
const double dZ = Z[1] - Z[0];
const int imaxF = ex1;
const int jmaxF = ex2;
const int kmaxF = ex3;
int iminF = 1, jminF = 1, kminF = 1;
if (Symmetry > NO_SYMM && fabs(Z[0]) < dZ) kminF = -1;
if (Symmetry > EQ_SYMM && fabs(X[0]) < dX) iminF = -1;
if (Symmetry > EQ_SYMM && fabs(Y[0]) < dY) jminF = -1;
const double SoA[3] = { SYM1, SYM2, SYM3 };
/* fh: (ex1+2)*(ex2+2)*(ex3+2) because ord=2 */
const size_t nx = (size_t)ex1 + 2;
const size_t ny = (size_t)ex2 + 2;
const size_t nz = (size_t)ex3 + 2;
const size_t fh_size = nx * ny * nz;
static double *fh = NULL;
static size_t cap = 0;
if (fh_size > cap) {
free(fh);
fh = (double*)aligned_alloc(64, fh_size * sizeof(double));
cap = fh_size;
}
// double *fh = (double*)malloc(fh_size * sizeof(double));
if (!fh) return;
symmetry_bd(2, ex, f, fh, SoA);
/* 系数:按 Fortran 原式 */
const double Sdxdx = ONE / (dX * dX);
const double Sdydy = ONE / (dY * dY);
const double Sdzdz = ONE / (dZ * dZ);
const double Fdxdx = F1o12 / (dX * dX);
const double Fdydy = F1o12 / (dY * dY);
const double Fdzdz = F1o12 / (dZ * dZ);
const double Sdxdy = F1o4 / (dX * dY);
const double Sdxdz = F1o4 / (dX * dZ);
const double Sdydz = F1o4 / (dY * dZ);
const double Fdxdy = F1o144 / (dX * dY);
const double Fdxdz = F1o144 / (dX * dZ);
const double Fdydz = F1o144 / (dY * dZ);
/* 只清零不被主循环覆盖的边界面 */
{
/* 高边界k0=ex3-1 */
for (int j0 = 0; j0 < ex2; ++j0)
for (int i0 = 0; i0 < ex1; ++i0) {
const size_t p = idx_ex(i0, j0, ex3 - 1, ex);
fxx[p]=ZEO; fyy[p]=ZEO; fzz[p]=ZEO;
fxy[p]=ZEO; fxz[p]=ZEO; fyz[p]=ZEO;
}
/* 高边界j0=ex2-1 */
for (int k0 = 0; k0 < ex3 - 1; ++k0)
for (int i0 = 0; i0 < ex1; ++i0) {
const size_t p = idx_ex(i0, ex2 - 1, k0, ex);
fxx[p]=ZEO; fyy[p]=ZEO; fzz[p]=ZEO;
fxy[p]=ZEO; fxz[p]=ZEO; fyz[p]=ZEO;
}
/* 高边界i0=ex1-1 */
for (int k0 = 0; k0 < ex3 - 1; ++k0)
for (int j0 = 0; j0 < ex2 - 1; ++j0) {
const size_t p = idx_ex(ex1 - 1, j0, k0, ex);
fxx[p]=ZEO; fyy[p]=ZEO; fzz[p]=ZEO;
fxy[p]=ZEO; fxz[p]=ZEO; fyz[p]=ZEO;
}
/* 低边界:当二阶模板也不可用时,对应 i0/j0/k0=0 面 */
if (kminF == 1) {
for (int j0 = 0; j0 < ex2; ++j0)
for (int i0 = 0; i0 < ex1; ++i0) {
const size_t p = idx_ex(i0, j0, 0, ex);
fxx[p]=ZEO; fyy[p]=ZEO; fzz[p]=ZEO;
fxy[p]=ZEO; fxz[p]=ZEO; fyz[p]=ZEO;
}
}
if (jminF == 1) {
for (int k0 = 0; k0 < ex3; ++k0)
for (int i0 = 0; i0 < ex1; ++i0) {
const size_t p = idx_ex(i0, 0, k0, ex);
fxx[p]=ZEO; fyy[p]=ZEO; fzz[p]=ZEO;
fxy[p]=ZEO; fxz[p]=ZEO; fyz[p]=ZEO;
}
}
if (iminF == 1) {
for (int k0 = 0; k0 < ex3; ++k0)
for (int j0 = 0; j0 < ex2; ++j0) {
const size_t p = idx_ex(0, j0, k0, ex);
fxx[p]=ZEO; fyy[p]=ZEO; fzz[p]=ZEO;
fxy[p]=ZEO; fxz[p]=ZEO; fyz[p]=ZEO;
}
}
}
/*
* 两段式:
* 1) 二阶可用区域先计算二阶模板
* 2) 高阶可用区域再覆盖四阶模板
*/
const int i2_lo = (iminF > 0) ? iminF : 0;
const int j2_lo = (jminF > 0) ? jminF : 0;
const int k2_lo = (kminF > 0) ? kminF : 0;
const int i2_hi = ex1 - 2;
const int j2_hi = ex2 - 2;
const int k2_hi = ex3 - 2;
const int i4_lo = (iminF + 1 > 0) ? (iminF + 1) : 0;
const int j4_lo = (jminF + 1 > 0) ? (jminF + 1) : 0;
const int k4_lo = (kminF + 1 > 0) ? (kminF + 1) : 0;
const int i4_hi = ex1 - 3;
const int j4_hi = ex2 - 3;
const int k4_hi = ex3 - 3;
/*
* Strategy A:
* Avoid redundant work in overlap of 2nd/4th-order regions.
* Only compute 2nd-order on shell points that are NOT overwritten by
* the 4th-order pass.
*/
const int has4 = (i4_lo <= i4_hi && j4_lo <= j4_hi && k4_lo <= k4_hi);
if (i2_lo <= i2_hi && j2_lo <= j2_hi && k2_lo <= k2_hi) {
for (int k0 = k2_lo; k0 <= k2_hi; ++k0) {
const int kF = k0 + 1;
for (int j0 = j2_lo; j0 <= j2_hi; ++j0) {
const int jF = j0 + 1;
for (int i0 = i2_lo; i0 <= i2_hi; ++i0) {
if (has4 &&
i0 >= i4_lo && i0 <= i4_hi &&
j0 >= j4_lo && j0 <= j4_hi &&
k0 >= k4_lo && k0 <= k4_hi) {
continue;
}
const int iF = i0 + 1;
const size_t p = idx_ex(i0, j0, k0, ex);
fxx[p] = Sdxdx * (
fh[idx_fh_F_ord2(iF - 1, jF, kF, ex)] -
TWO * fh[idx_fh_F_ord2(iF, jF, kF, ex)] +
fh[idx_fh_F_ord2(iF + 1, jF, kF, ex)]
);
fyy[p] = Sdydy * (
fh[idx_fh_F_ord2(iF, jF - 1, kF, ex)] -
TWO * fh[idx_fh_F_ord2(iF, jF, kF, ex)] +
fh[idx_fh_F_ord2(iF, jF + 1, kF, ex)]
);
fzz[p] = Sdzdz * (
fh[idx_fh_F_ord2(iF, jF, kF - 1, ex)] -
TWO * fh[idx_fh_F_ord2(iF, jF, kF, ex)] +
fh[idx_fh_F_ord2(iF, jF, kF + 1, ex)]
);
fxy[p] = Sdxdy * (
fh[idx_fh_F_ord2(iF - 1, jF - 1, kF, ex)] -
fh[idx_fh_F_ord2(iF + 1, jF - 1, kF, ex)] -
fh[idx_fh_F_ord2(iF - 1, jF + 1, kF, ex)] +
fh[idx_fh_F_ord2(iF + 1, jF + 1, kF, ex)]
);
fxz[p] = Sdxdz * (
fh[idx_fh_F_ord2(iF - 1, jF, kF - 1, ex)] -
fh[idx_fh_F_ord2(iF + 1, jF, kF - 1, ex)] -
fh[idx_fh_F_ord2(iF - 1, jF, kF + 1, ex)] +
fh[idx_fh_F_ord2(iF + 1, jF, kF + 1, ex)]
);
fyz[p] = Sdydz * (
fh[idx_fh_F_ord2(iF, jF - 1, kF - 1, ex)] -
fh[idx_fh_F_ord2(iF, jF + 1, kF - 1, ex)] -
fh[idx_fh_F_ord2(iF, jF - 1, kF + 1, ex)] +
fh[idx_fh_F_ord2(iF, jF + 1, kF + 1, ex)]
);
}
}
}
}
if (has4) {
for (int k0 = k4_lo; k0 <= k4_hi; ++k0) {
const int kF = k0 + 1;
for (int j0 = j4_lo; j0 <= j4_hi; ++j0) {
const int jF = j0 + 1;
for (int i0 = i4_lo; i0 <= i4_hi; ++i0) {
const int iF = i0 + 1;
const size_t p = idx_ex(i0, j0, k0, ex);
fxx[p] = Fdxdx * (
-fh[idx_fh_F_ord2(iF - 2, jF, kF, ex)] +
F16 * fh[idx_fh_F_ord2(iF - 1, jF, kF, ex)] -
F30 * fh[idx_fh_F_ord2(iF, jF, kF, ex)] -
fh[idx_fh_F_ord2(iF + 2, jF, kF, ex)] +
F16 * fh[idx_fh_F_ord2(iF + 1, jF, kF, ex)]
);
fyy[p] = Fdydy * (
-fh[idx_fh_F_ord2(iF, jF - 2, kF, ex)] +
F16 * fh[idx_fh_F_ord2(iF, jF - 1, kF, ex)] -
F30 * fh[idx_fh_F_ord2(iF, jF, kF, ex)] -
fh[idx_fh_F_ord2(iF, jF + 2, kF, ex)] +
F16 * fh[idx_fh_F_ord2(iF, jF + 1, kF, ex)]
);
fzz[p] = Fdzdz * (
-fh[idx_fh_F_ord2(iF, jF, kF - 2, ex)] +
F16 * fh[idx_fh_F_ord2(iF, jF, kF - 1, ex)] -
F30 * fh[idx_fh_F_ord2(iF, jF, kF, ex)] -
fh[idx_fh_F_ord2(iF, jF, kF + 2, ex)] +
F16 * fh[idx_fh_F_ord2(iF, jF, kF + 1, ex)]
);
{
const double t_jm2 =
( fh[idx_fh_F_ord2(iF - 2, jF - 2, kF, ex)]
-F8*fh[idx_fh_F_ord2(iF - 1, jF - 2, kF, ex)]
+F8*fh[idx_fh_F_ord2(iF + 1, jF - 2, kF, ex)]
- fh[idx_fh_F_ord2(iF + 2, jF - 2, kF, ex)] );
const double t_jm1 =
( fh[idx_fh_F_ord2(iF - 2, jF - 1, kF, ex)]
-F8*fh[idx_fh_F_ord2(iF - 1, jF - 1, kF, ex)]
+F8*fh[idx_fh_F_ord2(iF + 1, jF - 1, kF, ex)]
- fh[idx_fh_F_ord2(iF + 2, jF - 1, kF, ex)] );
const double t_jp1 =
( fh[idx_fh_F_ord2(iF - 2, jF + 1, kF, ex)]
-F8*fh[idx_fh_F_ord2(iF - 1, jF + 1, kF, ex)]
+F8*fh[idx_fh_F_ord2(iF + 1, jF + 1, kF, ex)]
- fh[idx_fh_F_ord2(iF + 2, jF + 1, kF, ex)] );
const double t_jp2 =
( fh[idx_fh_F_ord2(iF - 2, jF + 2, kF, ex)]
-F8*fh[idx_fh_F_ord2(iF - 1, jF + 2, kF, ex)]
+F8*fh[idx_fh_F_ord2(iF + 1, jF + 2, kF, ex)]
- fh[idx_fh_F_ord2(iF + 2, jF + 2, kF, ex)] );
fxy[p] = Fdxdy * ( t_jm2 - F8 * t_jm1 + F8 * t_jp1 - t_jp2 );
}
{
const double t_km2 =
( fh[idx_fh_F_ord2(iF - 2, jF, kF - 2, ex)]
-F8*fh[idx_fh_F_ord2(iF - 1, jF, kF - 2, ex)]
+F8*fh[idx_fh_F_ord2(iF + 1, jF, kF - 2, ex)]
- fh[idx_fh_F_ord2(iF + 2, jF, kF - 2, ex)] );
const double t_km1 =
( fh[idx_fh_F_ord2(iF - 2, jF, kF - 1, ex)]
-F8*fh[idx_fh_F_ord2(iF - 1, jF, kF - 1, ex)]
+F8*fh[idx_fh_F_ord2(iF + 1, jF, kF - 1, ex)]
- fh[idx_fh_F_ord2(iF + 2, jF, kF - 1, ex)] );
const double t_kp1 =
( fh[idx_fh_F_ord2(iF - 2, jF, kF + 1, ex)]
-F8*fh[idx_fh_F_ord2(iF - 1, jF, kF + 1, ex)]
+F8*fh[idx_fh_F_ord2(iF + 1, jF, kF + 1, ex)]
- fh[idx_fh_F_ord2(iF + 2, jF, kF + 1, ex)] );
const double t_kp2 =
( fh[idx_fh_F_ord2(iF - 2, jF, kF + 2, ex)]
-F8*fh[idx_fh_F_ord2(iF - 1, jF, kF + 2, ex)]
+F8*fh[idx_fh_F_ord2(iF + 1, jF, kF + 2, ex)]
- fh[idx_fh_F_ord2(iF + 2, jF, kF + 2, ex)] );
fxz[p] = Fdxdz * ( t_km2 - F8 * t_km1 + F8 * t_kp1 - t_kp2 );
}
{
const double t_km2 =
( fh[idx_fh_F_ord2(iF, jF - 2, kF - 2, ex)]
-F8*fh[idx_fh_F_ord2(iF, jF - 1, kF - 2, ex)]
+F8*fh[idx_fh_F_ord2(iF, jF + 1, kF - 2, ex)]
- fh[idx_fh_F_ord2(iF, jF + 2, kF - 2, ex)] );
const double t_km1 =
( fh[idx_fh_F_ord2(iF, jF - 2, kF - 1, ex)]
-F8*fh[idx_fh_F_ord2(iF, jF - 1, kF - 1, ex)]
+F8*fh[idx_fh_F_ord2(iF, jF + 1, kF - 1, ex)]
- fh[idx_fh_F_ord2(iF, jF + 2, kF - 1, ex)] );
const double t_kp1 =
( fh[idx_fh_F_ord2(iF, jF - 2, kF + 1, ex)]
-F8*fh[idx_fh_F_ord2(iF, jF - 1, kF + 1, ex)]
+F8*fh[idx_fh_F_ord2(iF, jF + 1, kF + 1, ex)]
- fh[idx_fh_F_ord2(iF, jF + 2, kF + 1, ex)] );
const double t_kp2 =
( fh[idx_fh_F_ord2(iF, jF - 2, kF + 2, ex)]
-F8*fh[idx_fh_F_ord2(iF, jF - 1, kF + 2, ex)]
+F8*fh[idx_fh_F_ord2(iF, jF + 1, kF + 2, ex)]
- fh[idx_fh_F_ord2(iF, jF + 2, kF + 2, ex)] );
fyz[p] = Fdydz * ( t_km2 - F8 * t_km1 + F8 * t_kp1 - t_kp2 );
}
}
}
}
}
// free(fh);
}

View File

@@ -1,167 +0,0 @@
#include "tool.h"
/*
* C 版 fderivs
*
* Fortran:
* subroutine fderivs(ex,f,fx,fy,fz,X,Y,Z,SYM1,SYM2,SYM3,symmetry,onoff)
*
* 约定:
* f, fx, fy, fz: ex1*ex2*ex3按 idx_ex 布局
* X: ex1, Y: ex2, Z: ex3
*/
void fderivs(const int ex[3],
const double *f,
double *fx, double *fy, double *fz,
const double *X, const double *Y, const double *Z,
double SYM1, double SYM2, double SYM3,
int Symmetry, int onoff)
{
(void)onoff; // Fortran 里没用到
const double ZEO = 0.0, ONE = 1.0;
const double TWO = 2.0, EIT = 8.0;
const double F12 = 12.0;
const int NO_SYMM = 0, EQ_SYMM = 1; // OCTANT=2 在本子程序里不直接用
const int ex1 = ex[0], ex2 = ex[1], ex3 = ex[2];
// dX = X(2)-X(1) -> C: X[1]-X[0]
const double dX = X[1] - X[0];
const double dY = Y[1] - Y[0];
const double dZ = Z[1] - Z[0];
// Fortran 1-based bounds
const int imaxF = ex1;
const int jmaxF = ex2;
const int kmaxF = ex3;
int iminF = 1, jminF = 1, kminF = 1;
if (Symmetry > NO_SYMM && fabs(Z[0]) < dZ) kminF = -1;
if (Symmetry > EQ_SYMM && fabs(X[0]) < dX) iminF = -1;
if (Symmetry > EQ_SYMM && fabs(Y[0]) < dY) jminF = -1;
// SoA(1:3) = SYM1,SYM2,SYM3
const double SoA[3] = { SYM1, SYM2, SYM3 };
// fh: (ex1+2)*(ex2+2)*(ex3+2) because ord=2
const size_t nx = (size_t)ex1 + 2;
const size_t ny = (size_t)ex2 + 2;
const size_t nz = (size_t)ex3 + 2;
const size_t fh_size = nx * ny * nz;
static double *fh = NULL;
static size_t cap = 0;
if (fh_size > cap) {
free(fh);
fh = (double*)aligned_alloc(64, fh_size * sizeof(double));
cap = fh_size;
}
// double *fh = (double*)malloc(fh_size * sizeof(double));
if (!fh) return;
// call symmetry_bd(2,ex,f,fh,SoA)
symmetry_bd(2, ex, f, fh, SoA);
const double d12dx = ONE / F12 / dX;
const double d12dy = ONE / F12 / dY;
const double d12dz = ONE / F12 / dZ;
const double d2dx = ONE / TWO / dX;
const double d2dy = ONE / TWO / dY;
const double d2dz = ONE / TWO / dZ;
// fx = fy = fz = 0
const size_t all = (size_t)ex1 * (size_t)ex2 * (size_t)ex3;
for (size_t p = 0; p < all; ++p) {
fx[p] = ZEO;
fy[p] = ZEO;
fz[p] = ZEO;
}
/*
* 两段式:
* 1) 先在二阶可用区域计算二阶模板
* 2) 再在高阶可用区域覆盖为四阶模板
*
* 与原 if/elseif 逻辑等价,但减少逐点分支判断。
*/
const int i2_lo = (iminF > 0) ? iminF : 0;
const int j2_lo = (jminF > 0) ? jminF : 0;
const int k2_lo = (kminF > 0) ? kminF : 0;
const int i2_hi = ex1 - 2;
const int j2_hi = ex2 - 2;
const int k2_hi = ex3 - 2;
const int i4_lo = (iminF + 1 > 0) ? (iminF + 1) : 0;
const int j4_lo = (jminF + 1 > 0) ? (jminF + 1) : 0;
const int k4_lo = (kminF + 1 > 0) ? (kminF + 1) : 0;
const int i4_hi = ex1 - 3;
const int j4_hi = ex2 - 3;
const int k4_hi = ex3 - 3;
if (i2_lo <= i2_hi && j2_lo <= j2_hi && k2_lo <= k2_hi) {
for (int k0 = k2_lo; k0 <= k2_hi; ++k0) {
const int kF = k0 + 1;
for (int j0 = j2_lo; j0 <= j2_hi; ++j0) {
const int jF = j0 + 1;
for (int i0 = i2_lo; i0 <= i2_hi; ++i0) {
const int iF = i0 + 1;
const size_t p = idx_ex(i0, j0, k0, ex);
fx[p] = d2dx * (
-fh[idx_fh_F_ord2(iF - 1, jF, kF, ex)] +
fh[idx_fh_F_ord2(iF + 1, jF, kF, ex)]
);
fy[p] = d2dy * (
-fh[idx_fh_F_ord2(iF, jF - 1, kF, ex)] +
fh[idx_fh_F_ord2(iF, jF + 1, kF, ex)]
);
fz[p] = d2dz * (
-fh[idx_fh_F_ord2(iF, jF, kF - 1, ex)] +
fh[idx_fh_F_ord2(iF, jF, kF + 1, ex)]
);
}
}
}
}
if (i4_lo <= i4_hi && j4_lo <= j4_hi && k4_lo <= k4_hi) {
for (int k0 = k4_lo; k0 <= k4_hi; ++k0) {
const int kF = k0 + 1;
for (int j0 = j4_lo; j0 <= j4_hi; ++j0) {
const int jF = j0 + 1;
for (int i0 = i4_lo; i0 <= i4_hi; ++i0) {
const int iF = i0 + 1;
const size_t p = idx_ex(i0, j0, k0, ex);
fx[p] = d12dx * (
fh[idx_fh_F_ord2(iF - 2, jF, kF, ex)] -
EIT * fh[idx_fh_F_ord2(iF - 1, jF, kF, ex)] +
EIT * fh[idx_fh_F_ord2(iF + 1, jF, kF, ex)] -
fh[idx_fh_F_ord2(iF + 2, jF, kF, ex)]
);
fy[p] = d12dy * (
fh[idx_fh_F_ord2(iF, jF - 2, kF, ex)] -
EIT * fh[idx_fh_F_ord2(iF, jF - 1, kF, ex)] +
EIT * fh[idx_fh_F_ord2(iF, jF + 1, kF, ex)] -
fh[idx_fh_F_ord2(iF, jF + 2, kF, ex)]
);
fz[p] = d12dz * (
fh[idx_fh_F_ord2(iF, jF, kF - 2, ex)] -
EIT * fh[idx_fh_F_ord2(iF, jF, kF - 1, ex)] +
EIT * fh[idx_fh_F_ord2(iF, jF, kF + 1, ex)] -
fh[idx_fh_F_ord2(iF, jF, kF + 2, ex)]
);
}
}
}
}
// free(fh);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,117 +0,0 @@
#include "tool.h"
/*
* C 版 kodis
*
* Fortran signature:
* subroutine kodis(ex,X,Y,Z,f,f_rhs,SoA,Symmetry,eps)
*
* 约定:
* X: ex1, Y: ex2, Z: ex3
* f, f_rhs: ex1*ex2*ex3 按 idx_ex 布局
* SoA[3]
* eps: double
*/
void kodis(const int ex[3],
const double *X, const double *Y, const double *Z,
const double *f, double *f_rhs,
const double SoA[3],
int Symmetry, double eps)
{
const double ONE = 1.0, SIX = 6.0, FIT = 15.0, TWT = 20.0;
const double cof = 64.0; // 2^6
const int NO_SYMM = 0, OCTANT = 2;
const int ex1 = ex[0], ex2 = ex[1], ex3 = ex[2];
// Fortran: dX = X(2)-X(1) -> C: X[1]-X[0]
const double dX = X[1] - X[0];
const double dY = Y[1] - Y[0];
const double dZ = Z[1] - Z[0];
(void)ONE; // ONE 在原 Fortran 里只是参数,这里不一定用得上
// Fortran: imax=ex(1) 等是 1-based 上界
const int imaxF = ex1;
const int jmaxF = ex2;
const int kmaxF = ex3;
// Fortran: imin=jmin=kmin=1某些对称情况变 -2
int iminF = 1, jminF = 1, kminF = 1;
if (Symmetry > NO_SYMM && fabs(Z[0]) < dZ) kminF = -2;
if (Symmetry == OCTANT && fabs(X[0]) < dX) iminF = -2;
if (Symmetry == OCTANT && fabs(Y[0]) < dY) jminF = -2;
// 分配 fh大小 (ex1+3)*(ex2+3)*(ex3+3),对应 ord=3
const size_t nx = (size_t)ex1 + 3;
const size_t ny = (size_t)ex2 + 3;
const size_t nz = (size_t)ex3 + 3;
const size_t fh_size = nx * ny * nz;
double *fh = (double*)malloc(fh_size * sizeof(double));
if (!fh) return;
// Fortran: call symmetry_bd(3,ex,f,fh,SoA)
symmetry_bd(3, ex, f, fh, SoA);
/*
* Fortran loops:
* do k=1,ex3
* do j=1,ex2
* do i=1,ex1
*
* C: k0=0..ex3-1, j0=0..ex2-1, i0=0..ex1-1
* 并定义 Fortran index: iF=i0+1, ...
*/
// 收紧循环范围:只遍历满足 iF±3/jF±3/kF±3 条件的内部点
// iF-3 >= iminF => iF >= iminF+3 => i0 >= iminF+2 (因为 iF=i0+1)
// iF+3 <= imaxF => iF <= imaxF-3 => i0 <= imaxF-4
const int i0_lo = (iminF + 2 > 0) ? iminF + 2 : 0;
const int j0_lo = (jminF + 2 > 0) ? jminF + 2 : 0;
const int k0_lo = (kminF + 2 > 0) ? kminF + 2 : 0;
const int i0_hi = imaxF - 4; // inclusive
const int j0_hi = jmaxF - 4;
const int k0_hi = kmaxF - 4;
if (i0_lo > i0_hi || j0_lo > j0_hi || k0_lo > k0_hi) {
free(fh);
return;
}
for (int k0 = k0_lo; k0 <= k0_hi; ++k0) {
const int kF = k0 + 1;
for (int j0 = j0_lo; j0 <= j0_hi; ++j0) {
const int jF = j0 + 1;
for (int i0 = i0_lo; i0 <= i0_hi; ++i0) {
const int iF = i0 + 1;
const size_t p = idx_ex(i0, j0, k0, ex);
// 三个方向各一份同型的 7 点组合(实际上是对称的 6th-order dissipation/filter 核)
const double Dx_term =
( (fh[idx_fh_F(iF - 3, jF, kF, ex)] + fh[idx_fh_F(iF + 3, jF, kF, ex)]) -
SIX * (fh[idx_fh_F(iF - 2, jF, kF, ex)] + fh[idx_fh_F(iF + 2, jF, kF, ex)]) +
FIT * (fh[idx_fh_F(iF - 1, jF, kF, ex)] + fh[idx_fh_F(iF + 1, jF, kF, ex)]) -
TWT * fh[idx_fh_F(iF , jF, kF, ex)] ) / dX;
const double Dy_term =
( (fh[idx_fh_F(iF, jF - 3, kF, ex)] + fh[idx_fh_F(iF, jF + 3, kF, ex)]) -
SIX * (fh[idx_fh_F(iF, jF - 2, kF, ex)] + fh[idx_fh_F(iF, jF + 2, kF, ex)]) +
FIT * (fh[idx_fh_F(iF, jF - 1, kF, ex)] + fh[idx_fh_F(iF, jF + 1, kF, ex)]) -
TWT * fh[idx_fh_F(iF, jF , kF, ex)] ) / dY;
const double Dz_term =
( (fh[idx_fh_F(iF, jF, kF - 3, ex)] + fh[idx_fh_F(iF, jF, kF + 3, ex)]) -
SIX * (fh[idx_fh_F(iF, jF, kF - 2, ex)] + fh[idx_fh_F(iF, jF, kF + 2, ex)]) +
FIT * (fh[idx_fh_F(iF, jF, kF - 1, ex)] + fh[idx_fh_F(iF, jF, kF + 1, ex)]) -
TWT * fh[idx_fh_F(iF, jF, kF , ex)] ) / dZ;
// Fortran:
// f_rhs(i,j,k) = f_rhs(i,j,k) + eps/cof*(Dx_term + Dy_term + Dz_term)
f_rhs[p] += (eps / cof) * (Dx_term + Dy_term + Dz_term);
}
}
}
free(fh);
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@@ -1,106 +1,106 @@
#ifndef NULLNEWS_H
#define NULLNEWS_H
#ifdef fortran1
#define f_drive_null_news drive_null_news
#define f_get_null_news2 get_null_news2
#define f_drive_null_news_diff drive_null_news_diff
#define f_omega_rhs omega_rhs
#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_LN get_omega_and_dtomega_ln
#define f_get_dtomega get_dtomega
#endif
#ifdef fortran2
#define f_drive_null_news DRIVE_NULL_NEWS
#define f_get_null_news2 GET_NULL_NEWS2
#define f_drive_null_news_diff DRIVE_NULL_NEWS_DIFF
#define f_omega_rhs OMEGA_RHS
#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_LN GET_OMEGA_AND_DTOMEGA_LN
#define f_get_dtomega GET_DTOMEGA
#endif
#ifdef fortran3
#define f_drive_null_news drive_null_news_
#define f_get_null_news2 get_null_news2_
#define f_drive_null_news_diff drive_null_news_diff_
#define f_omega_rhs omega_rhs_
#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_LN get_omega_and_dtomega_ln_
#define f_get_dtomega get_dtomega_
#endif
extern "C"
{
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 &, int &);
}
extern "C"
{
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 &, int &, double &);
}
extern "C"
{
void f_omega_rhs(int *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *);
}
extern "C"
{
void f_get_exact_omega(int *, double *, double *, double *,
double *,
int &, double &, double &);
}
extern "C"
{
void f_get_null_news2(int *, double *, double *, double *,
double *, double *,
double *, double *, double *, double *,
double *, double *, double *,
double *, double *, double *,
double *, double *, double &, int &);
}
extern "C"
{
void f_get_omega_and_dtomega_pre(int *, double *, double *, double *,
double *, double *, double *,
double *, double *, double &);
}
extern "C"
{
void f_get_dtomega(int *, double *, double *, double *,
double *, double *, double *,
double *, double *, double &);
}
extern "C"
{
void f_get_omega_and_dtomega_LN(double &, int *, double *, double *, double *,
double *, double *, double &, int &);
}
#endif /* NULLNEWS_H */
#ifndef NULLNEWS_H
#define NULLNEWS_H
#ifdef fortran1
#define f_drive_null_news drive_null_news
#define f_get_null_news2 get_null_news2
#define f_drive_null_news_diff drive_null_news_diff
#define f_omega_rhs omega_rhs
#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_LN get_omega_and_dtomega_ln
#define f_get_dtomega get_dtomega
#endif
#ifdef fortran2
#define f_drive_null_news DRIVE_NULL_NEWS
#define f_get_null_news2 GET_NULL_NEWS2
#define f_drive_null_news_diff DRIVE_NULL_NEWS_DIFF
#define f_omega_rhs OMEGA_RHS
#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_LN GET_OMEGA_AND_DTOMEGA_LN
#define f_get_dtomega GET_DTOMEGA
#endif
#ifdef fortran3
#define f_drive_null_news drive_null_news_
#define f_get_null_news2 get_null_news2_
#define f_drive_null_news_diff drive_null_news_diff_
#define f_omega_rhs omega_rhs_
#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_LN get_omega_and_dtomega_ln_
#define f_get_dtomega get_dtomega_
#endif
extern "C"
{
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 &, int &);
}
extern "C"
{
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 &, int &, double &);
}
extern "C"
{
void f_omega_rhs(int *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *,
double *, double *);
}
extern "C"
{
void f_get_exact_omega(int *, double *, double *, double *,
double *,
int &, double &, double &);
}
extern "C"
{
void f_get_null_news2(int *, double *, double *, double *,
double *, double *,
double *, double *, double *, double *,
double *, double *, double *,
double *, double *, double *,
double *, double *, double &, int &);
}
extern "C"
{
void f_get_omega_and_dtomega_pre(int *, double *, double *, double *,
double *, double *, double *,
double *, double *, double &);
}
extern "C"
{
void f_get_dtomega(int *, double *, double *, double *,
double *, double *, double *,
double *, double *, double &);
}
extern "C"
{
void f_get_omega_and_dtomega_LN(double &, int *, double *, double *, double *,
double *, double *, double &, int &);
}
#endif /* NULLNEWS_H */

View File

@@ -1,189 +1,189 @@
#ifndef NULLSHELLPATCH_H
#define NULLSHELLPATCH_H
#ifdef newc
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <complex>
using namespace std;
#else
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <complex.h>
#endif
#include <mpi.h>
#include "MyList.h"
#include "Block.h"
#include "Parallel.h"
#include "ShellPatch.h"
#include "var.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3)
#error NullShellPatch only supports 3 dimensional stuff yet
#endif
class xp_npatch : public ss_patch
{
public:
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
{
public:
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
{
public:
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
{
public:
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
{
public:
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
{
public:
zm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
};
class NullShellPatch
{
public:
struct pointstru
{
double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate
Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef;
int *sind;
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
};
var *FXZEO;
var *gx, *gy, *gz;
// 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
var *beta, *W;
var *Rnu, *Inu, *Rk, *Ik, *RB, *IB;
var *RQ, *IQ, *RU, *IU, *RTheta, *ITheta;
var *KK, *HKK, *KKx, *HKKx;
var *RJo, *IJo, *omegao;
var *RJ0, *IJ0, *omega0;
var *RJ, *IJ, *omega;
var *RJ1, *IJ1, *omega1;
var *RJ_rhs, *IJ_rhs, *omega_rhs;
var *quR1, *quR2, *quI1, *quI2;
var *qlR1, *qlR2, *qlI1, *qlI2;
var *gR, *gI;
var *dquR1, *dquR2, *dquI1, *dquI2;
var *bdquR1, *bdquR2, *bdquI1, *bdquI2;
var *dgR, *dgI;
var *bdgR, *bdgI;
var *RNews, *INews;
MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList;
MyList<var> *OldStateList, *DumpList, *CheckList;
MyList<var> *betaList, *QUList, *WTheList, *TheList, *JrhsList, *J1List;
int betawt[1], QUwt[2], WThewt[2];
int myrank;
int shape[dim]; // for (rho, sigma, X), for rho and sigma means number of points for every pi/2
double Rmin, xmin, xmax;
int Symmetry;
int ingfs, fngfs;
MyList<ss_patch> *PatL;
MyList<pointstru> **ss_src, **ss_dst;
MyList<pointstru> **cs_src, **cs_dst;
public:
NullShellPatch(int *shapei, double Rmini, double xmini, double xmaxi, int Symmetry, int myranki);
~NullShellPatch();
void destroypsuList(MyList<pointstru> *ct);
void fill_symmetric_boundarybuffer(MyList<var> *VarList, int *Varwt);
MyList<Block> *compose_sh(int cpusize);
int getdumydimension(int acsst, int posst);
void Setup_dyad();
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_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_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 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 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);
void prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPpi, double DH[dim],
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],
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],
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 checkPatch();
void checkBlock(int sst);
double getdX(int dir);
void shellname(char *sn, int i);
void Dump_xyz(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,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry, int *Varwt);
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);
void Synch(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_pointstrul2(MyList<pointstru> *pp, int first_last_only);
void matchcheck(MyList<Patch> *CPatL);
void Interp_Points(MyList<var> *VarList,
int NN, double **XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry);
void Interp_Points_2D(MyList<var> *VarList,
int NN, double **XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry);
void Step(double dT, double PhysTime, monitor *ErrorMonitor);
void Null_Boundary(double PhysTime);
void HyperSlice(double dT, double PhysTime, monitor *ErrorMonitor, int RK_count);
double News_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);
void Compute_News(double PhysTime, double dT, bool dp);
void Check_News(double PhysTime, double dT, bool dp);
};
#endif /* NULLSHELLPATCH_H */
#ifndef NULLSHELLPATCH_H
#define NULLSHELLPATCH_H
#ifdef newc
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <complex>
using namespace std;
#else
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <complex.h>
#endif
#include <mpi.h>
#include "MyList.h"
#include "Block.h"
#include "Parallel.h"
#include "ShellPatch.h"
#include "var.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3)
#error NullShellPatch only supports 3 dimensional stuff yet
#endif
class xp_npatch : public ss_patch
{
public:
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
{
public:
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
{
public:
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
{
public:
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
{
public:
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
{
public:
zm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
};
class NullShellPatch
{
public:
struct pointstru
{
double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate
Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef;
int *sind;
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
};
var *FXZEO;
var *gx, *gy, *gz;
// 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
var *beta, *W;
var *Rnu, *Inu, *Rk, *Ik, *RB, *IB;
var *RQ, *IQ, *RU, *IU, *RTheta, *ITheta;
var *KK, *HKK, *KKx, *HKKx;
var *RJo, *IJo, *omegao;
var *RJ0, *IJ0, *omega0;
var *RJ, *IJ, *omega;
var *RJ1, *IJ1, *omega1;
var *RJ_rhs, *IJ_rhs, *omega_rhs;
var *quR1, *quR2, *quI1, *quI2;
var *qlR1, *qlR2, *qlI1, *qlI2;
var *gR, *gI;
var *dquR1, *dquR2, *dquI1, *dquI2;
var *bdquR1, *bdquR2, *bdquI1, *bdquI2;
var *dgR, *dgI;
var *bdgR, *bdgI;
var *RNews, *INews;
MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList;
MyList<var> *OldStateList, *DumpList, *CheckList;
MyList<var> *betaList, *QUList, *WTheList, *TheList, *JrhsList, *J1List;
int betawt[1], QUwt[2], WThewt[2];
int myrank;
int shape[dim]; // for (rho, sigma, X), for rho and sigma means number of points for every pi/2
double Rmin, xmin, xmax;
int Symmetry;
int ingfs, fngfs;
MyList<ss_patch> *PatL;
MyList<pointstru> **ss_src, **ss_dst;
MyList<pointstru> **cs_src, **cs_dst;
public:
NullShellPatch(int *shapei, double Rmini, double xmini, double xmaxi, int Symmetry, int myranki);
~NullShellPatch();
void destroypsuList(MyList<pointstru> *ct);
void fill_symmetric_boundarybuffer(MyList<var> *VarList, int *Varwt);
MyList<Block> *compose_sh(int cpusize);
int getdumydimension(int acsst, int posst);
void Setup_dyad();
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_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_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 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 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);
void prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPpi, double DH[dim],
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],
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],
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 checkPatch();
void checkBlock(int sst);
double getdX(int dir);
void shellname(char *sn, int i);
void Dump_xyz(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,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry, int *Varwt);
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);
void Synch(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_pointstrul2(MyList<pointstru> *pp, int first_last_only);
void matchcheck(MyList<Patch> *CPatL);
void Interp_Points(MyList<var> *VarList,
int NN, double **XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry);
void Interp_Points_2D(MyList<var> *VarList,
int NN, double **XX, /*input global Cartesian coordinate*/
double *Shellf, int Symmetry);
void Step(double dT, double PhysTime, monitor *ErrorMonitor);
void Null_Boundary(double PhysTime);
void HyperSlice(double dT, double PhysTime, monitor *ErrorMonitor, int RK_count);
double News_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);
void Compute_News(double PhysTime, double dT, bool dp);
void Check_News(double PhysTime, double dT, bool dp);
};
#endif /* NULLSHELLPATCH_H */

View File

@@ -1,183 +1,183 @@
#ifndef NULLSHELLPATCH2_H
#define NULLSHELLPATCH2_H
#ifdef newc
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <complex>
using namespace std;
#else
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <complex.h>
#endif
#include <mpi.h>
#include "MyList.h"
#include "Block.h"
#include "Parallel.h"
#include "ShellPatch.h"
#include "var.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3)
#error NullShellPatch2 only supports 3 dimensional stuff yet
#endif
// x x x x x o *
// * o x x x x x
// each side contribute an overlap points
// so we need half of that
#define overghost ((ghost_width + 1) / 2 + ghost_width)
class NullShellPatch2
{
class xp_npatch : public ss_patch
{
public:
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
{
public:
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
{
public:
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
{
public:
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
{
public:
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
{
public:
zm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
};
public:
struct pointstru
{
double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate
Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef;
int *sind; // index position, considered dummy dimension already
int dumyd; // the dimension which has common lines, only useful in interdata_packer
double Jacob[2][2];
int indz; // index position of r direction
};
var *gx, *gy, *gz;
// surface variable
var *g00, *g01, *p02, *p03, *g02, *g03;
var *Theta22, *Theta23, *Theta33;
// evolution variables
var *g22o, *g23o, *g33o;
var *g220, *g230, *g330;
var *g22, *g23, *g33;
var *g221, *g231, *g331;
var *g22_rhs, *g23_rhs, *g33_rhs;
var *RNews, *INews;
var *omega, *dtomega;
MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList;
MyList<var> *OldStateList, *DumpList, *CheckList;
MyList<var> *NewsList;
MyList<var> *g01List, *pg0AList, *g00List, *ThetaList;
double **g01wt, **pg0Awt, **g00wt, **Thetawt;
int myrank;
int shape[dim]; // for (rho, sigma, X), for rho and sigma means number of points for every pi/2
double Rmin, xmin, xmax;
int Symmetry;
int ingfs, fngfs;
MyList<ss_patch> *PatL;
MyList<pointstru> **ss_src, **ss_dst;
MyList<pointstru> **cs_src, **cs_dst;
public:
NullShellPatch2(int *shapei, double Rmini, double xmini, double xmaxi, int Symmetry, int myranki);
~NullShellPatch2();
double getdX(int dir);
void shellname(char *sn, int i);
void destroypsuList(MyList<pointstru> *ct);
MyList<Block> *compose_sh(int cpusize);
void Dump_xyz(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 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(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(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);
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],
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],
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],
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 Step(double dT, double PhysTime, monitor *ErrorMonitor);
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 fill_symmetric_boundarybuffer(MyList<var> *VarList, double **Varwt);
void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry, double **Varwt, const short int svt);
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,
const short int svt);
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,
const short int svt);
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,
const short int svt);
void check_pointstrul(MyList<pointstru> *pp, bool first_only);
void checkBlock(int sst);
void Null_Boundary(double PhysTime);
void Compute_News(double PhysTime);
void Interp_Points_2D(MyList<var> *VarList,
int NN, double **XX, /*input fake global Cartesian coordinate*/
double *Shellf, int Symmetry);
double Error_Check(double PhysTime);
};
#endif /* NULLSHELLPATCH2_H */
#ifndef NULLSHELLPATCH2_H
#define NULLSHELLPATCH2_H
#ifdef newc
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <complex>
using namespace std;
#else
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <complex.h>
#endif
#include <mpi.h>
#include "MyList.h"
#include "Block.h"
#include "Parallel.h"
#include "ShellPatch.h"
#include "var.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3)
#error NullShellPatch2 only supports 3 dimensional stuff yet
#endif
// x x x x x o *
// * o x x x x x
// each side contribute an overlap points
// so we need half of that
#define overghost ((ghost_width + 1) / 2 + ghost_width)
class NullShellPatch2
{
class xp_npatch : public ss_patch
{
public:
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
{
public:
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
{
public:
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
{
public:
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
{
public:
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
{
public:
zm_npatch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
};
public:
struct pointstru
{
double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate
Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef;
int *sind; // index position, considered dummy dimension already
int dumyd; // the dimension which has common lines, only useful in interdata_packer
double Jacob[2][2];
int indz; // index position of r direction
};
var *gx, *gy, *gz;
// surface variable
var *g00, *g01, *p02, *p03, *g02, *g03;
var *Theta22, *Theta23, *Theta33;
// evolution variables
var *g22o, *g23o, *g33o;
var *g220, *g230, *g330;
var *g22, *g23, *g33;
var *g221, *g231, *g331;
var *g22_rhs, *g23_rhs, *g33_rhs;
var *RNews, *INews;
var *omega, *dtomega;
MyList<var> *StateList, *SynchList_pre, *SynchList_cor, *RHSList;
MyList<var> *OldStateList, *DumpList, *CheckList;
MyList<var> *NewsList;
MyList<var> *g01List, *pg0AList, *g00List, *ThetaList;
double **g01wt, **pg0Awt, **g00wt, **Thetawt;
int myrank;
int shape[dim]; // for (rho, sigma, X), for rho and sigma means number of points for every pi/2
double Rmin, xmin, xmax;
int Symmetry;
int ingfs, fngfs;
MyList<ss_patch> *PatL;
MyList<pointstru> **ss_src, **ss_dst;
MyList<pointstru> **cs_src, **cs_dst;
public:
NullShellPatch2(int *shapei, double Rmini, double xmini, double xmaxi, int Symmetry, int myranki);
~NullShellPatch2();
double getdX(int dir);
void shellname(char *sn, int i);
void destroypsuList(MyList<pointstru> *ct);
MyList<Block> *compose_sh(int cpusize);
void Dump_xyz(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 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(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(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);
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],
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],
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],
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 Step(double dT, double PhysTime, monitor *ErrorMonitor);
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 fill_symmetric_boundarybuffer(MyList<var> *VarList, double **Varwt);
void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry, double **Varwt, const short int svt);
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,
const short int svt);
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,
const short int svt);
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,
const short int svt);
void check_pointstrul(MyList<pointstru> *pp, bool first_only);
void checkBlock(int sst);
void Null_Boundary(double PhysTime);
void Compute_News(double PhysTime);
void Interp_Points_2D(MyList<var> *VarList,
int NN, double **XX, /*input fake global Cartesian coordinate*/
double *Shellf, int Symmetry);
double Error_Check(double PhysTime);
};
#endif /* NULLSHELLPATCH2_H */

View File

@@ -1,231 +1,167 @@
#ifndef PARALLEL_H
#define PARALLEL_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <new>
using namespace std;
#include "Parallel_bam.h"
#include "var.h"
#include "MPatch.h"
#include "Block.h"
#include "MyList.h"
#include "macrodef.h" //need dim; ghost_width; CONTRACT
namespace Parallel
{
struct gridseg
{
double llb[dim];
double uub[dim];
int shape[dim];
double illb[dim], iuub[dim]; // only use for OutBdLow2Hi
Block *Bg;
};
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 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_optimize(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0);
Block* splitHotspotBlock(MyList<Block>* &BlL, int _dim,
int ib0_orig, int ib3_orig,
int jb1_orig, int jb4_orig,
int kb2_orig, int kb5_orig,
Patch* PP, int r_left, int r_right,
int ingfsi, int fngfsi, bool periodic,
Block* &split_first_block, Block* &split_last_block);
Block* createMappedBlock(MyList<Block>* &BlL, int _dim, int* shape, double* bbox,
int block_id, int ingfsi, int fngfsi, int lev);
void KillBlocks(MyList<Patch> *PatchLIST);
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 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);
void writefile(double time, int nx, int ny, double xmin, double xmax, double ymin, double ymax,
char *filename, double *datain);
void getarrayindex(int DIM, int *shape, int *index, int n);
int getarraylocation(int DIM, int *shape, int *index);
void copy(int DIM, double *llbout, double *uubout, int *Dshape, double *DD, double *llbin, double *uubin,
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_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);
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(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);
double global_interp(int DIM, int *ext, double **CoX, double *datain,
double *poX, int ordn, double *SoA, int Symmetry);
double global_interp(int DIM, int *ext, double **CoX, double *datain,
double *poX, int ordn);
double Lagrangian_Int(double x, int npts, double *xpts, double *funcvals);
double LagrangePoly(double x, int pt, int npts, double *xpts);
MyList<gridseg> *build_complete_gsl(Patch *Pat);
MyList<gridseg> *build_complete_gsl(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_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_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_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_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);
int data_packer(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
void transfer(MyList<gridseg> **src, MyList<gridseg> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry);
int data_packermix(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
void transfermix(MyList<gridseg> **src, MyList<gridseg> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry);
void Sync(Patch *Pat, 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);
struct SyncCache {
bool valid;
int cpusize;
MyList<gridseg> **combined_src;
MyList<gridseg> **combined_dst;
int *send_lengths;
int *recv_lengths;
double **send_bufs;
double **recv_bufs;
int *send_buf_caps;
int *recv_buf_caps;
MPI_Request *reqs;
MPI_Status *stats;
int max_reqs;
bool lengths_valid;
int *tc_req_node;
int *tc_req_is_recv;
int *tc_completed;
SyncCache();
void invalidate();
void destroy();
};
void Sync_cached(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry, SyncCache &cache);
void transfer_cached(MyList<gridseg> **src, MyList<gridseg> **dst,
MyList<var> *VarList1, MyList<var> *VarList2,
int Symmetry, SyncCache &cache);
struct AsyncSyncState {
int req_no;
bool active;
int *req_node;
int *req_is_recv;
int pending_recv;
AsyncSyncState() : req_no(0), active(false), req_node(0), req_is_recv(0), pending_recv(0) {}
};
void Sync_start(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry,
SyncCache &cache, AsyncSyncState &state);
void Sync_finish(SyncCache &cache, AsyncSyncState &state,
MyList<var> *VarList, int Symmetry);
void OutBdLow2Hi(Patch *Patc, Patch *Patf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void OutBdLow2Hi(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void OutBdLow2Himix(Patch *Patc, Patch *Patf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void OutBdLow2Himix(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Restrict_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1, MyList<var> *VarList2,
int Symmetry, SyncCache &cache);
void OutBdLow2Hi_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1, MyList<var> *VarList2,
int Symmetry, SyncCache &cache);
void OutBdLow2Himix_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1, MyList<var> *VarList2,
int Symmetry, SyncCache &cache);
void Prolong(Patch *Patc, Patch *Patf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Prolongint(Patch *Patc, Patch *Patf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Restrict(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Restrict_after(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry); // for -ghost - BDghost
MyList<Parallel::gridseg> *build_PhysBD_gsl(Patch *Pat);
MyList<Parallel::gridseg> *build_ghost_gsl(MyList<Patch> *PatL);
MyList<Parallel::gridseg> *build_ghost_gsl(Patch *Pat);
MyList<Parallel::gridseg> *build_buffer_gsl(Patch *Pat);
MyList<Parallel::gridseg> *build_buffer_gsl(MyList<Patch> *PatL);
MyList<Parallel::gridseg> *gsl_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *gs_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *gsl_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *gs_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *clone_gsl(MyList<Parallel::gridseg> *p, bool first_only);
MyList<Parallel::gridseg> *build_bulk_gsl(Patch *Pat); // similar to build_owned_gsl0 but does not care rank issue
MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp, Patch *Pat);
void build_PhysBD_gstl(Patch *Pat, MyList<Parallel::gridseg> *srci, MyList<Parallel::gridseg> *dsti,
MyList<Parallel::gridseg> **out_src, MyList<Parallel::gridseg> **out_dst);
void PeriodicBD(Patch *Pat, MyList<var> *VarList, int Symmetry);
double L2Norm(Patch *Pat, var *vf);
void L2Norm7(Patch *Pat, var **vf, double *norms);
void checkgsl(MyList<Parallel::gridseg> *pp, bool first_only);
void checkvarl(MyList<var> *pp, bool first_only);
MyList<Parallel::gridseg> *divide_gsl(MyList<Parallel::gridseg> *p, Patch *Pat);
MyList<Parallel::gridseg> *divide_gs(MyList<Parallel::gridseg> *p, Patch *Pat);
void prepare_inter_time_level(Patch *Pat,
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
void prepare_inter_time_level(Patch *Pat,
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
void prepare_inter_time_level(MyList<Patch> *PatL,
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
void prepare_inter_time_level(MyList<Patch> *Pat,
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
void merge_gsl(MyList<gridseg> *&A, const double ratio);
bool merge_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C, const double ratio);
// Add ghost region to tangent plane
// we assume the grids have the same resolution
void add_ghost_touch(MyList<gridseg> *&A);
void cut_gsl(MyList<gridseg> *&A);
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);
void fill_level_data(MyList<Patch> *PatLd, MyList<Patch> *PatLs, MyList<Patch> *PatcL,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *FutureList,
MyList<var> *tmList, int Symmetry, bool BB, bool CC);
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList,
int NN, double **XX,
double *Shellf, int Symmetry);
void aligncheck(double *bbox0, double *bboxl, int lev, double *DH0, int *shape);
bool point_locat_gsl(double *pox, MyList<Parallel::gridseg> *gsl);
void checkpatchlist(MyList<Patch> *PatL, bool buflog);
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 */
#ifndef PARALLEL_H
#define PARALLEL_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <new>
using namespace std;
#include "Parallel_bam.h"
#include "var.h"
#include "MPatch.h"
#include "Block.h"
#include "MyList.h"
#include "macrodef.h" //need dim; ghost_width; CONTRACT
namespace Parallel
{
struct gridseg
{
double llb[dim];
double uub[dim];
int shape[dim];
double illb[dim], iuub[dim]; // only use for OutBdLow2Hi
Block *Bg;
};
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 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
void KillBlocks(MyList<Patch> *PatchLIST);
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 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);
void writefile(double time, int nx, int ny, double xmin, double xmax, double ymin, double ymax,
char *filename, double *datain);
void getarrayindex(int DIM, int *shape, int *index, int n);
int getarraylocation(int DIM, int *shape, int *index);
void copy(int DIM, double *llbout, double *uubout, int *Dshape, double *DD, double *llbin, double *uubin,
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_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);
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(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);
double global_interp(int DIM, int *ext, double **CoX, double *datain,
double *poX, int ordn, double *SoA, int Symmetry);
double global_interp(int DIM, int *ext, double **CoX, double *datain,
double *poX, int ordn);
double Lagrangian_Int(double x, int npts, double *xpts, double *funcvals);
double LagrangePoly(double x, int pt, int npts, double *xpts);
MyList<gridseg> *build_complete_gsl(Patch *Pat);
MyList<gridseg> *build_complete_gsl(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_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_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_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_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);
int data_packer(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
void transfer(MyList<gridseg> **src, MyList<gridseg> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry);
int data_packermix(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
void transfermix(MyList<gridseg> **src, MyList<gridseg> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry);
void Sync(Patch *Pat, MyList<var> *VarList, int Symmetry);
void Sync(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry);
void OutBdLow2Hi(Patch *Patc, Patch *Patf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void OutBdLow2Hi(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void OutBdLow2Himix(Patch *Patc, Patch *Patf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void OutBdLow2Himix(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Prolong(Patch *Patc, Patch *Patf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Prolongint(Patch *Patc, Patch *Patf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Restrict(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Restrict_after(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry); // for -ghost - BDghost
MyList<Parallel::gridseg> *build_PhysBD_gsl(Patch *Pat);
MyList<Parallel::gridseg> *build_ghost_gsl(MyList<Patch> *PatL);
MyList<Parallel::gridseg> *build_ghost_gsl(Patch *Pat);
MyList<Parallel::gridseg> *build_buffer_gsl(Patch *Pat);
MyList<Parallel::gridseg> *build_buffer_gsl(MyList<Patch> *PatL);
MyList<Parallel::gridseg> *gsl_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *gs_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *gsl_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *gs_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
MyList<Parallel::gridseg> *clone_gsl(MyList<Parallel::gridseg> *p, bool first_only);
MyList<Parallel::gridseg> *build_bulk_gsl(Patch *Pat); // similar to build_owned_gsl0 but does not care rank issue
MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp, Patch *Pat);
void build_PhysBD_gstl(Patch *Pat, MyList<Parallel::gridseg> *srci, MyList<Parallel::gridseg> *dsti,
MyList<Parallel::gridseg> **out_src, MyList<Parallel::gridseg> **out_dst);
void PeriodicBD(Patch *Pat, MyList<var> *VarList, int Symmetry);
double L2Norm(Patch *Pat, var *vf);
void checkgsl(MyList<Parallel::gridseg> *pp, bool first_only);
void checkvarl(MyList<var> *pp, bool first_only);
MyList<Parallel::gridseg> *divide_gsl(MyList<Parallel::gridseg> *p, Patch *Pat);
MyList<Parallel::gridseg> *divide_gs(MyList<Parallel::gridseg> *p, Patch *Pat);
void prepare_inter_time_level(Patch *Pat,
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
void prepare_inter_time_level(Patch *Pat,
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
void prepare_inter_time_level(MyList<Patch> *PatL,
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
void prepare_inter_time_level(MyList<Patch> *Pat,
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
void merge_gsl(MyList<gridseg> *&A, const double ratio);
bool merge_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C, const double ratio);
// Add ghost region to tangent plane
// we assume the grids have the same resolution
void add_ghost_touch(MyList<gridseg> *&A);
void cut_gsl(MyList<gridseg> *&A);
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);
void fill_level_data(MyList<Patch> *PatLd, MyList<Patch> *PatLs, MyList<Patch> *PatcL,
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *FutureList,
MyList<var> *tmList, int Symmetry, bool BB, bool CC);
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList,
int NN, double **XX,
double *Shellf, int Symmetry);
void aligncheck(double *bbox0, double *bboxl, int lev, double *DH0, int *shape);
bool point_locat_gsl(double *pox, MyList<Parallel::gridseg> *gsl);
void checkpatchlist(MyList<Patch> *PatL, bool buflog);
double L2Norm(Patch *Pat, var *vf, 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
#define PARALLEL_BAM_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <new>
using namespace std;
#include "var.h"
#include "MPatch.h"
#include "Block.h"
#include "MyList.h"
#include "macrodef.h"
namespace Parallel
{
struct pointstru_bam
{
double pox[dim]; // cordinate
Block *Bgs; // interplate from
Block *Bgd; // interplate for
double *coef; // interpolation coefficients
int sind[dim]; // interpolation starting array index
};
void destroypsuList_bam(MyList<pointstru_bam> *ct);
void OutBdLow2Hi_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void OutBdLow2Hi_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::pointstru_bam> *bdsul, int Symmetry);
void Constr_pointstr_OutBdLow2Hi(MyList<Patch> *PLf, MyList<Patch> *PLc,
MyList<Parallel::pointstru_bam> *&bdsul);
void Restrict_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Restrict_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::pointstru_bam> *rsul, int Symmetry);
void Constr_pointstr_Restrict(MyList<Patch> *PLf, MyList<Patch> *PLc,
MyList<Parallel::pointstru_bam> *&rsul);
void intertransfer(MyList<Parallel::pointstru_bam> *&sul,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry);
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);
}
#endif /*PARALLEL_BAM_H */
#ifndef PARALLEL_BAM_H
#define PARALLEL_BAM_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <new>
using namespace std;
#include "var.h"
#include "MPatch.h"
#include "Block.h"
#include "MyList.h"
#include "macrodef.h"
namespace Parallel
{
struct pointstru_bam
{
double pox[dim]; // cordinate
Block *Bgs; // interplate from
Block *Bgd; // interplate for
double *coef; // interpolation coefficients
int sind[dim]; // interpolation starting array index
};
void destroypsuList_bam(MyList<pointstru_bam> *ct);
void OutBdLow2Hi_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void OutBdLow2Hi_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::pointstru_bam> *bdsul, int Symmetry);
void Constr_pointstr_OutBdLow2Hi(MyList<Patch> *PLf, MyList<Patch> *PLc,
MyList<Parallel::pointstru_bam> *&bdsul);
void Restrict_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
int Symmetry);
void Restrict_bam(MyList<Patch> *PLc, MyList<Patch> *PLf,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
MyList<Parallel::pointstru_bam> *rsul, int Symmetry);
void Constr_pointstr_Restrict(MyList<Patch> *PLf, MyList<Patch> *PLc,
MyList<Parallel::pointstru_bam> *&rsul);
void intertransfer(MyList<Parallel::pointstru_bam> *&sul,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry);
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);
}
#endif /*PARALLEL_BAM_H */

View File

@@ -1,212 +0,0 @@
#include "rungekutta4_rout.h"
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <complex>
#include <immintrin.h>
namespace {
inline void rk4_stage0(std::size_t n,
const double *__restrict f0,
const double *__restrict frhs,
double *__restrict f1,
double c) {
std::size_t i = 0;
#if defined(__AVX512F__)
const __m512d vc = _mm512_set1_pd(c);
for (; i + 7 < n; i += 8) {
const __m512d v0 = _mm512_loadu_pd(f0 + i);
const __m512d vr = _mm512_loadu_pd(frhs + i);
_mm512_storeu_pd(f1 + i, _mm512_fmadd_pd(vc, vr, v0));
}
#elif defined(__AVX2__)
const __m256d vc = _mm256_set1_pd(c);
for (; i + 3 < n; i += 4) {
const __m256d v0 = _mm256_loadu_pd(f0 + i);
const __m256d vr = _mm256_loadu_pd(frhs + i);
_mm256_storeu_pd(f1 + i, _mm256_fmadd_pd(vc, vr, v0));
}
#endif
#pragma ivdep
for (; i < n; ++i) {
f1[i] = f0[i] + c * frhs[i];
}
}
inline void rk4_rhs_accum(std::size_t n,
const double *__restrict f1,
double *__restrict frhs) {
std::size_t i = 0;
#if defined(__AVX512F__)
const __m512d v2 = _mm512_set1_pd(2.0);
for (; i + 7 < n; i += 8) {
const __m512d v1 = _mm512_loadu_pd(f1 + i);
const __m512d vrhs = _mm512_loadu_pd(frhs + i);
_mm512_storeu_pd(frhs + i, _mm512_fmadd_pd(v2, v1, vrhs));
}
#elif defined(__AVX2__)
const __m256d v2 = _mm256_set1_pd(2.0);
for (; i + 3 < n; i += 4) {
const __m256d v1 = _mm256_loadu_pd(f1 + i);
const __m256d vrhs = _mm256_loadu_pd(frhs + i);
_mm256_storeu_pd(frhs + i, _mm256_fmadd_pd(v2, v1, vrhs));
}
#endif
#pragma ivdep
for (; i < n; ++i) {
frhs[i] = frhs[i] + 2.0 * f1[i];
}
}
inline void rk4_f1_from_f0_f1(std::size_t n,
const double *__restrict f0,
double *__restrict f1,
double c) {
std::size_t i = 0;
#if defined(__AVX512F__)
const __m512d vc = _mm512_set1_pd(c);
for (; i + 7 < n; i += 8) {
const __m512d v0 = _mm512_loadu_pd(f0 + i);
const __m512d v1 = _mm512_loadu_pd(f1 + i);
_mm512_storeu_pd(f1 + i, _mm512_fmadd_pd(vc, v1, v0));
}
#elif defined(__AVX2__)
const __m256d vc = _mm256_set1_pd(c);
for (; i + 3 < n; i += 4) {
const __m256d v0 = _mm256_loadu_pd(f0 + i);
const __m256d v1 = _mm256_loadu_pd(f1 + i);
_mm256_storeu_pd(f1 + i, _mm256_fmadd_pd(vc, v1, v0));
}
#endif
#pragma ivdep
for (; i < n; ++i) {
f1[i] = f0[i] + c * f1[i];
}
}
inline void rk4_stage3(std::size_t n,
const double *__restrict f0,
double *__restrict f1,
const double *__restrict frhs,
double c) {
std::size_t i = 0;
#if defined(__AVX512F__)
const __m512d vc = _mm512_set1_pd(c);
for (; i + 7 < n; i += 8) {
const __m512d v0 = _mm512_loadu_pd(f0 + i);
const __m512d v1 = _mm512_loadu_pd(f1 + i);
const __m512d vr = _mm512_loadu_pd(frhs + i);
_mm512_storeu_pd(f1 + i, _mm512_fmadd_pd(vc, _mm512_add_pd(v1, vr), v0));
}
#elif defined(__AVX2__)
const __m256d vc = _mm256_set1_pd(c);
for (; i + 3 < n; i += 4) {
const __m256d v0 = _mm256_loadu_pd(f0 + i);
const __m256d v1 = _mm256_loadu_pd(f1 + i);
const __m256d vr = _mm256_loadu_pd(frhs + i);
_mm256_storeu_pd(f1 + i, _mm256_fmadd_pd(vc, _mm256_add_pd(v1, vr), v0));
}
#endif
#pragma ivdep
for (; i < n; ++i) {
f1[i] = f0[i] + c * (f1[i] + frhs[i]);
}
}
} // namespace
extern "C" {
void f_rungekutta4_scalar(double &dT, double &f0, double &f1, double &f_rhs, int &RK4) {
constexpr double F1o6 = 1.0 / 6.0;
constexpr double HLF = 0.5;
constexpr double TWO = 2.0;
switch (RK4) {
case 0:
f1 = f0 + HLF * dT * f_rhs;
break;
case 1:
f_rhs = f_rhs + TWO * f1;
f1 = f0 + HLF * dT * f1;
break;
case 2:
f_rhs = f_rhs + TWO * f1;
f1 = f0 + dT * f1;
break;
case 3:
f1 = f0 + F1o6 * dT * (f1 + f_rhs);
break;
default:
std::fprintf(stderr, "rungekutta4_scalar_c: invalid RK4 stage %d\n", RK4);
std::abort();
}
}
void rungekutta4_cplxscalar_(double &dT,
std::complex<double> &f0,
std::complex<double> &f1,
std::complex<double> &f_rhs,
int &RK4) {
constexpr double F1o6 = 1.0 / 6.0;
constexpr double HLF = 0.5;
constexpr double TWO = 2.0;
switch (RK4) {
case 0:
f1 = f0 + HLF * dT * f_rhs;
break;
case 1:
f_rhs = f_rhs + TWO * f1;
f1 = f0 + HLF * dT * f1;
break;
case 2:
f_rhs = f_rhs + TWO * f1;
f1 = f0 + dT * f1;
break;
case 3:
f1 = f0 + F1o6 * dT * (f1 + f_rhs);
break;
default:
std::fprintf(stderr, "rungekutta4_cplxscalar_c: invalid RK4 stage %d\n", RK4);
std::abort();
}
}
int f_rungekutta4_rout(int *ex, double &dT,
double *f0, double *f1, double *f_rhs,
int &RK4) {
const std::size_t n = static_cast<std::size_t>(ex[0]) *
static_cast<std::size_t>(ex[1]) *
static_cast<std::size_t>(ex[2]);
const double *const __restrict f0r = f0;
double *const __restrict f1r = f1;
double *const __restrict frhs = f_rhs;
if (__builtin_expect(static_cast<unsigned>(RK4) > 3u, 0)) {
std::fprintf(stderr, "rungekutta4_rout_c: invalid RK4 stage %d\n", RK4);
std::abort();
}
switch (RK4) {
case 0:
rk4_stage0(n, f0r, frhs, f1r, 0.5 * dT);
break;
case 1:
rk4_rhs_accum(n, f1r, frhs);
rk4_f1_from_f0_f1(n, f0r, f1r, 0.5 * dT);
break;
case 2:
rk4_rhs_accum(n, f1r, frhs);
rk4_f1_from_f0_f1(n, f0r, f1r, dT);
break;
default:
rk4_stage3(n, f0r, f1r, frhs, (1.0 / 6.0) * dT);
break;
}
return 0;
}
} // extern "C"

View File

@@ -1,271 +1,271 @@
! define scalar field distribution and potential in F(R) scalar-tensor theory
! 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
! 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))
! 5: shell with phi0*dexp(-(r-r0)**2/sigma), V = 0
! original way, manually define the preprocessor macro
! #define CC 2
! the new way, define according to the preprocessor macro in "macrodef.fh"
#include "macrodef.fh"
#define CC EScalar_CC
subroutine setparameters(a2,r0,phi0,sigma,l2)
implicit none
real*8,intent(out) :: a2,r0,phi0,sigma,l2
! original way: read in parameters one by one
! call seta2(a2)
! call setphi0(phi0)
! new way: read in all parameters at once
call set_escalar_parameter(a2, phi0, r0, sigma, l2)
! r0=120.d0
! sigma=8.d0
! l2=1.d4
! write(*,*)
! write(*,*) " Set_Rho_ADM.f90 a2 = ", a2
! write(*,*) " Set_Rho_ADM.f90 phi0 = ", phi0
! write(*,*) " Set_Rho_ADM.f90 r0 = ", r0
! write(*,*) " Set_Rho_ADM.f90 sigma0 = ", sigma
! write(*,*) " Set_Rho_ADM.f90 l2 = ", l2
! write(*,*)
return
end subroutine setparameters
!===================================================================
function phi(X,Y,Z) result(gont)
implicit none
double precision,intent(in)::X
double precision,intent(in)::Y
double precision,intent(in)::Z
real*8 :: gont
real*8 ::r
real*8 :: a2,r0,phi0,sigma,l2
call setparameters(a2,r0,phi0,sigma,l2)
r=dsqrt(X*X+Y*Y+Z*Z)
#if ( CC == 1)
! configuration 1
gont = phi0*dtanh((r-r0)/sigma)
#elif ( CC == 2)
! configuration 2
phi0 = a2**2*phi0/(1+a2**2)
gont = phi0*dexp(-(r-r0)**2/sigma)
#elif ( CC == 3)
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.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.021649d0*dexp(-0.68406d0*(r-8.78608d-8)*(r-8.78608d-8)/l2))/l2
#elif ( CC == 4)
! configuration 4, a2 = oo
phi0 = 0.5d0*phi0
gont = phi0*(dtanh((r+r0)/sigma)-dtanh((r-r0)/sigma))
#elif ( CC == 5)
! configuration 5
gont = phi0*dexp(-(r-r0)**2/sigma)
#endif
return
end function phi
! d phi/dr
function dphi(X,Y,Z) result(gont)
implicit none
double precision,intent(in)::X
double precision,intent(in)::Y
double precision,intent(in)::Z
real*8 :: gont
real*8 ::r
real*8 :: a2,r0,phi0,sigma,l2
call setparameters(a2,r0,phi0,sigma,l2)
r=dsqrt(X*X+Y*Y+Z*Z)
#if ( CC == 1)
! configuration 1
gont = phi0/sigma*(1-(dtanh((r-r0)/sigma))**2)
#elif ( CC == 2)
! configuration 2
phi0 = a2**2*phi0/(1+a2**2)
gont = -2.d0*phi0*(r-r0)/sigma*exp(-(r-r0)**2/sigma)
#elif ( CC == 3)
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.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.2961842988d-1*(r-0.878608d-7)/l2*dexp(-0.68406*(r-0.878608d-7)**2/l2))/l2
#elif ( CC == 4)
! configuration 4, a2 = oo
phi0 = 0.5d0*phi0
gont = phi0*((1-dtanh((r+r0)/sigma)**2)/sigma- &
(1-dtanh((r-r0)/sigma)**2)/sigma)
#elif ( CC == 5)
! configuration 5
gont = -2.d0*phi0*(r-r0)/sigma*exp(-(r-r0)**2/sigma)
#endif
return
end function dphi
!==================================================================
function potential(X,Y,Z) result(gont)
implicit none
double precision,intent(in)::X
double precision,intent(in)::Y
double precision,intent(in)::Z
real*8 :: gont
real*8 :: phi
real*8 :: PI,v
real*8 :: a2,r0,phi0,sigma,l2
#if ( CC == 1 || CC == 4 || CC == 5)
gont = 0.d0
#elif ( CC == 2 || CC == 3)
call setparameters(a2,r0,phi0,sigma,l2)
PI = dacos(-1.d0)
v = phi(X,Y,Z)
gont = dexp(-8.d0*dsqrt(PI/3)*v)*(1-dexp(4*dsqrt(PI/3)*v))**2/32/PI/a2
#endif
return
end function potential
!==================================================================
!Note this part is for evolution
!not just for initial configuration
!f(R) potential F=R+a_2R^2
subroutine frpotential(ex,Sphi,V,dVdSphi)
implicit none
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(out) :: V,dVdSphi
real*8 :: a2,r0,phi0,sigma,l2
real*8, parameter :: Four = 4.d0, TWO = 2.d0,ONE = 1.d0,ZEO=0.d0
real*8 :: PI
PI = dacos(-ONE)
#if ( CC == 1 || CC == 4 || CC == 5)
V = ZEO
dVdSphi = ZEO
#elif ( CC == 2 || CC == 3)
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
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
return
end subroutine frpotential
!==================================================================
!f(R) potential F=R+a_2R^2
!fprim(R) = 1+2*a_2*R
subroutine frfprim(ex,RR,fprim)
implicit none
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(out) :: fprim
real*8 :: a2,r0,phi0,sigma,l2
real*8, parameter :: ONE=1.d0, TWO = 2.d0
#if ( CC == 1 || CC == 4 || CC == 5)
fprim = ONE
#elif ( CC == 2 || CC == 3)
call setparameters(a2,r0,phi0,sigma,l2)
fprim = ONE+TWO*a2*RR
#endif
return
end subroutine frfprim
!==================================================================
subroutine set_rho_adm2(ex,rho,X,Y,Z)
implicit none
! argument variables
integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z
double precision,intent(out),dimension(ex)::rho
integer :: i
real*8 :: dphi
do i=1,ex
! rho(i) = dphi(X,Y,Z)
rho(i) = dphi(X(i),Y(i),Z(i))
rho(i) = rho(i)*rho(i)
enddo
return
end subroutine set_rho_adm2
subroutine set_rho_adm1(ex,rho,X,Y,Z)
implicit none
! argument variables
integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z
double precision,intent(out),dimension(ex)::rho
real*8 :: potential
integer :: i
do i=1,ex
rho(i) = potential(X(i),Y(i),Z(i))
enddo
return
end subroutine set_rho_adm1
subroutine set_rho_adm(ex,rho,X,Y,Z)
implicit none
! argument variables
integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z
! in psivac, out rho_adm
double precision,intent(inout),dimension(ex)::rho
double precision,dimension(ex)::rho1,rho2
call set_rho_adm1(ex,rho1,X,Y,Z)
call set_rho_adm2(ex,rho2,X,Y,Z)
rho = rho**4
rho = rho**2*rho1+rho*rho2
return
end subroutine set_rho_adm
! define scalar field distribution and potential in F(R) scalar-tensor theory
! 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
! 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))
! 5: shell with phi0*dexp(-(r-r0)**2/sigma), V = 0
! original way, manually define the preprocessor macro
! #define CC 2
! the new way, define according to the preprocessor macro in "macrodef.fh"
#include "macrodef.fh"
#define CC EScalar_CC
subroutine setparameters(a2,r0,phi0,sigma,l2)
implicit none
real*8,intent(out) :: a2,r0,phi0,sigma,l2
! original way: read in parameters one by one
! call seta2(a2)
! call setphi0(phi0)
! new way: read in all parameters at once
call set_escalar_parameter(a2, phi0, r0, sigma, l2)
! r0=120.d0
! sigma=8.d0
! l2=1.d4
! write(*,*)
! write(*,*) " Set_Rho_ADM.f90 a2 = ", a2
! write(*,*) " Set_Rho_ADM.f90 phi0 = ", phi0
! write(*,*) " Set_Rho_ADM.f90 r0 = ", r0
! write(*,*) " Set_Rho_ADM.f90 sigma0 = ", sigma
! write(*,*) " Set_Rho_ADM.f90 l2 = ", l2
! write(*,*)
return
end subroutine setparameters
!===================================================================
function phi(X,Y,Z) result(gont)
implicit none
double precision,intent(in)::X
double precision,intent(in)::Y
double precision,intent(in)::Z
real*8 :: gont
real*8 ::r
real*8 :: a2,r0,phi0,sigma,l2
call setparameters(a2,r0,phi0,sigma,l2)
r=dsqrt(X*X+Y*Y+Z*Z)
#if ( CC == 1)
! configuration 1
gont = phi0*dtanh((r-r0)/sigma)
#elif ( CC == 2)
! configuration 2
phi0 = a2**2*phi0/(1+a2**2)
gont = phi0*dexp(-(r-r0)**2/sigma)
#elif ( CC == 3)
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.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.021649d0*dexp(-0.68406d0*(r-8.78608d-8)*(r-8.78608d-8)/l2))/l2
#elif ( CC == 4)
! configuration 4, a2 = oo
phi0 = 0.5d0*phi0
gont = phi0*(dtanh((r+r0)/sigma)-dtanh((r-r0)/sigma))
#elif ( CC == 5)
! configuration 5
gont = phi0*dexp(-(r-r0)**2/sigma)
#endif
return
end function phi
! d phi/dr
function dphi(X,Y,Z) result(gont)
implicit none
double precision,intent(in)::X
double precision,intent(in)::Y
double precision,intent(in)::Z
real*8 :: gont
real*8 ::r
real*8 :: a2,r0,phi0,sigma,l2
call setparameters(a2,r0,phi0,sigma,l2)
r=dsqrt(X*X+Y*Y+Z*Z)
#if ( CC == 1)
! configuration 1
gont = phi0/sigma*(1-(dtanh((r-r0)/sigma))**2)
#elif ( CC == 2)
! configuration 2
phi0 = a2**2*phi0/(1+a2**2)
gont = -2.d0*phi0*(r-r0)/sigma*exp(-(r-r0)**2/sigma)
#elif ( CC == 3)
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.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.2961842988d-1*(r-0.878608d-7)/l2*dexp(-0.68406*(r-0.878608d-7)**2/l2))/l2
#elif ( CC == 4)
! configuration 4, a2 = oo
phi0 = 0.5d0*phi0
gont = phi0*((1-dtanh((r+r0)/sigma)**2)/sigma- &
(1-dtanh((r-r0)/sigma)**2)/sigma)
#elif ( CC == 5)
! configuration 5
gont = -2.d0*phi0*(r-r0)/sigma*exp(-(r-r0)**2/sigma)
#endif
return
end function dphi
!==================================================================
function potential(X,Y,Z) result(gont)
implicit none
double precision,intent(in)::X
double precision,intent(in)::Y
double precision,intent(in)::Z
real*8 :: gont
real*8 :: phi
real*8 :: PI,v
real*8 :: a2,r0,phi0,sigma,l2
#if ( CC == 1 || CC == 4 || CC == 5)
gont = 0.d0
#elif ( CC == 2 || CC == 3)
call setparameters(a2,r0,phi0,sigma,l2)
PI = dacos(-1.d0)
v = phi(X,Y,Z)
gont = dexp(-8.d0*dsqrt(PI/3)*v)*(1-dexp(4*dsqrt(PI/3)*v))**2/32/PI/a2
#endif
return
end function potential
!==================================================================
!Note this part is for evolution
!not just for initial configuration
!f(R) potential F=R+a_2R^2
subroutine frpotential(ex,Sphi,V,dVdSphi)
implicit none
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(out) :: V,dVdSphi
real*8 :: a2,r0,phi0,sigma,l2
real*8, parameter :: Four = 4.d0, TWO = 2.d0,ONE = 1.d0,ZEO=0.d0
real*8 :: PI
PI = dacos(-ONE)
#if ( CC == 1 || CC == 4 || CC == 5)
V = ZEO
dVdSphi = ZEO
#elif ( CC == 2 || CC == 3)
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
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
return
end subroutine frpotential
!==================================================================
!f(R) potential F=R+a_2R^2
!fprim(R) = 1+2*a_2*R
subroutine frfprim(ex,RR,fprim)
implicit none
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(out) :: fprim
real*8 :: a2,r0,phi0,sigma,l2
real*8, parameter :: ONE=1.d0, TWO = 2.d0
#if ( CC == 1 || CC == 4 || CC == 5)
fprim = ONE
#elif ( CC == 2 || CC == 3)
call setparameters(a2,r0,phi0,sigma,l2)
fprim = ONE+TWO*a2*RR
#endif
return
end subroutine frfprim
!==================================================================
subroutine set_rho_adm2(ex,rho,X,Y,Z)
implicit none
! argument variables
integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z
double precision,intent(out),dimension(ex)::rho
integer :: i
real*8 :: dphi
do i=1,ex
! rho(i) = dphi(X,Y,Z)
rho(i) = dphi(X(i),Y(i),Z(i))
rho(i) = rho(i)*rho(i)
enddo
return
end subroutine set_rho_adm2
subroutine set_rho_adm1(ex,rho,X,Y,Z)
implicit none
! argument variables
integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z
double precision,intent(out),dimension(ex)::rho
real*8 :: potential
integer :: i
do i=1,ex
rho(i) = potential(X(i),Y(i),Z(i))
enddo
return
end subroutine set_rho_adm1
subroutine set_rho_adm(ex,rho,X,Y,Z)
implicit none
! argument variables
integer,intent(in)::ex
double precision,intent(in),dimension(ex)::X
double precision,intent(in),dimension(ex)::Y
double precision,intent(in),dimension(ex)::Z
! in psivac, out rho_adm
double precision,intent(inout),dimension(ex)::rho
double precision,dimension(ex)::rho1,rho2
call set_rho_adm1(ex,rho1,X,Y,Z)
call set_rho_adm2(ex,rho2,X,Y,Z)
rho = rho**4
rho = rho**2*rho1+rho*rho2
return
end subroutine set_rho_adm

View File

@@ -1,205 +1,204 @@
#ifndef SHELLPATCH_H
#define SHELLPATCH_H
#include <mpi.h>
#include "MyList.h"
#include "Block.h"
#include "Parallel.h"
#include "var.h"
#include "monitor.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3)
#error shellpatch only supports 3 dimensional stuff yet
#endif
class ss_patch
{
public:
int sst; // ss_patch type: 0:zp, 1:zm, 2:xp, 3:xm, 4:yp, 5:ym
int myrank;
int shape[dim];
double bbox[2 * dim]; // this bbox includes nominal points and overlap points
MyList<Block> *blb, *ble;
int ingfs, fngfs;
ss_patch() {};
ss_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki);
~ss_patch();
virtual void setupcordtrans() {};
void Sync(MyList<var> *VarList, int Symmetry);
MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp);
MyList<Parallel::gridseg> *build_ghost_gsl();
MyList<Parallel::gridseg> *build_owned_gsl0(int rank_in);
};
class xp_patch : public ss_patch
{
public:
xp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 2; };
void setupcordtrans();
};
class xm_patch : public ss_patch
{
public:
xm_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 3; };
void setupcordtrans();
};
class yp_patch : public ss_patch
{
public:
yp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 4; };
void setupcordtrans();
};
class ym_patch : public ss_patch
{
public:
ym_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 5; };
void setupcordtrans();
};
class zp_patch : public ss_patch
{
public:
zp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 0; };
void setupcordtrans();
};
class zm_patch : public ss_patch
{
public:
zm_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
void setupcordtrans();
};
// Shell Patch system
// for derivatives usage we ask 27 more double type grid functions
// here we use **sngfs corresponding to fngfs to store them:
// drho/dx, drho/dy, drho/dz
// dsigma/dx, dsigma/dy, dsigma/dz
// dR/dx, dR/dy, dR/dz
// drho/dxdx, drho/dxdy, drho/dxdz, drho/dydy, drho/dydz, drho/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
class ShellPatch
{
public:
struct pointstru
{
double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate
Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef;
int *sind;
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
};
int myrank;
int shape[dim]; // for (rho, sigma, R), for rho and sigma means number of points for every pi/2
double Rrange[2]; // for Rmin and Rmax
int Symmetry;
int ingfs, fngfs;
MyList<ss_patch> *PatL;
// we use fngfs+v to reference the variable
enum
{
gx = 0,
gy,
gz,
drhodx,
drhody,
drhodz,
dsigmadx,
dsigmady,
dsigmadz,
dRdx,
dRdy,
dRdz,
drhodxx,
drhodxy,
drhodxz,
drhodyy,
drhodyz,
drhodzz,
dsigmadxx,
dsigmadxy,
dsigmadxz,
dsigmadyy,
dsigmadyz,
dsigmadzz,
dRdxx,
dRdxy,
dRdxz,
dRdyy,
dRdyz,
dRdzz
};
MyList<pointstru> **ss_src, **ss_dst;
// at means target
MyList<pointstru> **csatc_src, **csatc_dst;
MyList<pointstru> **csats_src, **csats_dst;
public:
ShellPatch(int ingfsi, int fngfsi, char *filename, int Symmetry, int myranki, monitor *ErrorMonitor);
~ShellPatch();
MyList<Block> *compose_sh(int cpusize, int nodes = 0);
MyList<Block> *compose_shr(int cpusize, int nodes = 0);
void setupcordtrans();
double getR(double r);
double getsr(double R);
void checkPatch();
void checkBlock(int sst);
void check_pointstrul(MyList<pointstru> *pp, bool first_only);
void check_pointstrul2(MyList<pointstru> *pp, int first_last_only);
double getdX(int dir); //(rho, sigma, R)
void Dump_xyz(char *tag, double time, double dT);
void Dump_Data(MyList<var> *DumpList, char *tag, double time, double dT);
double *Collect_Data(ss_patch *PP, var *VP);
void getlocalpoxsst(double gx, double gy, double gz, int sst, double &lx, double &ly, double &lz);
void getlocalpox(double gx, double gy, double gz, 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 prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPp, double DH[dim],
MyList<Patch> *Pp, double CDH[dim], MyList<pointstru> *pss);
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);
void setupintintstuff(int cpusize, MyList<Patch> *CPatL, int Symmetry);
void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry);
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);
void Synch(MyList<var> *VarList, int Symmetry);
void CS_Inter(MyList<var> *VarList, int Symmetry);
void destroypsuList(MyList<pointstru> *ct);
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 */
#ifndef SHELLPATCH_H
#define SHELLPATCH_H
#include <mpi.h>
#include "MyList.h"
#include "Block.h"
#include "Parallel.h"
#include "var.h"
#include "monitor.h"
#include "macrodef.h" //need dim here; Vertex or Cell; ghost_width
#if (dim != 3)
#error shellpatch only supports 3 dimensional stuff yet
#endif
class ss_patch
{
public:
int sst; // ss_patch type: 0:zp, 1:zm, 2:xp, 3:xm, 4:yp, 5:ym
int myrank;
int shape[dim];
double bbox[2 * dim]; // this bbox includes nominal points and overlap points
MyList<Block> *blb, *ble;
int ingfs, fngfs;
ss_patch() {};
ss_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki);
~ss_patch();
virtual void setupcordtrans() {};
void Sync(MyList<var> *VarList, int Symmetry);
MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp);
MyList<Parallel::gridseg> *build_ghost_gsl();
MyList<Parallel::gridseg> *build_owned_gsl0(int rank_in);
};
class xp_patch : public ss_patch
{
public:
xp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 2; };
void setupcordtrans();
};
class xm_patch : public ss_patch
{
public:
xm_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 3; };
void setupcordtrans();
};
class yp_patch : public ss_patch
{
public:
yp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 4; };
void setupcordtrans();
};
class ym_patch : public ss_patch
{
public:
ym_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 5; };
void setupcordtrans();
};
class zp_patch : public ss_patch
{
public:
zp_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 0; };
void setupcordtrans();
};
class zm_patch : public ss_patch
{
public:
zm_patch(int ingfsi, int fngfsi, int *shapei, double *bboxi, int myranki) : ss_patch(ingfsi, fngfsi, shapei, bboxi, myranki) { sst = 1; };
void setupcordtrans();
};
// Shell Patch system
// for derivatives usage we ask 27 more double type grid functions
// here we use **sngfs corresponding to fngfs to store them:
// drho/dx, drho/dy, drho/dz
// dsigma/dx, dsigma/dy, dsigma/dz
// dR/dx, dR/dy, dR/dz
// drho/dxdx, drho/dxdy, drho/dxdz, drho/dydy, drho/dydz, drho/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
class ShellPatch
{
public:
struct pointstru
{
double gpox[dim]; // global cordinate
double lpox[dim]; // local cordinate
Block *Bg;
int ssst; //-1: cardisian, others as sst of ss_patch source sst
int tsst; //-1: cardisian, others as sst of ss_patch target sst
double *coef;
int *sind;
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
};
int myrank;
int shape[dim]; // for (rho, sigma, R), for rho and sigma means number of points for every pi/2
double Rrange[2]; // for Rmin and Rmax
int Symmetry;
int ingfs, fngfs;
MyList<ss_patch> *PatL;
// we use fngfs+v to reference the variable
enum
{
gx = 0,
gy,
gz,
drhodx,
drhody,
drhodz,
dsigmadx,
dsigmady,
dsigmadz,
dRdx,
dRdy,
dRdz,
drhodxx,
drhodxy,
drhodxz,
drhodyy,
drhodyz,
drhodzz,
dsigmadxx,
dsigmadxy,
dsigmadxz,
dsigmadyy,
dsigmadyz,
dsigmadzz,
dRdxx,
dRdxy,
dRdxz,
dRdyy,
dRdyz,
dRdzz
};
MyList<pointstru> **ss_src, **ss_dst;
// at means target
MyList<pointstru> **csatc_src, **csatc_dst;
MyList<pointstru> **csats_src, **csats_dst;
public:
ShellPatch(int ingfsi, int fngfsi, char *filename, int Symmetry, int myranki, monitor *ErrorMonitor);
~ShellPatch();
MyList<Block> *compose_sh(int cpusize, int nodes = 0);
MyList<Block> *compose_shr(int cpusize, int nodes = 0);
void setupcordtrans();
double getR(double r);
double getsr(double R);
void checkPatch();
void checkBlock(int sst);
void check_pointstrul(MyList<pointstru> *pp, bool first_only);
void check_pointstrul2(MyList<pointstru> *pp, int first_last_only);
double getdX(int dir); //(rho, sigma, R)
void Dump_xyz(char *tag, double time, double dT);
void Dump_Data(MyList<var> *DumpList, char *tag, double time, double dT);
double *Collect_Data(ss_patch *PP, var *VP);
void getlocalpoxsst(double gx, double gy, double gz, int sst, double &lx, double &ly, double &lz);
void getlocalpox(double gx, double gy, double gz, 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 prolongpointstru(MyList<pointstru> *&psul, MyList<ss_patch> *sPp, double DH[dim],
MyList<Patch> *Pp, double CDH[dim], MyList<pointstru> *pss);
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);
void setupintintstuff(int cpusize, MyList<Patch> *CPatL, int Symmetry);
void intertransfer(MyList<pointstru> **src, MyList<pointstru> **dst,
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
int Symmetry);
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);
void Synch(MyList<var> *VarList, int Symmetry);
void CS_Inter(MyList<var> *VarList, int Symmetry);
void destroypsuList(MyList<pointstru> *ct);
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 Find_Maximum(MyList<var> *VarList, double *XX, double *Shellf);
};
#endif /* SHELLPATCH_H */

View File

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

View File

@@ -1,167 +1,171 @@
#ifndef TWO_PUNCTURES_H
#define TWO_PUNCTURES_H
#include <omp.h>
#define StencilSize 19
#define N_PlaneRelax 1
#define NRELAX 200
#define Step_Relax 1
#define Pi 3.14159265358979323846264338328
#define Pih 1.57079632679489661923132169164 /* Pi/2*/
#define Piq 0.78539816339744830961566084582 /* Pi/4*/
#define TINY 1.0e-20
class TwoPunctures
{
public:
typedef struct DERIVS
{
double *d0, *d1, *d2, *d3, *d11, *d12, *d13, *d22, *d23, *d33;
} derivs;
double *F;
derivs u, v;
private:
double par_m_plus, par_m_minus, par_b;
double par_P_plus[3], par_P_minus[3];
double par_S_plus[3], par_S_minus[3];
int npoints_A, npoints_B, npoints_phi;
double target_M_plus, target_M_minus;
double admMass;
double adm_tol;
double Newton_tol;
int Newton_maxit;
int ntotal;
// ===== Precomputed spectral derivative matrices =====
double *D1_A, *D2_A;
double *D1_B, *D2_B;
double *DF1_phi, *DF2_phi;
// ===== Pre-allocated workspace for LineRelax (per-thread) =====
int max_threads;
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_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;
struct parameters
{
int nvar, n1, n2, n3;
double b;
};
public:
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 P_minusx, double P_minusy, double P_minusz,
double S_minusx, double S_minusy, double S_minusz,
int nA, int nB, int nphi,
double Mp, double Mm, double admtol, double Newtontol,
int Newtonmaxit);
~TwoPunctures();
// 02/07: New/modified methods
void allocate_workspace();
void free_workspace();
void precompute_derivative_matrices();
void build_cheb_deriv_matrices(int n, double *D1, double *D2);
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 ThomasAlgorithm_ws(int N, double *b, double *a, double *c, double *x, double *q,
double *l, double *u_ws, double *d, double *y);
void LineRelax_be_omp(double *dv,
int const i, int const k, int const nvar,
int const n1, int const n2, int const n3,
double const *rhs, int const *ncols, int **cols,
double **JFD, int tid);
void LineRelax_al_omp(double *dv,
int const j, int const k, int const nvar,
int const n1, int const n2, int const n3,
double const *rhs, int const *ncols,
int **cols, double **JFD, int tid);
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);
void Solve();
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 *ivector(long nl, long nh);
double *dvector(long nl, long nh);
int **imatrix(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);
void free_ivector(int *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_dmatrix(double **m, 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);
int minimum2(int i, int j);
int minimum3(int i, int j, int k);
int maximum2(int i, int j);
int maximum3(int i, int j, int k);
int pow_int(int mantisse, int exponent);
void chebft_Zeros(double u[], int n, int inv);
void chebft_Extremes(double u[], int n, int inv);
void chder(double *c, double *cder, int n);
double chebev(double a, double b, double c[], int m, double x);
void fourft(double *u, int N, int inv);
void fourder(double u[], double du[], int N);
void fourder2(double u[], double d2u[], int N);
double fourev(double *u, int N, double x);
double norm1(double *v, int n);
double norm2(double *v, int n);
double scalarproduct(double *v, double *w, int n);
double PunctIntPolAtArbitPosition(int ivar, int nvar, int n1,
int n2, int n3, derivs v, double x, double y,
double z);
double PunctEvalAtArbitPosition(double *v, int ivar, double A, double B, double phi,
int nvar, int n1, int n2, int n3);
void AB_To_XR(int nvar, double A, double B, double *X, double *R,
derivs U);
void C_To_c(int nvar, double X, double R, double *x, double *r,
derivs U);
void rx3_To_xyz(int nvar, double x, double r, double phi,
double *y, double *z, derivs U);
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,
derivs v, double const tol, int const itmax);
void F_of_v(int nvar, int n1, int n2, int n3, derivs v, double *F,
derivs u);
double norm_inf(double const *F, int const ntotal);
int bicgstab(int const nvar, int const n1, int const n2, int const n3,
derivs v, derivs dv, int const itmax, double const tol,
double *normres);
void allocate_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);
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 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 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,
int n3, derivs dv, derivs u, double *values);
void LinEquations(double A, double B, double X, double R,
double x, double r, double phi,
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 Save(char *fname);
// provided by Vasileios Paschalidis (vpaschal@illinois.edu)
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);
void SpecCoef(parameters par, int ivar, double *v, double *cf);
};
#endif /* TWO_PUNCTURES_H */
#ifndef TWO_PUNCTURES_H
#define TWO_PUNCTURES_H
#define StencilSize 19
#define N_PlaneRelax 1
#define NRELAX 200
#define Step_Relax 1
#define Pi 3.14159265358979323846264338328
#define Pih 1.57079632679489661923132169164 /* Pi/2*/
#define Piq 0.78539816339744830961566084582 /* Pi/4*/
#define TINY 1.0e-20
class TwoPunctures
{
public:
typedef struct DERIVS
{
double *d0, *d1, *d2, *d3, *d11, *d12, *d13, *d22, *d23, *d33;
} derivs;
double *F;
derivs u, v;
private:
double par_m_plus, par_m_minus, par_b;
double par_P_plus[3], par_P_minus[3];
double par_S_plus[3], par_S_minus[3];
int npoints_A, npoints_B, npoints_phi;
double target_M_plus, target_M_minus;
double admMass;
double adm_tol;
double Newton_tol;
int Newton_maxit;
int ntotal;
// Pre-allocated workspace buffers for hot-path allocation elimination
// LineRelax_be workspace (sized for n2)
double *ws_diag_be, *ws_e_be, *ws_f_be, *ws_b_be, *ws_x_be;
// LineRelax_al workspace (sized for n1)
double *ws_diag_al, *ws_e_al, *ws_f_al, *ws_b_al, *ws_x_al;
// ThomasAlgorithm workspace (sized for max(n1,n2))
double *ws_thomas_y;
// JFD_times_dv workspace (sized for nvar)
double *ws_jfd_values;
derivs ws_jfd_dU, ws_jfd_U;
// chebft_Zeros workspace (sized for max(n1,n2,n3)+1)
double *ws_cheb_c;
// fourft workspace (sized for max(n1,n2,n3)/2+1 each)
double *ws_four_a, *ws_four_b;
// Derivatives_AB3 workspace
double *ws_deriv_p, *ws_deriv_dp, *ws_deriv_d2p;
double *ws_deriv_q, *ws_deriv_dq;
double *ws_deriv_r, *ws_deriv_dr;
int *ws_deriv_indx;
// F_of_v workspace
double *ws_fov_sources;
double *ws_fov_values;
derivs ws_fov_U;
// J_times_dv workspace
double *ws_jtdv_values;
derivs ws_jtdv_dU, ws_jtdv_U;
struct parameters
{
int nvar, n1, n2, n3;
double b;
};
public:
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 P_minusx, double P_minusy, double P_minusz,
double S_minusx, double S_minusy, double S_minusz,
int nA, int nB, int nphi,
double Mp, double Mm, double admtol, double Newtontol,
int Newtonmaxit);
~TwoPunctures();
void Solve();
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 *ivector(long nl, long nh);
double *dvector(long nl, long nh);
int **imatrix(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);
void free_ivector(int *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_dmatrix(double **m, 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);
int minimum2(int i, int j);
int minimum3(int i, int j, int k);
int maximum2(int i, int j);
int maximum3(int i, int j, int k);
int pow_int(int mantisse, int exponent);
void chebft_Zeros(double u[], int n, int inv);
void chebft_Extremes(double u[], int n, int inv);
void chder(double *c, double *cder, int n);
double chebev(double a, double b, double c[], int m, double x);
void fourft(double *u, int N, int inv);
void fourder(double u[], double du[], int N);
void fourder2(double u[], double d2u[], int N);
double fourev(double *u, int N, double x);
double norm1(double *v, int n);
double norm2(double *v, int n);
double scalarproduct(double *v, double *w, int n);
double PunctIntPolAtArbitPosition(int ivar, int nvar, int n1,
int n2, int n3, derivs v, double x, double y,
double z);
double PunctEvalAtArbitPosition(double *v, int ivar, double A, double B, double phi,
int nvar, int n1, int n2, int n3);
void AB_To_XR(int nvar, double A, double B, double *X, double *R,
derivs U);
void C_To_c(int nvar, double X, double R, double *x, double *r,
derivs U);
void rx3_To_xyz(int nvar, double x, double r, double phi,
double *y, double *z, derivs U);
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,
derivs v, double const tol, int const itmax);
void F_of_v(int nvar, int n1, int n2, int n3, derivs v, double *F,
derivs u);
double norm_inf(double const *F, int const ntotal);
int bicgstab(int const nvar, int const n1, int const n2, int const n3,
derivs v, derivs dv, int const itmax, double const tol,
double *normres);
void allocate_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);
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 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 J_times_dv(int nvar, int n1, int n2, int n3, derivs dv, double *Jdv, derivs u);
void relax(double *dv, int const nvar, int const n1, int const n2, int const n3,
double const *rhs, int const *ncols, int **cols, double **JFD);
void LineRelax_be(double *dv,
int const i, int const k, int const nvar,
int const n1, int const n2, int const n3,
double const *rhs, int const *ncols, int **cols,
double **JFD);
void JFD_times_dv(int i, int j, int k, int nvar, int n1, int n2,
int n3, derivs dv, derivs u, double *values);
void LinEquations(double A, double B, double X, double R,
double x, double r, double phi,
double y, double z, derivs dU, derivs U, double *values);
void LineRelax_al(double *dv,
int const j, int const k, int const nvar,
int const n1, int const n2, int const n3,
double const *rhs, int const *ncols,
int **cols, double **JFD);
void ThomasAlgorithm(int N, double *b, double *a, double *c, double *x, double *q);
void Save(char *fname);
// provided by Vasileios Paschalidis (vpaschal@illinois.edu)
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);
void SpecCoef(parameters par, int ivar, double *v, double *cf);
};
#endif /* TWO_PUNCTURES_H */

View File

@@ -1,64 +1,64 @@
#ifndef Z4c_CLASS_H
#define Z4c_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 "cgh.h"
#include "ShellPatch.h"
#include "misc.h"
#include "var.h"
#include "MyList.h"
#include "monitor.h"
#include "surface_integral.h"
#include "macrodef.h"
#ifdef USE_GPU
#include "bssn_gpu_class.h"
#else
#include "bssn_class.h"
#endif
class Z4c_class : public bssn_class
{
public:
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 a_levi, int maxli, int decni, double maxrexi, double drexi);
~Z4c_class();
void Initialize();
void Check_extrop();
// Since we have set zero to variables at very begining
// we can neglect TZ for initial data setting
void Step(int lev, int YN);
void Interp_Constraint();
void Constraint_Out();
void Compute_Constraint();
protected:
var *TZo;
var *TZ0;
var *TZ;
var *TZ1;
var *TZ_rhs;
};
#endif /* Z4c_CLASS_H */
#ifndef Z4c_CLASS_H
#define Z4c_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 "cgh.h"
#include "ShellPatch.h"
#include "misc.h"
#include "var.h"
#include "MyList.h"
#include "monitor.h"
#include "surface_integral.h"
#include "macrodef.h"
#ifdef USE_GPU
#include "bssn_gpu_class.h"
#else
#include "bssn_class.h"
#endif
class Z4c_class : public bssn_class
{
public:
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 a_levi, int maxli, int decni, double maxrexi, double drexi);
~Z4c_class();
void Initialize();
void Check_extrop();
// Since we have set zero to variables at very begining
// we can neglect TZ for initial data setting
void Step(int lev, int YN);
void Interp_Constraint();
void Constraint_Out();
void Compute_Constraint();
protected:
var *TZo;
var *TZ0;
var *TZ;
var *TZ1;
var *TZ_rhs;
};
#endif /* Z4c_CLASS_H */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,69 +1,69 @@
#ifndef BSSNEM_CLASS_H
#define BSSNEM_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 "cgh.h"
#include "ShellPatch.h"
#include "misc.h"
#include "var.h"
#include "MyList.h"
#include "monitor.h"
#include "surface_integral.h"
#include "macrodef.h"
#ifdef USE_GPU
#include "bssn_gpu_class.h"
#else
#include "bssn_class.h"
#endif
class bssnEM_class : public bssn_class
{
public:
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 a_levi, int maxli, int decni, double maxrexi, double drexi);
~bssnEM_class();
void Initialize();
void Read_Ansorg();
void Setup_Initial_Data();
void Step(int lev, int YN);
void Compute_Phi2(int lev);
void AnalysisStuff_EM(int lev, double dT_lev);
void Interp_Constraint();
protected:
var *Exo, *Eyo, *Ezo, *Bxo, *Byo, *Bzo, *Kpsio, *Kphio;
var *Ex0, *Ey0, *Ez0, *Bx0, *By0, *Bz0, *Kpsi0, *Kphi0;
var *Ex, *Ey, *Ez, *Bx, *By, *Bz, *Kpsi, *Kphi;
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 *Jx, *Jy, *Jz, *qchar;
var *Rphi2, *Iphi2;
var *Rphi1, *Iphi1;
monitor *Phi2Monitor;
monitor *Phi1Monitor;
};
#endif /* BSSNEM_CLASS_H */
#ifndef BSSNEM_CLASS_H
#define BSSNEM_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 "cgh.h"
#include "ShellPatch.h"
#include "misc.h"
#include "var.h"
#include "MyList.h"
#include "monitor.h"
#include "surface_integral.h"
#include "macrodef.h"
#ifdef USE_GPU
#include "bssn_gpu_class.h"
#else
#include "bssn_class.h"
#endif
class bssnEM_class : public bssn_class
{
public:
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 a_levi, int maxli, int decni, double maxrexi, double drexi);
~bssnEM_class();
void Initialize();
void Read_Ansorg();
void Setup_Initial_Data();
void Step(int lev, int YN);
void Compute_Phi2(int lev);
void AnalysisStuff_EM(int lev, double dT_lev);
void Interp_Constraint();
protected:
var *Exo, *Eyo, *Ezo, *Bxo, *Byo, *Bzo, *Kpsio, *Kphio;
var *Ex0, *Ey0, *Ez0, *Bx0, *By0, *Bz0, *Kpsi0, *Kphi0;
var *Ex, *Ey, *Ez, *Bx, *By, *Bz, *Kpsi, *Kphi;
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 *Jx, *Jy, *Jz, *qchar;
var *Rphi2, *Iphi2;
var *Rphi1, *Iphi1;
monitor *Phi2Monitor;
monitor *Phi1Monitor;
};
#endif /* BSSNEM_CLASS_H */

View File

@@ -1,70 +1,70 @@
#ifndef BSSNESCALAR_CLASS_H
#define BSSNESCALAR_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 "cgh.h"
#include "ShellPatch.h"
#include "misc.h"
#include "var.h"
#include "MyList.h"
#include "monitor.h"
#include "surface_integral.h"
#include "macrodef.h"
#ifdef USE_GPU
#include "bssn_gpu_class.h"
#else
#include "bssn_class.h"
#endif
class bssnEScalar_class : public bssn_class
{
public:
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 a_levi, int maxli, int decni, double maxrexi, double drexi);
~bssnEScalar_class();
void Initialize();
void Read_Ansorg();
void Read_Pablo();
void Compute_Psi4(int lev);
void Step(int lev, int YN);
void AnalysisStuff_EScalar(int lev, double dT_lev);
void Interp_Constraint();
void Constraint_Out();
protected:
var *Sphio, *Spio;
var *Sphi0, *Spi0;
var *Sphi, *Spi;
var *Sphi1, *Spi1;
var *Sphi_rhs, *Spi_rhs;
var *Cons_fR;
monitor *MaxScalar_Monitor;
};
#endif /* BSSNESCALAR_CLASS_H */
#ifndef BSSNESCALAR_CLASS_H
#define BSSNESCALAR_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 "cgh.h"
#include "ShellPatch.h"
#include "misc.h"
#include "var.h"
#include "MyList.h"
#include "monitor.h"
#include "surface_integral.h"
#include "macrodef.h"
#ifdef USE_GPU
#include "bssn_gpu_class.h"
#else
#include "bssn_class.h"
#endif
class bssnEScalar_class : public bssn_class
{
public:
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 a_levi, int maxli, int decni, double maxrexi, double drexi);
~bssnEScalar_class();
void Initialize();
void Read_Ansorg();
void Read_Pablo();
void Compute_Psi4(int lev);
void Step(int lev, int YN);
void AnalysisStuff_EScalar(int lev, double dT_lev);
void Interp_Constraint();
void Constraint_Out();
protected:
var *Sphio, *Spio;
var *Sphi0, *Spi0;
var *Sphi, *Spi;
var *Sphi1, *Spi1;
var *Sphi_rhs, *Spi_rhs;
var *Cons_fR;
monitor *MaxScalar_Monitor;
};
#endif /* BSSNESCALAR_CLASS_H */

View File

@@ -1,206 +1,198 @@
#ifndef BSSN_CLASS_H
#define BSSN_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"
extern void setpbh(int iBHN, double **iPBH, double *iMass, int rBHN);
class bssn_class
{
public:
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;
int *ConstraintRefreshLevels;
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;
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_rp_coarse; // RestrictProlong sync on PatL[lev-1]
Parallel::SyncCache *sync_cache_rp_fine; // RestrictProlong sync on PatL[lev]
Parallel::SyncCache *sync_cache_restrict; // cached Restrict in RestrictProlong
Parallel::SyncCache *sync_cache_outbd; // cached OutBdLow2Hi in RestrictProlong
monitor *ErrorMonitor, *Psi4Monitor, *BHMonitor, *MAPMonitor;
monitor *ConVMonitor, *TimingMonitor;
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 == 3)
void RecursiveStep(int lev, int num);
#endif
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
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();
bool check_Stdin_Abort();
virtual void Setup_Initial_Data_Cao();
virtual void Setup_Initial_Data_Lousto();
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_CLASS_H */
#ifndef BSSN_CLASS_H
#define BSSN_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"
extern void setpbh(int iBHN, double **iPBH, double *iMass, int rBHN);
class bssn_class
{
public:
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 == 3)
void RecursiveStep(int lev, int num);
#endif
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
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();
bool check_Stdin_Abort();
virtual void Setup_Initial_Data_Cao();
virtual void Setup_Initial_Data_Lousto();
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_CLASS_H */

View File

@@ -1,73 +1,73 @@
#ifndef BSSN_GPU_H_
#define BSSN_GPU_H_
#include "bssn_macro.h"
#include "macrodef.fh"
#define DEVICE_ID 0
// #define DEVICE_ID_BY_MPI_RANK
#define GRID_DIM 256
#define BLOCK_DIM 128
#define _FH2_(i, j, k) fh[(i) + (j) * _1D_SIZE[2] + (k) * _2D_SIZE[2]]
#define _FH3_(i, j, k) fh[(i) + (j) * _1D_SIZE[3] + (k) * _2D_SIZE[3]]
#define pow2(x) ((x) * (x))
#define TimeBetween(a, b) ((b.tv_sec - a.tv_sec) + (b.tv_usec - a.tv_usec) / 1000000.0f)
#define M_ metac.
#define Mh_ meta->
#define Ms_ metassc.
#define Msh_ metass->
// #define TIMING
#define RHS_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 *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 &sst, int &co
/** main function */
int gpu_rhs(int calledby, int mpi_rank, 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 gpu_rhs_ss(RHS_SS_PARA);
/** Init GPU side data in GPUMeta. */
// void init_fluid_meta_gpu(GPUMeta *gpu_meta);
#endif
#ifndef BSSN_GPU_H_
#define BSSN_GPU_H_
#include "bssn_macro.h"
#include "macrodef.fh"
#define DEVICE_ID 0
// #define DEVICE_ID_BY_MPI_RANK
#define GRID_DIM 256
#define BLOCK_DIM 128
#define _FH2_(i, j, k) fh[(i) + (j) * _1D_SIZE[2] + (k) * _2D_SIZE[2]]
#define _FH3_(i, j, k) fh[(i) + (j) * _1D_SIZE[3] + (k) * _2D_SIZE[3]]
#define pow2(x) ((x) * (x))
#define TimeBetween(a, b) ((b.tv_sec - a.tv_sec) + (b.tv_usec - a.tv_usec) / 1000000.0f)
#define M_ metac.
#define Mh_ meta->
#define Ms_ metassc.
#define Msh_ metass->
// #define TIMING
#define RHS_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 *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 &sst, int &co
/** main function */
int gpu_rhs(int calledby, int mpi_rank, 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 gpu_rhs_ss(RHS_SS_PARA);
/** Init GPU side data in GPUMeta. */
// void init_fluid_meta_gpu(GPUMeta *gpu_meta);
#endif

View File

@@ -1,210 +1,210 @@
#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 */
#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 */

View File

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

View File

@@ -1,94 +1,94 @@
#ifndef BSSN_STEP_H
#define BSSN_STEP_H
//1---------------------FLAGS---------------------
#define USE_GPU
#define MAX_GPU_PROCESS_NUM 1
#define COUNT_CPU_RHS_TIME
//2---------------------TIMER---------------------
//2.1 TIMER_INIT
//2.2 TIMER_TIC_WITHOUT_OUTPUT
//2.3 TIMER_TIC(tag,order,label)
//2.4 TIMER_TIC_TAIL_OF_FUNC(tag,label)
#define TIME_COUNT_EACH_RANK 0
#define TIMER_INIT \
double clock_prev,clock_curr,step_begin_clock;\
if(1 == 1){\
clock_curr =MPI_Wtime();\
step_begin_clock = MPI_Wtime();\
}else{\
if(myrank == 0){\
clock_curr= MPI_Wtime();\
step_begin_clock = MPI_Wtime();\
}\
}
#define TIMER_TIC(tag,order,label) \
if(TIME_COUNT_EACH_RANK == 1){\
clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\
cout<<#tag <<order <<":MPI Rank: "<<myrank<<" "<<#label <<" "<<(clock_curr-clock_prev)<<endl;\
}else{\
if(myrank==0){\
clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\
cout<<#tag <<order <<" "<<#label " "<<(clock_curr-clock_prev)<<endl;\
}\
}
#define TIMER_TIC_EACH_PROC(tag,order,label) \
clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\
cout<<#tag <<order <<":MPI Rank: "<<myrank<<" "<<#label <<" "<<(clock_curr-clock_prev)<<endl;\
}
#define TIMER_TIC_WITHOUT_OUTPUT \
if(TIME_COUNT_EACH_RANK == 1){\
clock_curr = MPI_Wtime();\
}else{\
if(myrank==0){\
clock_curr = MPI_Wtime();\
}\
}
#define TIMER_TIC_TAIL_OF_FUNC(tag,label) \
if(TIME_COUNT_EACH_RANK == 1){\
cout<<#tag <<"MPI Rank: "<<myrank<<" "<<#label <<" "<<(MPI_Wtime()-step_begin_clock)<<" seconds!"<<endl;\
}else{\
if(myrank==0)\
{\
cout<<#tag <<#label <<" "<<(MPI_Wtime()-step_begin_clock)<<" seconds!"<<endl;\
}\
}
//3---------------------GPU---------------------
#define CALLED_BY_STEP 0
#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_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_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_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_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------------------------------
int compare_result(int ftag1,double * d2,int data_num);
#endif
#ifndef BSSN_STEP_H
#define BSSN_STEP_H
//1---------------------FLAGS---------------------
#define USE_GPU
#define MAX_GPU_PROCESS_NUM 1
#define COUNT_CPU_RHS_TIME
//2---------------------TIMER---------------------
//2.1 TIMER_INIT
//2.2 TIMER_TIC_WITHOUT_OUTPUT
//2.3 TIMER_TIC(tag,order,label)
//2.4 TIMER_TIC_TAIL_OF_FUNC(tag,label)
#define TIME_COUNT_EACH_RANK 0
#define TIMER_INIT \
double clock_prev,clock_curr,step_begin_clock;\
if(1 == 1){\
clock_curr =MPI_Wtime();\
step_begin_clock = MPI_Wtime();\
}else{\
if(myrank == 0){\
clock_curr= MPI_Wtime();\
step_begin_clock = MPI_Wtime();\
}\
}
#define TIMER_TIC(tag,order,label) \
if(TIME_COUNT_EACH_RANK == 1){\
clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\
cout<<#tag <<order <<":MPI Rank: "<<myrank<<" "<<#label <<" "<<(clock_curr-clock_prev)<<endl;\
}else{\
if(myrank==0){\
clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\
cout<<#tag <<order <<" "<<#label " "<<(clock_curr-clock_prev)<<endl;\
}\
}
#define TIMER_TIC_EACH_PROC(tag,order,label) \
clock_prev= clock_curr;\
clock_curr = MPI_Wtime();\
cout<<#tag <<order <<":MPI Rank: "<<myrank<<" "<<#label <<" "<<(clock_curr-clock_prev)<<endl;\
}
#define TIMER_TIC_WITHOUT_OUTPUT \
if(TIME_COUNT_EACH_RANK == 1){\
clock_curr = MPI_Wtime();\
}else{\
if(myrank==0){\
clock_curr = MPI_Wtime();\
}\
}
#define TIMER_TIC_TAIL_OF_FUNC(tag,label) \
if(TIME_COUNT_EACH_RANK == 1){\
cout<<#tag <<"MPI Rank: "<<myrank<<" "<<#label <<" "<<(MPI_Wtime()-step_begin_clock)<<" seconds!"<<endl;\
}else{\
if(myrank==0)\
{\
cout<<#tag <<#label <<" "<<(MPI_Wtime()-step_begin_clock)<<" seconds!"<<endl;\
}\
}
//3---------------------GPU---------------------
#define CALLED_BY_STEP 0
#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_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_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_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_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------------------------------
int compare_result(int ftag1,double * d2,int data_num);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,244 +1,231 @@
#ifndef BSSN_H
#define BSSN_H
#ifdef fortran1
#define f_compute_rhs_bssn compute_rhs_bssn
#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_ss compute_rhs_bssn_escalar_ss
#define f_compute_rhs_Z4c compute_rhs_z4c
#define f_compute_rhs_Z4cnot compute_rhs_z4cnot
#define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss
#define f_compute_constraint_fr compute_constraint_fr
#endif
#ifdef fortran2
#define f_compute_rhs_bssn COMPUTE_RHS_BSSN
#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_ss COMPUTE_RHS_BSSN_ESCALAR_SS
#define f_compute_rhs_Z4c COMPUTE_RHS_Z4C
#define f_compute_rhs_Z4cnot COMPUTE_RHS_Z4CNOT
#define f_compute_rhs_Z4c_ss COMPUTE_RHS_Z4C_SS
#define f_compute_constraint_fr COMPUTE_CONSTRAINT_FR
#endif
#ifdef fortran3
#define f_compute_rhs_bssn compute_rhs_bssn_
#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_ss compute_rhs_bssn_escalar_ss_
#define f_compute_rhs_Z4c compute_rhs_z4c_
#define f_compute_rhs_Z4cnot compute_rhs_z4cnot_
#define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss_
#define f_compute_constraint_fr compute_constraint_fr_
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void f_bssn_rhs_kernel_timing_reset();
int f_bssn_rhs_kernel_timing_bucket_count();
const double *f_bssn_rhs_kernel_timing_local_seconds();
const char *f_bssn_rhs_kernel_timing_label(int);
#ifdef __cplusplus
}
#endif
extern "C"
{
int f_compute_rhs_bssn(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
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 *, // 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 *, double *, // constraint violation
int &, int &, double &, int &);
}
extern "C"
{
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 *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz
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 *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
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 *, // 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 *, double *, // constraint violation
int &, int &, double &, int &, int &);
}
extern "C"
{
int f_compute_rhs_bssn_escalar(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi, Spi
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi, Spi
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 *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &);
}
extern "C"
{
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 *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz
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 *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi,Spi
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi,Spi
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 *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &, int &);
}
extern "C"
{
int f_compute_rhs_Z4c(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // Z4
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
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 *,
int &, int &, double &, int &);
}
extern "C"
{
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 *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz
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 *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // TZ
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // TZ
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 *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &, int &);
}
extern "C"
{
int f_compute_rhs_Z4cnot(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // Z4
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
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 *,
int &, int &, double &, int &, double &);
}
extern "C"
{
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 *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, double *, double *, double *, // Rij
double *, double *, double *, double *, double *, double *, // Sij
double *);
} // FR_cons
#endif /* BSSN_H */
#ifndef BSSN_H
#define BSSN_H
#ifdef fortran1
#define f_compute_rhs_bssn compute_rhs_bssn
#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_ss compute_rhs_bssn_escalar_ss
#define f_compute_rhs_Z4c compute_rhs_z4c
#define f_compute_rhs_Z4cnot compute_rhs_z4cnot
#define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss
#define f_compute_constraint_fr compute_constraint_fr
#endif
#ifdef fortran2
#define f_compute_rhs_bssn COMPUTE_RHS_BSSN
#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_ss COMPUTE_RHS_BSSN_ESCALAR_SS
#define f_compute_rhs_Z4c COMPUTE_RHS_Z4C
#define f_compute_rhs_Z4cnot COMPUTE_RHS_Z4CNOT
#define f_compute_rhs_Z4c_ss COMPUTE_RHS_Z4C_SS
#define f_compute_constraint_fr COMPUTE_CONSTRAINT_FR
#endif
#ifdef fortran3
#define f_compute_rhs_bssn compute_rhs_bssn_
#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_ss compute_rhs_bssn_escalar_ss_
#define f_compute_rhs_Z4c compute_rhs_z4c_
#define f_compute_rhs_Z4cnot compute_rhs_z4cnot_
#define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss_
#define f_compute_constraint_fr compute_constraint_fr_
#endif
extern "C"
{
int f_compute_rhs_bssn(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
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 *, // 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 *, double *, // constraint violation
int &, int &, double &, int &);
}
extern "C"
{
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 *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz
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 *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
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 *, // 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 *, double *, // constraint violation
int &, int &, double &, int &, int &);
}
extern "C"
{
int f_compute_rhs_bssn_escalar(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi, Spi
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi, Spi
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 *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &);
}
extern "C"
{
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 *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz
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 *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi,Spi
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi,Spi
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 *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &, int &);
}
extern "C"
{
int f_compute_rhs_Z4c(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // Z4
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
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 *,
int &, int &, double &, int &);
}
extern "C"
{
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 *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz
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 *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // TZ
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // TZ
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 *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &, int &);
}
extern "C"
{
int f_compute_rhs_Z4cnot(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // Z4
double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
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 *,
int &, int &, double &, int &, double &);
}
extern "C"
{
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 *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, double *, double *, double *, // Rij
double *, double *, double *, double *, double *, double *, // Sij
double *);
} // FR_cons
#endif /* BSSN_H */

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -1,16 +1,16 @@
#ifndef AHFINDERDIRECT__CONFIG_H
#define AHFINDERDIRECT__CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
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);
typedef CCTK_REAL fp;
typedef CCTK_INT integer;
#endif /* AHFINDERDIRECT__CONFIG_H */
#ifndef AHFINDERDIRECT__CONFIG_H
#define AHFINDERDIRECT__CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
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);
typedef CCTK_REAL fp;
typedef CCTK_INT integer;
#endif /* AHFINDERDIRECT__CONFIG_H */

View File

@@ -1,173 +1,173 @@
#ifndef COORDS_H
#define COORDS_H
namespace AHFinderDirect
{
namespace local_coords
{
// 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_dang(fp dang1, fp dang2); // degrees
// modulo-reduce {ang,dang} to be (fuzzily) within the range
// [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_dang(fp dang, fp min_dang, fp max_dang);
} // close namespace local_coords::
namespace local_coords
{
// (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_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);
fp r_of_xyz(fp x, fp y, fp z);
fp mu_of_yz(fp y, fp z);
fp nu_of_xz(fp x, fp z);
fp phi_of_xy(fp x, fp y);
// ((mu,nu,phi)) --> the 3rd
fp phi_of_mu_nu(fp mu, fp nu);
fp nu_of_mu_phi(fp mu, fp phi);
fp mu_of_nu_phi(fp nu, fp phi);
// partial {x,y,z} / partial {mu,nu,phi}
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_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);
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_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);
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_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);
// partial {mu,nu,phi} / partial {x,y,z}
fp partial_mu_wrt_y(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_z(fp x, fp z);
fp partial_phi_wrt_x(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}
fp partial2_mu_wrt_yy(fp y, fp z);
fp partial2_mu_wrt_yz(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_xz(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_xy(fp x, fp y);
fp partial2_phi_wrt_yy(fp x, fp y);
// 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 r_theta_phi_of_xyz(fp x, fp y, fp z, fp &r, fp &theta, fp &phi);
// ... already have r_of_xyz()
// ... already have phi_of_xy()
fp theta_of_xyz(fp x, fp y, fp z);
// ((mu,nu,phi)) <--> usual polar spherical (theta,phi)
// ... 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_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 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 nu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &nu, fp &phi);
// ((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_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);
} // close namespace local_coords::
//*****************************************************************************
//
// ***** bit masks for coordinates ****
//
//
// We need to manipulate coordinates to do calculations like "which
// coordinate do these two patches have in common". We do these by
// Boolean operations on integers using the following bit masks:
//
namespace local_coords
{
typedef int coords_set;
enum
{
coords_set_mu = 0x1,
coords_set_nu = 0x2,
coords_set_phi = 0x4,
coords_set_empty = 0x0,
coords_set_all = coords_set_mu | coords_set_nu | coords_set_phi // no comma
};
// human-readable coordinate names for debugging etc
const char *name_of_coords_set(coords_set S);
// set complement of coordinates
inline coords_set coords_set_not(coords_set S)
{
return coords_set_all & ~S;
}
} // close namespace local_coords::
//******************************************************************************
//
// This class stores the origin point of our local coordinates, and
// provides conversions between local and global coordinates.
//
class global_coords
{
public:
// get global (x,y,z) coordinates of local origin point
fp origin_x() const { return origin_x_; }
fp origin_y() const { return origin_y_; }
fp origin_z() const { return origin_z_; }
// 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)
: origin_x_(origin_x_in),
origin_y_(origin_y_in),
origin_z_(origin_z_in)
{
}
// destructor: compiler-generated no-op is ok
void recentering(fp x, fp y, fp z)
{
origin_x_ = x;
origin_y_ = y;
origin_z_ = z;
}
private:
// we forbid copying and passing by value
// by declaring the copy constructor and assignment operator
// private, but never defining them
global_coords(const global_coords &rhs);
global_coords &operator=(const global_coords &rhs);
private:
// global (x,y,z) coordinates of local origin point
fp origin_x_, origin_y_, origin_z_;
};
//******************************************************************************
} // namespace AHFinderDirect
#endif /* COORDS_H */
#ifndef COORDS_H
#define COORDS_H
namespace AHFinderDirect
{
namespace local_coords
{
// 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_dang(fp dang1, fp dang2); // degrees
// modulo-reduce {ang,dang} to be (fuzzily) within the range
// [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_dang(fp dang, fp min_dang, fp max_dang);
} // close namespace local_coords::
namespace local_coords
{
// (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_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);
fp r_of_xyz(fp x, fp y, fp z);
fp mu_of_yz(fp y, fp z);
fp nu_of_xz(fp x, fp z);
fp phi_of_xy(fp x, fp y);
// ((mu,nu,phi)) --> the 3rd
fp phi_of_mu_nu(fp mu, fp nu);
fp nu_of_mu_phi(fp mu, fp phi);
fp mu_of_nu_phi(fp nu, fp phi);
// partial {x,y,z} / partial {mu,nu,phi}
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_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);
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_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);
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_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);
// partial {mu,nu,phi} / partial {x,y,z}
fp partial_mu_wrt_y(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_z(fp x, fp z);
fp partial_phi_wrt_x(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}
fp partial2_mu_wrt_yy(fp y, fp z);
fp partial2_mu_wrt_yz(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_xz(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_xy(fp x, fp y);
fp partial2_phi_wrt_yy(fp x, fp y);
// 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 r_theta_phi_of_xyz(fp x, fp y, fp z, fp &r, fp &theta, fp &phi);
// ... already have r_of_xyz()
// ... already have phi_of_xy()
fp theta_of_xyz(fp x, fp y, fp z);
// ((mu,nu,phi)) <--> usual polar spherical (theta,phi)
// ... 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_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 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 nu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &nu, fp &phi);
// ((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_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);
} // close namespace local_coords::
//*****************************************************************************
//
// ***** bit masks for coordinates ****
//
//
// We need to manipulate coordinates to do calculations like "which
// coordinate do these two patches have in common". We do these by
// Boolean operations on integers using the following bit masks:
//
namespace local_coords
{
typedef int coords_set;
enum
{
coords_set_mu = 0x1,
coords_set_nu = 0x2,
coords_set_phi = 0x4,
coords_set_empty = 0x0,
coords_set_all = coords_set_mu | coords_set_nu | coords_set_phi // no comma
};
// human-readable coordinate names for debugging etc
const char *name_of_coords_set(coords_set S);
// set complement of coordinates
inline coords_set coords_set_not(coords_set S)
{
return coords_set_all & ~S;
}
} // close namespace local_coords::
//******************************************************************************
//
// This class stores the origin point of our local coordinates, and
// provides conversions between local and global coordinates.
//
class global_coords
{
public:
// get global (x,y,z) coordinates of local origin point
fp origin_x() const { return origin_x_; }
fp origin_y() const { return origin_y_; }
fp origin_z() const { return origin_z_; }
// 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)
: origin_x_(origin_x_in),
origin_y_(origin_y_in),
origin_z_(origin_z_in)
{
}
// destructor: compiler-generated no-op is ok
void recentering(fp x, fp y, fp z)
{
origin_x_ = x;
origin_y_ = y;
origin_z_ = z;
}
private:
// we forbid copying and passing by value
// by declaring the copy constructor and assignment operator
// private, but never defining them
global_coords(const global_coords &rhs);
global_coords &operator=(const global_coords &rhs);
private:
// global (x,y,z) coordinates of local origin point
fp origin_x_, origin_y_, origin_z_;
};
//******************************************************************************
} // namespace AHFinderDirect
#endif /* COORDS_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,56 +1,56 @@
#ifndef CPBC_H
#define CPBC_H
#ifdef fortran1
#define f_david_milton_extroplate_ss david_milton_extroplate_ss
#define f_david_milton_cpbc_ss david_milton_cpbc_ss
#endif
#ifdef fortran2
#define f_david_milton_extroplate_ss DAVID_MILTON_EXTROPLATE_SS
#define f_david_milton_cpbc_ss DAVID_MILTON_CPBC_SS
#endif
#ifdef fortran3
#define f_david_milton_extroplate_ss david_milton_extroplate_ss_
#define f_david_milton_cpbc_ss david_milton_cpbc_ss_
#endif
extern "C"
{
int f_david_milton_extroplate_ss(int *, double *, double *, double *, // ex,crho,sigma,R
double *, double *, double *, // TZ, chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double &, double &);
} // zmin,zmax
extern "C"
{
int f_david_milton_cpbc_ss(int *, double *, double *, double *, // ex,crho,sigma,R
double *, double *, double *, // x,y,z
double *, double *, double *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz
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 *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double &, double &, double &, double &, double &, double &, // xmin,ymin,zmin,xmax,ymax,zmax
double *, double *, double *, // TZ,chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, // TZ, chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
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 *, // Ricci
double *, double *, double *, // Gama constraint
int &, double &, int &);
} // Symmetry, eps, sst
#endif /* CPBC_H */
#ifndef CPBC_H
#define CPBC_H
#ifdef fortran1
#define f_david_milton_extroplate_ss david_milton_extroplate_ss
#define f_david_milton_cpbc_ss david_milton_cpbc_ss
#endif
#ifdef fortran2
#define f_david_milton_extroplate_ss DAVID_MILTON_EXTROPLATE_SS
#define f_david_milton_cpbc_ss DAVID_MILTON_CPBC_SS
#endif
#ifdef fortran3
#define f_david_milton_extroplate_ss david_milton_extroplate_ss_
#define f_david_milton_cpbc_ss david_milton_cpbc_ss_
#endif
extern "C"
{
int f_david_milton_extroplate_ss(int *, double *, double *, double *, // ex,crho,sigma,R
double *, double *, double *, // TZ, chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double &, double &);
} // zmin,zmax
extern "C"
{
int f_david_milton_cpbc_ss(int *, double *, double *, double *, // ex,crho,sigma,R
double *, double *, double *, // x,y,z
double *, double *, double *, // drhodx,drhody,drhodz
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, // dRdx,dRdy,dRdz
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 *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
double &, double &, double &, double &, double &, double &, // xmin,ymin,zmin,xmax,ymax,zmax
double *, double *, double *, // TZ,chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, // TZ, chi, trK
double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam
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 *, // Ricci
double *, double *, double *, // Gama constraint
int &, double &, int &);
} // Symmetry, eps, sst
#endif /* CPBC_H */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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