Compare commits

..

26 Commits

Author SHA1 Message Date
a6104724e4 Fix BSSN C gauge RHS parity 2026-05-15 18:02:03 +08:00
52bb8ccf12 Fix lower-order C lopsided boundary fallbacks 2026-05-14 21:35:25 +08:00
02c69f6e34 Fix eighth-order C derivative and lopsided stencils 2026-05-14 20:32:53 +08:00
359540af4b Fix C derivative ghost-buffer indexing across FD orders 2026-05-14 16:00:11 +08:00
a628b8e2ff Fix fourth-order C lopsided and KO stencil indexing 2026-05-14 15:19:36 +08:00
c6e1a125b8 Fix shell C kernel symbol names for Fortran linkage (fderivs_sh_ etc.)
Shell C functions must export Fortran-compatible symbols with trailing
underscore so bssn_rhs_ss.f90 and getnp4.f90 can link when WithShell is
active and USE_CXX_SHELL_KERNELS=1 replaces Fortran diff_new_sh.o.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 14:09:16 +08:00
547c62a116 Add full GAUGE 2-7 support to Z4C C RHS kernel (z4c_rhs_c.C)
Previously only GAUGE 0 and 1 were supported with a compile error for 2-7.
Now supports all 8 gauge choices matching BSSN Fortran formulas:
- GAUGE 2: variable-eta gamma-driver, chi-sqrt denominator
- GAUGE 3: variable-eta gamma-driver, chi-linear denominator
- GAUGE 4: first-order variable-eta, chi-sqrt denominator
- GAUGE 5: first-order variable-eta, chi-linear denominator
- GAUGE 6: Jason's rational position-dependent damping
- GAUGE 7: Jason's exponential position-dependent damping
Also fixes dtSf advection/dissipation guards for gauges where dtSf is active.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 13:00:07 +08:00
3e55068548 Add C kernel for BSSN-EM (Maxwell/electromagnetic field) RHS computation
New bssn_em_rhs_c.C computes EM field RHS (E,B,Kpsi,Kphi) and stress-energy
tensor, then calls the C BSSN RHS kernel with source terms. Replaces empart.f90
when USE_CXX_EM_KERNEL=1. Supports all ghost_width orders via existing derivative
kernels. Controlled by USE_CXX_EM_KERNEL switch (default 0, experimental).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 11:25:08 +08:00
4a413d669d Add C implementations of shell-patch derivative kernels (WithShell support)
New files provide C equivalents of Fortran diff_new_sh.f90 and kodiss_sh.f90:
- fderivs_sh_c.C: first derivatives in shell (rho, sigma, R) coords
- fdderivs_sh_c.C: second derivatives in shell coords
- fderivs_shc_c.C: shell first derivs + chain rule to Cartesian
- fdderivs_shc_c.C: shell second derivs + chain rule to Cartesian
- kodiss_sh_c.C: Kreiss-Oliger dissipation on shell patches

Also add symmetry_stbd() C implementation and shell fh indexing to share_func.h.
Controlled by USE_CXX_SHELL_KERNELS switch (default 0, experimental).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 02:52:48 +08:00
9e51793499 Add full FD order support (2nd/4th/6th/8th) to C derivative kernels via ghost_width dispatch
Wrap each C kernel in #if (ghost_width == N) blocks matching Fortran stencil
coefficients from diff_new.f90, kodiss.f90, and lopsidediff.f90. Add fast-path
indexing for ord=1,4,5 in share_func.h.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 02:27:21 +08:00
66bce8c42d Add plot-only restart script to skip recomputation when plotting is interrupted
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 14:56:38 +08:00
32529f09a6 Use static OpenMP schedule in ShellPatch::setupintintstuff
Static scheduling has lower overhead than guided for uniform workloads
(grid points all have equal computational cost).

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

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

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

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 20:05:46 +08:00
26f5add3fb Accelerate Shell-Patch CPU interpolation 2026-05-08 14:30:15 +08:00
f669180572 Merge branch 'cjy-vitality'
# Conflicts:
#	AMSS_NCKU_source/bssn_class.C
#	AMSS_NCKU_source/makefile.inc
2026-04-28 16:55:47 +08:00
0db537479b Fix BSSN build config selection 2026-04-27 18:42:34 +08:00
1f3fd264c0 Add missing setup_transfer_caches() to bssnEM_class::Initialize()
bssnEScalar_class::Initialize() already calls setup_transfer_caches(),
but bssnEM_class::Initialize() did not. When USE_TRANSFER_CACHE=1,
the sync_cache pointers remain NULL, causing SIGSEGV in wrapper
methods that dereference sync_cache_*[lev].

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 15:32:27 +08:00
442674cedc Fix direct sync_cache accesses bypassing use_transfer_cache() guard
Seven Parallel::*_cached() calls in RestrictProlong and
RestrictProlong_aux were missed during the transfer-cache refactoring
(commits 9cd3741..8d28c29). When BSSN_USE_TRANSFER_CACHE=0, all
sync_cache pointers are NULL, so dereferencing sync_cache_*[lev]
triggers SIGSEGV.

Replace them with the equivalent wrapper methods (sync_evolution,
restrict_evolution, outbdlow2hi_evolution) that check
use_transfer_cache() and fall back to uncached direct calls.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 14:50:59 +08:00
a13b6901f6 Fix Z4C C++ gauge damping ordering 2026-04-27 12:00:47 +08:00
7e67feddbf Add C++ Z4C RHS path and port some BSSN optimizations 2026-04-25 08:03:19 +08:00
8d28c29a91 Default to safe BSSN-EScalar C kernel 2026-04-25 02:02:01 +08:00
0cf58176d9 Add safe BSSN-EScalar kernel and transfer toggles 2026-04-25 01:41:55 +08:00
0f1d0de1e7 Stabilize and wire BSSN-EScalar C path 2026-04-25 00:08:35 +08:00
c60bc03664 Also disable cached sync for Z4C 2026-04-24 21:06:13 +08:00
b57d80ca61 Disable cached sync for BSSN-EScalar 2026-04-24 01:58:57 +08:00
9cd3741a90 Fallback BSSN-EScalar restrict/prolong path 2026-04-24 01:37:54 +08:00
231 changed files with 192806 additions and 186675 deletions

4
.gitignore vendored
View File

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

6
.idea/vcs.xml generated
View File

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

View File

@@ -126,7 +126,12 @@ setup.generate_AMSSNCKU_input()
#inputvalue = input() ## Wait for user input (press Enter) to proceed #inputvalue = input() ## Wait for user input (press Enter) to proceed
#print() #print()
## Generate AMSS-NCKU program input files based on the configured parameters setup.print_puncture_information()
##################################################################
## Generate AMSS-NCKU program input files based on the configured parameters
print( ) print( )
print( " Generating the AMSS-NCKU input parfile for the ABE executable. " ) print( " Generating the AMSS-NCKU input parfile for the ABE executable. " )
@@ -169,11 +174,14 @@ import generate_macrodef
generate_macrodef.generate_macrodef_h() generate_macrodef.generate_macrodef_h()
print( " AMSS-NCKU macro file macrodef.h has been generated. " ) print( " AMSS-NCKU macro file macrodef.h has been generated. " )
generate_macrodef.generate_macrodef_fh() generate_macrodef.generate_macrodef_fh()
print( " AMSS-NCKU macro file macrodef.fh has been generated. " ) print( " AMSS-NCKU macro file macrodef.fh has been generated. " )
generate_macrodef.generate_build_config()
################################################################## print( " AMSS-NCKU build config AMSS_NCKU_build.mk has been generated. " )
##################################################################
# Compile the AMSS-NCKU program according to user requirements # Compile the AMSS-NCKU program according to user requirements
@@ -212,11 +220,13 @@ shutil.copytree(AMSS_NCKU_source_path, AMSS_NCKU_source_copy)
# Copy the generated macro files into the AMSS_NCKU source folder # Copy the generated macro files into the AMSS_NCKU source folder
macrodef_h_path = os.path.join(File_directory, "macrodef.h") macrodef_h_path = os.path.join(File_directory, "macrodef.h")
macrodef_fh_path = os.path.join(File_directory, "macrodef.fh") macrodef_fh_path = os.path.join(File_directory, "macrodef.fh")
build_config_path = os.path.join(File_directory, "AMSS_NCKU_build.mk")
shutil.copy2(macrodef_h_path, AMSS_NCKU_source_copy)
shutil.copy2(macrodef_fh_path, AMSS_NCKU_source_copy) shutil.copy2(macrodef_h_path, AMSS_NCKU_source_copy)
shutil.copy2(macrodef_fh_path, AMSS_NCKU_source_copy)
shutil.copy2(build_config_path, AMSS_NCKU_source_copy)
# Notes on copying files: # Notes on copying files:
# shutil.copy2 preserves file metadata such as modification time. # shutil.copy2 preserves file metadata such as modification time.
@@ -307,7 +317,7 @@ if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
import generate_TwoPuncture_input import generate_TwoPuncture_input
generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input(numerical_grid.puncture_data) generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input()
print( ) print( )
print( " The input parfile for the TwoPunctureABE executable has been generated. " ) print( " The input parfile for the TwoPunctureABE executable has been generated. " )
@@ -349,7 +359,7 @@ if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
import renew_puncture_parameter import renew_puncture_parameter
renew_puncture_parameter.append_AMSSNCKU_BSSN_input(File_directory, output_directory, numerical_grid.puncture_data) renew_puncture_parameter.append_AMSSNCKU_BSSN_input(File_directory, output_directory)
## Generated AMSS-NCKU input filename ## Generated AMSS-NCKU input filename

