TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Resoudre.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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
16#include <Resoudre.h>
17#include <Probleme_U.h>
18#include <Catch_SIGINIT.h>
19#include <signal.h>
20#include <Perf_counters.h>
21
22Implemente_instanciable(Resoudre,"Resoudre|Solve",Interprete);
23// XD solve interprete resoudre NO_BRACE Interpretor to start calculation with TRUST.
24// XD attr pb ref_pb_gen_base pb REQ Name of problem to be solved.
25
26/*! @brief Simple call to: Interprete::printOn(Sortie&)
27 *
28 * Prints the interpreter to an output stream
29 *
30 * @param (Sortie& os) an output stream
31 * @return (Sortie&) the modified output stream
32 */
34{
35 return Interprete::printOn(os);
36}
37
38
39/*! @brief Simple call to: Interprete::readOn(Entree&)
40 *
41 * @param (Entree& is) an input stream
42 * @return (Entree&) the modified input stream
43 */
45{
46 return Interprete::readOn(is);
47}
48
49
50/*! @brief Task of the interpretor: Solve a problem (name read from the input stream)
51 *
52 */
54{
55 Nom problem_name;
56 is >> problem_name;
57 Probleme_U& pb=ref_cast(Probleme_U,objet(problem_name));
58 statistics().begin_count(STD_COUNTERS::computation_start_up);
59 Nom string("=====================================================");
60 Cerr << string << finl;
61 Cerr << "Initialization of the problem " << pb.le_nom() << " ("<<que_suis_je()<<") in progress ... " << finl;
62 Cerr << string << finl;
63 // Initialize the problem
64 pb.initialize();
65
66 // Register signal and signal handler (SIGINT) if user presses ctrl-c during exec
68 {
69 Catch_SIGINIT sig;
72 }
73
74 Cerr << string << finl;
75 Cerr << "Solving of the problem " << pb.le_nom() << " ("<<que_suis_je()<<") in progress ... " << finl;
76 Cerr << string << finl;
77 // Run the problem
78 bool ok = pb.run();
79
80 // Terminate the problem
81 pb.terminate();
82 Cerr << string << finl;
83 Cerr << "End of solving of the problem " << pb.le_nom() << " ("<<que_suis_je()<<")" << finl;
84 Cerr << string << finl;
85 if (!ok)
86 {
87 Cerr << "Error while solving!" << finl;
88 exit();
89 }
90
91 return is;
92}
93
static void signal_callback_handler(int signum)
void set_nom_cas_pour_signal(const Nom &cas)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Base class for "interpreter" objects.
Definition Interprete.h:38
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
Definition Objet_U.cpp:145
static int DEACTIVATE_SIGINT_CATCH
Definition Objet_U.h:98
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Probleme_U.
Definition Probleme_U.h:46
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
virtual void terminate()
This method is called once at the end, after any other one.
virtual bool run()
This method is a sort of main() for the Problem. It can be used if the problem is not coupled with an...
virtual void initialize()
This method is called once at the beginning, before any other one of the interface Problem.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Resoudre Interpreter that solves a problem:
Definition Resoudre.h:31
Entree & interpreter(Entree &) override
Task of the interpretor: Solve a problem (name read from the input stream).
Definition Resoudre.cpp:53
Base class for output streams.
Definition Sortie.h:52