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.
set_material_properties_for_thermal_coupling_process.hpp
Go to the documentation of this file.
1 //-------------------------------------------------------------
2 // ___ __ ___ _ _ _
3 // KRATOS| _ \/ _|___ _ __ | __| |_ _(_)__| |
4 // | _/ _/ -_) ' \| _|| | || | / _` |
5 // |_| |_| \___|_|_|_|_| |_|\_,_|_\__,_|DYNAMICS
6 //
7 // BSD License: PfemFluidDynamicsApplication/license.txt
8 //
9 // Main authors: Rafael Rangel
10 // Collaborators:
11 //
12 //-------------------------------------------------------------
13 //
14 
15 #if !defined(SET_MATERIAL_PROPERTIES_FOR_THERMAL_COUPLING_PROCESS)
16 #define SET_MATERIAL_PROPERTIES_FOR_THERMAL_COUPLING_PROCESS
17 
18 #include "includes/variables.h"
20 #include "includes/define.h"
21 #include "includes/model_part.h"
22 #include "processes/process.h"
25 
26 namespace Kratos
27 {
28 
40 
41  public:
42 
44 
48  rThermalModelPart(thermal_model_part) {}
49 
52 
53  void operator()() {
54  Execute();
55  }
56 
57  void Execute() override {
58  KRATOS_TRY;
59 
60  this->SetMaterialProperties(rFluidModelPart, rThermalModelPart);
61 
62  KRATOS_CATCH("");
63  }
64 
65  void ExecuteInitialize() override {}
66 
67  void ExecuteInitializeSolutionStep() override {}
68 
69  protected:
70 
73 
74  private:
75 
76  void SetMaterialProperties(ModelPart& rFluidModelPart, ModelPart& rThermalModelPart) const {
77 
78  const ProcessInfo& rCurrentProcessInfo = rFluidModelPart.GetProcessInfo();
79  ConvectionDiffusionSettings::Pointer my_settings = rCurrentProcessInfo.GetValue(CONVECTION_DIFFUSION_SETTINGS);
80 
81  // Loop over all nodes
82  for (ModelPart::NodesContainerType::iterator i_node = rFluidModelPart.NodesBegin(); i_node != rFluidModelPart.NodesEnd(); i_node++) {
83 
84  // Nodal temperature
85  double temp = i_node->FastGetSolutionStepValue(TEMPERATURE);
86 
87  // Initialize thermal properties
88  double density = 0.0;
89  double conductivity = 0.0;
90  double capacity = 0.0;
91 
92  // Loop over incident elements
93  ElementWeakPtrVectorType& neighbour_elements = i_node->GetValue(NEIGHBOUR_ELEMENTS);
94  int n = 0;
95 
96  for (auto& i_nelem : neighbour_elements) {
97 
98  // Get constitutive law
99  ConstitutiveLaw::Pointer constLaw = i_nelem.GetProperties().GetValue(CONSTITUTIVE_LAW);
100  if (constLaw != nullptr) {
101  n++;
102  auto constitutive_law_values = ConstitutiveLaw::Parameters(i_nelem.GetGeometry(), i_nelem.GetProperties(), rCurrentProcessInfo);
103  const Properties& r_properties = constitutive_law_values.GetMaterialProperties();
104 
105  double effective_density = 0.0;
106  double effective_conductivity = 0.0;
107  double effective_capacity = 0.0;
108 
109  // Compute effective properties corresponding to nodal temperature
110  if (r_properties.HasTable(TEMPERATURE, DENSITY)) {
111  const auto& r_table = r_properties.GetTable(TEMPERATURE, DENSITY);
112  effective_density = r_table.GetValue(temp);
113  } else {
114  effective_density = r_properties[DENSITY];
115  }
116 
117  if (r_properties.HasTable(TEMPERATURE, CONDUCTIVITY)) {
118  const auto& r_table = r_properties.GetTable(TEMPERATURE, CONDUCTIVITY);
119  effective_conductivity = r_table.GetValue(temp);
120  }
121  else {
122  effective_conductivity = r_properties[CONDUCTIVITY];
123  }
124 
125  if (r_properties.HasTable(TEMPERATURE, SPECIFIC_HEAT)) {
126  const auto& r_table = r_properties.GetTable(TEMPERATURE, SPECIFIC_HEAT);
127  effective_capacity = r_table.GetValue(temp);
128  }
129  else {
130  effective_capacity = r_properties[SPECIFIC_HEAT];
131  }
132 
133  // Accumulate element properties
134  density += effective_density;
135  conductivity += effective_conductivity;
136  capacity += effective_capacity;
137  }
138  }
139 
140  // Set nodal properties as the average of the values computed in the incident elements
141  if (n > 0) {
142  const Variable<double>& rDensityVar = my_settings->GetDensityVariable();
143  const Variable<double>& rDiffusionVar = my_settings->GetDiffusionVariable();
144  const Variable<double>& rSpecificHeatVar = my_settings->GetSpecificHeatVariable();
145 
146  i_node->FastGetSolutionStepValue(rDensityVar) = density / n;
147  i_node->FastGetSolutionStepValue(rDiffusionVar) = conductivity / n;
148  i_node->FastGetSolutionStepValue(rSpecificHeatVar) = capacity / n;
149  }
150  }
151  }
152  }; // Class SetMaterialPropertiesForThermalCouplingProcess
153 
155  inline std::istream& operator>>(std::istream& rIStream,
157 
159  inline std::ostream& operator<<(std::ostream& rOStream,
161  rThis.PrintInfo(rOStream);
162  rOStream << std::endl;
163  rThis.PrintData(rOStream);
164 
165  return rOStream;
166  }
167 
168 } // namespace Kratos.
169 
170 #endif /* SET_MATERIAL_PROPERTIES_FOR_THERMAL_COUPLING_PROCESS defined */
TDataType & GetValue(const Variable< TDataType > &rThisVariable)
Gets the value associated with a given variable.
Definition: data_value_container.h:268
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
The base class for all processes in Kratos.
Definition: process.h:49
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: process.h:204
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: process.h:210
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
bool HasTable(const TXVariableType &XVariable, const TYVariableType &YVariable) const
Definition: properties.h:584
TableType & GetTable(const TXVariableType &XVariable, const TYVariableType &YVariable)
Definition: properties.h:376
This process sets the nodal value of thermal properties (density, conductivity and capacity) that dep...
Definition: set_material_properties_for_thermal_coupling_process.hpp:39
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: set_material_properties_for_thermal_coupling_process.hpp:57
ModelPart & rThermalModelPart
Definition: set_material_properties_for_thermal_coupling_process.hpp:72
SetMaterialPropertiesForThermalCouplingProcess(ModelPart &fluid_model_part, ModelPart &thermal_model_part)
Constructor.
Definition: set_material_properties_for_thermal_coupling_process.hpp:46
void ExecuteInitializeSolutionStep() override
This function will be executed at every time step BEFORE performing the solve phase.
Definition: set_material_properties_for_thermal_coupling_process.hpp:67
void ExecuteInitialize() override
This function is designed for being called at the beginning of the computations right after reading t...
Definition: set_material_properties_for_thermal_coupling_process.hpp:65
void operator()()
Definition: set_material_properties_for_thermal_coupling_process.hpp:53
KRATOS_CLASS_POINTER_DEFINITION(SetMaterialPropertiesForThermalCouplingProcess)
~SetMaterialPropertiesForThermalCouplingProcess() override
Destructor.
Definition: set_material_properties_for_thermal_coupling_process.hpp:51
ModelPart & rFluidModelPart
Definition: set_material_properties_for_thermal_coupling_process.hpp:71
TResultType GetValue(TArgumentType const &X) const
Definition: piecewize_linear_table.h:138
#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
fluid_model_part
Definition: edgebased_PureConvection.py:18
float conductivity
Definition: face_heat.py:55
float density
Definition: face_heat.py:56
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
float temp
Definition: rotating_cone.py:85
Definition: constitutive_law.h:189