100
AMSS_NCKU_Program_Plot.py Normal file
View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,323 @@
#include "macrodef.h"
#include "bssn_rhs.h"
#include "share_func.h"
#include "tool.h"
#include <cstddef>
/*
* C 版 BSSN-EM RHS kernel — replaces empart.f90 + bssn_rhs.f90 for BSSN+Maxwell.
*
* Computes:
* 1. All metric and EM field derivatives
* 2. Physical metric, Christoffel-like terms
* 3. EM field RHS (E, B, Kpsi, Kphi)
* 4. Stress-energy tensor (rho, Si, Sij)
* 5. Calls f_compute_rhs_bssn (C BSSN RHS) with stress-energy
* 6. Advection + KO dissipation for EM fields
* 7. NaN check
*/
int f_compute_rhs_bssn_em_c(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 *Ex, double *Ey, double *Ez,
double *Bx, double *By, double *Bz,
double *Kpsi, double *Kphi,
double *Jx, double *Jy, double *Jz, double *qchar,
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 *Ex_rhs, double *Ey_rhs, double *Ez_rhs,
double *Bx_rhs, double *By_rhs, double *Bz_rhs,
double *Kpsi_rhs, double *Kphi_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)
{
(void)T;
int gont = 0;
const int nx = ex[0], ny = ex[1], nz = ex[2];
const int all = nx * ny * nz;
const size_t n = (size_t)all;
const double ZEO = 0.0, ONE = 1.0, TWO = 2.0, FOUR = 4.0, EIT = 8.0;
const double HALF = 0.5, THR = 3.0, F3o2 = 1.5, PI = 3.14159265358979323846;
const double SYM = 1.0, ANTI = -1.0;
const double kappa = 1.0;
const double SSS[3]={SYM,SYM,SYM}, AAS[3]={ANTI,ANTI,SYM};
const double ASA[3]={ANTI,SYM,ANTI}, SAA[3]={SYM,ANTI,ANTI};
const double ASS[3]={ANTI,SYM,SYM}, SAS[3]={SYM,ANTI,SYM};
const double SSA[3]={SYM,SYM,ANTI};
/* ---- allocate temporary arrays ---- */
double *chix = (double*)malloc(n*sizeof(double));
double *chiy = (double*)malloc(n*sizeof(double));
double *chiz = (double*)malloc(n*sizeof(double));
double *Exx=(double*)malloc(n*sizeof(double)),*Exy=(double*)malloc(n*sizeof(double)),*Exz=(double*)malloc(n*sizeof(double));
double *Eyx=(double*)malloc(n*sizeof(double)),*Eyy=(double*)malloc(n*sizeof(double)),*Eyz=(double*)malloc(n*sizeof(double));
double *Ezx=(double*)malloc(n*sizeof(double)),*Ezy=(double*)malloc(n*sizeof(double)),*Ezz=(double*)malloc(n*sizeof(double));
double *Bxx=(double*)malloc(n*sizeof(double)),*Bxy=(double*)malloc(n*sizeof(double)),*Bxz=(double*)malloc(n*sizeof(double));
double *Byx=(double*)malloc(n*sizeof(double)),*Byy=(double*)malloc(n*sizeof(double)),*Byz=(double*)malloc(n*sizeof(double));
double *Bzx=(double*)malloc(n*sizeof(double)),*Bzy=(double*)malloc(n*sizeof(double)),*Bzz=(double*)malloc(n*sizeof(double));
double *Kpsix=(double*)malloc(n*sizeof(double)),*Kpsiy=(double*)malloc(n*sizeof(double)),*Kpsiz=(double*)malloc(n*sizeof(double));
double *Kphix=(double*)malloc(n*sizeof(double)),*Kphiy=(double*)malloc(n*sizeof(double)),*Kphiz=(double*)malloc(n*sizeof(double));
double *Lapx=(double*)malloc(n*sizeof(double)),*Lapy=(double*)malloc(n*sizeof(double)),*Lapz=(double*)malloc(n*sizeof(double));
double *betaxx=(double*)malloc(n*sizeof(double)),*betaxy=(double*)malloc(n*sizeof(double)),*betaxz=(double*)malloc(n*sizeof(double));
double *betayx=(double*)malloc(n*sizeof(double)),*betayy=(double*)malloc(n*sizeof(double)),*betayz=(double*)malloc(n*sizeof(double));
double *betazx=(double*)malloc(n*sizeof(double)),*betazy=(double*)malloc(n*sizeof(double)),*betazz=(double*)malloc(n*sizeof(double));
double *gxxx=(double*)malloc(n*sizeof(double)),*gxxy=(double*)malloc(n*sizeof(double)),*gxxz=(double*)malloc(n*sizeof(double));
double *gxyx=(double*)malloc(n*sizeof(double)),*gxyy=(double*)malloc(n*sizeof(double)),*gxyz=(double*)malloc(n*sizeof(double));
double *gxzx=(double*)malloc(n*sizeof(double)),*gxzy=(double*)malloc(n*sizeof(double)),*gxzz=(double*)malloc(n*sizeof(double));
double *gyyx=(double*)malloc(n*sizeof(double)),*gyyy=(double*)malloc(n*sizeof(double)),*gyyz=(double*)malloc(n*sizeof(double));
double *gyzx=(double*)malloc(n*sizeof(double)),*gyzy=(double*)malloc(n*sizeof(double)),*gyzz=(double*)malloc(n*sizeof(double));
double *gzzx=(double*)malloc(n*sizeof(double)),*gzzy=(double*)malloc(n*sizeof(double)),*gzzz=(double*)malloc(n*sizeof(double));
double *gupxx=(double*)malloc(n*sizeof(double)),*gupxy=(double*)malloc(n*sizeof(double)),*gupxz=(double*)malloc(n*sizeof(double));
double *gupyy=(double*)malloc(n*sizeof(double)),*gupyz=(double*)malloc(n*sizeof(double)),*gupzz=(double*)malloc(n*sizeof(double));
if (!chix||!chiy||!chiz||!Exx||!Exy||!Exz||!Eyx||!Eyy||!Eyz||!Ezx||!Ezy||!Ezz||
!Bxx||!Bxy||!Bxz||!Byx||!Byy||!Byz||!Bzx||!Bzy||!Bzz||
!Kpsix||!Kpsiy||!Kpsiz||!Kphix||!Kphiy||!Kphiz||
!Lapx||!Lapy||!Lapz||
!betaxx||!betaxy||!betaxz||!betayx||!betayy||!betayz||!betazx||!betazy||!betazz||
!gxxx||!gxxy||!gxxz||!gxyx||!gxyy||!gxyz||!gxzx||!gxzy||!gxzz||
!gyyx||!gyyy||!gyyz||!gyzx||!gyzy||!gyzz||!gzzx||!gzzy||!gzzz||
!gupxx||!gupxy||!gupxz||!gupyy||!gupyz||!gupzz) {
gont = 1;
}
/* ==== 1. Compute all derivatives ==== */
if (!gont) {
/* metric derivatives */
fderivs(ex, Lap, Lapx, Lapy, Lapz, X, Y, Z, SYM, SYM, SYM, Symmetry, Lev);
fderivs(ex, betax, betaxx, betaxy, betaxz, X, Y, Z, ANTI, SYM, SYM, Symmetry, Lev);
fderivs(ex, betay, betayx, betayy, betayz, X, Y, Z, SYM, ANTI, SYM, Symmetry, Lev);
fderivs(ex, betaz, betazx, betazy, betazz, X, Y, Z, SYM, SYM, ANTI, Symmetry, Lev);
fderivs(ex, chi, chix, chiy, chiz, X, Y, Z, SYM, SYM, SYM, Symmetry, Lev);
fderivs(ex, dxx, gxxx, gxxy, gxxz, X, Y, Z, SYM, SYM, SYM, Symmetry, Lev);
fderivs(ex, gxy, gxyx, gxyy, gxyz, X, Y, Z, ANTI, ANTI, SYM, Symmetry, Lev);
fderivs(ex, gxz, gxzx, gxzy, gxzz, X, Y, Z, ANTI, SYM, ANTI, Symmetry, Lev);
fderivs(ex, dyy, gyyx, gyyy, gyyz, X, Y, Z, SYM, SYM, SYM, Symmetry, Lev);
fderivs(ex, gyz, gyzx, gyzy, gyzz, X, Y, Z, SYM, ANTI, ANTI, Symmetry, Lev);
fderivs(ex, dzz, gzzx, gzzy, gzzz, X, Y, Z, SYM, SYM, SYM, Symmetry, Lev);
/* EM field derivatives */
fderivs(ex, Kpsi, Kpsix, Kpsiy, Kpsiz, X, Y, Z, SYM, SYM, SYM, Symmetry, Lev);
fderivs(ex, Kphi, Kphix, Kphiy, Kphiz, X, Y, Z, SYM, SYM, SYM, Symmetry, Lev);
fderivs(ex, Ex, Exx, Exy, Exz, X, Y, Z, ANTI, SYM, SYM, Symmetry, Lev);
fderivs(ex, Ey, Eyx, Eyy, Eyz, X, Y, Z, SYM, ANTI, SYM, Symmetry, Lev);
fderivs(ex, Ez, Ezx, Ezy, Ezz, X, Y, Z, SYM, SYM, ANTI, Symmetry, Lev);
fderivs(ex, Bx, Bxx, Bxy, Bxz, X, Y, Z, SYM, ANTI, ANTI, Symmetry, Lev);
fderivs(ex, By, Byx, Byy, Byz, X, Y, Z, ANTI, SYM, ANTI, Symmetry, Lev);
fderivs(ex, Bz, Bzx, Bzy, Bzz, X, Y, Z, ANTI, ANTI, SYM, Symmetry, Lev);
/* ==== 2. Compute EM RHS and stress-energy ==== */
const double F1o4PI = ONE / (FOUR * PI);
for (size_t i = 0; i < n; ++i) {
const double alpn1 = Lap[i] + ONE;
const double chin1 = chi[i] + ONE;
const double chi3o2 = sqrt(chin1) * chin1; // chi^{3/2}
const double ichi = ONE / chin1;
/* physical metric */
const double pgxx = (dxx[i] + ONE) * ichi;
const double pgyy = (dyy[i] + ONE) * ichi;
const double pgzz = (dzz[i] + ONE) * ichi;
const double pgxy = gxy[i] * ichi;
const double pgxz = gxz[i] * ichi;
const double pgyz = gyz[i] * ichi;
/* inverse physical metric */
const double det = pgxx * pgyy * pgzz + pgxy * pgyz * pgxz + pgxz * pgxy * pgyz
- pgxz * pgyy * pgxz - pgxy * pgxy * pgzz - pgxx * pgyz * pgyz;
const double idet = ONE / det;
const double upxx = (pgyy * pgzz - pgyz * pgyz) * idet;
const double upxy = -(pgxy * pgzz - pgyz * pgxz) * idet;
const double upxz = (pgxy * pgyz - pgyy * pgxz) * idet;
const double upyy = (pgxx * pgzz - pgxz * pgxz) * idet;
const double upyz = -(pgxx * pgyz - pgxy * pgxz) * idet;
const double upzz = (pgxx * pgyy - pgxy * pgxy) * idet;
gupxx[i]=upxx; gupxy[i]=upxy; gupxz[i]=upxz;
gupyy[i]=upyy; gupyz[i]=upyz; gupzz[i]=upzz;
/* E-field RHS */
/* curl(B) part: epsilon^{ijk} ∂_j (alpha * B_k) in coordinate basis */
/* Using lower-index B fields: B_i_lower = pg_{ij} * B^j */
const double BxL = pgxx*Bx[i] + pgxy*By[i] + pgxz*Bz[i];
const double ByL = pgxy*Bx[i] + pgyy*By[i] + pgyz*Bz[i];
const double BzL = pgxz*Bx[i] + pgyz*By[i] + pgzz*Bz[i];
/* Physical metric derivatives (chain rule from conformal) */
const double pgxx_x = (gxxx[i] - pgxx*chix[i]) * ichi;
/* const double pgxx_y = (gxxy[i] - pgxx*chiy[i]) * ichi; */
const double pgxy_x = (gxyx[i] - pgxy*chix[i]) * ichi;
const double pgxy_y = (gxyy[i] - pgxy*chiy[i]) * ichi;
const double pgxz_x = (gxzx[i] - pgxz*chix[i]) * ichi;
const double pgxz_z = (gxzz[i] - pgxz*chiz[i]) * ichi;
const double pgyy_y = (gyyy[i] - pgyy*chiy[i]) * ichi;
const double pgyz_y = (gyzy[i] - pgyz*chiy[i]) * ichi;
const double pgyz_z = (gyzz[i] - pgyz*chiz[i]) * ichi;
const double pgzz_z = (gzzz[i] - pgzz*chiz[i]) * ichi;
/* Curl_x(B) = ∂_y (alpha*BzL) - ∂_z (alpha*ByL) */
const double aBx = alpn1*BxL, aBy = alpn1*ByL, aBz = alpn1*BzL;
const double curlBx = (aBz*Lapy[i] + alpn1*(pgxz*Bxy[i]+pgyz*Byy[i]+pgzz*Bzy[i]) + alpn1*(Bx[i]*gxzy[i]+By[i]*gyzy[i]+Bz[i]*gzzy[i]))
- (aBy*Lapz[i] + alpn1*(pgxy*Bxz[i]+pgyy*Byz[i]+pgyz*Bzz[i]) + alpn1*(Bx[i]*gxyz[i]+By[i]*gyyz[i]+Bz[i]*gyzz[i]));
double curlBy = (aBx*Lapz[i] + alpn1*(pgxx*Bxz[i]+pgxy*Byz[i]+pgxz*Bzz[i]) + alpn1*(Bx[i]*gxxz[i]+By[i]*gxyz[i]+Bz[i]*gxzz[i]))
- (aBz*Lapx[i] + alpn1*(pgxz*Bxx[i]+pgyz*Byx[i]+pgzz*Bzx[i]) + alpn1*(Bx[i]*gxzx[i]+By[i]*gyzx[i]+Bz[i]*gzzx[i]));
double curlBz = (aBy*Lapx[i] + alpn1*(pgxy*Bxx[i]+pgyy*Byx[i]+pgyz*Bzx[i]) + alpn1*(Bx[i]*gxyx[i]+By[i]*gyyx[i]+Bz[i]*gyzx[i]))
- (aBx*Lapy[i] + alpn1*(pgxx*Bxy[i]+pgxy*Byy[i]+pgxz*Bzy[i]) + alpn1*(Bx[i]*gxxy[i]+By[i]*gxyy[i]+Bz[i]*gxzy[i]));
/* Advection part: -beta^j * ∂_j E^i */
const double advEx = Ex[i]*betaxx[i] + Ey[i]*betaxy[i] + Ez[i]*betaxz[i];
const double advEy = Ex[i]*betayx[i] + Ey[i]*betayy[i] + Ez[i]*betayz[i];
const double advEz = Ex[i]*betazx[i] + Ey[i]*betazy[i] + Ez[i]*betazz[i];
/* grad(Kpsi) contracted with inverse metric */
const double gupKx = upxx*Kpsix[i] + upxy*Kpsiy[i] + upxz*Kpsiz[i];
const double gupKy = upxy*Kpsix[i] + upyy*Kpsiy[i] + upyz*Kpsiz[i];
const double gupKz = upxz*Kpsix[i] + upyz*Kpsiy[i] + upzz*Kpsiz[i];
Ex_rhs[i] = alpn1*trK[i]*Ex[i] - advEx - FOUR*PI*alpn1*Jx[i] - alpn1*gupKx + chi3o2*curlBx;
Ey_rhs[i] = alpn1*trK[i]*Ey[i] - advEy - FOUR*PI*alpn1*Jy[i] - alpn1*gupKy + chi3o2*curlBy;
Ez_rhs[i] = alpn1*trK[i]*Ez[i] - advEz - FOUR*PI*alpn1*Jz[i] - alpn1*gupKz + chi3o2*curlBz;
/* B-field RHS: similar but with -chi^{3/2} * curl(E) and grad(Kphi) */
const double ExL = pgxx*Ex[i] + pgxy*Ey[i] + pgxz*Ez[i];
const double EyL = pgxy*Ex[i] + pgyy*Ey[i] + pgyz*Ez[i];
const double EzL = pgxz*Ex[i] + pgyz*Ey[i] + pgzz*Ez[i];
const double aEx = alpn1*ExL, aEy = alpn1*EyL, aEz = alpn1*EzL;
const double curlEx = (aEz*Lapy[i] + alpn1*(pgxz*Exy[i]+pgyz*Eyy[i]+pgzz*Ezy[i]) + alpn1*(Ex[i]*gxzy[i]+Ey[i]*gyzy[i]+Ez[i]*gzzy[i]))
- (aEy*Lapz[i] + alpn1*(pgxy*Exz[i]+pgyy*Eyz[i]+pgyz*Ezz[i]) + alpn1*(Ex[i]*gxyz[i]+Ey[i]*gyyz[i]+Ez[i]*gyzz[i]));
double curlEy = (aEx*Lapz[i] + alpn1*(pgxx*Exz[i]+pgxy*Eyz[i]+pgxz*Ezz[i]) + alpn1*(Ex[i]*gxxz[i]+Ey[i]*gxyz[i]+Ez[i]*gxzz[i]))
- (aEz*Lapx[i] + alpn1*(pgxz*Exx[i]+pgyz*Eyx[i]+pgzz*Ezx[i]) + alpn1*(Ex[i]*gxzx[i]+Ey[i]*gyzx[i]+Ez[i]*gzzx[i]));
double curlEz = (aEy*Lapx[i] + alpn1*(pgxy*Exx[i]+pgyy*Eyx[i]+pgyz*Ezx[i]) + alpn1*(Ex[i]*gxyx[i]+Ey[i]*gyyx[i]+Ez[i]*gyzx[i]))
- (aEx*Lapy[i] + alpn1*(pgxx*Exy[i]+pgxy*Eyy[i]+pgxz*Ezy[i]) + alpn1*(Ex[i]*gxxy[i]+Ey[i]*gxyy[i]+Ez[i]*gxzy[i]));
const double advBx = Bx[i]*betaxx[i] + By[i]*betaxy[i] + Bz[i]*betaxz[i];
const double advBy = Bx[i]*betayx[i] + By[i]*betayy[i] + Bz[i]*betayz[i];
const double advBz = Bx[i]*betazx[i] + By[i]*betazy[i] + Bz[i]*betazz[i];
const double gupKphix = upxx*Kphix[i] + upxy*Kphiy[i] + upxz*Kphiz[i];
const double gupKphiy = upxy*Kphix[i] + upyy*Kphiy[i] + upyz*Kphiz[i];
const double gupKphiz = upxz*Kphix[i] + upyz*Kphiy[i] + upzz*Kphiz[i];
Bx_rhs[i] = alpn1*trK[i]*Bx[i] - advBx - alpn1*gupKphix - chi3o2*curlEx;
By_rhs[i] = alpn1*trK[i]*By[i] - advBy - alpn1*gupKphiy - chi3o2*curlEy;
Bz_rhs[i] = alpn1*trK[i]*Bz[i] - advBz - alpn1*gupKphiz - chi3o2*curlEz;
/* Scalar potential RHS */
const double divE = Exx[i] + Eyy[i] + Ezz[i];
const double divB = Bxx[i] + Byy[i] + Bzz[i];
const double chiCont = F3o2 * ichi * (chix[i]*Ex[i] + chiy[i]*Ey[i] + chiz[i]*Ez[i]);
Kpsi_rhs[i] = FOUR*PI*alpn1*qchar[i] - alpn1*kappa*Kpsi[i] - alpn1*(divE - chiCont);
Kphi_rhs[i] = -alpn1*kappa*Kphi[i] - alpn1*(divB - F3o2*ichi*(chix[i]*Bx[i] + chiy[i]*By[i] + chiz[i]*Bz[i]));
/* Stress-energy tensor */
const double E2 = pgxx*Ex[i]*Ex[i] + pgyy*Ey[i]*Ey[i] + pgzz*Ez[i]*Ez[i]
+ TWO*(pgxy*Ex[i]*Ey[i] + pgxz*Ex[i]*Ez[i] + pgyz*Ey[i]*Ez[i]);
const double B2 = pgxx*Bx[i]*Bx[i] + pgyy*By[i]*By[i] + pgzz*Bz[i]*Bz[i]
+ TWO*(pgxy*Bx[i]*By[i] + pgxz*Bx[i]*Bz[i] + pgyz*By[i]*Bz[i]);
rho[i] = (E2 + B2) / (EIT * PI);
const double ichi3o2 = ONE / chi3o2;
Sx[i] = (Ey[i]*Bz[i] - Ez[i]*By[i]) * F1o4PI * ichi3o2;
Sy[i] = (Ez[i]*Bx[i] - Ex[i]*Bz[i]) * F1o4PI * ichi3o2;
Sz[i] = (Ex[i]*By[i] - Ey[i]*Bx[i]) * F1o4PI * ichi3o2;
const double lExi = pgxx*Ex[i] + pgxy*Ey[i] + pgxz*Ez[i];
const double lEyi = pgxy*Ex[i] + pgyy*Ey[i] + pgyz*Ez[i];
const double lEzi = pgxz*Ex[i] + pgyz*Ey[i] + pgzz*Ez[i];
const double lBxi = pgxx*Bx[i] + pgxy*By[i] + pgxz*Bz[i];
const double lByi = pgxy*Bx[i] + pgyy*By[i] + pgyz*Bz[i];
const double lBzi = pgxz*Bx[i] + pgyz*By[i] + pgzz*Bz[i];
Sxx[i] = rho[i]*pgxx - (lExi*lExi + lBxi*lBxi) * F1o4PI;
Sxy[i] = rho[i]*pgxy - (lExi*lEyi + lBxi*lByi) * F1o4PI;
Sxz[i] = rho[i]*pgxz - (lExi*lEzi + lBxi*lBzi) * F1o4PI;
Syy[i] = rho[i]*pgyy - (lEyi*lEyi + lByi*lByi) * F1o4PI;
Syz[i] = rho[i]*pgyz - (lEyi*lEzi + lByi*lBzi) * F1o4PI;
Szz[i] = rho[i]*pgzz - (lEzi*lEzi + lBzi*lBzi) * F1o4PI;
}
/* ==== 3. Call BSSN RHS with EM stress-energy ==== */
gont = f_compute_rhs_bssn(ex, T, X, Y, Z,
chi, trK, dxx, gxy, gxz, dyy, gyz, dzz,
Axx, Axy, Axz, Ayy, Ayz, Azz,
Gamx, Gamy, Gamz, Lap, betax, betay, betaz, dtSfx, dtSfy, dtSfz,
chi_rhs, trK_rhs,
gxx_rhs, gxy_rhs, gxz_rhs, gyy_rhs, gyz_rhs, gzz_rhs,
Axx_rhs, Axy_rhs, Axz_rhs, Ayy_rhs, Ayz_rhs, Azz_rhs,
Gamx_rhs, Gamy_rhs, Gamz_rhs, Lap_rhs, betax_rhs, betay_rhs, betaz_rhs,
dtSfx_rhs, dtSfy_rhs, dtSfz_rhs,
rho, Sx, Sy, Sz, Sxx, Sxy, Sxz, Syy, Syz, Szz,
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,
Gmx_Res, Gmy_Res, Gmz_Res,
Symmetry, Lev, eps, co);
if (!gont) {
/* ==== 4. Advection terms for EM fields ==== */
lopsided(ex, X, Y, Z, Kpsi, Kpsi_rhs, betax, betay, betaz, Symmetry, SSS);
lopsided(ex, X, Y, Z, Kphi, Kphi_rhs, betax, betay, betaz, Symmetry, SSS);
lopsided(ex, X, Y, Z, Ex, Ex_rhs, betax, betay, betaz, Symmetry, ASS);
lopsided(ex, X, Y, Z, Ey, Ey_rhs, betax, betay, betaz, Symmetry, SAS);
lopsided(ex, X, Y, Z, Ez, Ez_rhs, betax, betay, betaz, Symmetry, SSA);
lopsided(ex, X, Y, Z, Bx, Bx_rhs, betax, betay, betaz, Symmetry, SAA);
lopsided(ex, X, Y, Z, By, By_rhs, betax, betay, betaz, Symmetry, ASA);
lopsided(ex, X, Y, Z, Bz, Bz_rhs, betax, betay, betaz, Symmetry, AAS);
/* ==== 5. KO dissipation for EM fields ==== */
if (eps > ZEO) {
kodis(ex, X, Y, Z, Kpsi, Kpsi_rhs, SSS, Symmetry, eps);
kodis(ex, X, Y, Z, Kphi, Kphi_rhs, SSS, Symmetry, eps);
kodis(ex, X, Y, Z, Ex, Ex_rhs, ASS, Symmetry, eps);
kodis(ex, X, Y, Z, Ey, Ey_rhs, SAS, Symmetry, eps);
kodis(ex, X, Y, Z, Ez, Ez_rhs, SSA, Symmetry, eps);
kodis(ex, X, Y, Z, Bx, Bx_rhs, SAA, Symmetry, eps);
kodis(ex, X, Y, Z, By, By_rhs, ASA, Symmetry, eps);
kodis(ex, X, Y, Z, Bz, Bz_rhs, AAS, Symmetry, eps);
}
/* ==== 6. NaN check ==== */
for (int i = 0; i < all; ++i) {
if (!isfinite(Ex_rhs[i]+Ey_rhs[i]+Ez_rhs[i]+Bx_rhs[i]+By_rhs[i]+Bz_rhs[i]+Kpsi_rhs[i]+Kphi_rhs[i])) {
gont = 1; break;
}
}
} /* inner if (!gont) */
} /* outer if (!gont) */
free(chix);free(chiy);free(chiz);
free(Exx);free(Exy);free(Exz);free(Eyx);free(Eyy);free(Eyz);free(Ezx);free(Ezy);free(Ezz);
free(Bxx);free(Bxy);free(Bxz);free(Byx);free(Byy);free(Byz);free(Bzx);free(Bzy);free(Bzz);
free(Kpsix);free(Kpsiy);free(Kpsiz);
free(Kphix);free(Kphiy);free(Kphiz);
free(Lapx);free(Lapy);free(Lapz);
free(betaxx);free(betaxy);free(betaxz);free(betayx);free(betayy);free(betayz);free(betazx);free(betazy);free(betazz);
free(gxxx);free(gxxy);free(gxxz);free(gxyx);free(gxyy);free(gxyz);free(gxzx);free(gxzy);free(gxzz);
free(gyyx);free(gyyy);free(gyyz);free(gyzx);free(gyzy);free(gyzz);free(gzzx);free(gzzy);free(gzzz);
free(gupxx);free(gupxy);free(gupxz);free(gupyy);free(gupyz);free(gupzz);
return gont;
}

