Canoe
Comprehensive Atmosphere N' Ocean Engine
particle_integrator.cpp
Go to the documentation of this file.
1 
4 // C/C++
5 #include <cstring>
6 
7 // athena
8 #include <athena/athena.hpp>
9 
10 // n-body
11 #include "particle_data.hpp"
12 #include "particles.hpp"
13 
14 void ParticleBase::TimeIntegrate(Real time, Real dt) {
15  if (std::strcmp(COORDINATE_SYSTEM, "cartesian") == 0) {
16  for (auto& it : pc) {
17  it.x1 += it.v1 * dt;
18  it.x2 += it.v2 * dt;
19  it.x3 += it.v3 * dt;
20  }
21  } else if (std::strcmp(COORDINATE_SYSTEM, "spherical_polar") == 0) {
22  for (auto& it : pc) {
23  it.x1 += it.v1 * dt;
24  it.x2 += it.v2 * dt / it.x1;
25  it.x3 += it.v3 * dt / (it.x1 * sin(it.x2));
26  }
27  }
28 
29  linked_flag_ = false;
30 }
31 
32 void ParticleBase::WeightedAverage(Real ave_wghts[]) {
33  size_t psize = pc.size();
34 
35  for (size_t i = 0; i < psize; ++i) {
36  pc[i].x1 = ave_wghts[0] * pc[i].x1 + ave_wghts[1] * pc1[i].x1;
37  pc[i].x2 = ave_wghts[0] * pc[i].x2 + ave_wghts[1] * pc1[i].x2;
38  pc[i].x3 = ave_wghts[0] * pc[i].x3 + ave_wghts[1] * pc1[i].x3;
39 
40  pc[i].v1 = ave_wghts[0] * pc[i].v1 + ave_wghts[1] * pc1[i].v1;
41  pc[i].v2 = ave_wghts[0] * pc[i].v2 + ave_wghts[1] * pc1[i].v2;
42  pc[i].v3 = ave_wghts[0] * pc[i].v3 + ave_wghts[1] * pc1[i].v3;
43  }
44 }
void WeightedAverage(Real ave_wghts[]) override
void TimeIntegrate(Real time, Real dt) override
ParticleContainer pc
Definition: particles.hpp:39
bool linked_flag_
linked flag
Definition: particles.hpp:78
ParticleContainer pc1
Definition: particles.hpp:39