-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix memory leaks in CHeatSolver #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3771900
e3f878a
84e0585
9f78e46
3f65e8e
dad20d7
f32f9ee
daad1d0
e1896e6
64b33d1
8042ff1
026fbff
0e250e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,3 +205,60 @@ struct C3DDummyMiddleView | |
| return data(i,k); | ||
| } | ||
| }; | ||
|
|
||
| /*--- Helper functions to allocate containers of containers. ---*/ | ||
|
|
||
| /*! | ||
| * \brief Allocate a vector of varying-size vectors and initialize with some value. | ||
| * \param[in] M - the first index is >=0 and < M | ||
| * \param[in] N - the second index is >=0 and < N[first index] | ||
| * \param[in,out] X - the vector of vectors | ||
| * \param[in] val - the value for initialization, default is 0 | ||
| * \tparam IndexVector - type of N | ||
| * \tparam VectorOfVector - type of X | ||
| */ | ||
| template<class IndexVector, class VectorOfVector, class Scalar = int> | ||
| inline void AllocVectorOfVectors(size_t M, const IndexVector& N, VectorOfVector& X, Scalar val = 0) { | ||
| X.resize(M); | ||
| for(size_t i = 0; i < M; ++i){ | ||
| X[i].resize(N[i]); | ||
| for (auto& x : X[i]) x = val; | ||
| } | ||
| } | ||
|
|
||
| /*! | ||
| * \overload Deduce outer size from index vector. | ||
| */ | ||
| template<class IndexVector, class VectorOfVector, class Scalar = int> | ||
| inline void AllocVectorOfVectors(const IndexVector& N, VectorOfVector& X, Scalar val = 0) { | ||
| auto M = N.size(); | ||
| AllocVectorOfVectors(M, N, X, val); | ||
|
Comment on lines
+234
to
+235
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea with the overload 👍 |
||
| } | ||
|
|
||
| /*! | ||
| * \brief Allocate a vector of matrices with varying row count, and initialize with some value. | ||
| * \param[in] M - the first index is >=0 and < M | ||
| * \param[in] N - the second index is >=0 and < N[first index] | ||
| * \param[in] P - the third index is >=0 and < P | ||
| * \param[in,out] X - the vector of matrices | ||
| * \param[in] val - the value for initialization, default is 0 | ||
| * \tparam IndexVector - type of N | ||
| * \tparam VectorOfMatrix - type of X | ||
| */ | ||
| template<class IndexVector, class VectorOfMatrix, class Scalar = int> | ||
| inline void AllocVectorOfMatrices(size_t M, const IndexVector& N, size_t P, VectorOfMatrix& X, Scalar val=0) { | ||
| X.resize(M); | ||
| for(size_t i = 0; i < M; ++i){ | ||
| X[i].resize(N[i],P); | ||
| for (auto& x : X[i]) x = val; | ||
| } | ||
| } | ||
|
|
||
| /*! | ||
| * \overload Deduce outer size from index vector. | ||
| */ | ||
| template<class IndexVector, class VectorOfMatrix, class Scalar = int> | ||
| inline void AllocVectorOfMatrices(const IndexVector& N, size_t P, VectorOfMatrix& X, Scalar val=0) { | ||
| auto M = N.size(); | ||
| AllocVectorOfMatrices(M, N, P, X, val); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,12 +38,23 @@ | |
| */ | ||
| class CHeatSolver final : public CSolver { | ||
| protected: | ||
| static constexpr size_t MAXNDIM = 3; /*!< \brief Max number of space dimensions, used in some static arrays. */ | ||
| static constexpr size_t MAXNVAR = 1; /*!< \brief Max number of variables, for static arrays. */ | ||
|
|
||
| unsigned short nVarFlow, nMarker, CurrentMesh; | ||
| su2double **HeatFlux, *HeatFlux_per_Marker, *Surface_HF, Total_HeatFlux, AllBound_HeatFlux, | ||
| *AverageT_per_Marker, Total_AverageT, AllBound_AverageT, | ||
| *Primitive, *Primitive_Flow_i, *Primitive_Flow_j, | ||
| *Surface_Areas, Total_HeatFlux_Areas, Total_HeatFlux_Areas_Monitor; | ||
| su2double ***ConjugateVar, ***InterfaceVar; | ||
| vector<vector<su2double> > HeatFlux; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe someone could add
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm yes I can do that, I already worked on the output of the heatsolver ... but I put that on the long bench. I am not sure if all those containers are necessary. |
||
| vector<su2double> HeatFlux_per_Marker; | ||
| su2double Total_HeatFlux; | ||
| su2double AllBound_HeatFlux; | ||
| vector<su2double> AverageT_per_Marker; | ||
| su2double Total_AverageT; | ||
| su2double AllBound_AverageT; | ||
| vector<su2double> Primitive_Flow_i; | ||
| vector<su2double> Primitive_Flow_j; | ||
| vector<su2double> Surface_Areas; | ||
| su2double Total_HeatFlux_Areas; | ||
| su2double Total_HeatFlux_Areas_Monitor; | ||
| vector<su2activematrix> ConjugateVar; | ||
|
|
||
| CHeatVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it a bit to try to make it compatible with more types. If I broke anything I'll fix it.
Thanks for all the cleanup.