View File

@@ -0,0 +1,169 @@
#include "macrodef.h"
#include "bssn_rhs.h"
#include "share_func.h"
#include "tool.h"
#include <vector>
namespace
{
// Reuse the temporary workspace across block calls to avoid repeated heap churn
// in the EScalar wrapper. MPI ranks execute this path sequentially, so a single
// process-local buffer is sufficient here.
std::vector<double> g_escalar_tmp_store;
}
#ifdef fortran1
#define f_frpotential frpotential
#endif
#ifdef fortran2
#define f_frpotential FRPOTENTIAL
#endif
#ifdef fortran3
#define f_frpotential frpotential_
#endif
extern "C"
{
void f_frpotential(int *, double *, double *, double *);
}
int f_compute_rhs_bssn_escalar_c(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 *Sphi, double *Spi,
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 *Sphi_rhs, double *Spi_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)
{
const int nx = ex[0], ny = ex[1], nz = ex[2];
const int all = nx * ny * nz;
const size_t workspace_size = size_t(all) * 17;
if (g_escalar_tmp_store.size() < workspace_size)
g_escalar_tmp_store.resize(workspace_size);
double *tmp_ptr = g_escalar_tmp_store.data();
auto alloc_tmp = [&](int n = 1) -> double *
{
double *ptr = tmp_ptr;
tmp_ptr += size_t(all) * n;
return ptr;
};
double *chix = alloc_tmp(), *chiy = alloc_tmp(), *chiz = alloc_tmp();
double *Kx = alloc_tmp(), *Ky = alloc_tmp(), *Kz = alloc_tmp();
double *fxx = alloc_tmp(), *fxy = alloc_tmp(), *fxz = alloc_tmp();
double *fyy = alloc_tmp(), *fyz = alloc_tmp(), *fzz = alloc_tmp();
double *Lapx = alloc_tmp(), *Lapy = alloc_tmp(), *Lapz = alloc_tmp();
double *V = alloc_tmp(), *dVdSphi = alloc_tmp();
const double ZEO = 0.0, ONE = 1.0, TWO = 2.0, HALF = 0.5;
const double SSS[3] = {1.0, 1.0, 1.0};
fderivs(ex, chi, chix, chiy, chiz, X, Y, Z, 1.0, 1.0, 1.0, Symmetry, Lev);
fderivs(ex, Lap, Lapx, Lapy, Lapz, X, Y, Z, 1.0, 1.0, 1.0, Symmetry, Lev);
fderivs(ex, Sphi, Kx, Ky, Kz, X, Y, Z, 1.0, 1.0, 1.0, Symmetry, Lev);
fdderivs(ex, Sphi, fxx, fxy, fxz, fyy, fyz, fzz, X, Y, Z, 1.0, 1.0, 1.0, Symmetry, Lev);
f_frpotential(ex, Sphi, V, dVdSphi);
for (int i = 0; i < all; ++i)
{
const double alpn1 = Lap[i] + ONE;
const double chin1 = chi[i] + ONE;
const double gxx = dxx[i] + ONE;
const double gyy = dyy[i] + ONE;
const double gzz = dzz[i] + ONE;
const double det = gxx * gyy * gzz + gxy[i] * gyz[i] * gxz[i] + gxz[i] * gxy[i] * gyz[i]
- gxz[i] * gyy * gxz[i] - gxy[i] * gxy[i] * gzz - gxx * gyz[i] * gyz[i];
const double gupxx = (gyy * gzz - gyz[i] * gyz[i]) / det;
const double gupxy = -(gxy[i] * gzz - gyz[i] * gxz[i]) / det;
const double gupxz = (gxy[i] * gyz[i] - gyy * gxz[i]) / det;
const double gupyy = (gxx * gzz - gxz[i] * gxz[i]) / det;
const double gupyz = -(gxx * gyz[i] - gxy[i] * gxz[i]) / det;
const double gupzz = (gxx * gyy - gxy[i] * gxy[i]) / det;
Sphi_rhs[i] = alpn1 * Spi[i];
Spi_rhs[i] = gupxx * fxx[i] + gupyy * fyy[i] + gupzz * fzz[i]
+ TWO * (gupxy * fxy[i] + gupxz * fxz[i] + gupyz * fyz[i])
- ((Gamx[i] + (gupxx * chix[i] + gupxy * chiy[i] + gupxz * chiz[i]) / TWO / chin1) * Kx[i]
+ (Gamy[i] + (gupxy * chix[i] + gupyy * chiy[i] + gupyz * chiz[i]) / TWO / chin1) * Ky[i]
+ (Gamz[i] + (gupxz * chix[i] + gupyz * chiy[i] + gupzz * chiz[i]) / TWO / chin1) * Kz[i]);
Spi_rhs[i] = Spi_rhs[i] * alpn1
+ gupxx * Lapx[i] * Kx[i] + gupxy * Lapx[i] * Ky[i] + gupxz * Lapx[i] * Kz[i]
+ gupxy * Lapy[i] * Kx[i] + gupyy * Lapy[i] * Ky[i] + gupyz * Lapy[i] * Kz[i]
+ gupxz * Lapz[i] * Kx[i] + gupyz * Lapz[i] * Ky[i] + gupzz * Lapz[i] * Kz[i];
Spi_rhs[i] = Spi_rhs[i] * chin1 + alpn1 * (trK[i] * Spi[i] - dVdSphi[i]);
rho[i] = chin1 * ((gupxx * Kx[i] * Kx[i] + gupyy * Ky[i] * Ky[i] + gupzz * Kz[i] * Kz[i]) * HALF
+ gupxy * Kx[i] * Ky[i] + gupxz * Kx[i] * Kz[i] + gupyz * Ky[i] * Kz[i])
+ Spi[i] * Spi[i] * HALF + V[i];
Sx[i] = -Spi[i] * Kx[i];
Sy[i] = -Spi[i] * Ky[i];
Sz[i] = -Spi[i] * Kz[i];
const double pressure = (rho[i] - Spi[i] * Spi[i]) / chin1;
Sxx[i] = Kx[i] * Kx[i] - pressure * gxx;
Sxy[i] = Kx[i] * Ky[i] - pressure * gxy[i];
Sxz[i] = Kx[i] * Kz[i] - pressure * gxz[i];
Syy[i] = Ky[i] * Ky[i] - pressure * gyy;
Syz[i] = Ky[i] * Kz[i] - pressure * gyz[i];
Szz[i] = Kz[i] * Kz[i] - pressure * gzz;
}
if (f_compute_rhs_bssn(ex, T, X, Y, Z,
chi, trK,
dxx, gxy, gxz, dyy, gyz, dzz,
Axx, Axy, Axz, Ayy, Ayz, Azz,
Gamx, Gamy, Gamz,
Lap, betax, betay, betaz,
dtSfx, dtSfy, dtSfz,
chi_rhs, trK_rhs,
gxx_rhs, gxy_rhs, gxz_rhs, gyy_rhs, gyz_rhs, gzz_rhs,
Axx_rhs, Axy_rhs, Axz_rhs, Ayy_rhs, Ayz_rhs, Azz_rhs,
Gamx_rhs, Gamy_rhs, Gamz_rhs,
Lap_rhs, betax_rhs, betay_rhs, betaz_rhs,
dtSfx_rhs, dtSfy_rhs, dtSfz_rhs,
rho, Sx, Sy, Sz,
Sxx, Sxy, Sxz, Syy, Syz, Szz,
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,
Gmx_Res, Gmy_Res, Gmz_Res,
Symmetry, Lev, eps, co))
return 1;
lopsided_kodis(ex, X, Y, Z, Sphi, Sphi_rhs, betax, betay, betaz, Symmetry, SSS, eps);
lopsided_kodis(ex, X, Y, Z, Spi, Spi_rhs, betax, betay, betaz, Symmetry, SSS, eps);
for (int i = 0; i < all; ++i)
{
if (Sphi_rhs[i] != Sphi_rhs[i] || Spi_rhs[i] != Spi_rhs[i] || rho[i] != rho[i])
return 1;
}
return 0;
}

