From: Jean-Paul Pelteret Date: Wed, 17 Feb 2016 10:43:03 +0000 (+0200) Subject: Use shared pointer to store Material class inside PointHistory. X-Git-Tag: v8.5.0-rc1~1304^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=869735beb448b5a76b7b33ce3a5fc980540e7bd5;p=dealii.git Use shared pointer to store Material class inside PointHistory. --- diff --git a/examples/step-44/step-44.cc b/examples/step-44/step-44.cc index a502a3f859..a9800e7770 100644 --- a/examples/step-44/step-44.cc +++ b/examples/step-44/step-44.cc @@ -706,7 +706,6 @@ namespace Step44 public: PointHistory() : - material(NULL), F_inv(StandardTensors::I), tau(SymmetricTensor<2, dim>()), d2Psi_vol_dJ2(0.0), @@ -714,11 +713,10 @@ namespace Step44 Jc(SymmetricTensor<4, dim>()) {} + // That the material is stored in a smart pointer, we don't need to worry + // about its memory management virtual ~PointHistory() - { - delete material; - material = NULL; - } + {} // The first function is used to create a material object and to // initialize all tensors correctly: The second one updates the stored @@ -727,8 +725,8 @@ namespace Step44 // dilation $\widetilde{J}$ field values. void setup_lqp (const Parameters::AllParameters ¶meters) { - material = new Material_Compressible_Neo_Hook_Three_Field(parameters.mu, - parameters.nu); + material.reset(new Material_Compressible_Neo_Hook_Three_Field(parameters.mu, + parameters.nu)); update_values(Tensor<2, dim>(), 0.0, 1.0); } @@ -819,7 +817,7 @@ namespace Step44 // materials are used in different regions of the domain, as well as the // inverse of the deformation gradient... private: - Material_Compressible_Neo_Hook_Three_Field *material; + std_cxx11::shared_ptr< Material_Compressible_Neo_Hook_Three_Field > material; Tensor<2, dim> F_inv;