LCOV - code coverage report
Current view: top level - src/reduced_basis - rb_temporal_discretization.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 54 54 100.0 %
Date: 2025-08-19 19:27:09 Functions: 13 13 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // rbOOmit: An implementation of the Certified Reduced Basis method.
       2             : // Copyright (C) 2009, 2010 David J. Knezevic
       3             : 
       4             : // This file is part of rbOOmit.
       5             : 
       6             : // rbOOmit is free software; you can redistribute it and/or
       7             : // modify it under the terms of the GNU Lesser General Public
       8             : // License as published by the Free Software Foundation; either
       9             : // version 2.1 of the License, or (at your option) any later version.
      10             : 
      11             : // rbOOmit is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             : // Lesser General Public License for more details.
      15             : 
      16             : // You should have received a copy of the GNU Lesser General Public
      17             : // License along with this library; if not, write to the Free Software
      18             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      19             : 
      20             : // rbOOmit includes
      21             : #include "libmesh/rb_temporal_discretization.h"
      22             : 
      23             : // libMesh includes
      24             : #include "libmesh/getpot.h"
      25             : 
      26             : namespace libMesh
      27             : {
      28             : 
      29         280 : RBTemporalDiscretization::RBTemporalDiscretization()
      30         264 :   : _delta_t(0.),
      31         264 :     _euler_theta(0.),
      32         264 :     _current_time_step(0),
      33         280 :     _n_time_steps(0)
      34         280 : {}
      35             : 
      36     4576361 : Real RBTemporalDiscretization::get_delta_t() const
      37             : {
      38     4576361 :   return _delta_t;
      39             : }
      40             : 
      41         280 : void RBTemporalDiscretization::set_delta_t(const Real delta_t_in)
      42             : {
      43         280 :   _delta_t = delta_t_in;
      44         280 : }
      45             : 
      46     2369361 : Real RBTemporalDiscretization::get_euler_theta() const
      47             : {
      48     2369361 :   return _euler_theta;
      49             : }
      50             : 
      51         280 : void RBTemporalDiscretization::set_euler_theta(const Real euler_theta_in)
      52             : {
      53           8 :   libmesh_assert((0. <= euler_theta_in ) && (euler_theta_in <= 1.));
      54         280 :   _euler_theta = euler_theta_in;
      55         280 : }
      56             : 
      57     2510691 : unsigned int RBTemporalDiscretization::get_time_step() const
      58             : {
      59     2510691 :   return _current_time_step;
      60             : }
      61             : 
      62     2370820 : void RBTemporalDiscretization::set_time_step(const unsigned int k)
      63             : {
      64      206252 :   libmesh_assert_less_equal (k, get_n_time_steps());
      65     2370820 :   this->_current_time_step = k;
      66     2370820 : }
      67             : 
      68     7845953 : unsigned int RBTemporalDiscretization::get_n_time_steps() const
      69             : {
      70     7845953 :   return _n_time_steps;
      71             : }
      72             : 
      73         280 : void RBTemporalDiscretization::set_n_time_steps(const unsigned int K)
      74             : {
      75         280 :   _n_time_steps = K;
      76         280 :   _control.assign(_n_time_steps+1,1.0);
      77         280 : }
      78             : 
      79     4554000 : Real RBTemporalDiscretization::get_control(const unsigned int k) const
      80             : {
      81      404400 :   libmesh_assert_less_equal (k, get_n_time_steps());
      82     4958400 :   return _control[k];
      83             : }
      84             : 
      85         140 : void RBTemporalDiscretization::set_control(const std::vector<Real> & control)
      86             : {
      87           4 :   libmesh_assert_less_equal(control.size(),_n_time_steps+1);
      88         140 :   _control = control;
      89             :   // If the input vector is smaller than the number of time steps (+1), we complete it with zeros
      90         140 :   _control.resize(_n_time_steps+1);
      91         140 : }
      92             : 
      93          70 : void RBTemporalDiscretization::process_temporal_parameters_file (const std::string & parameters_filename)
      94             : {
      95             :   // Read in data from parameters_filename
      96         144 :   GetPot infile(parameters_filename);
      97             : 
      98             :   // Read in parameters related to temporal discretization
      99          70 :   unsigned int n_time_steps_in = infile("n_time_steps", get_n_time_steps());
     100          70 :   const Real delta_t_in        = infile("delta_t",      get_delta_t());
     101          70 :   const Real euler_theta_in    = infile("euler_theta",  get_euler_theta());
     102             : 
     103             :   // and set the relevant member variables
     104          70 :   set_n_time_steps(n_time_steps_in);
     105          70 :   set_delta_t(delta_t_in);
     106          70 :   set_euler_theta(euler_theta_in);
     107          70 :   set_time_step(0);
     108          70 : }
     109             : 
     110         140 : void RBTemporalDiscretization::pull_temporal_discretization_data(RBTemporalDiscretization & other)
     111             : {
     112         140 :   this->set_delta_t( other.get_delta_t() );
     113         140 :   this->set_euler_theta( other.get_euler_theta() );
     114         140 :   this->set_n_time_steps( other.get_n_time_steps() );
     115         140 :   this->set_time_step( other.get_time_step() );
     116         140 :   this->set_control( other._control );
     117         140 : }
     118             : 
     119             : }

Generated by: LCOV version 1.14