View File

@@ -1,73 +1,73 @@
#ifndef BSSN_GPU_H_ #ifndef BSSN_GPU_H_
#define BSSN_GPU_H_ #define BSSN_GPU_H_
#include "bssn_macro.h" #include "bssn_macro.h"
#include "macrodef.fh" #include "macrodef.fh"
#define DEVICE_ID 0 #define DEVICE_ID 0
// #define DEVICE_ID_BY_MPI_RANK // #define DEVICE_ID_BY_MPI_RANK
#define GRID_DIM 256 #define GRID_DIM 256
#define BLOCK_DIM 128 #define BLOCK_DIM 128
#define _FH2_(i, j, k) fh[(i) + (j) * _1D_SIZE[2] + (k) * _2D_SIZE[2]] #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 _FH3_(i, j, k) fh[(i) + (j) * _1D_SIZE[3] + (k) * _2D_SIZE[3]]
#define pow2(x) ((x) * (x)) #define pow2(x) ((x) * (x))
#define TimeBetween(a, b) ((b.tv_sec - a.tv_sec) + (b.tv_usec - a.tv_usec) / 1000000.0f) #define TimeBetween(a, b) ((b.tv_sec - a.tv_sec) + (b.tv_usec - a.tv_usec) / 1000000.0f)
#define M_ metac. #define M_ metac.
#define Mh_ meta-> #define Mh_ meta->
#define Ms_ metassc. #define Ms_ metassc.
#define Msh_ metass-> #define Msh_ metass->
// #define TIMING // #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 #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 */ /** main function */
int gpu_rhs(int calledby, int mpi_rank, int *ex, double &T, int gpu_rhs(int calledby, int mpi_rank, int *ex, double &T,
double *X, double *Y, double *Z, double *X, double *Y, double *Z,
double *chi, double *trK, double *chi, double *trK,
double *dxx, double *gxy, double *gxz, double *dyy, double *gyz, double *dzz, double *dxx, double *gxy, double *gxz, double *dyy, double *gyz, double *dzz,
double *Axx, double *Axy, double *Axz, double *Ayy, double *Ayz, double *Azz, double *Axx, double *Axy, double *Axz, double *Ayy, double *Ayz, double *Azz,
double *Gamx, double *Gamy, double *Gamz, double *Gamx, double *Gamy, double *Gamz,
double *Lap, double *betax, double *betay, double *betaz, double *Lap, double *betax, double *betay, double *betaz,
double *dtSfx, double *dtSfy, double *dtSfz, double *dtSfx, double *dtSfy, double *dtSfz,
double *chi_rhs, double *trK_rhs, double *chi_rhs, double *trK_rhs,
double *gxx_rhs, double *gxy_rhs, double *gxz_rhs, double *gyy_rhs, double *gyz_rhs, double *gzz_rhs, double *gxx_rhs, double *gxy_rhs, double *gxz_rhs, double *gyy_rhs, double *gyz_rhs, double *gzz_rhs,
double *Axx_rhs, double *Axy_rhs, double *Axz_rhs, double *Ayy_rhs, double *Ayz_rhs, double *Azz_rhs, double *Axx_rhs, double *Axy_rhs, double *Axz_rhs, double *Ayy_rhs, double *Ayz_rhs, double *Azz_rhs,
double *Gamx_rhs, double *Gamy_rhs, double *Gamz_rhs, double *Gamx_rhs, double *Gamy_rhs, double *Gamz_rhs,
double *Lap_rhs, double *betax_rhs, double *betay_rhs, double *betaz_rhs, double *Lap_rhs, double *betax_rhs, double *betay_rhs, double *betaz_rhs,
double *dtSfx_rhs, double *dtSfy_rhs, double *dtSfz_rhs, double *dtSfx_rhs, double *dtSfy_rhs, double *dtSfz_rhs,
double *rho, double *Sx, double *Sy, double *Sz, double *Sxx, double *rho, double *Sx, double *Sy, double *Sz, double *Sxx,
double *Sxy, double *Sxz, double *Syy, double *Syz, double *Szz, double *Sxy, double *Sxz, double *Syy, double *Syz, double *Szz,
double *Gamxxx, double *Gamxxy, double *Gamxxz, double *Gamxyy, double *Gamxyz, double *Gamxzz, double *Gamxxx, double *Gamxxy, double *Gamxxz, double *Gamxyy, double *Gamxyz, double *Gamxzz,
double *Gamyxx, double *Gamyxy, double *Gamyxz, double *Gamyyy, double *Gamyyz, double *Gamyzz, double *Gamyxx, double *Gamyxy, double *Gamyxz, double *Gamyyy, double *Gamyyz, double *Gamyzz,
double *Gamzxx, double *Gamzxy, double *Gamzxz, double *Gamzyy, double *Gamzyz, double *Gamzzz, double *Gamzxx, double *Gamzxy, double *Gamzxz, double *Gamzyy, double *Gamzyz, double *Gamzzz,
double *Rxx, double *Rxy, double *Rxz, double *Ryy, double *Ryz, double *Rzz, double *Rxx, double *Rxy, double *Rxz, double *Ryy, double *Ryz, double *Rzz,
double *ham_Res, double *movx_Res, double *movy_Res, double *movz_Res, double *ham_Res, double *movx_Res, double *movy_Res, double *movz_Res,
double *Gmx_Res, double *Gmy_Res, double *Gmz_Res, double *Gmx_Res, double *Gmy_Res, double *Gmz_Res,
int &Symmetry, int &Lev, double &eps, int &co); int &Symmetry, int &Lev, double &eps, int &co);
int gpu_rhs_ss(RHS_SS_PARA); int gpu_rhs_ss(RHS_SS_PARA);
/** Init GPU side data in GPUMeta. */ /** Init GPU side data in GPUMeta. */
// void init_fluid_meta_gpu(GPUMeta *gpu_meta); // void init_fluid_meta_gpu(GPUMeta *gpu_meta);
#endif #endif

