Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/viennaps/models/psNeutralTransport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ class NeutralTransportSurfaceModel : public SurfaceModel<NumericType> {
void updateCoverages(SmartPointer<PointData<NumericType>> fluxes,
const std::vector<NumericType> &materialIds) override {
auto neutralFlux = fluxes->getScalarData(params.fluxLabel);
auto desorbedFlux =
fluxes->getScalarData(params.fluxLabel + "_surface", true);
auto coverage = coverages->getScalarData(params.coverageLabel);
assert(neutralFlux && coverage);
assert(neutralFlux->size() == materialIds.size());
assert(desorbedFlux == nullptr ||
desorbedFlux->size() == materialIds.size());

coverage->resize(neutralFlux->size());

Expand All @@ -207,9 +211,11 @@ class NeutralTransportSurfaceModel : public SurfaceModel<NumericType> {
MaterialMap::isMaterial(materialIds[i], params.etchFrontMaterial)
? params.etchFrontSticking
: params.zeroCoverageSticking;
const auto desorbed = desorbedFlux ? desorbedFlux->at(i) : 0.;
const auto adsorptionCoefficient =
params.surfaceSiteDensity > 0.
? sticking * params.incomingFlux * neutralFlux->at(i) /
? sticking * params.incomingFlux *
(neutralFlux->at(i) + desorbed) /
(constants::N_A * params.surfaceSiteDensity)
: NumericType(0.);
const auto etchLossRate =
Expand Down
3 changes: 2 additions & 1 deletion include/viennaps/models/psSingleParticleALD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ class SingleParticleALD : public ProcessModelGPU<NumericType, D> {

// particles
viennaray::gpu::Particle<NumericType> particle{
.name = "SingleParticle", .sticking = params_.stickingProbability};
.name = "SingleParticle",
.sticking = static_cast<NumericType>(params_.stickingProbability)};
particle.dataLabels.push_back("ParticleFlux");

std::unordered_map<std::string, unsigned> pMap = {{"SingleParticle", 0}};
Expand Down
7 changes: 4 additions & 3 deletions include/viennaps/process/psCPUDiskEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class CPUDiskEngine final : public FluxEngine<NumericType, D> {
std::move(sourceData), context.rayTracingParams.raysPerPoint);

rayTracer_.setSource(source);
runRayTracer(context, fluxes);
runRayTracer(context, fluxes, "_surface");

// reset source
if (auto source = model_->getSource()) {
Expand All @@ -160,7 +160,8 @@ class CPUDiskEngine final : public FluxEngine<NumericType, D> {

private:
void runRayTracer(ProcessContext<NumericType, D> const &context,
SmartPointer<PointData<NumericType>> &fluxes) {
SmartPointer<PointData<NumericType>> &fluxes,
std::string const &postFix = "") {
assert(fluxes != nullptr);
assert(model_ != nullptr);
fluxes->clear();
Expand Down Expand Up @@ -213,7 +214,7 @@ class CPUDiskEngine final : public FluxEngine<NumericType, D> {

for (int i = 0; i < numFluxes; ++i) {
fluxes->insertNextScalarData(std::move(particleFluxes[i]),
particleFluxLabels[i]);
particleFluxLabels[i] + postFix);
}

++particleIdx;
Expand Down
2 changes: 2 additions & 0 deletions include/viennaps/process/psCPUTriangleEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,11 @@ class CPUTriangleEngine final : public FluxEngine<NumericType, D> {
fluxes->clear();
postProcessing_.setPointData(fluxes);
postProcessing_.setElementDataArrays(std::move(elementFluxes));
postProcessing_.setPostFix("_surface");
postProcessing_.prepare(true); // prepare without building the tree again
postProcessing_.validate();
postProcessing_.convert();
postProcessing_.setPostFix(""); // clear postfix

// reset source
if (auto modelSource = model_->getSource()) {
Expand Down
6 changes: 3 additions & 3 deletions include/viennaps/process/psFluxProcessStrategy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class FluxProcessStrategy final : public ProcessStrategy<NumericType, D> {
auto desorptionFlux = PointData<NumericType>::New();
if (fluxEngine_->calculateSurfaceFluxes(context, desorptionFlux) ==
ProcessResult::SUCCESS) {
fluxes->mergeScalarData(*desorptionFlux);
fluxes->append(*desorptionFlux);
}
}

Expand All @@ -325,12 +325,12 @@ class FluxProcessStrategy final : public ProcessStrategy<NumericType, D> {
PROCESS_CHECK(calculateSurfaceDiffusion(context, fluxes));
}

// Update coverages
// Update coverages in surface model
if (context.flags.useCoverages) {
PROCESS_CHECK(updateCoverages(context, fluxes));
}

// Calculate velocities in model
// Calculate velocities in surface model
auto velocities = calculateVelocities(context, fluxes);
context.model->getVelocityField()->prepare(context.domain, velocities,
context.processTime);
Expand Down
8 changes: 5 additions & 3 deletions include/viennaps/process/psGPUDiskEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class GPUDiskEngine final : public FluxEngine<NumericType, D> {
auto desorptionResults = rayTracer_.getResults();

copyResultsToPointData(*fluxes, context.rayTracingParams.smoothingNeighbors,
desorptionResults);
desorptionResults, "_surface");

rayTracer_.clearSurfaceSource();
this->timer_.finish();
Expand Down Expand Up @@ -259,7 +259,8 @@ class GPUDiskEngine final : public FluxEngine<NumericType, D> {

void copyResultsToPointData(
PointData<NumericType> &pointData, int smoothingNeighbors,
std::vector<std::vector<viennaray::gpu::ResultType>> results) {
std::vector<std::vector<viennaray::gpu::ResultType>> results,
const std::string &postFix = "") {
const auto numRates = rayTracer_.getNumberOfRates();
const auto numPoints = rayTracer_.getNumberOfElements();
assert(numRates > 0);
Expand All @@ -276,7 +277,8 @@ class GPUDiskEngine final : public FluxEngine<NumericType, D> {

std::vector<NumericType> diskFluxCasted(diskFlux.begin(),
diskFlux.end());
pointData.insertReplaceScalarData(std::move(diskFluxCasted), name);
pointData.insertReplaceScalarData(std::move(diskFluxCasted),
name + postFix);
}
offset += particles[pIdx].dataLabels.size();
}
Expand Down
4 changes: 3 additions & 1 deletion include/viennaps/process/psGPUTriangleEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class GPUTriangleEngine final : public FluxEngine<NumericType, D> {
// Prepare post-processing
fluxes->clear();
postProcessing_.setPointData(fluxes);
postProcessing_.setPostFix("_surface");
postProcessing_.prepare(true);

rayTracer_.normalizeResults();
Expand All @@ -292,7 +293,8 @@ class GPUTriangleEngine final : public FluxEngine<NumericType, D> {

postProcessing_.setElementDataArrays(std::move(desorptionResults));
postProcessing_.validate();
postProcessing_.convert(); // run post-processing
postProcessing_.convert(); // run post-processing
postProcessing_.setPostFix(""); // clear postfix

if (Logger::hasDebug()) {
viennals::VTKWriter<float>(
Expand Down
5 changes: 4 additions & 1 deletion include/viennaps/psElementToPointData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ElementToPointData {
SmartPointer<viennals::Mesh<NumericType>> diskMesh_;
SmartPointer<viennals::Mesh<MeshNT>> surfaceMesh_;
NumericType conversionRadius_;
std::string postFix_ = "";

struct CloseElements {
std::vector<size_t> indices;
Expand Down Expand Up @@ -75,6 +76,8 @@ class ElementToPointData {
elementKdTree_ = elementKdTree;
}

void setPostFix(const std::string &postFix) { postFix_ = postFix; }

void prepare(bool skipBuild = false) {
const auto numData = dataLabels_.size();
const auto &points = diskMesh_->nodes;
Expand All @@ -89,7 +92,7 @@ class ElementToPointData {
pointData_->clear();
for (const auto &label : dataLabels_) {
std::vector<NumericType> data(numPoints, 0.);
pointData_->insertNextScalarData(std::move(data), label);
pointData_->insertNextScalarData(std::move(data), label + postFix_);
}

if (skipBuild)
Expand Down
Loading