Commit 6295ff22 authored by Mathieu Westphal's avatar Mathieu Westphal Committed by Kitware Robot
Browse files

Merge topic 'LagrangianParticleTrackerSmallFixes'

5293ea05 Adding ParticleAboutToBeDeleted
5a831f95 Adding integrator in ManualIntegration
a0dde0a5

 Adding Particle to LagrangianParticleTracker manual integration
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Michael Migliore's avatarMichael Migliore <michael.migliore@kitware.com>
Acked-by: default avatarJoachim Pouderoux <joachim.pouderoux@kitware.com>
Merge-request: !6022
parents c7e13dd1 5293ea05
Pipeline #147763 failed with stage
in 0 seconds
......@@ -245,7 +245,7 @@ int TestLagrangianIntegrationModel(int, char*[])
double* tmpPt = nullptr;
double tmpVald = 0;
int tmpVali = 0;
if (odeWavelet->ManualIntegration(tmpPt, tmpPt, 0, tmpVald, tmpVald, 0, 0, 0, 1, tmpVald, tmpVali))
if (odeWavelet->ManualIntegration(nullptr, tmpPt, tmpPt, 0, tmpVald, tmpVald, 0, 0, 0, 1, tmpVald, tmpVali, &part))
{
std::cerr << "ManualIntegration should do nothing and return false with matida model" << std::endl;
}
......
......@@ -1582,11 +1582,13 @@ vtkIntArray* vtkLagrangianBasicIntegrationModel::GetSurfaceArrayTypes()
}
//---------------------------------------------------------------------------
bool vtkLagrangianBasicIntegrationModel::ManualIntegration(double* vtkNotUsed(xcur),
bool vtkLagrangianBasicIntegrationModel::ManualIntegration(
vtkInitialValueProblemSolver* vtkNotUsed(integrator), double* vtkNotUsed(xcur),
double* vtkNotUsed(xnext), double vtkNotUsed(t), double& vtkNotUsed(delT),
double& vtkNotUsed(delTActual), double vtkNotUsed(minStep), double vtkNotUsed(maxStep),
double vtkNotUsed(maxError), double vtkNotUsed(cellLength),
double& vtkNotUsed(error), int& vtkNotUsed(integrationResult))
double& vtkNotUsed(error), int& vtkNotUsed(integrationResult),
vtkLagrangianParticle* vtkNotUsed(particle))
{
return false;
}
......
......@@ -74,6 +74,7 @@ class vtkDataSetsType;
class vtkDoubleArray;
class vtkFieldData;
class vtkGenericCell;
class vtkInitialValueProblemSolver;
class vtkIntArray;
class vtkLagrangianParticle;
class vtkLagrangianParticleTracker;
......@@ -339,9 +340,10 @@ public:
* implementation.
* This method is thread-safe, its reimplementation should still be thread-safe.
*/
virtual bool ManualIntegration(double* xcur, double* xnext, double t, double& delT,
virtual bool ManualIntegration(vtkInitialValueProblemSolver* integrator,
double* xcur, double* xnext, double t, double& delT,
double& delTActual, double minStep, double maxStep, double maxError, double cellLength,
double& error, int& integrationResult);
double& error, int& integrationResult, vtkLagrangianParticle* particle);
/**
* Method called by parallel algorithm
......@@ -432,6 +434,14 @@ public:
*/
virtual void InsertSeedData(vtkLagrangianParticle* particle, vtkFieldData* data);
/**
* Method to be reimplemented if needed in inherited classes.
* Allows a inherited class to take action just before a particle is deleted
* This can be practical when working with vtkLagrangianParticle::TemporaryUserData.
* This can be called with not fully initialized particle.
*/
virtual void ParticleAboutToBeDeleted(vtkLagrangianParticle* vtkNotUsed(particle)) {}
protected:
vtkLagrangianBasicIntegrationModel();
~vtkLagrangianBasicIntegrationModel() override;
......
......@@ -96,6 +96,7 @@ struct IntegratingFunctor
this->Tracker->ParticleCounter;
this->Tracker->UpdateProgress(progress);
this->Tracker->IntegrationModel->ParticleAboutToBeDeleted(particle);
delete particle;
}
}
......@@ -350,6 +351,7 @@ int vtkLagrangianParticleTracker::RequestData(vtkInformation* vtkNotUsed(request
{
vtkLagrangianParticle* particle = particlesQueue.front();
particlesQueue.pop();
this->IntegrationModel->ParticleAboutToBeDeleted(particle);
delete particle;
}
}
......@@ -910,6 +912,7 @@ void vtkLagrangianParticleTracker::GenerateParticles(const vtkBoundingBox* vtkNo
}
else
{
this->IntegrationModel->ParticleAboutToBeDeleted(particle);
delete particle;
}
}
......@@ -1008,6 +1011,7 @@ int vtkLagrangianParticleTracker::Integrate(vtkInitialValueProblemSolver* integr
std::lock_guard<std::mutex> guard(this->InteractionOutputMutex);
this->InsertInteractionOutputPoint(
interactionParticle, interactedSurfaceFlaxIndex, interactionOutput);
this->IntegrationModel->ParticleAboutToBeDeleted(interactionParticle);
delete interactionParticle;
interactionParticle = nullptr;
}
......@@ -1028,6 +1032,7 @@ int vtkLagrangianParticleTracker::Integrate(vtkInitialValueProblemSolver* integr
this->InsertInteractionOutputPoint(item.second, item.first, interactionOutput);
// the pass through particles needs to be deleted
this->IntegrationModel->ParticleAboutToBeDeleted(item.second);
delete item.second;
}
......@@ -1293,8 +1298,8 @@ bool vtkLagrangianParticleTracker::ComputeNextStep(vtkInitialValueProblemSolver*
{
// Check for potential manual integration
double error;
if (!this->IntegrationModel->ManualIntegration(xprev, xnext, t, delT, delTActual, minStep,
maxStep, this->IntegrationModel->GetTolerance(), cellLength, error, integrationRes))
if (!this->IntegrationModel->ManualIntegration(integrator, xprev, xnext, t, delT, delTActual, minStep,
maxStep, this->IntegrationModel->GetTolerance(), cellLength, error, integrationRes, particle))
{
// integrate one step
integrationRes = integrator->ComputeNextStep(xprev, xnext, t, delT, delTActual, minStep,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment