Skip to content

Commit

Permalink
port signal calculation to using DistributedWeightingField; compiles …
Browse files Browse the repository at this point in the history
…but may not run yet
  • Loading branch information
philippwindischhofer committed Jan 26, 2024
1 parent a0b9361 commit c5825f0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 27 deletions.
6 changes: 3 additions & 3 deletions include/Eisvogel/DistributedWeightingField.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public:
void RegisterChunk(const chunk_t& chunk_E_r, const chunk_t& chunk_E_z, const chunk_t& chunk_E_phi,
const IndexVector start_ind);

const storage_t& E_r() const {return *m_E_r;};
const storage_t& E_z() const {return *m_E_z;};
const storage_t& E_phi() const {return *m_E_phi;};
storage_t& E_r() const {return *m_E_r;};
storage_t& E_z() const {return *m_E_z;};
storage_t& E_phi() const {return *m_E_phi;};

static inline CoordVector FracIndsToCoord(const CoordVector& frac_inds, const CoordVector& start_coords, const CoordVector& end_coords,
const CoordVector& shape) {
Expand Down
8 changes: 4 additions & 4 deletions include/Eisvogel/Integrator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <memory>
#include "Common.hh"
#include "WeightingField.hh"
#include "DistributedWeightingField.hh"
#include "Interpolator.hh"
#include "Current0D.hh"
#include "SparseCurrentDensity3D.hh"
Expand All @@ -12,16 +12,16 @@ class Integrator {

public:

void SetGeometry(std::shared_ptr<WeightingField> wf, std::shared_ptr<Kernel> kernel);
void SetGeometry(std::shared_ptr<DistributedWeightingField> dwf, std::shared_ptr<Kernel> kernel);
scalar_t integrate(scalar_t t, const Current0D& curr, scalar_t os_factor = 1.0) const;
scalar_t integrate(scalar_t t, const SparseCurrentDensity3D& current_distribution) const;

private:

std::shared_ptr<Kernel> m_kernel;
std::shared_ptr<WeightingField> m_wf;
std::shared_ptr<DistributedWeightingField> m_dwf;

using interpolator_t = Interpolator<DenseNDArray, scalar_t, 3>;
using interpolator_t = Interpolator<DistributedNDArray, scalar_t, 3>;

std::unique_ptr<interpolator_t> m_itpl_E_r;
std::unique_ptr<interpolator_t> m_itpl_E_z;
Expand Down
4 changes: 2 additions & 2 deletions include/Eisvogel/Interpolator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Interpolator {

public:

Interpolator(const ArrayT<ValueT, dims>& data, const Kernel& kernel) :
Interpolator(ArrayT<ValueT, dims>& data, const Kernel& kernel) :
m_data(data), m_kernel(kernel) { };

template <typename... FracInds>
Expand Down Expand Up @@ -64,7 +64,7 @@ public:

private:

const ArrayT<ValueT, dims>& m_data;
ArrayT<ValueT, dims>& m_data;
const Kernel& m_kernel;
};

Expand Down
3 changes: 1 addition & 2 deletions include/Eisvogel/SignalCalculator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <memory>
#include "Eisvogel/Common.hh"
#include "Eisvogel/Integrator.hh"
#include "Eisvogel/WeightingField.hh"
#include "Eisvogel/DistributedWeightingField.hh"
#include "Eisvogel/Current0D.hh"
#include "Eisvogel/SparseCurrentDensity3D.hh"

Expand All @@ -19,7 +19,6 @@ public:
private:
std::string m_geometry_path;
Integrator m_integrator;
static std::shared_ptr<WeightingField> load_wf(const std::string& path);
};

#endif
16 changes: 8 additions & 8 deletions src/Integrator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

namespace CU = CoordUtils;

void Integrator::SetGeometry(std::shared_ptr<WeightingField> wf,
void Integrator::SetGeometry(std::shared_ptr<DistributedWeightingField> dwf,
std::shared_ptr<Kernel> kernel) {
m_kernel = kernel;
m_wf = wf;
m_dwf = dwf;

m_itpl_E_r = std::make_unique<interpolator_t>(m_wf -> E_r(), *m_kernel);
m_itpl_E_z = std::make_unique<interpolator_t>(m_wf -> E_z(), *m_kernel);
m_itpl_E_phi = std::make_unique<interpolator_t>(m_wf -> E_phi(), *m_kernel);
m_itpl_E_r = std::make_unique<interpolator_t>(m_dwf -> E_r(), *m_kernel);
m_itpl_E_z = std::make_unique<interpolator_t>(m_dwf -> E_z(), *m_kernel);
m_itpl_E_phi = std::make_unique<interpolator_t>(m_dwf -> E_phi(), *m_kernel);
}

scalar_t Integrator::integrate(scalar_t t, const Current0D& curr, scalar_t os_factor) const {
Expand All @@ -28,7 +28,7 @@ scalar_t Integrator::integrate(scalar_t t, const Current0D& curr, scalar_t os_fa
velocities.AddPoint(deltas(pt_ind) / CU::getT(deltas(pt_ind)));
}

DeltaVector wf_sampling_intervals = m_wf -> getSamplingIntervals();
DeltaVector wf_sampling_intervals = m_dwf -> getSamplingIntervals();

// Main signal integration loop
scalar_t signal = 0;
Expand Down Expand Up @@ -63,7 +63,7 @@ scalar_t Integrator::integrate(scalar_t t, const Current0D& curr, scalar_t os_fa
CoordVector cur_pos_trz = CU::TXYZ_to_TRZ(cur_pos_txyz);
CoordVector wf_eval_pos = CU::MakeCoordVectorTRZ(t - cur_t, CU::getR(cur_pos_trz), CU::getZ(cur_pos_trz));

CoordVector wf_eval_frac_inds = m_wf -> getFracInds(wf_eval_pos);
CoordVector wf_eval_frac_inds = m_dwf -> getFracInds(wf_eval_pos);

FieldVector wf_rzphi = CU::MakeFieldVectorRZPHI(m_itpl_E_r -> Interpolate(wf_eval_frac_inds),
m_itpl_E_z -> Interpolate(wf_eval_frac_inds),
Expand Down Expand Up @@ -99,7 +99,7 @@ scalar_t Integrator::integrate(scalar_t t, const SparseCurrentDensity3D& current
CoordVector cur_pos_trz = CU::TXYZ_to_TRZ(cur_pos_txyz);
CoordVector wf_eval_pos = CU::MakeCoordVectorTRZ(t - cur_t, CU::getR(cur_pos_trz), CU::getZ(cur_pos_trz));

CoordVector wf_eval_frac_inds = m_wf -> getFracInds(wf_eval_pos);
CoordVector wf_eval_frac_inds = m_dwf -> getFracInds(wf_eval_pos);

FieldVector wf_rzphi = CU::MakeFieldVectorRZPHI(m_itpl_E_r -> Interpolate(wf_eval_frac_inds),
m_itpl_E_z -> Interpolate(wf_eval_frac_inds),
Expand Down
10 changes: 2 additions & 8 deletions src/SignalCalculator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
#include <iostream>
#include <fstream>

std::shared_ptr<WeightingField> SignalCalculator::load_wf(const std::string& path) {
std::fstream ifs;
ifs.open(path, std::ios::in | std::ios::binary);
stor::Serializer iser(ifs);
return std::make_shared<WeightingField>(iser.deserialize<WeightingField>());
}

SignalCalculator::SignalCalculator(const std::string& geometry_path) :
m_geometry_path(geometry_path), m_integrator()
{
// For now, simply load the weighting field and set it
// Later, loading the weighting field will be removed here ...
std::shared_ptr<Kernel> kernel = std::make_shared<KeysCubicInterpolationKernel>();
m_integrator.SetGeometry(load_wf(m_geometry_path), kernel);
std::shared_ptr<DistributedWeightingField> dwf = std::make_shared<DistributedWeightingField>(m_geometry_path);
m_integrator.SetGeometry(dwf, kernel);
}

scalar_t SignalCalculator::ComputeSignal(const Current0D& track, scalar_t t_sig) {
Expand Down

0 comments on commit c5825f0

Please sign in to comment.