1 //============================================================================
3 * \file DiffusionEquation.hxx
4 * \author Michael NDJINGA
7 * \brief Heat diffusion equation
9 //============================================================================
11 /*! \class DiffusionEquation DiffusionEquation.hxx "DiffusionEquation.hxx"
12 * \brief Scalar heat equation for the Uranium rods temperature
13 * \details see \ref DiffusionEqPage for more details
15 #ifndef DiffusionEquation_HXX_
16 #define DiffusionEquation_HXX_
18 #include "ProblemCoreFlows.hxx"
23 //! enumeration BoundaryType
24 /*! Boundary condition type */
25 enum BoundaryTypeDiffusion { NeumannDiffusion, DirichletDiffusion, NoneBCDiffusion};
27 /** \struct LimitField
28 * \brief value of some fields on the boundary */
29 struct LimitFieldDiffusion{
30 LimitFieldDiffusion(){bcType=NoneBCDiffusion; T=0; normalFlux=0;}
31 LimitFieldDiffusion(BoundaryTypeDiffusion _bcType, double _T, double _normalFlux){
32 bcType=_bcType; T=_T; normalFlux=_normalFlux;
35 BoundaryTypeDiffusion bcType;
36 double T; //for Dirichlet
37 double normalFlux; //for Neumann
40 class DiffusionEquation: public ProblemCoreFlows
44 /** \fn DiffusionEquation
45 * \brief Constructor for the temperature diffusion in a solid
46 * \param [in] int : space dimension
47 * \param [in] double : solid density
48 * \param [in] double : solid specific heat at constant pressure
49 * \param [in] double : solid conductivity
52 DiffusionEquation( int dim,bool FECalculation=true,double rho=10000,double cp=300,double lambda=5);
56 void terminate();//vide la mémoire et enregistre le résultat final
57 bool initTimeStep(double dt);
58 double computeTimeStep(bool & stop);//propose un pas de temps pour le calcul. Celà nécessite de discrétiser les opérateur (convection, diffusion, sources) et pour chacun d'employer la condition cfl. En cas de problème durant ce calcul (exemple t=tmax), renvoie stop=true
59 void abortTimeStep();//efface les inconnues calculées par solveTimeStep() et reinitialise dt à 0
60 bool iterateTimeStep(bool &ok);
62 void validateTimeStep();
64 /* Boundary conditions */
65 void setBoundaryFields(map<string, LimitFieldDiffusion> boundaryFields){
66 _limitField = boundaryFields;
68 /** \fn setDirichletBoundaryCondition
69 * \brief adds a new boundary condition of type Dirichlet
71 * \param [in] string : the name of the boundary
72 * \param [in] double : the value of the temperature at the boundary
75 void setDirichletBoundaryCondition(string groupName,double Temperature){
76 _limitField[groupName]=LimitFieldDiffusion(DirichletDiffusion,Temperature,-1);
78 /** \fn setNeumannBoundaryCondition
79 * \brief adds a new boundary condition of type Neumann
81 * \param [in] string : the name of the boundary
84 void setNeumannBoundaryCondition(string groupName, double normalFlux=0){
85 _limitField[groupName]=LimitFieldDiffusion(NeumannDiffusion,-1, normalFlux);
88 void setRodDensity(double rho){
91 void setConductivity(double conductivite){
92 _conductivity=conductivite;
94 void setFluidTemperatureField(Field coupledTemperatureField){
95 _fluidTemperatureField=coupledTemperatureField;
96 _fluidTemperatureFieldSet=true;
99 void setDiffusiontensor(Matrix DiffusionTensor){
100 _DiffusionTensor=DiffusionTensor;
103 void setFluidTemperature(double fluidTemperature){
104 _fluidTemperature=fluidTemperature;
107 //get output fields for postprocessing or coupling
108 vector<string> getOutputFieldsNames() ;//liste tous les champs que peut fournir le code pour le postraitement
109 Field& getOutputField(const string& nameField );//Renvoie un champs pour le postraitement
111 Field& getRodTemperatureField(){
114 Field& getFluidTemperatureField(){
115 return _fluidTemperatureField;
119 double computeDiffusionMatrix(bool & stop);
120 double computeDiffusionMatrixFV(bool & stop);
121 double computeRHS(bool & stop);
123 Field _fluidTemperatureField;
124 bool _fluidTemperatureFieldSet, _diffusionMatrixSet;
125 double _conductivity,_diffusivity, _fluidTemperature;
129 Matrix _DiffusionTensor;
130 Vec _Tn, _deltaT, _Tk, _Tkm1, _b0;
131 double _dt_diffusion, _dt_src;
133 /************ Data for FE calculation *************/
135 int _NunknownNodes;/* number of unknown nodes for FE calculation */
136 int _NboundaryNodes;/* total number of boundary nodes */
137 int _NdirichletNodes;/* number of boundary nodes with Dirichlet BC for FE calculation */
138 std::vector< int > _boundaryNodeIds;/* List of boundary nodes */
139 std::vector< int > _dirichletNodeIds;/* List of boundary nodes with Dirichlet BC */
141 /*********** Functions for finite element method ***********/
142 Vector gradientNodal(Matrix M, vector< double > v);//gradient of nodal shape functions
143 double computeDiffusionMatrixFE(bool & stop);
145 int unknownNodeIndex(int globalIndex, std::vector< int > dirichletNodes);
146 int globalNodeIndex(int unknownIndex, std::vector< int > dirichletNodes);
148 TimeScheme _timeScheme;
149 map<string, LimitFieldDiffusion> _limitField;
152 #endif /* DiffusionEquation_HXX_ */