View File

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

View File

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

View File

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

View File

@@ -1,244 +1,292 @@
#ifndef BSSN_H #ifndef BSSN_H
#define BSSN_H #define BSSN_H
#ifdef fortran1 #ifdef fortran1
#define f_compute_rhs_bssn compute_rhs_bssn #define f_compute_rhs_bssn compute_rhs_bssn
#define f_compute_rhs_bssn_ss compute_rhs_bssn_ss #define f_compute_rhs_bssn_ss compute_rhs_bssn_ss
#define f_compute_rhs_bssn_escalar compute_rhs_bssn_escalar #define f_compute_rhs_bssn_escalar compute_rhs_bssn_escalar
#define f_compute_rhs_bssn_escalar_ss compute_rhs_bssn_escalar_ss #define f_compute_rhs_bssn_escalar_ss compute_rhs_bssn_escalar_ss
#define f_compute_rhs_Z4c compute_rhs_z4c #define f_compute_rhs_Z4c compute_rhs_z4c
#define f_compute_rhs_Z4cnot compute_rhs_z4cnot #define f_compute_rhs_Z4cnot compute_rhs_z4cnot
#define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss #define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss
#define f_compute_constraint_fr compute_constraint_fr #define f_compute_constraint_fr compute_constraint_fr
#endif #endif
#ifdef fortran2 #ifdef fortran2
#define f_compute_rhs_bssn COMPUTE_RHS_BSSN #define f_compute_rhs_bssn COMPUTE_RHS_BSSN
#define f_compute_rhs_bssn_ss COMPUTE_RHS_BSSN_SS #define f_compute_rhs_bssn_ss COMPUTE_RHS_BSSN_SS
#define f_compute_rhs_bssn_escalar COMPUTE_RHS_BSSN_ESCALAR #define f_compute_rhs_bssn_escalar COMPUTE_RHS_BSSN_ESCALAR
#define f_compute_rhs_bssn_escalar_ss COMPUTE_RHS_BSSN_ESCALAR_SS #define f_compute_rhs_bssn_escalar_ss COMPUTE_RHS_BSSN_ESCALAR_SS
#define f_compute_rhs_Z4c COMPUTE_RHS_Z4C #define f_compute_rhs_Z4c COMPUTE_RHS_Z4C
#define f_compute_rhs_Z4cnot COMPUTE_RHS_Z4CNOT #define f_compute_rhs_Z4cnot COMPUTE_RHS_Z4CNOT
#define f_compute_rhs_Z4c_ss COMPUTE_RHS_Z4C_SS #define f_compute_rhs_Z4c_ss COMPUTE_RHS_Z4C_SS
#define f_compute_constraint_fr COMPUTE_CONSTRAINT_FR #define f_compute_constraint_fr COMPUTE_CONSTRAINT_FR
#endif #endif
#ifdef fortran3 #ifdef fortran3
#define f_compute_rhs_bssn compute_rhs_bssn_ #define f_compute_rhs_bssn compute_rhs_bssn_
#define f_compute_rhs_bssn_ss compute_rhs_bssn_ss_ #define f_compute_rhs_bssn_ss compute_rhs_bssn_ss_
#define f_compute_rhs_bssn_escalar compute_rhs_bssn_escalar_ #define f_compute_rhs_bssn_escalar compute_rhs_bssn_escalar_
#define f_compute_rhs_bssn_escalar_ss compute_rhs_bssn_escalar_ss_ #define f_compute_rhs_bssn_escalar_ss compute_rhs_bssn_escalar_ss_
#define f_compute_rhs_Z4c compute_rhs_z4c_ #define f_compute_rhs_Z4c compute_rhs_z4c_
#define f_compute_rhs_Z4cnot compute_rhs_z4cnot_ #define f_compute_rhs_Z4cnot compute_rhs_z4cnot_
#define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss_ #define f_compute_rhs_Z4c_ss compute_rhs_z4c_ss_
#define f_compute_constraint_fr compute_constraint_fr_ #define f_compute_constraint_fr compute_constraint_fr_
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
void f_bssn_rhs_kernel_timing_reset(); void f_bssn_rhs_kernel_timing_reset();
int f_bssn_rhs_kernel_timing_bucket_count(); int f_bssn_rhs_kernel_timing_bucket_count();
const double *f_bssn_rhs_kernel_timing_local_seconds(); const double *f_bssn_rhs_kernel_timing_local_seconds();
const char *f_bssn_rhs_kernel_timing_label(int); const char *f_bssn_rhs_kernel_timing_label(int);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
extern "C" extern "C"
{ {
int f_compute_rhs_bssn(int *, double &, double *, double *, double *, // ex,T,X,Y,Z int f_compute_rhs_bssn(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // chi, trK double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // Gam double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, double *, double *, double *, double *, // constraint violation
int &, int &, double &, int &); int &, int &, double &, int &);
} }
extern "C" int f_compute_rhs_bssn_escalar_c(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
{ double *, double *, // chi, trK
int f_compute_rhs_bssn_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, // X,Y,Z double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // drhodx,drhody,drhodz double *, double *, double *, // Gam
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, // dRdx,dRdy,dRdz double *, double *, // Sphi, Spi
double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double *, double *, double *, double *, double *, double *, // Aij
double *, double *, // chi, trK double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // Aij double *, double *, // Sphi, Spi
double *, double *, double *, // Gam double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, // chi, trK double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, // Gam double *, double *, double *, double *, double *, double *, double *, // constraint violation
double *, double *, double *, double *, double *, double *, double *, // Gauge int &, int &, double &, int &);
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, // Christoffel extern "C"
double *, double *, double *, double *, double *, double *, // Christoffel {
double *, double *, double *, double *, double *, double *, // Christoffel int f_compute_rhs_bssn_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, // X,Y,Z
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, // drhodx,drhody,drhodz
int &, int &, double &, int &, int &); double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
} double *, double *, double *, // dRdx,dRdy,dRdz
double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz
extern "C" double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz
{ double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz
int f_compute_rhs_bssn_escalar(int *, double &, double *, double *, double *, // ex,T,X,Y,Z double *, double *, // chi, trK
double *, double *, // chi, trK double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, // Gam
double *, double *, double *, // Gam double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, // chi, trK
double *, double *, // Sphi, Spi double *, double *, double *, double *, double *, double *, // gij
double *, double *, // chi, trK double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, // Gam double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, // Sphi, Spi double *, double *, double *, double *, double *, double *, // Christoffel
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 *, // Ricci
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, double *, double *, double *, double *, // constraint violation
double *, double *, double *, double *, double *, double *, // Christoffel int &, int &, double &, int &, int &);
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(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
extern "C" double *, double *, // chi, trK
{ double *, double *, double *, double *, double *, double *, // gij
int f_compute_rhs_bssn_escalar_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // X,Y,Z double *, double *, double *, // Gam
double *, double *, double *, // drhodx,drhody,drhodz double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz double *, double *, // Sphi, Spi
double *, double *, double *, // dRdx,dRdy,dRdz double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double *, double *, double *, // Gam
double *, double *, // chi, trK double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // gij double *, double *, // Sphi, Spi
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, // Gam double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, // Sphi,Spi double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, // chi, trK double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, double *, // constraint violation
double *, double *, double *, double *, double *, double *, // Aij int &, int &, double &, int &);
double *, double *, double *, // Gam }
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, // Sphi,Spi extern "C"
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy {
double *, double *, double *, double *, double *, double *, // Christoffel int f_compute_rhs_bssn_escalar_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, // X,Y,Z
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, // drhodx,drhody,drhodz
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, // dRdx,dRdy,dRdz
int &, int &, double &, int &, int &); 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
extern "C" double *, double *, // chi, trK
{ double *, double *, double *, double *, double *, double *, // gij
int f_compute_rhs_Z4c(int *, double &, double *, double *, double *, // ex,T,X,Y,Z double *, double *, double *, double *, double *, double *, // Aij
double *, double *, // chi, trK double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // Aij double *, double *, // Sphi,Spi
double *, double *, double *, // Gam double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, // gij
double *, // Z4 double *, double *, double *, double *, double *, double *, // Aij
double *, double *, // chi, trK double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // Aij double *, double *, // Sphi,Spi
double *, double *, double *, // Gam double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, // Christoffel
double *, // Z4 double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // constraint violation
double *, double *, double *, double *, double *, double *, int &, int &, double &, int &, int &);
double *, double *, double *, double *, double *, double *, }
double *, double *, double *, double *, double *, double *, double *,
int &, int &, double &, int &); extern "C"
} {
int f_compute_rhs_Z4c(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
extern "C" double *, double *, // chi, trK
{ double *, double *, double *, double *, double *, double *, // gij
int f_compute_rhs_Z4c_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, // X,Y,Z double *, double *, double *, // Gam
double *, double *, double *, // drhodx,drhody,drhodz double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, // dsigmadx,dsigmady,dsigmadz double *, // Z4
double *, double *, double *, // dRdx,dRdy,dRdz double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // drhodxx,drhodxy,drhodxz,drhodyy,drhodyz,drhodzz double *, double *, double *, double *, double *, double *, // gij
double *, double *, double *, double *, double *, double *, // dsigmadxx,dsigmadxy,dsigmadxz,dsigmadyy,dsigmadyz,dsigmadzz double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, double *, double *, double *, // dRdxx,dRdxy,dRdxz,dRdyy,dRdyz,dRdzz double *, double *, double *, // Gam
double *, double *, // chi, trK double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // gij double *, // Z4
double *, double *, double *, double *, double *, double *, // Aij double *, double *, double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, // Gam double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *,
double *, // TZ double *, double *, double *, double *, double *, double *,
double *, double *, // chi, trK double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, // Aij int &, int &, double &, int &);
double *, double *, double *, // Gam }
double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, // TZ extern "C"
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy {
double *, double *, double *, double *, double *, double *, // Christoffel int f_compute_rhs_Z4c_ss(int *, double &, double *, double *, double *, // ex,T,rho,sigma,R
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, // X,Y,Z
double *, double *, double *, double *, double *, double *, // Christoffel double *, double *, double *, // drhodx,drhody,drhodz
double *, double *, double *, double *, double *, double *, // Ricci double *, double *, double *, // dsigmadx,dsigmady,dsigmadz
double *, double *, double *, double *, double *, double *, double *, // constraint violation double *, double *, double *, // dRdx,dRdy,dRdz
int &, int &, double &, int &, int &); 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
extern "C" double *, double *, // chi, trK
{ double *, double *, double *, double *, double *, double *, // gij
int f_compute_rhs_Z4cnot(int *, double &, double *, double *, double *, // ex,T,X,Y,Z double *, double *, double *, double *, double *, double *, // Aij
double *, double *, // chi, trK double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // Aij double *, // TZ
double *, double *, double *, // Gam double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, // gij
double *, // Z4 double *, double *, double *, double *, double *, double *, // Aij
double *, double *, // chi, trK double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // Aij double *, // TZ
double *, double *, double *, // Gam double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // stress-energy
double *, double *, double *, double *, double *, double *, double *, // Gauge double *, double *, double *, double *, double *, double *, // Christoffel
double *, // Z4 double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // Christoffel
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // Ricci
double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, // constraint violation
double *, double *, double *, double *, double *, double *, int &, int &, double &, int &, int &);
double *, double *, double *, double *, double *, double *, }
double *, double *, double *, double *, double *, double *, double *,
int &, int &, double &, int &, double &); extern "C"
} {
int f_compute_rhs_Z4cnot(int *, double &, double *, double *, double *, // ex,T,X,Y,Z
extern "C" double *, double *, // chi, trK
{ double *, double *, double *, double *, double *, double *, // gij
void f_compute_constraint_fr(int *, double *, double *, double *, // ex,X,Y,Z double *, double *, double *, double *, double *, double *, // Aij
double *, double *, double *, double *, // chi, trK,rho,Sphi double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, // gij double *, double *, double *, double *, double *, double *, double *, // Gauge
double *, double *, double *, double *, double *, double *, // Aij double *, // Z4
double *, double *, double *, double *, double *, double *, // Rij double *, double *, // chi, trK
double *, double *, double *, double *, double *, double *, // Sij double *, double *, double *, double *, double *, double *, // gij
double *); double *, double *, double *, double *, double *, double *, // Aij
} // FR_cons double *, double *, double *, // Gam
double *, double *, double *, double *, double *, double *, double *, // Gauge
#endif /* BSSN_H */ 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
// BSSN-EM C kernel (replaces empart.f90 + bssn_rhs.f90 for BSSN+Maxwell)
int f_compute_rhs_bssn_em_c(int *, double &, double *, double *, double *,
double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *,
double *, double *,
double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *, double *, double *,
double *, double *, double *,
double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
double *, double *, double *, double *, double *, double *,
int &, int &, double &, int &);
#endif /* BSSN_H */

View File

@@ -1075,6 +1075,10 @@ int f_compute_rhs_bssn(int *ex, double &T,
} }
#endif #endif
#if (GAUGE == 2 || GAUGE == 3 || GAUGE == 4 || GAUGE == 5)
fderivs(ex,chi,dtSfx_rhs,dtSfy_rhs,dtSfz_rhs,X,Y,Z,SYM,SYM,SYM,Symmetry,Lev);
#endif
for (int i = 0; i < all; i += 1) { for (int i = 0; i < all; i += 1) {
#if (GAUGE == 0) #if (GAUGE == 0)
betax_rhs[i] = FF * dtSfx[i]; betax_rhs[i] = FF * dtSfx[i];
@@ -1160,11 +1164,17 @@ int f_compute_rhs_bssn(int *ex, double &T,
lopsided_kodis(ex,X,Y,Z,gyz,gyz_rhs,betax,betay,betaz,Symmetry,SAA,eps); lopsided_kodis(ex,X,Y,Z,gyz,gyz_rhs,betax,betay,betaz,Symmetry,SAA,eps);
lopsided_kodis(ex,X,Y,Z,betaz,betaz_rhs,betax,betay,betaz,Symmetry,SSA,eps); lopsided_kodis(ex,X,Y,Z,betaz,betaz_rhs,betax,betay,betaz,Symmetry,SSA,eps);
lopsided_kodis(ex,X,Y,Z,dzz,gzz_rhs,betax,betay,betaz,Symmetry,SSS,eps); lopsided_kodis(ex,X,Y,Z,dzz,gzz_rhs,betax,betay,betaz,Symmetry,SSS,eps);
#if (GAUGE == 0 || GAUGE == 2 || GAUGE == 3 || GAUGE == 6 || GAUGE == 7)
lopsided_kodis(ex,X,Y,Z,dtSfx,dtSfx_rhs,betax,betay,betaz,Symmetry,ASS,eps); lopsided_kodis(ex,X,Y,Z,dtSfx,dtSfx_rhs,betax,betay,betaz,Symmetry,ASS,eps);
#endif
lopsided_kodis(ex,X,Y,Z,Axx,Axx_rhs,betax,betay,betaz,Symmetry,SSS,eps); lopsided_kodis(ex,X,Y,Z,Axx,Axx_rhs,betax,betay,betaz,Symmetry,SSS,eps);
#if (GAUGE == 0 || GAUGE == 2 || GAUGE == 3 || GAUGE == 6 || GAUGE == 7)
lopsided_kodis(ex,X,Y,Z,dtSfy,dtSfy_rhs,betax,betay,betaz,Symmetry,SAS,eps); lopsided_kodis(ex,X,Y,Z,dtSfy,dtSfy_rhs,betax,betay,betaz,Symmetry,SAS,eps);
#endif
lopsided_kodis(ex,X,Y,Z,Axy,Axy_rhs,betax,betay,betaz,Symmetry,AAS,eps); lopsided_kodis(ex,X,Y,Z,Axy,Axy_rhs,betax,betay,betaz,Symmetry,AAS,eps);
#if (GAUGE == 0 || GAUGE == 2 || GAUGE == 3 || GAUGE == 6 || GAUGE == 7)
lopsided_kodis(ex,X,Y,Z,dtSfz,dtSfz_rhs,betax,betay,betaz,Symmetry,SSA,eps); lopsided_kodis(ex,X,Y,Z,dtSfz,dtSfz_rhs,betax,betay,betaz,Symmetry,SSA,eps);
#endif
lopsided_kodis(ex,X,Y,Z,Axz,Axz_rhs,betax,betay,betaz,Symmetry,ASA,eps); lopsided_kodis(ex,X,Y,Z,Axz,Axz_rhs,betax,betay,betaz,Symmetry,ASA,eps);
lopsided_kodis(ex,X,Y,Z,Ayy,Ayy_rhs,betax,betay,betaz,Symmetry,SSS,eps); lopsided_kodis(ex,X,Y,Z,Ayy,Ayy_rhs,betax,betay,betaz,Symmetry,SSS,eps);
lopsided_kodis(ex,X,Y,Z,Ayz,Ayz_rhs,betax,betay,betaz,Symmetry,SAA,eps); lopsided_kodis(ex,X,Y,Z,Ayz,Ayz_rhs,betax,betay,betaz,Symmetry,SAA,eps);

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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