22 real *density, total = 0.0, fulltotal=0.0;
24 density = array->Field;
28 for (j = 0; j < ns; j++) {
29 total +=
Surf[i]*density[j+i*ns];
49 real *density, *vtheta, total = 0.0, fulltotal=0.0;
51 density = Density->Field;
52 vtheta = Vtheta->Field;
56 for (j = 1; j < ns; j++) {
78 real *num, *denom, *res;
84 #pragma omp parallel for private(j,l)
85 for (i = 0; i <= nr; i++) {
86 for (j = 0; j < ns; j++) {
88 res[l] = num[l]/(denom[l]+1e-20);
103 for (i = 0; i < nr; i++) {
104 for (j = 0; j < ns; j++) {
116 real *rho, *vr, *energy;
121 energy = Energy->Field;
123 #pragma omp parallel for private(l)
124 for (j = 0; j < ns; j++) {
127 energy[l-ns] = energy[l];
128 if ((vr[l+ns] > 0.0) || (rho[l] <
SigmaMed[0]))
138 int i,j,l,ns,nr,jp,lp,i_angle;
139 real *rho, *vr, *energy, *cs;
140 real dangle, mean, vr_med, csin, csout;
146 energy = Energy->Field;
151 for (j=0; j<ns; j++) {
159 dangle = (pow(
Rinf[1],-1.5)-1.0)/(.5*(csin + csout));
162 #pragma omp parallel for private(l,jp,lp,vr_med)
163 for (j = 0; j < ns; j++) {
166 if (jp >= ns) jp -= ns;
167 if (jp < 0) jp += ns;
170 energy[lp] = energy[l];
172 vr[l] = 2.*vr_med-vr[l+ns];
175 for (j = 0; j < ns; j++) {
179 for (j = 0; j < ns; j++) {
184 for (j = 0; j < ns; j++) {
188 for (j = 0; j < ns; j++) {
196 for (j=0; j<ns; j++) {
197 csin += cs[(nr-2)*ns+j];
198 csout += cs[(nr-1)*ns+j];
204 dangle = (pow(
Rinf[nr-2],-1.5)-1.0)/(.5*(csin + csout));
207 #pragma omp parallel for private(l,jp,lp,vr_med)
208 for (j = 0; j < ns; j++) {
211 if (jp >= ns) jp -= ns;
212 if (jp < 0) jp += ns;
215 energy[l] = energy[lp];
217 vr[l] = 2.*vr_med-vr[l-ns];
220 for (j = 0; j < ns; j++) {
221 mean += rho[j+ns*(nr-1)];
224 for (j = 0; j < ns; j++) {
225 rho[j+(nr-1)*ns] +=
SigmaMed[nr-1]-mean;
229 for (j = 0; j < ns; j++) {
230 mean += energy[j+ns*(nr-1)];
233 for (j = 0; j < ns; j++) {
234 energy[j+(nr-1)*ns] +=
EnergyMed[nr-1]-mean;
245 real DRin, DRout, tauin, tauout, damp;
254 if (
Rmed[i] < DRin) {
255 damp = (DRin -
Rmed[i])/(DRin -
RMIN);
258 if (
Rmed[i] > DRout) {
259 damp = (
Rmed[i] - DRout)/(
RMAX - DRout);
275 real *vrad, *vtheta, *rho, *energy;
276 real vrad0, vtheta0=0.0, rho0, energy0;
277 real DRin, DRout, lambda;
280 vtheta = Vtheta->Field;
283 energy = Energy->Field;
286 #pragma omp parallel default(none) \
287 shared(Zero_or_active,Max_or_active,Rmed,DRin,DRout,DampInit,\
288 ns,vrad,rho,energy,vtheta,WaveKiller,OmegaFrame,SigmaMed,EnergyMed,VthetaMed,step) \
289 private(i,vrad0,rho0,energy0,vtheta0,lambda,j,l)
293 if (
Rmed[i] < DRin ||
Rmed[i] > DRout) {
301 for (j=0; j<ns; j++) {
303 vrad[l] = (vrad[l] + lambda*vrad0)/(1.0 + lambda);
305 rho[l] = (rho[l] + lambda*rho0)/(1.0 + lambda);
306 energy[l] = (energy[l] + lambda*energy0)/(1.0 + lambda);
307 vtheta[l] = (vtheta[l] + lambda*vtheta0)/(1.0 + lambda);
322 real DRin, DRout, lambda;
323 real pdens0, pvr0, pvt0;
324 real *pdens, *pvr, *pvt;
326 ns = PebbleDens->
Nsec;
327 pdens = PebbleDens->Field;
328 pvr = PebbleVrad->Field;
329 pvt = PebbleVtheta->Field;
332 #pragma omp parallel for default(none) \
333 shared (Zero_or_active,Max_or_active,Rmed,DRin,DRout, \
334 WaveKiller,PebDensInit,PebVradInit,PebVthetaInit,OmegaFrame,dt,pdens,pvr,pvt,ns) \
335 private (i,j,l,lambda,pdens0,pvr0,pvt0)
337 if (
Rmed[i] < DRin ||
Rmed[i] > DRout) {
342 for (j=0; j<ns; j++) {
344 pdens[l] = (pdens[l] + lambda*pdens0)/(1.0 + lambda);
345 pvr[l] = (pvr[l] + lambda*pvr0)/(1.0 + lambda);
346 pvt[l] = (pvt[l] + lambda*pvt0)/(1.0 + lambda);
358 real *rho, average_rho = 0.0, *vr, penul_vr;
365 for (j = 0; j < ns; j++) {
367 average_rho += rho[l];
369 average_rho /= (
real)ns;
370 average_rho =
SigmaMed[nr-1]-average_rho;
371 for (j = 0; j < ns; j++) {
373 rho[l] += average_rho;
377 for (j = 0; j < ns; j++) {
407 for (i = 0; i < nr; i++) {
408 for (j = 0; j < ns; j++) {
410 vt[l] -= domega*
Rmed[i];
421 real total = 0.0, fulltotal = 0.0;
422 real *density, *vrad, *vtheta, *energy;
425 density = Rho->Field;
427 vtheta = Vtheta->Field;
428 energy = Energy->Field;
432 for (j = 0; j < ns; j++) {
444 total += 0.5*
Surf[i]*density[l]*(vr_cent*vr_cent + vt_cent*
vt_cent) + \
double real
Definition of the type 'real' used throughout the code.
static real vt_cent[MAX1D]
void OpenBoundary(PolarGrid *Vrad, PolarGrid *Rho, PolarGrid *Energy)
void DivisePolarGrid(PolarGrid *Num, PolarGrid *Denom, PolarGrid *Res)
PolarGrid * CreatePolarGrid(int Nr, int Ns, char *name)
real GasMomentum(PolarGrid *Density, PolarGrid *Vtheta)
void SetWaveKillingZones()
Sets the wave-killing factors within the damping zones; inspired by de Val-Borro et al...
A structure used to store any scalar fied on the computational domain.
int Nrad
Radial size of the grid, in number of zones.
real GasTotalEnergy(PolarGrid *Rho, PolarGrid *Vrad, PolarGrid *Vtheta, PolarGrid *Energy)
void ApplyOuterSourceMass(PolarGrid *Rho, PolarGrid *Vrad)
real PebVthetaInit[MAX1D]
void DampPebbles(PolarGrid *PebbleDens, PolarGrid *PebbleVrad, PolarGrid *PebbleVtheta, real dt)
Damps the pebble disk inside the wave-killing zones towards its equilibrium state.
real GasTotalMass(PolarGrid *array)
void MPI_Allreduce(void *ptr, void *ptr2, int count, int type, int foo3, int foo4)
void NonReflectingBoundary(PolarGrid *Vrad, PolarGrid *Rho, PolarGrid *Energy)
void ApplyBoundaryCondition(PolarGrid *Vrad, PolarGrid *Vtheta, PolarGrid *Rho, PolarGrid *Energy, real dt)
Contains all the include directives requested by the code.
int Nsec
Azimuthal size of the grid, in number of zones.
void CorrectVtheta(PolarGrid *vtheta, real domega)
void DampingBoundary(PolarGrid *Vrad, PolarGrid *Vtheta, PolarGrid *Rho, PolarGrid *Energy, real step)
Imposes the wave-killing boundary condition.