From 11f4c388175405e2e33b50b5b25a61b281345bde Mon Sep 17 00:00:00 2001
From: Chichi Lalescu <chichilalescu@gmail.com>
Date: Thu, 26 Oct 2017 22:31:48 +0200
Subject: [PATCH] sample vorticity at particle locations

---
 bfps/DNS.py                             |  1 +
 bfps/cpp/full_code/NSVEparticlesP2P.cpp | 61 +++++++++++++++----------
 2 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/bfps/DNS.py b/bfps/DNS.py
index 3be9123b..488ff1b0 100644
--- a/bfps/DNS.py
+++ b/bfps/DNS.py
@@ -910,6 +910,7 @@ class DNS(_code):
                     particle_file.create_group('tracers0/acceleration')
                     if self.dns_type in ['NSVEparticlesP2P']:
                         particle_file.create_group('tracers0/orientation')
+                        particle_file.create_group('tracers0/vorticity')
         return None
     def launch_jobs(
             self,
diff --git a/bfps/cpp/full_code/NSVEparticlesP2P.cpp b/bfps/cpp/full_code/NSVEparticlesP2P.cpp
index a9e1493c..85caafe0 100644
--- a/bfps/cpp/full_code/NSVEparticlesP2P.cpp
+++ b/bfps/cpp/full_code/NSVEparticlesP2P.cpp
@@ -90,7 +90,7 @@ int NSVEparticlesP2P<rnumber>::finalize(void)
     return EXIT_SUCCESS;
 }
 
-/** \brief Compute fluid stats and sample fields at particle locations.
+/** \brief Compute fluid stats and sample particle data.
  */
 
 template <typename rnumber>
@@ -128,29 +128,42 @@ int NSVEparticlesP2P<rnumber>::do_stats()
             this->ps->getLocalNbParticles(),
             this->ps->get_step_idx()-1);
 
-    ///// sample velocity
-    //this->ps->sample_compute_field(*this->tmp_vec_field, pdata.get());
-    //this->particles_sample_writer_mpi->save_dataset(
-    //        "tracers0",
-    //        "velocity",
-    //        this->ps->getParticlesState(),
-    //        &pdata,
-    //        this->ps->getParticlesIndexes(),
-    //        this->ps->getLocalNbParticles(),
-    //        this->ps->get_step_idx()-1);
-
-    ///// compute acceleration and sample it
-    //this->fs->compute_Lagrangian_acceleration(this->tmp_vec_field);
-    //this->tmp_vec_field->ift();
-    //this->ps->sample_compute_field(*this->tmp_vec_field, pdata.get());
-    //this->particles_sample_writer_mpi->save_dataset(
-    //        "tracers0",
-    //        "acceleration",
-    //        this->ps->getParticlesState(),
-    //        &pdata,
-    //        this->ps->getParticlesIndexes(),
-    //        this->ps->getLocalNbParticles(),
-    //        this->ps->get_step_idx()-1);
+    /// sample velocity
+    this->ps->sample_compute_field(*this->tmp_vec_field, pdata1.get());
+    this->particles_sample_writer_mpi->save_dataset(
+            "tracers0",
+            "velocity",
+            pdata0.get(),
+            &pdata1,
+            this->ps->getParticlesIndexes(),
+            this->ps->getLocalNbParticles(),
+            this->ps->get_step_idx()-1);
+
+    /// sample vorticity
+    *this->tmp_vec_field = this->fs->cvorticity->get_cdata();
+    this->tmp_vec_field->ift();
+    this->ps->sample_compute_field(*this->tmp_vec_field, pdata1.get());
+    this->particles_sample_writer_mpi->save_dataset(
+            "tracers0",
+            "vorticity",
+            pdata0.get(),
+            &pdata1,
+            this->ps->getParticlesIndexes(),
+            this->ps->getLocalNbParticles(),
+            this->ps->get_step_idx()-1);
+
+    /// compute acceleration and sample it
+    this->fs->compute_Lagrangian_acceleration(this->tmp_vec_field);
+    this->tmp_vec_field->ift();
+    this->ps->sample_compute_field(*this->tmp_vec_field, pdata1.get());
+    this->particles_sample_writer_mpi->save_dataset(
+            "tracers0",
+            "acceleration",
+            pdata0.get(),
+            &pdata1,
+            this->ps->getParticlesIndexes(),
+            this->ps->getLocalNbParticles(),
+            this->ps->get_step_idx()-1);
 
     return EXIT_SUCCESS;
 }
-- 
GitLab