diff --git a/include/viennaps/models/psNeutralTransport.hpp b/include/viennaps/models/psNeutralTransport.hpp index 0312e526..5eff7a8b 100644 --- a/include/viennaps/models/psNeutralTransport.hpp +++ b/include/viennaps/models/psNeutralTransport.hpp @@ -188,9 +188,13 @@ class NeutralTransportSurfaceModel : public SurfaceModel { void updateCoverages(SmartPointer> fluxes, const std::vector &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()); @@ -207,9 +211,11 @@ class NeutralTransportSurfaceModel : public SurfaceModel { 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 = diff --git a/include/viennaps/models/psSingleParticleALD.hpp b/include/viennaps/models/psSingleParticleALD.hpp index 5e874db7..537d03cc 100644 --- a/include/viennaps/models/psSingleParticleALD.hpp +++ b/include/viennaps/models/psSingleParticleALD.hpp @@ -215,7 +215,8 @@ class SingleParticleALD : public ProcessModelGPU { // particles viennaray::gpu::Particle particle{ - .name = "SingleParticle", .sticking = params_.stickingProbability}; + .name = "SingleParticle", + .sticking = static_cast(params_.stickingProbability)}; particle.dataLabels.push_back("ParticleFlux"); std::unordered_map pMap = {{"SingleParticle", 0}}; diff --git a/include/viennaps/process/psCPUDiskEngine.hpp b/include/viennaps/process/psCPUDiskEngine.hpp index 22ff46fa..52308243 100644 --- a/include/viennaps/process/psCPUDiskEngine.hpp +++ b/include/viennaps/process/psCPUDiskEngine.hpp @@ -144,7 +144,7 @@ class CPUDiskEngine final : public FluxEngine { std::move(sourceData), context.rayTracingParams.raysPerPoint); rayTracer_.setSource(source); - runRayTracer(context, fluxes); + runRayTracer(context, fluxes, "_surface"); // reset source if (auto source = model_->getSource()) { @@ -160,7 +160,8 @@ class CPUDiskEngine final : public FluxEngine { private: void runRayTracer(ProcessContext const &context, - SmartPointer> &fluxes) { + SmartPointer> &fluxes, + std::string const &postFix = "") { assert(fluxes != nullptr); assert(model_ != nullptr); fluxes->clear(); @@ -213,7 +214,7 @@ class CPUDiskEngine final : public FluxEngine { for (int i = 0; i < numFluxes; ++i) { fluxes->insertNextScalarData(std::move(particleFluxes[i]), - particleFluxLabels[i]); + particleFluxLabels[i] + postFix); } ++particleIdx; diff --git a/include/viennaps/process/psCPUTriangleEngine.hpp b/include/viennaps/process/psCPUTriangleEngine.hpp index 93367e63..3da6f3f2 100644 --- a/include/viennaps/process/psCPUTriangleEngine.hpp +++ b/include/viennaps/process/psCPUTriangleEngine.hpp @@ -244,9 +244,11 @@ class CPUTriangleEngine final : public FluxEngine { 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()) { diff --git a/include/viennaps/process/psFluxProcessStrategy.hpp b/include/viennaps/process/psFluxProcessStrategy.hpp index c9875556..1fd3bd99 100644 --- a/include/viennaps/process/psFluxProcessStrategy.hpp +++ b/include/viennaps/process/psFluxProcessStrategy.hpp @@ -316,7 +316,7 @@ class FluxProcessStrategy final : public ProcessStrategy { auto desorptionFlux = PointData::New(); if (fluxEngine_->calculateSurfaceFluxes(context, desorptionFlux) == ProcessResult::SUCCESS) { - fluxes->mergeScalarData(*desorptionFlux); + fluxes->append(*desorptionFlux); } } @@ -325,12 +325,12 @@ class FluxProcessStrategy final : public ProcessStrategy { 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); diff --git a/include/viennaps/process/psGPUDiskEngine.hpp b/include/viennaps/process/psGPUDiskEngine.hpp index 8eb2d1e4..f9616a16 100644 --- a/include/viennaps/process/psGPUDiskEngine.hpp +++ b/include/viennaps/process/psGPUDiskEngine.hpp @@ -226,7 +226,7 @@ class GPUDiskEngine final : public FluxEngine { auto desorptionResults = rayTracer_.getResults(); copyResultsToPointData(*fluxes, context.rayTracingParams.smoothingNeighbors, - desorptionResults); + desorptionResults, "_surface"); rayTracer_.clearSurfaceSource(); this->timer_.finish(); @@ -259,7 +259,8 @@ class GPUDiskEngine final : public FluxEngine { void copyResultsToPointData( PointData &pointData, int smoothingNeighbors, - std::vector> results) { + std::vector> results, + const std::string &postFix = "") { const auto numRates = rayTracer_.getNumberOfRates(); const auto numPoints = rayTracer_.getNumberOfElements(); assert(numRates > 0); @@ -276,7 +277,8 @@ class GPUDiskEngine final : public FluxEngine { std::vector diskFluxCasted(diskFlux.begin(), diskFlux.end()); - pointData.insertReplaceScalarData(std::move(diskFluxCasted), name); + pointData.insertReplaceScalarData(std::move(diskFluxCasted), + name + postFix); } offset += particles[pIdx].dataLabels.size(); } diff --git a/include/viennaps/process/psGPUTriangleEngine.hpp b/include/viennaps/process/psGPUTriangleEngine.hpp index d93b89b3..0dcdd32a 100644 --- a/include/viennaps/process/psGPUTriangleEngine.hpp +++ b/include/viennaps/process/psGPUTriangleEngine.hpp @@ -284,6 +284,7 @@ class GPUTriangleEngine final : public FluxEngine { // Prepare post-processing fluxes->clear(); postProcessing_.setPointData(fluxes); + postProcessing_.setPostFix("_surface"); postProcessing_.prepare(true); rayTracer_.normalizeResults(); @@ -292,7 +293,8 @@ class GPUTriangleEngine final : public FluxEngine { 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( diff --git a/include/viennaps/psElementToPointData.hpp b/include/viennaps/psElementToPointData.hpp index 0dd540f5..665c8a6e 100644 --- a/include/viennaps/psElementToPointData.hpp +++ b/include/viennaps/psElementToPointData.hpp @@ -21,6 +21,7 @@ class ElementToPointData { SmartPointer> diskMesh_; SmartPointer> surfaceMesh_; NumericType conversionRadius_; + std::string postFix_ = ""; struct CloseElements { std::vector indices; @@ -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; @@ -89,7 +92,7 @@ class ElementToPointData { pointData_->clear(); for (const auto &label : dataLabels_) { std::vector data(numPoints, 0.); - pointData_->insertNextScalarData(std::move(data), label); + pointData_->insertNextScalarData(std::move(data), label + postFix_); } if (skipBuild)