TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Schema_Adams_Bashforth_order_2.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Schema_Adams_Bashforth_order_2.h>
17#include <Equation_base.h>
18#include <TRUSTTrav.h>
19
20Implemente_instanciable(Schema_Adams_Bashforth_order_2,"Schema_Adams_Bashforth_order_2",Schema_Adams_Bashforth_base);
21// XD schema_adams_bashforth_order_2 schema_temps_base schema_adams_bashforth_order_2 INHERITS_BRACE not_set
22
24{
26}
27
29{
31}
32
33////////////////////////////////
34// //
35// Schema characteristics //
36// //
37////////////////////////////////
38
39
40/*! @brief Returns the number of temporal values to keep.
41 *
42 * Here: n-1, n and n+1, so 3.
43 *
44 */
49
50/*! @brief Returns the number of time steps strictly beyond which the Adams-Bashforth scheme is applied.
51 *
52 * Here: we need at least 1 past time, so 0.
53 *
54 */
56{
57 return 0 ;
58}
59
60/*! @brief Returns the number of past temporal values.
61 *
62 * Here: n-1, so 1.
63 *
64 */
66{
67 return 1 ;
68}
69
70/////////////////////////////////////////
71// //
72// End of schema characteristics //
73// //
74/////////////////////////////////////////
75
77{
78 assert(times.size_array() == 3); //past, present and future times, stored in ascending order inside "times" table
79
80 if (coefficients().size_array() != 2)
81 {
82 coefficients().resize(2,RESIZE_OPTIONS::NOCOPY_NOINIT);
83 }
84
85 double past_time = times[0];
86 double present_time = times[1];
87 double future_time = times[2];
88 double past_time_step = present_time-past_time;
89
90 coefficients()[1] = 1./past_time_step;
91 coefficients()[1] *= (future_time+present_time-2*past_time);
92 coefficients()[1] *= 0.5;
93 assert(coefficients()[1] >= 0.);
94
95 coefficients()[0] = 1-coefficients()[1];
96 assert(coefficients()[0] <= 1.);
97}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
const DoubleTab & coefficients() const override
class Schema_Adams_Bashforth_order_2 This class represents a variable time-step second-order Adams-Ba...
int nb_pas_dt_seuil() const override
Returns the number of time steps strictly beyond which the Adams-Bashforth scheme is applied.
int nb_valeurs_temporelles() const override
Returns the number of temporal values to keep.
int nb_valeurs_passees() const override
Returns the number of past temporal values.
void compute_adams_bashforth_coefficients(double time_step, const DoubleTab &times) override
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size_array() const
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469