[TEST]UPSTREAM: Pick some source changes from 48080d0a97
* Sync new folder structure
This commit is contained in:
221
AMSS_NCKU_source/Two_Puncture/TwoPunctureABE.C
Normal file
221
AMSS_NCKU_source/Two_Puncture/TwoPunctureABE.C
Normal file
@@ -0,0 +1,221 @@
|
||||
|
||||
#ifdef newc
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <strstream>
|
||||
using namespace std;
|
||||
#else
|
||||
#include <iostream.h>
|
||||
#include <iomanip.h>
|
||||
#include <fstream.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include "TwoPunctures.h"
|
||||
|
||||
inline string &lTrim(string &ss)
|
||||
{
|
||||
string::iterator p = find_if(ss.begin(), ss.end(), not1(ptr_fun<int, int>(isspace)));
|
||||
ss.erase(ss.begin(), p);
|
||||
return ss;
|
||||
}
|
||||
inline string &rTrim(string &ss)
|
||||
{
|
||||
string::reverse_iterator p = find_if(ss.rbegin(), ss.rend(), not1(ptr_fun<int, int>(isspace)));
|
||||
ss.erase(p.base(), ss.end());
|
||||
return ss;
|
||||
}
|
||||
inline string &Trim(string &st)
|
||||
{
|
||||
lTrim(rTrim(st));
|
||||
return st;
|
||||
}
|
||||
|
||||
int parse_parts(string str, string &sgrp, string &skey, string &sval, int &ind)
|
||||
{
|
||||
int pos1, pos2;
|
||||
string s0;
|
||||
|
||||
ind = 0;
|
||||
|
||||
// remove comments
|
||||
str = str.substr(0, str.find("#"));
|
||||
if (rTrim(str).empty())
|
||||
return 0; // continue;
|
||||
|
||||
// parse {group, key, val}
|
||||
pos1 = str.find("::");
|
||||
pos2 = str.find("=");
|
||||
if (pos1 == string::npos || pos2 == string::npos)
|
||||
return -1;
|
||||
|
||||
s0 = str.substr(0, pos1);
|
||||
sgrp = lTrim(s0);
|
||||
s0 = str.substr(pos1 + 2, pos2 - pos1 - 2);
|
||||
skey = rTrim(s0);
|
||||
s0 = str.substr(pos2 + 1);
|
||||
sval = Trim(s0);
|
||||
|
||||
pos1 = sval.find("\"");
|
||||
pos2 = sval.rfind("\"");
|
||||
if (pos1 != string::npos)
|
||||
{
|
||||
sval = sval.substr(1, pos2 - 1);
|
||||
}
|
||||
|
||||
pos1 = skey.find("[");
|
||||
pos2 = skey.find("]");
|
||||
if (pos1 != string::npos)
|
||||
{
|
||||
s0 = skey.substr(0, pos1);
|
||||
ind = atoi(skey.substr(pos1 + 1, pos2 - pos1 - 1).c_str());
|
||||
skey = s0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
//=======================================
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
double mp, mm, b, Mp, Mm, admtol, Newtontol;
|
||||
int nA, nB, nphi, Newtonmaxit;
|
||||
double P_plusx, P_plusy, P_plusz;
|
||||
double P_minusx, P_minusy, P_minusz;
|
||||
double S_plusx, S_plusy, S_plusz;
|
||||
double S_minusx, S_minusy, S_minusz;
|
||||
// read parameter from file
|
||||
{
|
||||
const int LEN = 256;
|
||||
char pline[LEN];
|
||||
string str, sgrp, skey, sval;
|
||||
int sind;
|
||||
const char pname[] = "TwoPunctureinput.par";
|
||||
ifstream inf(pname, ifstream::in);
|
||||
if (!inf.good())
|
||||
{
|
||||
cout << "Can not open parameter file " << pname << endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (int i = 1; inf.good(); i++)
|
||||
{
|
||||
inf.getline(pline, LEN);
|
||||
str = pline;
|
||||
|
||||
int status = parse_parts(str, sgrp, skey, sval, sind);
|
||||
if (status == -1)
|
||||
{
|
||||
cout << "error reading parameter file " << pname << " in line " << i << endl;
|
||||
exit(0);
|
||||
}
|
||||
else if (status == 0)
|
||||
continue;
|
||||
// we assume input in Brugmann's convention
|
||||
if (sgrp == "ABE")
|
||||
{
|
||||
if (skey == "mm")
|
||||
mm = atof(sval.c_str());
|
||||
else if (skey == "mp")
|
||||
mp = atof(sval.c_str());
|
||||
else if (skey == "b")
|
||||
b = atof(sval.c_str());
|
||||
else if (skey == "P_plusx")
|
||||
P_plusy = -atof(sval.c_str());
|
||||
else if (skey == "P_plusy")
|
||||
P_plusx = atof(sval.c_str());
|
||||
else if (skey == "P_plusz")
|
||||
P_plusz = atof(sval.c_str());
|
||||
else if (skey == "P_minusx")
|
||||
P_minusy = -atof(sval.c_str());
|
||||
else if (skey == "P_minusy")
|
||||
P_minusx = atof(sval.c_str());
|
||||
else if (skey == "P_minusz")
|
||||
P_minusz = atof(sval.c_str());
|
||||
else if (skey == "S_plusx")
|
||||
S_plusy = -atof(sval.c_str());
|
||||
else if (skey == "S_plusy")
|
||||
S_plusx = atof(sval.c_str());
|
||||
else if (skey == "S_plusz")
|
||||
S_plusz = atof(sval.c_str());
|
||||
else if (skey == "S_minusx")
|
||||
S_minusy = -atof(sval.c_str());
|
||||
else if (skey == "S_minusy")
|
||||
S_minusx = atof(sval.c_str());
|
||||
else if (skey == "S_minusz")
|
||||
S_minusz = atof(sval.c_str());
|
||||
else if (skey == "Mp")
|
||||
Mp = atof(sval.c_str());
|
||||
else if (skey == "Mm")
|
||||
Mm = atof(sval.c_str());
|
||||
else if (skey == "admtol")
|
||||
admtol = atof(sval.c_str());
|
||||
else if (skey == "Newtontol")
|
||||
Newtontol = atof(sval.c_str());
|
||||
else if (skey == "nA")
|
||||
nA = atoi(sval.c_str());
|
||||
else if (skey == "nB")
|
||||
nB = atoi(sval.c_str());
|
||||
else if (skey == "nphi")
|
||||
nphi = atoi(sval.c_str());
|
||||
else if (skey == "Newtonmaxit")
|
||||
Newtonmaxit = atoi(sval.c_str());
|
||||
}
|
||||
}
|
||||
inf.close();
|
||||
}
|
||||
// echo parameters
|
||||
{
|
||||
cout << "///////////////////////////////////////////////////////////////" << endl;
|
||||
cout << " mp = " << mp << endl;
|
||||
cout << " mm = " << mm << endl;
|
||||
cout << " b = " << b << endl;
|
||||
cout << " P_plusx = " << P_plusx << endl;
|
||||
cout << " P_plusy = " << P_plusy << endl;
|
||||
cout << " P_plusz = " << P_plusz << endl;
|
||||
cout << " P_minusx = " << P_minusx << endl;
|
||||
cout << " P_minusy = " << P_minusy << endl;
|
||||
cout << " P_minusz = " << P_minusz << endl;
|
||||
cout << " S_plusx = " << S_plusx << endl;
|
||||
cout << " S_plusy = " << S_plusy << endl;
|
||||
cout << " S_plusz = " << S_plusz << endl;
|
||||
cout << " S_minusx = " << S_minusx << endl;
|
||||
cout << " S_minusy = " << S_minusy << endl;
|
||||
cout << " S_minusz = " << S_minusz << endl;
|
||||
cout << " Mp = " << Mp << endl;
|
||||
cout << " Mm = " << Mm << endl;
|
||||
cout << " admtol = " << admtol << endl;
|
||||
cout << " Newtontol = " << Newtontol << endl;
|
||||
cout << " nA = " << nA << endl;
|
||||
cout << " nB = " << nB << endl;
|
||||
cout << " nphi = " << nphi << endl;
|
||||
cout << "Newtonmaxit = " << Newtonmaxit << endl;
|
||||
cout << "///////////////////////////////////////////////////////////////" << endl;
|
||||
}
|
||||
//===========================the computation body====================================================
|
||||
TwoPunctures *ADM;
|
||||
|
||||
ADM = new TwoPunctures(mp, mm, b, P_plusx, P_plusy, P_plusz, S_plusx, S_plusy, S_plusz,
|
||||
P_minusx, P_minusy, P_minusz, S_minusx, S_minusy, S_minusz,
|
||||
nA, nB, nphi, Mp, Mm, admtol, Newtontol, Newtonmaxit);
|
||||
ADM->Solve();
|
||||
ADM->Save("Ansorg.psid");
|
||||
|
||||
delete ADM;
|
||||
//=======================caculation done=============================================================
|
||||
cout << "===============================================================" << endl;
|
||||
cout << "Initial data is successfully producede!!" << endl;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
3201
AMSS_NCKU_source/Two_Puncture/TwoPunctures.C
Normal file
3201
AMSS_NCKU_source/Two_Puncture/TwoPunctures.C
Normal file
File diff suppressed because it is too large
Load Diff
167
AMSS_NCKU_source/Two_Puncture/TwoPunctures.h
Normal file
167
AMSS_NCKU_source/Two_Puncture/TwoPunctures.h
Normal file
@@ -0,0 +1,167 @@
|
||||
#ifndef TWO_PUNCTURES_H
|
||||
#define TWO_PUNCTURES_H
|
||||
|
||||
#include <omp.h>
|
||||
|
||||
#define StencilSize 19
|
||||
#define N_PlaneRelax 1
|
||||
#define NRELAX 200
|
||||
#define Step_Relax 1
|
||||
|
||||
#define Pi 3.14159265358979323846264338328
|
||||
#define Pih 1.57079632679489661923132169164 /* Pi/2*/
|
||||
#define Piq 0.78539816339744830961566084582 /* Pi/4*/
|
||||
|
||||
#define TINY 1.0e-20
|
||||
|
||||
class TwoPunctures
|
||||
{
|
||||
public:
|
||||
typedef struct DERIVS
|
||||
{
|
||||
double *d0, *d1, *d2, *d3, *d11, *d12, *d13, *d22, *d23, *d33;
|
||||
} derivs;
|
||||
|
||||
double *F;
|
||||
derivs u, v;
|
||||
|
||||
private:
|
||||
double par_m_plus, par_m_minus, par_b;
|
||||
double par_P_plus[3], par_P_minus[3];
|
||||
double par_S_plus[3], par_S_minus[3];
|
||||
|
||||
int npoints_A, npoints_B, npoints_phi;
|
||||
|
||||
double target_M_plus, target_M_minus;
|
||||
|
||||
double admMass;
|
||||
|
||||
double adm_tol;
|
||||
|
||||
double Newton_tol;
|
||||
int Newton_maxit;
|
||||
|
||||
int ntotal;
|
||||
|
||||
// ===== Precomputed spectral derivative matrices =====
|
||||
double *D1_A, *D2_A;
|
||||
double *D1_B, *D2_B;
|
||||
double *DF1_phi, *DF2_phi;
|
||||
|
||||
// ===== Pre-allocated workspace for LineRelax (per-thread) =====
|
||||
int max_threads;
|
||||
double **ws_diag_be, **ws_e_be, **ws_f_be, **ws_b_be, **ws_x_be;
|
||||
double **ws_l_be, **ws_u_be, **ws_d_be, **ws_y_be;
|
||||
double **ws_diag_al, **ws_e_al, **ws_f_al, **ws_b_al, **ws_x_al;
|
||||
double **ws_l_al, **ws_u_al, **ws_d_al, **ws_y_al;
|
||||
|
||||
struct parameters
|
||||
{
|
||||
int nvar, n1, n2, n3;
|
||||
double b;
|
||||
};
|
||||
|
||||
public:
|
||||
TwoPunctures(double mp, double mm, double b, double P_plusx, double P_plusy, double P_plusz,
|
||||
double S_plusx, double S_plusy, double S_plusz,
|
||||
double P_minusx, double P_minusy, double P_minusz,
|
||||
double S_minusx, double S_minusy, double S_minusz,
|
||||
int nA, int nB, int nphi,
|
||||
double Mp, double Mm, double admtol, double Newtontol,
|
||||
int Newtonmaxit);
|
||||
~TwoPunctures();
|
||||
|
||||
// 02/07: New/modified methods
|
||||
void allocate_workspace();
|
||||
void free_workspace();
|
||||
void precompute_derivative_matrices();
|
||||
void build_cheb_deriv_matrices(int n, double *D1, double *D2);
|
||||
void build_fourier_deriv_matrices(int N, double *DF1, double *DF2);
|
||||
void Derivatives_AB3_MatMul(int nvar, int n1, int n2, int n3, derivs v);
|
||||
void ThomasAlgorithm_ws(int N, double *b, double *a, double *c, double *x, double *q,
|
||||
double *l, double *u_ws, double *d, double *y);
|
||||
void LineRelax_be_omp(double *dv,
|
||||
int const i, int const k, int const nvar,
|
||||
int const n1, int const n2, int const n3,
|
||||
double const *rhs, int const *ncols, int **cols,
|
||||
double **JFD, int tid);
|
||||
void LineRelax_al_omp(double *dv,
|
||||
int const j, int const k, int const nvar,
|
||||
int const n1, int const n2, int const n3,
|
||||
double const *rhs, int const *ncols,
|
||||
int **cols, double **JFD, int tid);
|
||||
void relax_omp(double *dv, int const nvar, int const n1, int const n2, int const n3,
|
||||
double const *rhs, int const *ncols, int **cols, double **JFD);
|
||||
|
||||
void Solve();
|
||||
void set_initial_guess(derivs v);
|
||||
int index(int i, int j, int k, int l, int a, int b, int c, int d);
|
||||
int *ivector(long nl, long nh);
|
||||
double *dvector(long nl, long nh);
|
||||
int **imatrix(long nrl, long nrh, long ncl, long nch);
|
||||
double **dmatrix(long nrl, long nrh, long ncl, long nch);
|
||||
double ***d3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
|
||||
void free_ivector(int *v, long nl, long nh);
|
||||
void free_dvector(double *v, long nl, long nh);
|
||||
void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
|
||||
void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
|
||||
void free_d3tensor(double ***t, long nrl, long nrh, long ncl, long nch,
|
||||
long ndl, long ndh);
|
||||
int minimum2(int i, int j);
|
||||
int minimum3(int i, int j, int k);
|
||||
int maximum2(int i, int j);
|
||||
int maximum3(int i, int j, int k);
|
||||
int pow_int(int mantisse, int exponent);
|
||||
void chebft_Zeros(double u[], int n, int inv);
|
||||
void chebft_Extremes(double u[], int n, int inv);
|
||||
void chder(double *c, double *cder, int n);
|
||||
double chebev(double a, double b, double c[], int m, double x);
|
||||
void fourft(double *u, int N, int inv);
|
||||
void fourder(double u[], double du[], int N);
|
||||
void fourder2(double u[], double d2u[], int N);
|
||||
double fourev(double *u, int N, double x);
|
||||
double norm1(double *v, int n);
|
||||
double norm2(double *v, int n);
|
||||
double scalarproduct(double *v, double *w, int n);
|
||||
double PunctIntPolAtArbitPosition(int ivar, int nvar, int n1,
|
||||
int n2, int n3, derivs v, double x, double y,
|
||||
double z);
|
||||
double PunctEvalAtArbitPosition(double *v, int ivar, double A, double B, double phi,
|
||||
int nvar, int n1, int n2, int n3);
|
||||
void AB_To_XR(int nvar, double A, double B, double *X, double *R,
|
||||
derivs U);
|
||||
void C_To_c(int nvar, double X, double R, double *x, double *r,
|
||||
derivs U);
|
||||
void rx3_To_xyz(int nvar, double x, double r, double phi,
|
||||
double *y, double *z, derivs U);
|
||||
void Derivatives_AB3(int nvar, int n1, int n2, int n3, derivs v);
|
||||
void Newton(int const nvar, int const n1, int const n2, int const n3,
|
||||
derivs v, double const tol, int const itmax);
|
||||
void F_of_v(int nvar, int n1, int n2, int n3, derivs v, double *F,
|
||||
derivs u);
|
||||
double norm_inf(double const *F, int const ntotal);
|
||||
int bicgstab(int const nvar, int const n1, int const n2, int const n3,
|
||||
derivs v, derivs dv, int const itmax, double const tol,
|
||||
double *normres);
|
||||
void allocate_derivs(derivs *v, int n);
|
||||
void free_derivs(derivs *v, int n);
|
||||
int Index(int ivar, int i, int j, int k, int nvar, int n1, int n2, int n3);
|
||||
void NonLinEquations(double rho_adm, double A, double B, double X, double R, double x, double r, double phi,
|
||||
double y, double z, derivs U, double *values);
|
||||
double BY_KKofxyz(double x, double y, double z);
|
||||
void SetMatrix_JFD(int nvar, int n1, int n2, int n3, derivs u, int *ncols, int **cols, double **Matrix);
|
||||
void J_times_dv(int nvar, int n1, int n2, int n3, derivs dv, double *Jdv, derivs u);
|
||||
void JFD_times_dv(int i, int j, int k, int nvar, int n1, int n2,
|
||||
int n3, derivs dv, derivs u, double *values);
|
||||
void LinEquations(double A, double B, double X, double R,
|
||||
double x, double r, double phi,
|
||||
double y, double z, derivs dU, derivs U, double *values);
|
||||
void ThomasAlgorithm(int N, double *b, double *a, double *c, double *x, double *q);
|
||||
void Save(char *fname);
|
||||
// provided by Vasileios Paschalidis (vpaschal@illinois.edu)
|
||||
double Spec_IntPolABphiFast(parameters par, double *v, int ivar, double A, double B, double phi);
|
||||
double Spec_IntPolFast(parameters par, int ivar, double *v, double x, double y, double z);
|
||||
void SpecCoef(parameters par, int ivar, double *v, double *cf);
|
||||
};
|
||||
|
||||
#endif /* TWO_PUNCTURES_H */
|
||||
Reference in New Issue
Block a user