KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
dam_azenha_heat_source_process.hpp
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Lorenzo Gracia
11 //
12 //
13 
14 #if !defined(KRATOS_DAM_AZENHA_HEAT_SOURCE_PROCESS)
15 #define KRATOS_DAM_AZENHA_HEAT_SOURCE_PROCESS
16 
17 #include <cmath>
18 
19 // Project includes
20 #include "includes/kratos_flags.h"
22 #include "processes/process.h"
23 
24 // Application include
26 
27 namespace Kratos
28 {
29 
31 {
32 
33  public:
35 
36  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
37 
40  Parameters &rParameters) : Process(Flags()), mrModelPart(rModelPart)
41  {
43 
44  //only include validation with c++11 since raw_literals do not exist in c++03
45  Parameters default_parameters(R"(
46  {
47  "model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME",
48  "variable_name": "PLEASE_PRESCRIBE_VARIABLE_NAME",
49  "activation_energy" : 0.0,
50  "gas_constant" : 0.0,
51  "constant_rate" : 0.0,
52  "alpha_initial" : 0.0,
53  "q_total" : 0.0,
54  "aging" : false,
55  "young_inf" : 2e8,
56  "A" : 0.0,
57  "B" : 0.0,
58  "C" : 0.0,
59  "D" : 0.0,
60  "interval":[
61  0.0,
62  0.0
63  ]
64  } )");
65 
66  // Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them
67  // So that an error is thrown if they don't exist
68  rParameters["activation_energy"];
69  rParameters["gas_constant"];
70 
71  // Now validate agains defaults -- this also ensures no type mismatch
72  rParameters.ValidateAndAssignDefaults(default_parameters);
73 
74  mVariableName = rParameters["variable_name"].GetString();
75  mActivationEnergy = rParameters["activation_energy"].GetDouble();
76  mGasConstant = rParameters["gas_constant"].GetDouble();
77  mConstantRate = rParameters["constant_rate"].GetDouble();
78  mAlphaInitial = rParameters["alpha_initial"].GetDouble();
79  mQTotal = rParameters["q_total"].GetDouble();
80  mAging = rParameters["aging"].GetBool();
81  mA = rParameters["A"].GetDouble();
82  mB = rParameters["B"].GetDouble();
83  mC = rParameters["C"].GetDouble();
84  mD = rParameters["D"].GetDouble();
85 
86  if (mAging == true)
87  mYoungInf = rParameters["young_inf"].GetDouble();
88 
89  KRATOS_CATCH("");
90  }
91 
93 
96 
97  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
98 
99  void Execute() override
100  {
101  }
102 
103  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
104 
105  void ExecuteInitialize() override
106  {
107  KRATOS_TRY;
108 
109  if (mAging == false)
110  {
111  const int nnodes = mrModelPart.GetMesh(0).Nodes().size();
113 
114  if (nnodes != 0)
115  {
116  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.GetMesh(0).NodesBegin();
117 
118 #pragma omp parallel for
119  for (int i = 0; i < nnodes; i++)
120  {
121  ModelPart::NodesContainerType::iterator it = it_begin + i;
122 
123  // Computing initial function of alpha according las step.
124  double f_alpha = mA * (pow(mAlphaInitial, 2)) * exp(-mB * pow(mAlphaInitial, 3)) + mC * mAlphaInitial * exp(-mD * mAlphaInitial);
125 
126  // Transformation degress to Kelvins, it is necessary since gas constant is in Kelvins.
127  const double temp_current = it->FastGetSolutionStepValue(TEMPERATURE) + 273.0;
128  const double heat_flux = mConstantRate * f_alpha * exp((-mActivationEnergy) / (mGasConstant * temp_current));
129  it->FastGetSolutionStepValue(var) = heat_flux;
130  it->FastGetSolutionStepValue(ALPHA_HEAT_SOURCE) = mAlphaInitial;
131  }
132  }
133  }
134  else
135  {
136  this->ExecuteInitializeAging();
137  }
138 
139  KRATOS_CATCH("");
140  }
141 
142  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
143 
145  {
146  KRATOS_TRY;
147 
148  if (mAging == false)
149  {
150  const int nnodes = mrModelPart.GetMesh(0).Nodes().size();
152  double delta_time = mrModelPart.GetProcessInfo()[DELTA_TIME];
153 
154  if (nnodes != 0)
155  {
156  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.GetMesh(0).NodesBegin();
157 
158 #pragma omp parallel for
159  for (int i = 0; i < nnodes; i++)
160  {
161  ModelPart::NodesContainerType::iterator it = it_begin + i;
162 
163  // Computing the current alpha according las step.
164  double current_alpha = ((it->FastGetSolutionStepValue(var, 1)) / mQTotal) * delta_time + (it->FastGetSolutionStepValue(ALPHA_HEAT_SOURCE));
165  double f_alpha = mA * (pow(current_alpha, 2)) * exp(-mB * pow(current_alpha, 3)) + mC * current_alpha * exp(-mD * current_alpha);
166 
167  // This is neccesary for stopping the addition to the system once the process finish.
168  if (current_alpha >= 1.0)
169  {
170  f_alpha = 0.0;
171  current_alpha = 1.0;
172  }
173 
174  // Transformation degress to Kelvins, it is necessary since gas constant is in Kelvins.
175  const double temp_current = it->FastGetSolutionStepValue(TEMPERATURE, 1) + 273.0;
176  const double heat_flux = mConstantRate * f_alpha * exp((-mActivationEnergy) / (mGasConstant * temp_current));
177  it->FastGetSolutionStepValue(var) = heat_flux;
178  it->FastGetSolutionStepValue(ALPHA_HEAT_SOURCE) = current_alpha;
179  }
180  }
181  }
182  else
183  {
185  }
186 
187  KRATOS_CATCH("");
188  }
189 
190  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
191 
193  {
194  KRATOS_TRY;
195 
196  const int nnodes = mrModelPart.GetMesh(0).Nodes().size();
198 
199  if (nnodes != 0)
200  {
201  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.GetMesh(0).NodesBegin();
202 
203 #pragma omp parallel for
204  for (int i = 0; i < nnodes; i++)
205  {
206  ModelPart::NodesContainerType::iterator it = it_begin + i;
207 
208  // Computing initial function of alpha according las step.
209  double f_alpha = mA * (pow(mAlphaInitial, 2)) * exp(-mB * pow(mAlphaInitial, 3)) + mC * mAlphaInitial * exp(-mD * mAlphaInitial);
210 
211  // Transformation degress to Kelvins, it is necessary since gas constant is in Kelvins.
212  const double temp_current = it->FastGetSolutionStepValue(TEMPERATURE) + 273.0;
213  const double heat_flux = mConstantRate * f_alpha * exp((-mActivationEnergy) / (mGasConstant * temp_current));
214  it->FastGetSolutionStepValue(var) = heat_flux;
215  it->FastGetSolutionStepValue(ALPHA_HEAT_SOURCE) = mAlphaInitial;
216  it->FastGetSolutionStepValue(NODAL_YOUNG_MODULUS) = sqrt(mAlphaInitial) * mYoungInf;
217  }
218  }
219 
220  KRATOS_CATCH("");
221  }
222 
223  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
224 
226  {
227  KRATOS_TRY;
228 
229  const int nnodes = mrModelPart.GetMesh(0).Nodes().size();
231  double delta_time = mrModelPart.GetProcessInfo()[DELTA_TIME];
232 
233  if (nnodes != 0)
234  {
235  ModelPart::NodesContainerType::iterator it_begin = mrModelPart.GetMesh(0).NodesBegin();
236 
237 #pragma omp parallel for
238  for (int i = 0; i < nnodes; i++)
239  {
240  ModelPart::NodesContainerType::iterator it = it_begin + i;
241 
242  // Computing the current alpha according las step.
243  double current_alpha = ((it->FastGetSolutionStepValue(var, 1)) / mQTotal) * delta_time + (it->FastGetSolutionStepValue(ALPHA_HEAT_SOURCE));
244  double f_alpha = mA * (pow(current_alpha, 2)) * exp(-mB * pow(current_alpha, 3)) + mC * current_alpha * exp(-mD * current_alpha);
245 
246  // This is neccesary for stopping the addition to the system once the process finish.
247  if (current_alpha >= 1.0)
248  {
249  f_alpha = 0.0;
250  current_alpha = 1.0;
251  }
252 
253  // Transformation degress to Kelvins, it is necessary since gas constant is in Kelvins.
254  const double temp_current = it->FastGetSolutionStepValue(TEMPERATURE, 1) + 273.0;
255  const double heat_flux = mConstantRate * f_alpha * exp((-mActivationEnergy) / (mGasConstant * temp_current));
256  it->FastGetSolutionStepValue(var) = heat_flux;
257  it->FastGetSolutionStepValue(ALPHA_HEAT_SOURCE) = current_alpha;
258  it->FastGetSolutionStepValue(NODAL_YOUNG_MODULUS) = sqrt(current_alpha) * mYoungInf;
259  }
260  }
261 
262  KRATOS_CATCH("");
263  }
265 
267  std::string Info() const override
268  {
269  return "DamAzenhaHeatFluxProcess";
270  }
271 
273  void PrintInfo(std::ostream &rOStream) const override
274  {
275  rOStream << "DamAzenhaHeatFluxProcess";
276  }
277 
279  void PrintData(std::ostream &rOStream) const override
280  {
281  }
282 
284 
285  protected:
288  std::string mVariableName;
290  double mGasConstant;
293  double mQTotal;
294  double mYoungInf;
295  bool mAging;
296  double mA;
297  double mB;
298  double mC;
299  double mD;
300 
301  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
302 
303  private:
305  DamAzenhaHeatFluxProcess &operator=(DamAzenhaHeatFluxProcess const &rOther);
306 
307 }; //Class
308 
310 inline std::istream &operator>>(std::istream &rIStream,
311  DamAzenhaHeatFluxProcess &rThis);
312 
314 inline std::ostream &operator<<(std::ostream &rOStream,
315  const DamAzenhaHeatFluxProcess &rThis)
316 {
317  rThis.PrintInfo(rOStream);
318  rOStream << std::endl;
319  rThis.PrintData(rOStream);
320 
321  return rOStream;
322 }
323 
324 } /* namespace Kratos.*/
325 
326 #endif /* KRATOS_DAM_AZENHA_HEAT_SOURCE_PROCESS defined */
Definition: dam_azenha_heat_source_process.hpp:31
void ExecuteInitialize() override
This function is designed for being called at the beginning of the computations right after reading t...
Definition: dam_azenha_heat_source_process.hpp:105
bool mAging
Definition: dam_azenha_heat_source_process.hpp:295
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: dam_azenha_heat_source_process.hpp:273
double mAlphaInitial
Definition: dam_azenha_heat_source_process.hpp:292
double mGasConstant
Definition: dam_azenha_heat_source_process.hpp:290
void ExecuteInitializeSolutionStepAging()
Definition: dam_azenha_heat_source_process.hpp:225
double mC
Definition: dam_azenha_heat_source_process.hpp:298
double mQTotal
Definition: dam_azenha_heat_source_process.hpp:293
double mB
Definition: dam_azenha_heat_source_process.hpp:297
std::string mVariableName
Definition: dam_azenha_heat_source_process.hpp:288
DamAzenhaHeatFluxProcess(ModelPart &rModelPart, Parameters &rParameters)
Constructor.
Definition: dam_azenha_heat_source_process.hpp:39
double mA
Definition: dam_azenha_heat_source_process.hpp:296
double mActivationEnergy
Definition: dam_azenha_heat_source_process.hpp:289
double mD
Definition: dam_azenha_heat_source_process.hpp:299
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: dam_azenha_heat_source_process.hpp:99
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: dam_azenha_heat_source_process.hpp:279
double mConstantRate
Definition: dam_azenha_heat_source_process.hpp:291
KRATOS_CLASS_POINTER_DEFINITION(DamAzenhaHeatFluxProcess)
ModelPart & mrModelPart
Member Variables.
Definition: dam_azenha_heat_source_process.hpp:287
double mYoungInf
Definition: dam_azenha_heat_source_process.hpp:294
virtual ~DamAzenhaHeatFluxProcess()
Destructor.
Definition: dam_azenha_heat_source_process.hpp:95
void ExecuteInitializeSolutionStep() override
This function will be executed at every time step BEFORE performing the solve phase.
Definition: dam_azenha_heat_source_process.hpp:144
void ExecuteInitializeAging()
Definition: dam_azenha_heat_source_process.hpp:192
std::string Info() const override
Turn back information as a string.
Definition: dam_azenha_heat_source_process.hpp:267
Definition: flags.h:58
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
NodesContainerType & Nodes()
Definition: mesh.h:346
NodeIterator NodesBegin()
Definition: mesh.h:326
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
The base class for all processes in Kratos.
Definition: process.h:49
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
delta_time
Definition: generate_frictional_mortar_condition.py:130
int f_alpha
alpha method affected variables
Definition: generate_two_fluid_navier_stokes.py:133
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17