TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
ScalarRegister.cpp
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15#include <ScalarRegister.h>
16#include <iostream>
17#include <Process.h>
18
19void ScalarRegister::setInputIntValue(const Nom& name, const int& val)
20{
21 std::string nom = name.getString();
22 int_reg[nom] = val;
23}
24
25void ScalarRegister::setInputDoubleValue(const Nom& name, const double& val)
26{
27 std::string nom = name.getString();
28 double_reg[nom] = val;
29}
30
32{
33 std::string nom = name.getString();
34 if (int_reg.find(nom)!= int_reg.end())
35 return int_reg.at(nom);
36 else
37 {
38 Cerr << "Internal error, register int" << name << " does not exist!" << finl;
39 Process::exit(-1);
40 return 0;
41 }
42}
43
45{
46 std::string nom = name.getString();
47 if (double_reg.find(nom)!= double_reg.end())
48 return double_reg.at(nom);
49 else
50 {
51 Cerr << "Internal error, register double" << name << " does not exist" << finl;
52 Process::exit(-1);
53 return 0.;
54 }
55}
56
58{
59 std::string nom = name.getString();
60 if (int_reg.find(nom)!= int_reg.end())
61 return true;
62 else
63 return false;
64}
65
67{
68 std::string nom = name.getString();
69 if (double_reg.find(nom)!= double_reg.end())
70 return true;
71 else
72 return false;
73
74}
75
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
const std::string & getString() const
Definition Nom.h:92
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
std::map< std::string, double > double_reg
void setInputDoubleValue(const Nom &name, const double &val)
double getOutputDoubleValue(const Nom &name) const
int getOutputIntValue(const Nom &name) const
bool checkOutputIntEntry(const Nom &name) const
std::map< std::string, int > int_reg
bool checkOutputDoubleEntry(const Nom &name) const
void setInputIntValue(const Nom &name, const int &val)