LCOV - code coverage report
Current view: top level - coupling/transferstrategies - TransferStrategy4SchwarzCoupling.cpph (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 49 0
Test Date: 2026-08-21 15:14:06 Functions: 0.0 % 8 0

            Line data    Source code
       1              : // Copyright (C) 2015 Technische Universitaet Muenchen
       2              : // This file is part of the Mamico project. For conditions of distribution
       3              : // and use, please see the copyright notice in Mamico's main folder, or at
       4              : // www5.in.tum.de/mamico
       5              : 
       6              : template <class LinkedCell, unsigned int dim>
       7            0 : void coupling::transferstrategies::TransferStrategy4SchwarzCoupling<LinkedCell, dim>::beginProcessInnerCouplingCellsBeforeReceivingMacroscopicSolverData() {
       8              :   // reset sample counter
       9            0 :   _sampleCounter = 0;
      10            0 : }
      11              : 
      12              : template <class LinkedCell, unsigned int dim>
      13            0 : void coupling::transferstrategies::TransferStrategy4SchwarzCoupling<LinkedCell, dim>::processInnerCouplingCellAfterReceivingMacroscopicSolverData(
      14              :     coupling::datastructures::CouplingCellWithLinkedCells<LinkedCell, dim>& cell, I02 index) {
      15              :   // convert momentum to velocity values for cont->MD transfer
      16            0 :   if (cell.getMicroscopicMass() == 0.0) {
      17            0 :     cell.setMicroscopicMomentum(tarch::la::Vector<dim, double>(0.0));
      18              :   } else {
      19            0 :     cell.setMicroscopicMomentum((1.0 / cell.getMicroscopicMass()) * cell.getMicroscopicMomentum());
      20              :   }
      21              :   // currently: no mass transfer anywhere
      22            0 :   cell.setMicroscopicMass(0.0);
      23              :   // reset macroscopic solver values (from averaging) and store old mass
      24            0 :   cell.setMacroscopicMass(0.0);
      25            0 :   cell.setMacroscopicMomentum(tarch::la::Vector<dim, double>(0.0));
      26            0 : }
      27              : 
      28              : template <class LinkedCell, unsigned int dim>
      29            0 : void coupling::transferstrategies::TransferStrategy4SchwarzCoupling<LinkedCell, dim>::processOuterCouplingCellAfterReceivingMacroscopicSolverData(
      30              :     coupling::datastructures::CouplingCellWithLinkedCells<LinkedCell, dim>& cell, I02 index) {
      31            0 :   if (cell.getMicroscopicMass() == 0.0) {
      32            0 :     cell.setMicroscopicMomentum(tarch::la::Vector<dim, double>(0.0));
      33              :   } else {
      34            0 :     cell.setMicroscopicMomentum((1.0 / cell.getMicroscopicMass()) * cell.getMicroscopicMomentum());
      35              :   }
      36            0 :   cell.setMicroscopicMass(0.0);
      37            0 :   cell.setMacroscopicMass(0.0);
      38            0 :   cell.setMacroscopicMomentum(tarch::la::Vector<dim, double>(0.0));
      39            0 : }
      40              : 
      41              : template <class LinkedCell, unsigned int dim>
      42            0 : void coupling::transferstrategies::TransferStrategy4SchwarzCoupling<LinkedCell, dim>::processInnerCouplingCellBeforeSendingMDSolverData(
      43              :     coupling::datastructures::CouplingCellWithLinkedCells<LinkedCell, dim>& cell, I02 index) {
      44              : #if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
      45              :   std::cout << "processInnerCouplingCellBeforeSendingMDSolverData(): Data "
      46              :                "before averaging from cell "
      47              :             << index << "Mass: " << cell.getMacroscopicMass() << " , momentum: " << cell.getMacroscopicMomentum() << std::endl;
      48              : #endif
      49              :   // average sampled data from MD
      50            0 :   if (_sampleCounter != 0) {
      51            0 :     const double mass = cell.getMacroscopicMass() / ((double)_sampleCounter);
      52            0 :     const tarch::la::Vector<dim, double> momentum = (1.0 / ((double)_sampleCounter)) * cell.getMacroscopicMomentum();
      53            0 :     cell.setMacroscopicMass(mass);
      54            0 :     cell.setMacroscopicMomentum(momentum);
      55              :   } else {
      56            0 :     cell.setMacroscopicMass(0.0);
      57            0 :     cell.setMacroscopicMomentum(tarch::la::Vector<dim, double>(0.0));
      58              :   }
      59              : #if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
      60              :   std::cout << "Samplecounter=" << _sampleCounter << std::endl;
      61              :   std::cout << "processInnerCouplingCellBeforeSendingMDSolverData(): Data "
      62              :                "from cell "
      63              :             << index << "Mass: " << cell.getMacroscopicMass() << " , momentum: " << cell.getMacroscopicMomentum() << std::endl;
      64              : #endif
      65            0 : }
      66              : 
      67              : template <class LinkedCell, unsigned int dim>
      68            0 : void coupling::transferstrategies::TransferStrategy4SchwarzCoupling<LinkedCell, dim>::processOuterCouplingCellBeforeSendingMDSolverData(
      69              :     coupling::datastructures::CouplingCellWithLinkedCells<LinkedCell, dim>& cell, I02 index) {
      70            0 :   cell.setMacroscopicMass(0.0);
      71            0 :   cell.setMacroscopicMomentum(tarch::la::Vector<dim, double>(0.0));
      72            0 : }
      73              : 
      74              : template <class LinkedCell, unsigned int dim>
      75            0 : void coupling::transferstrategies::TransferStrategy4SchwarzCoupling<LinkedCell, dim>::beginProcessInnerCouplingCellsAfterMDTimestep() {
      76            0 :   _timestepCounter++;
      77            0 :   if (sample()) {
      78            0 :     _sampleCounter++;
      79              :   }
      80            0 : }
      81              : 
      82              : template <class LinkedCell, unsigned int dim>
      83            0 : void coupling::transferstrategies::TransferStrategy4SchwarzCoupling<LinkedCell, dim>::processInnerCouplingCellAfterMDTimestep(
      84              :     coupling::datastructures::CouplingCellWithLinkedCells<LinkedCell, dim>& cell, I02 index) {
      85              :   // averaging: evaluate current state
      86            0 :   if (sample()) {
      87            0 :     cell.iterateConstCells(_massMapping);
      88            0 :     const double mass = _massMapping.getMass();
      89            0 :     cell.iterateConstCells(_momentumMapping);
      90            0 :     const tarch::la::Vector<dim, double> momentum = _momentumMapping.getMomentum();
      91            0 :     cell.addMacroscopicMass(mass);
      92            0 :     cell.addMacroscopicMomentum(momentum);
      93              :   }
      94            0 : }
      95              : 
      96            0 : template <class LinkedCell, unsigned int dim> bool coupling::transferstrategies::TransferStrategy4SchwarzCoupling<LinkedCell, dim>::sample() const {
      97              :   // sample strategy: for a hard-coded time-limit, sample only over 20% of
      98              :   // coupling cycle
      99            0 :   const unsigned int timestepInThisCouplingCycle = _timestepCounter % _numberMDSteps;
     100            0 :   return ((timestepInThisCouplingCycle > 0.8 * _numberMDSteps - 1) && ((_timestepCounter - 1) % _sampleEveryTimestep == 0));
     101              : }
        

Generated by: LCOV version 2.0-1