LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMNumberDensity.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 21 34 61.8 %
Date: 2024-10-10 19:51:30 Functions: 6 8 75.0 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  * ALMA - Atacama Large Millimiter Array
       3             :  * (c) Instituto de Estructura de la Materia, 2009
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or
       6             :  * modify it under the terms of the GNU Lesser General Public
       7             :  * License as published by the Free Software Foundation; either
       8             :  * version 2.1 of the License, or (at your option) any later version.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  * Lesser General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public
      16             :  * License along with this library; if not, write to the Free Software
      17             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      18             :  *
      19             :  * "@(#) $Id: ATMNumberDensity.cpp Exp $"
      20             :  *
      21             :  * who       when      what
      22             :  * --------  --------  ----------------------------------------------
      23             :  * pardo     24/03/09  created
      24             :  */
      25             : 
      26             : #include "ATMNumberDensity.h"
      27             : 
      28             : 
      29             : 
      30             : ATM_NAMESPACE_BEGIN
      31             : 
      32       13025 : NumberDensity::NumberDensity() :
      33       13025 :   valueIS_(0.0)
      34             : {
      35       13025 : }
      36             : 
      37        2530 : NumberDensity::NumberDensity(double numberdensity) :
      38        2530 :   valueIS_(numberdensity)
      39             : {
      40        2530 : }
      41             : 
      42           0 : NumberDensity::NumberDensity(double numberdensity, const std::string &units)
      43             : {
      44           0 :   if(units == "cm**-3" || units == "CM**-3") {
      45           0 :     valueIS_ = 1.0E+6 * numberdensity;
      46           0 :   } else if(units == "m**-3" || units == "M**-3") {
      47           0 :     valueIS_ = numberdensity;
      48             :   } else {
      49             :     // Exception: unknown number density unit. S.I. unit (m**-3) used by default.
      50           0 :     valueIS_ = numberdensity;
      51             :   }
      52           0 : }
      53             : 
      54       13010 : NumberDensity::NumberDensity(double numberdensity, NumberDensity::Units units)
      55             : {
      56       13010 :   if(units == NumberDensity::UnitInverseCubicCentiMeter) {
      57       12650 :     valueIS_ = 1.0E+6 * numberdensity;
      58         360 :   } else if(units == NumberDensity::UnitInverseCubicMeter) {
      59         360 :     valueIS_ = numberdensity;
      60             :   } else {
      61             :     // Exception: unknown number density unit. S.I. unit (m**-3) used by default.
      62           0 :     valueIS_ = numberdensity;
      63             :   }
      64       13010 : }
      65             : 
      66       58925 : NumberDensity::~NumberDensity()
      67             : {
      68       58925 : }
      69             : 
      70         360 : double NumberDensity::get(const std::string &units) const
      71             : {
      72         360 :   if(units == "cm**-3" || units == "CM**-3") {
      73           0 :     return 1.0E-6 * valueIS_;
      74         360 :   } else if(units == "m**-3" || units == "M**-3") {
      75         360 :     return valueIS_;
      76             :   } else {
      77             :     // Exception: unknown number density unit. S.I. unit (m**-3) used by default.
      78           0 :     return valueIS_;
      79             :   }
      80             : }
      81             : 
      82       12650 : double NumberDensity::get(NumberDensity::Units units) const
      83             : {
      84       12650 :   if(units == NumberDensity::UnitInverseCubicCentiMeter) {
      85       12650 :     return 1.0E-6 * valueIS_;
      86           0 :   } else if(units == NumberDensity::UnitInverseCubicMeter) {
      87           0 :     return valueIS_;
      88             :   } else {
      89             :     // Exception: unknown number density unit. S.I. unit (m**-3) used by default.
      90           0 :     return valueIS_;
      91             :   }
      92             : }
      93             : 
      94             : ATM_NAMESPACE_END

Generated by: LCOV version 1.16