34 #ifdef DBG_SCALARFIELD
42 interpolationCacheSet_m(false)
59 layout->
getLayout().changeDomain(*fLayout);
70 for (
unsigned int i = 0; i <
Dimension; i++)
71 nr_m[i] = domain[i].length();
73 for (
int i = 0; i < 3; i++)
140 double scaleFactor = 1;
146 double tmp2 = 1 /
hr_m[0] * 1 /
hr_m[1] * 1 /
hr_m[2] / (scaleFactor * scaleFactor * scaleFactor) / gammaz;
152 hr_scaled[2] *= gammaz;
156 imagePotential =
rho_m;
161 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
173 eg_m *=
Vector_t(gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz));
179 int mx = (int)
nr_m[0];
180 int mx2 = (int)
nr_m[0] / 2;
181 int my = (int)
nr_m[1];
182 int my2 = (int)
nr_m[1] / 2;
183 int mz = (int)
nr_m[2];
184 int mz2 = (int)
nr_m[2] / 2;
186 for (
int i=0; i<mx; i++ )
187 *
gmsg <<
"Bin " << binNumber
188 <<
", Self Field along x axis E = " <<
eg_m[i][my2][mz2]
189 <<
", Pot = " <<
rho_m[i][my2][mz2] <<
endl;
191 for (
int i=0; i<my; i++ )
192 *
gmsg <<
"Bin " << binNumber
193 <<
", Self Field along y axis E = " <<
eg_m[mx2][i][mz2]
194 <<
", Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
196 for (
int i=0; i<mz; i++ )
197 *
gmsg <<
"Bin " << binNumber
198 <<
", Self Field along z axis E = " <<
eg_m[mx2][my2][i]
199 <<
", Pot = " <<
rho_m[mx2][my2][i] <<
endl;
230 double zshift = -(2 * origin(2) + (domain[2].first() + domain[2].last() + 1) * hz) * gammaz * scaleFactor;
237 imagePotential *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
243 #ifdef DBG_SCALARFIELD
244 const int dumpFreq = 100;
260 eg_m *=
Vector_t(gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz));
273 for (
int i=0; i<mx; i++ )
274 *
gmsg <<
"Bin " << binNumber
275 <<
", Image Field along x axis E = " <<
eg_m[i][my2][mz2]
276 <<
", Pot = " <<
rho_m[i][my2][mz2] <<
endl;
278 for (
int i=0; i<my; i++ )
279 *
gmsg <<
"Bin " << binNumber
280 <<
", Image Field along y axis E = " <<
eg_m[mx2][i][mz2]
281 <<
", Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
283 for (
int i=0; i<mz; i++ )
284 *
gmsg <<
"Bin " << binNumber
285 <<
", Image Field along z axis E = " <<
eg_m[mx2][my2][i]
286 <<
", Pot = " <<
rho_m[mx2][my2][i] <<
endl;
289 #ifdef DBG_SCALARFIELD
336 if(
R[
n](0) < xmin ||
R[
n](0) > xmax ||
337 R[
n](1) < ymin ||
R[
n](1) > ymax) {
392 double scaleFactor = 1;
396 hr_scaled[2] *= gammaz;
399 double tmp2 = 1 / hr_scaled[0] * 1 / hr_scaled[1] * 1 / hr_scaled[2];
403 #ifdef DBG_SCALARFIELD
416 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
424 #ifdef DBG_SCALARFIELD
432 eg_m *=
Vector_t(gammaz / (scaleFactor), gammaz / (scaleFactor), 1.0 / (scaleFactor * gammaz));
438 int mx = (int)
nr_m[0];
439 int mx2 = (int)
nr_m[0] / 2;
440 int my = (int)
nr_m[1];
441 int my2 = (int)
nr_m[1] / 2;
442 int mz = (int)
nr_m[2];
443 int mz2 = (int)
nr_m[2] / 2;
445 for (
int i=0; i<mx; i++ )
446 *
gmsg <<
"Field along x axis Ex = " <<
eg_m[i][my2][mz2] <<
" Pot = " <<
rho_m[i][my2][mz2] <<
endl;
448 for (
int i=0; i<my; i++ )
449 *
gmsg <<
"Field along y axis Ey = " <<
eg_m[mx2][i][mz2] <<
" Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
451 for (
int i=0; i<mz; i++ )
452 *
gmsg <<
"Field along z axis Ez = " <<
eg_m[mx2][my2][i] <<
" Pot = " <<
rho_m[mx2][my2][i] <<
endl;
455 #ifdef DBG_SCALARFIELD
474 Bf(0) =
Bf(0) - betaC *
Ef(1);
475 Bf(1) =
Bf(1) + betaC *
Ef(0);
513 hr_scaled[1] *= gamma;
516 double tmp2 = 1.0 / (hr_scaled[0] * hr_scaled[1] * hr_scaled[2]);
520 #ifdef DBG_SCALARFIELD
534 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
540 #ifdef DBG_SCALARFIELD
556 int mx = (int)
nr_m[0];
557 int mx2 = (int)
nr_m[0] / 2;
558 int my = (int)
nr_m[1];
559 int my2 = (int)
nr_m[1] / 2;
560 int mz = (int)
nr_m[2];
561 int mz2 = (int)
nr_m[2] / 2;
563 for (
int i=0; i<mx; i++ )
564 *
gmsg <<
"Field along x axis Ex = " <<
eg_m[i][my2][mz2] <<
" Pot = " <<
rho_m[i][my2][mz2] <<
endl;
566 for (
int i=0; i<my; i++ )
567 *
gmsg <<
"Field along y axis Ey = " <<
eg_m[mx2][i][mz2] <<
" Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
569 for (
int i=0; i<mz; i++ )
570 *
gmsg <<
"Field along z axis Ez = " <<
eg_m[mx2][my2][i] <<
" Pot = " <<
rho_m[mx2][my2][i] <<
endl;
573 #ifdef DBG_SCALARFIELD
587 Bf(0) = betaC *
Ef(2);
588 Bf(2) = -betaC *
Ef(0);
641 hr_scaled[1] *= gamma;
644 double tmp2 = 1.0 / (hr_scaled[0] * hr_scaled[1] * hr_scaled[2]);
648 #ifdef DBG_SCALARFIELD
660 rho_m *= hr_scaled[0] * hr_scaled[1] * hr_scaled[2];
666 #ifdef DBG_SCALARFIELD
682 int mx = (int)
nr_m[0];
683 int mx2 = (int)
nr_m[0] / 2;
684 int my = (int)
nr_m[1];
685 int my2 = (int)
nr_m[1] / 2;
686 int mz = (int)
nr_m[2];
687 int mz2 = (int)
nr_m[2] / 2;
689 for (
int i=0; i<mx; i++ )
690 *
gmsg <<
"Bin " << bin
691 <<
", Field along x axis Ex = " <<
eg_m[i][my2][mz2]
692 <<
", Pot = " <<
rho_m[i][my2][mz2] <<
endl;
694 for (
int i=0; i<my; i++ )
695 *
gmsg <<
"Bin " << bin
696 <<
", Field along y axis Ey = " <<
eg_m[mx2][i][mz2]
697 <<
", Pot = " <<
rho_m[mx2][i][mz2] <<
endl;
699 for (
int i=0; i<mz; i++ )
700 *
gmsg <<
"Bin " << bin
701 <<
", Field along z axis Ez = " <<
eg_m[mx2][my2][i]
702 <<
", Pot = " <<
rho_m[mx2][my2][i] <<
endl;
706 #ifdef DBG_SCALARFIELD
755 for (
int i = 0; i < 2 * 3; ++i) {
774 for (
int i = 0; i < 2 * 3; ++i) {
784 for (
int i = 0; i < 2 * 3; ++ i) {
808 for (
unsigned int i = 0; i <
Dimension; i++)
809 grid[i] = domain[i].length();
Tps< T > sqrt(const Tps< T > &x)
Square root.
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
void BinaryRepartition(FieldLayout< Dim > &layout, BareField< double, Dim > &weights)
Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > & Grad(Field< T, 1U, Cartesian< 1U, MFLOAT >, Vert > &x, Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > &r)
T ParticlePeriodicBCond(const T t, const T minval, const T maxval)
T ParticleNoBCond(const T t, const T, const T)
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
Inform & endl(Inform &inf)
Inform & level2(Inform &inf)
Inform & level3(Inform &inf)
constexpr double c
The velocity of light in m/s.
ParticleAttrib< Vector_t > Ef
std::shared_ptr< AbstractParticle< double, Dim > > pbase_m
long long localTrackStep_m
step in a TRACK command
ParticleBConds< Position_t, Dimension > & getBConds()
double getCouplingConstant() const
ParticleAttrib< Vector_t > Eftmp
size_t getLocalNum() const
Vector_t rmax_m
maximal extend of particles
size_t getTotalNum() const
ParticleAttrib< Vector_t > P
Inform & print(Inform &os)
double getBinGamma(int bin)
Get gamma of one bin.
ParticleAttrib< double > Q
Vector_t rmin_m
minimal extend of particles
FieldSolver * fs_m
stores the used field solver
std::pair< Vector_t, Vector_t > VectorPair_t
double dh_m
Mesh enlargement.
ParticleAttrib< double > dt
static const unsigned Dimension
void get_bounds(Vector_t &rmin, Vector_t &rmax)
Vector_t hr_m
meshspacing of cartesian mesh
void destroy(size_t M, size_t I, bool doNow=false)
ParticleAttrib< Vector_t > Bf
virtual void swap(unsigned int i, unsigned int j)
Vektor< int, 3 > nr_m
meshsize of cartesian mesh
IpplTimings::TimerRef selfFieldTimer_m
timer for selfField calculation
void resetInterpolationCache(bool clearCache=false)
BConds< double, 3, Mesh_t, Center_t > bc_m
for defining the boundary conditions
ParticleLayout< double, 3 > & getLayout()
Field_t rho_m
scalar potential
void swap(unsigned int i, unsigned int j)
void initialize(FieldLayout_t *fLayout)
bool interpolationCacheSet_m
Inform & print(Inform &os)
void updateDomainLength(Vektor< int, 3 > &grid)
FieldLayout_t & getFieldLayout()
VField_t eg_m
vector field on the grid
VectorPair_t getEExtrema()
const Mesh_t & getMesh() const
ParticleAttrib< CacheDataCIC< double, 3U > > interpolationCache_m
void resizeMesh()
resize mesh to geometry specified
BConds< Vector_t, 3, Mesh_t, Center_t > vbc_m
void computeSelfFields_cycl(double gamma)
Calculates the self electric field from the charge density distribution for use in cyclotrons.
void updateFields(const Vector_t &hr, const Vector_t &origin)
virtual void computePotential(Field_t &rho, Vector_t hr)=0
virtual double getYRangeMin(unsigned short level=0)=0
virtual double getXRangeMin(unsigned short level=0)=0
virtual void resizeMesh(Vector_t &, Vector_t &, const Vector_t &, const Vector_t &, double)
virtual double getYRangeMax(unsigned short level=0)=0
virtual void test(PartBunchBase< double, 3 > *bunch)=0
virtual double getXRangeMax(unsigned short level=0)=0
PoissonSolver * solver_m
the actual solver, should be a base object
std::string getFieldSolverType()
void dumpField(FieldType &field, std::string name, std::string unit, long long step, FieldType *image=nullptr)
Dump a scalar or vector field to a file.
void initialize(Layout_t &)
Mesh_t & get_mesh() const
void scatter(Field< T, Dim, M, C > &f, const ParticleAttrib< Vektor< PT, Dim > > &pp, const IntOp &) const
virtual void destroy(size_t M, size_t I, bool optDestroy=true)
virtual void create(size_t)
const NDIndex< Dim > & getDomain() const
void set_origin(const Vektor< MFLOAT, Dim > &o)
void set_meshSpacing(MFLOAT *const del)
RegionLayout< T, Dim, Mesh > & getLayout()
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)
Vektor< double, 3 > Vector_t