LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMNumberDensity.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 22 34 64.7 %
Date: 2024-12-11 20:54:31 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      152630 : NumberDensity::NumberDensity() :
      33      152630 :   valueIS_(0.0)
      34             : {
      35      152630 : }
      36             : 
      37       29917 : NumberDensity::NumberDensity(double numberdensity) :
      38       29917 :   valueIS_(numberdensity)
      39             : {
      40       29917 : }
      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      150745 : NumberDensity::NumberDensity(double numberdensity, NumberDensity::Units units)
      55             : {
      56      150745 :   if(units == NumberDensity::UnitInverseCubicCentiMeter) {
      57      149585 :     valueIS_ = 1.0E+6 * numberdensity;
      58        1160 :   } else if(units == NumberDensity::UnitInverseCubicMeter) {
      59        1160 :     valueIS_ = numberdensity;
      60             :   } else {
      61             :     // Exception: unknown number density unit. S.I. unit (m**-3) used by default.
      62           0 :     valueIS_ = numberdensity;
      63             :   }
      64      150745 : }
      65             : 
      66      692296 : NumberDensity::~NumberDensity()
      67             : {
      68      692296 : }
      69             : 
      70        1160 : double NumberDensity::get(const std::string &units) const
      71             : {
      72        1160 :   if(units == "cm**-3" || units == "CM**-3") {
      73           0 :     return 1.0E-6 * valueIS_;
      74        1160 :   } 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         800 :     return valueIS_;
      79             :   }
      80             : }
      81             : 
      82      149585 : double NumberDensity::get(NumberDensity::Units units) const
      83             : {
      84      149585 :   if(units == NumberDensity::UnitInverseCubicCentiMeter) {
      85      149585 :     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