LCOV - code coverage report
Current view: top level - synthesis/ImagerObjects - SynthesisDeconvolverMixin.h (source / functions) Hit Total Coverage
Test: casa_coverage.info Lines: 0 31 0.0 %
Date: 2023-10-25 08:47:59 Functions: 0 5 0.0 %

          Line data    Source code
       1             : /* -*- mode: c++ -*- */
       2             : //# SynthesisDeconvolverMixin.h: Mixin for using SynthesisDeconvolver class in
       3             : //#                              parallel imaging framework
       4             : //#                              (ParallelImagerMixin)
       5             : //# Copyright (C) 2016
       6             : //# Associated Universities, Inc. Washington DC, USA.
       7             : //#
       8             : //# This library is free software; you can redistribute it and/or modify it
       9             : //# under the terms of the GNU Library General Public License as published by
      10             : //# the Free Software Foundation; either version 2 of the License, or (at your
      11             : //# option) any later version.
      12             : //#
      13             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      14             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      15             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      16             : //# License for more details.
      17             : //#
      18             : //# You should have received a copy of the GNU Library General Public License
      19             : //# along with this library; if not, write to the Free Software Foundation,
      20             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      21             : //#
      22             : //# Correspondence concerning AIPS++ should be addressed as follows:
      23             : //#        Internet email: aips2-request@nrao.edu.
      24             : //#        Postal address: AIPS++ Project Office
      25             : //#                        National Radio Astronomy Observatory
      26             : //#                        520 Edgemont Road
      27             : //#                        Charlottesville, VA 22903-2475 USA
      28             : //#
      29             : #ifndef SYNTHESIS_DECONVOLVER_MIXIN_H_
      30             : #define SYNTHESIS_DECONVOLVER_MIXIN_H_
      31             : 
      32             : #include <casacore/casa/Containers/Record.h>
      33             : #include <synthesis/ImagerObjects/MPIGlue.h>
      34             : #include <synthesis/ImagerObjects/SynthesisDeconvolver.h>
      35             : #include <memory>
      36             : #include <algorithm>
      37             : #include <vector>
      38             : 
      39             : namespace casa {
      40             : 
      41             : /**
      42             :  * Simple mixin class to put SynthesisDeconvolver into ParallelImagerMixin
      43             :  * framework.
      44             :  */
      45             : template<class T>
      46             : class SynthesisDeconvolverMixin
      47             :         : public T {
      48             : 
      49             : private:
      50             :         std::vector< std::shared_ptr<SynthesisDeconvolver> > deconvolvers;
      51             : 
      52             :         casacore::Record controls;
      53             : 
      54             : protected:
      55             :         void
      56           0 :         setup_deconvolver(MPI_Comm comm,
      57             :                           std::vector<SynthesisParamsDeconv> &deconv_pars) {
      58             :                 // Create all deconvolver components on rank 0 of comm. TODO: Could we
      59             :                 // distribute deconvolvers in a round-robin fashion across processes in
      60             :                 // comm?
      61             : 
      62           0 :                 teardown_deconvolver();
      63           0 :                 if (T::effective_rank(comm) == 0) {
      64           0 :                         size_t num_fields = deconv_pars.size();
      65           0 :                         for (size_t i = 0; i < num_fields; ++i) {
      66           0 :                                 SynthesisDeconvolver *sd = new SynthesisDeconvolver();
      67           0 :                                 sd->setupDeconvolution(deconv_pars[i]);
      68           0 :                                 deconvolvers.push_back(
      69             :                                         std::shared_ptr<SynthesisDeconvolver>(sd));
      70             :                         }
      71             :                 }
      72           0 :         };
      73             : 
      74             :         void
      75           0 :         teardown_deconvolver() {
      76           0 :                 deconvolvers.clear();
      77           0 :         };
      78             : 
      79             : public:
      80             :         void
      81           0 :         initialize_minor_cycle() {
      82           0 :                 std::vector<casacore::Record> init_records;
      83           0 :                 for (auto sd : deconvolvers)
      84           0 :                         init_records.push_back(sd->initMinorCycle());
      85           0 :         casacore::Vector<casacore::Record> const init_records_casavec(init_records);
      86           0 :                 T::merge_initialization_records(init_records_casavec);
      87           0 :                 controls = T::get_minor_cycle_controls();
      88           0 :         };
      89             : 
      90             :         void
      91           0 :         execute_minor_cycle() {
      92           0 :                 std::vector<casacore::Record> exec_records;
      93           0 :                 for (auto sd : deconvolvers)
      94           0 :                         exec_records.push_back(sd->executeMinorCycle(controls));
      95           0 :         casacore::Vector<casacore::Record> const exec_records_casavec(exec_records);
      96           0 :                 T::merge_execution_records(exec_records_casavec);
      97           0 :         };
      98             : 
      99             :         void
     100           0 :         restore_images() {
     101           0 :                 for (auto sd : deconvolvers)
     102           0 :                         sd->restore();
     103           0 :         };
     104             : };
     105             : 
     106             : } // namespace casa
     107             : 
     108             : #endif // SYNTHESIS_DECONVOLVER_MIXIN_H_

Generated by: LCOV version 1.16