From 2cec2810b6acb97ecb1fce6e29c1ffe093178351 Mon Sep 17 00:00:00 2001 From: Benjamin Faigle <benjamin.faigle@posteo.de> Date: Wed, 9 Mar 2011 08:36:19 +0000 Subject: [PATCH] adapted Andreas' last commit to decoupled models: writer is now pointer, hence setname() is usable name() it is not overwritten by the specific problem. git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@5378 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- .../decoupled/1p/diffusion/fv/fvpressure1p.hh | 4 +-- .../decoupled/1p/diffusion/fv/fvvelocity1p.hh | 8 ++--- .../decoupled/2p/diffusion/fv/fvpressure2p.hh | 32 +++++++++---------- .../2p/diffusion/fvmpfa/fvmpfaopressure2p.hh | 16 +++++----- .../2p/diffusion/mimetic/mimeticpressure2p.hh | 4 +-- .../2p/transport/fv/fvsaturation2p.hh | 6 ++-- dumux/decoupled/2p2c/fvpressure2p2c.hh | 28 ++++++++-------- .../2p2c/fvpressure2p2cmultiphysics.hh | 20 ++++++------ dumux/decoupled/2p2c/fvtransport2p2c.hh | 10 +++--- .../2p2c/fvtransport2p2cmultiphysics.hh | 16 +++++----- dumux/decoupled/common/impetproblem.hh | 19 +++++++---- dumux/decoupled/common/onemodelproblem.hh | 19 ++++++----- 12 files changed, 95 insertions(+), 87 deletions(-) diff --git a/dumux/decoupled/1p/diffusion/fv/fvpressure1p.hh b/dumux/decoupled/1p/diffusion/fv/fvpressure1p.hh index 275ca97f3c..d2ca3ecbcd 100644 --- a/dumux/decoupled/1p/diffusion/fv/fvpressure1p.hh +++ b/dumux/decoupled/1p/diffusion/fv/fvpressure1p.hh @@ -164,12 +164,12 @@ public: template<class MultiWriter> void addOutputVtkFields(MultiWriter &writer) { - typename Variables::ScalarSolutionType *pressure = writer.template createField<Scalar, 1> ( + typename Variables::ScalarSolutionType *pressure = writer->template createField<Scalar, 1> ( problem_.gridView().size(0)); *pressure = problem_.variables().pressure(); - writer.addCellData(pressure, "pressure"); + writer->addCellData(pressure, "pressure"); return; } diff --git a/dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh b/dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh index 2df2b05edd..141b180185 100644 --- a/dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh +++ b/dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh @@ -106,9 +106,9 @@ public: { ParentType::addOutputVtkFields(writer); - typename Variables::ScalarSolutionType *velocityX = writer.template createField<Scalar, 1> ( + typename Variables::ScalarSolutionType *velocityX = writer->template createField<Scalar, 1> ( this->problem().gridView().size(0)); - typename Variables::ScalarSolutionType *velocityY = writer.template createField<Scalar, 1> ( + typename Variables::ScalarSolutionType *velocityY = writer->template createField<Scalar, 1> ( this->problem().gridView().size(0)); // compute update vector @@ -154,8 +154,8 @@ public: (*velocityY)[globalIdx] = elementVelocity[1]; } - writer.addCellData(velocityX, "x-velocity"); - writer.addCellData(velocityY, "y-velocity"); + writer->addCellData(velocityX, "x-velocity"); + writer->addCellData(velocityY, "y-velocity"); return; } diff --git a/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh b/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh index 53814cd213..edfac7aa22 100644 --- a/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh +++ b/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh @@ -202,51 +202,51 @@ public: template<class MultiWriter> void addOutputVtkFields(MultiWriter &writer) { - typename Variables::ScalarSolutionType *pressure = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *pressure = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *pressure = problem_.variables().pressure(); if (pressureType == pw) { - writer.addCellData(pressure, "wetting pressure"); + writer->addCellData(pressure, "wetting pressure"); } if (pressureType == pn) { - writer.addCellData(pressure, "nonwetting pressure"); + writer->addCellData(pressure, "nonwetting pressure"); } if (pressureType == pglobal) { - writer.addCellData(pressure, "global pressure"); + writer->addCellData(pressure, "global pressure"); } // output phase-dependent stuff - typename Variables::ScalarSolutionType *pC = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *pC = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *pC = problem_.variables().capillaryPressure(); - writer.addCellData(pC, "capillary pressure"); + writer->addCellData(pC, "capillary pressure"); - typename Variables::ScalarSolutionType *densityWetting = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *densityWetting = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *densityWetting = problem_.variables().densityWetting(); - writer.addCellData(densityWetting, "wetting density"); + writer->addCellData(densityWetting, "wetting density"); - typename Variables::ScalarSolutionType *densityNonwetting = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *densityNonwetting = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *densityNonwetting = problem_.variables().densityNonwetting(); - writer.addCellData(densityNonwetting, "nonwetting density"); + writer->addCellData(densityNonwetting, "nonwetting density"); - typename Variables::ScalarSolutionType *viscosityWetting = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *viscosityWetting = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *viscosityWetting = problem_.variables().viscosityWetting(); - writer.addCellData(viscosityWetting, "wetting viscosity"); + writer->addCellData(viscosityWetting, "wetting viscosity"); - typename Variables::ScalarSolutionType *viscosityNonwetting = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *viscosityNonwetting = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *viscosityNonwetting = problem_.variables().viscosityNonwetting(); - writer.addCellData(viscosityNonwetting, "nonwetting viscosity"); + writer->addCellData(viscosityNonwetting, "nonwetting viscosity"); -// typename Variables::ScalarSolutionType *saturation = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); +// typename Variables::ScalarSolutionType *saturation = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); // // *saturation = problem_.variables().saturation(); // -// writer.addCellData(saturation, "wetting saturation"); +// writer->addCellData(saturation, "wetting saturation"); return; } diff --git a/dumux/decoupled/2p/diffusion/fvmpfa/fvmpfaopressure2p.hh b/dumux/decoupled/2p/diffusion/fvmpfa/fvmpfaopressure2p.hh index 48132a3253..7aed00c3b4 100644 --- a/dumux/decoupled/2p/diffusion/fvmpfa/fvmpfaopressure2p.hh +++ b/dumux/decoupled/2p/diffusion/fvmpfa/fvmpfaopressure2p.hh @@ -163,24 +163,24 @@ public: template<class MultiWriter> void addOutputVtkFields(MultiWriter &writer) { - typename Variables::ScalarSolutionType *pressure = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *pressure = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *pressure = problem_.variables().pressure(); - writer.addCellData(pressure, "global pressure"); + writer->addCellData(pressure, "global pressure"); // output phase-dependent stuff - typename Variables::ScalarSolutionType *pC = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *pC = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *pC = problem_.variables().capillaryPressure(); - writer.addCellData(pC, "capillary pressure"); + writer->addCellData(pC, "capillary pressure"); - typename Variables::ScalarSolutionType *viscosityWetting = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *viscosityWetting = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *viscosityWetting = problem_.variables().viscosityWetting(); - writer.addCellData(viscosityWetting, "wetting viscosity"); + writer->addCellData(viscosityWetting, "wetting viscosity"); - typename Variables::ScalarSolutionType *viscosityNonwetting = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *viscosityNonwetting = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *viscosityNonwetting = problem_.variables().viscosityNonwetting(); - writer.addCellData(viscosityNonwetting, "nonwetting viscosity"); + writer->addCellData(viscosityNonwetting, "nonwetting viscosity"); return; } diff --git a/dumux/decoupled/2p/diffusion/mimetic/mimeticpressure2p.hh b/dumux/decoupled/2p/diffusion/mimetic/mimeticpressure2p.hh index 57f4331964..67878cab61 100644 --- a/dumux/decoupled/2p/diffusion/mimetic/mimeticpressure2p.hh +++ b/dumux/decoupled/2p/diffusion/mimetic/mimeticpressure2p.hh @@ -186,11 +186,11 @@ public: template<class MultiWriter> void addOutputVtkFields(MultiWriter &writer) { - typename Variables::ScalarSolutionType *pressure = writer.template createField<Scalar, 1> (problem_.gridView().size(0)); + typename Variables::ScalarSolutionType *pressure = writer->template createField<Scalar, 1> (problem_.gridView().size(0)); *pressure = problem_.variables().pressure(); - writer.addCellData(pressure, "global pressure"); + writer->addCellData(pressure, "global pressure"); return; } diff --git a/dumux/decoupled/2p/transport/fv/fvsaturation2p.hh b/dumux/decoupled/2p/transport/fv/fvsaturation2p.hh index 6bffe0369c..3c0cb37e82 100644 --- a/dumux/decoupled/2p/transport/fv/fvsaturation2p.hh +++ b/dumux/decoupled/2p/transport/fv/fvsaturation2p.hh @@ -181,18 +181,18 @@ public: void addOutputVtkFields(MultiWriter &writer) { typename Variables::ScalarSolutionType *saturation = - writer.template createField<Scalar, 1> ( + writer->template createField<Scalar, 1> ( problem_.gridView().size(0)); *saturation = problem_.variables().saturation(); if (saturationType_ == Sw) { - writer.addCellData(saturation, "wetting saturation"); + writer->addCellData(saturation, "wetting saturation"); } if (saturationType_ == Sn) { - writer.addCellData(saturation, "nonwetting saturation"); + writer->addCellData(saturation, "nonwetting saturation"); } return; diff --git a/dumux/decoupled/2p2c/fvpressure2p2c.hh b/dumux/decoupled/2p2c/fvpressure2p2c.hh index 87f9a41824..436303d0a9 100644 --- a/dumux/decoupled/2p2c/fvpressure2p2c.hh +++ b/dumux/decoupled/2p2c/fvpressure2p2c.hh @@ -191,27 +191,27 @@ public: #if DUNE_MINIMAL_DEBUG_LEVEL <= 2 // add debug stuff - Dune::BlockVector<Dune::FieldVector<double,1> > *errorCorrPtr = writer.template createField<double, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<double,1> > *errorCorrPtr = writer->template createField<double, 1> (dv_dp.size()); *errorCorrPtr = errorCorrection; // int size = subdomainPtr.size(); - writer.addCellData(errorCorrPtr, "Error Correction"); + writer->addCellData(errorCorrPtr, "Error Correction"); - Dune::BlockVector<Dune::FieldVector<double,1> > *dv_dpPtr = writer.template createField<double, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<double,1> > *dv_dpPtr = writer->template createField<double, 1> (dv_dp.size()); *dv_dpPtr = dv_dp; - writer.addCellData(dv_dpPtr, "dv_dp"); - Dune::BlockVector<Dune::FieldVector<double,1> > *dV_dC1Ptr = writer.template createField<double, 1> (dv_dp.size()); - Dune::BlockVector<Dune::FieldVector<double,1> > *dV_dC2Ptr = writer.template createField<double, 1> (dv_dp.size()); + writer->addCellData(dv_dpPtr, "dv_dp"); + Dune::BlockVector<Dune::FieldVector<double,1> > *dV_dC1Ptr = writer->template createField<double, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<double,1> > *dV_dC2Ptr = writer->template createField<double, 1> (dv_dp.size()); *dV_dC1Ptr = dV_[0]; *dV_dC2Ptr = dV_[1]; - writer.addCellData(dV_dC1Ptr, "dV_dC1"); - writer.addCellData(dV_dC2Ptr, "dV_dC2"); + writer->addCellData(dV_dC1Ptr, "dV_dC1"); + writer->addCellData(dV_dC2Ptr, "dV_dC2"); - Dune::BlockVector<Dune::FieldVector<double,1> > *updEstimate1 = writer.template createField<double, 1> (dv_dp.size()); - Dune::BlockVector<Dune::FieldVector<double,1> > *updEstimate2 = writer.template createField<double, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<double,1> > *updEstimate1 = writer->template createField<double, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<double,1> > *updEstimate2 = writer->template createField<double, 1> (dv_dp.size()); *updEstimate1 = problem_.variables().updateEstimate()[0]; *updEstimate2 = problem_.variables().updateEstimate()[1]; - writer.addCellData(updEstimate1, "updEstimate comp 1"); - writer.addCellData(updEstimate2, "updEstimate comp 2"); + writer->addCellData(updEstimate1, "updEstimate comp 1"); + writer->addCellData(updEstimate2, "updEstimate comp 2"); #endif return; } @@ -966,7 +966,7 @@ void FVPressure2P2C<TypeTag>::assemble(bool first) Scalar erri = fabs(problem_.variables().volErr()[globalIdxI]); Scalar x_lo = 0.6; Scalar x_mi = 0.9; - Scalar fac = 0.05; + Scalar fac = 0.5; Scalar lofac = 0.; Scalar hifac = 0.; hifac /= fac; @@ -1166,7 +1166,7 @@ void FVPressure2P2C<TypeTag>::updateMaterialLaws() // #if DUNE_MINIMAL_DEBUG_LEVEL <= 3 if(Z1<0. || Z1 > 1.) { - Dune::dgrave << "Feed mass fraction unphysical: Z1 = " << Z1 + std::cout << "Feed mass fraction unphysical: Z1 = " << Z1 << " at global Idx " << globalIdx << " , because totalConcentration(globalIdx, wCompIdx) = " << problem_.variables().totalConcentration(globalIdx, wCompIdx) diff --git a/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh b/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh index 603f9ae13d..39890bc05c 100644 --- a/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh +++ b/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh @@ -196,25 +196,25 @@ public: problem().variables().addOutputVtkFields(writer); // add multiphysics stuff - Dune::BlockVector<Dune::FieldVector<int,1> > *subdomainPtr = writer.template createField<int, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<int,1> > *subdomainPtr = writer->template createField<int, 1> (dv_dp.size()); *subdomainPtr = problem_.variables().subdomain(); - writer.addCellData(subdomainPtr, "subdomain"); + writer->addCellData(subdomainPtr, "subdomain"); #if DUNE_MINIMAL_DEBUG_LEVEL <= 3 // add debug stuff - Dune::BlockVector<Dune::FieldVector<double,1> > *errorCorrPtr = writer.template createField<double, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<double,1> > *errorCorrPtr = writer->template createField<double, 1> (dv_dp.size()); *errorCorrPtr = errorCorrection; - writer.addCellData(errorCorrPtr, "Error Correction"); + writer->addCellData(errorCorrPtr, "Error Correction"); // add debug stuff - Dune::BlockVector<Dune::FieldVector<double,1> > *dv_dpPtr = writer.template createField<double, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<double,1> > *dv_dpPtr = writer->template createField<double, 1> (dv_dp.size()); *dv_dpPtr = dv_dp; - writer.addCellData(dv_dpPtr, "dv_dP"); - Dune::BlockVector<Dune::FieldVector<double,1> > *dV_dC1Ptr = writer.template createField<double, 1> (dv_dp.size()); - Dune::BlockVector<Dune::FieldVector<double,1> > *dV_dC2Ptr = writer.template createField<double, 1> (dv_dp.size()); + writer->addCellData(dv_dpPtr, "dv_dP"); + Dune::BlockVector<Dune::FieldVector<double,1> > *dV_dC1Ptr = writer->template createField<double, 1> (dv_dp.size()); + Dune::BlockVector<Dune::FieldVector<double,1> > *dV_dC2Ptr = writer->template createField<double, 1> (dv_dp.size()); *dV_dC1Ptr = dV_[0]; *dV_dC2Ptr = dV_[1]; - writer.addCellData(dV_dC1Ptr, "dV_dC1"); - writer.addCellData(dV_dC2Ptr, "dV_dC2"); + writer->addCellData(dV_dC1Ptr, "dV_dC1"); + writer->addCellData(dV_dC2Ptr, "dV_dC2"); #endif return; diff --git a/dumux/decoupled/2p2c/fvtransport2p2c.hh b/dumux/decoupled/2p2c/fvtransport2p2c.hh index 7469c2ea63..f05a6967e2 100644 --- a/dumux/decoupled/2p2c/fvtransport2p2c.hh +++ b/dumux/decoupled/2p2c/fvtransport2p2c.hh @@ -337,7 +337,7 @@ void FVTransport2P2C<TypeTag>::update(const Scalar t, Scalar& dt, TransportSolut lambdaN = problem_.variables().mobilityNonwetting(globalIdxJ); double velocityW = lambdaW * potentialW; - double velocityN = lambdaN * potentialW; + double velocityN = lambdaN * potentialNW; // standardized velocity double velocityJIw = std::max(-velocityW * faceArea / volume, 0.0); @@ -465,10 +465,10 @@ void FVTransport2P2C<TypeTag>::update(const Scalar t, Scalar& dt, TransportSolut / viscosityNWBound; } // standardized velocity - double velocityJIw = std::max(-lambdaW * potentialW * faceArea / volume, 0.0); - double velocityIJw = std::max( lambdaW * potentialW * faceArea / volume, 0.0); - double velocityJIn = std::max(-lambdaN * potentialNW * faceArea / volume, 0.0); - double velocityIJn = std::max( lambdaN * potentialNW* faceArea / volume, 0.0); + double velocityJIw = std::max((-lambdaW * potentialW) * faceArea / volume, 0.0); + double velocityIJw = std::max(( lambdaW * potentialW)* faceArea / volume, 0.0); + double velocityJIn = std::max((-lambdaN * potentialNW) * faceArea / volume, 0.0); + double velocityIJn = std::max(( lambdaN * potentialNW) * faceArea / volume, 0.0); // for timestep control factor[0] = velocityJIw + velocityJIn; diff --git a/dumux/decoupled/2p2c/fvtransport2p2cmultiphysics.hh b/dumux/decoupled/2p2c/fvtransport2p2cmultiphysics.hh index 061878af22..832f02f94c 100644 --- a/dumux/decoupled/2p2c/fvtransport2p2cmultiphysics.hh +++ b/dumux/decoupled/2p2c/fvtransport2p2cmultiphysics.hh @@ -321,10 +321,10 @@ void FVTransport2P2CMultiPhysics<TypeTag>::update(const Scalar t, Scalar& dt, Tr lambdaNW = problem_.variables().mobilityNonwetting(globalIdxJ); // calculate and standardized velocity - double velocityJIw = std::max(-lambdaW * potentialW * faceArea / volume, 0.0); - double velocityIJw = std::max( lambdaW * potentialW * faceArea / volume, 0.0); - double velocityJIn = std::max(-lambdaNW * potentialNW * faceArea / volume, 0.0); - double velocityIJn = std::max( lambdaNW * potentialNW * faceArea / volume, 0.0); + double velocityJIw = std::max(-(lambdaW * potentialW) * faceArea / volume, 0.0); + double velocityIJw = std::max( (lambdaW * potentialW) * faceArea / volume, 0.0); + double velocityJIn = std::max(-(lambdaNW * potentialNW) * faceArea / volume, 0.0); + double velocityIJn = std::max( (lambdaNW * potentialNW) * faceArea / volume, 0.0); // for timestep control factor[0] = velocityJIw + velocityJIn; @@ -448,10 +448,10 @@ void FVTransport2P2CMultiPhysics<TypeTag>::update(const Scalar t, Scalar& dt, Tr / viscosityNWBound; } // standardized velocity - double velocityJIw = std::max(-lambdaW * potentialW * faceArea / volume, 0.0); - double velocityIJw = std::max( lambdaW * potentialW * faceArea / volume, 0.0); - double velocityJIn = std::max(-lambdaN * potentialNW * faceArea / volume, 0.0); - double velocityIJn = std::max( lambdaN * potentialNW* faceArea / volume, 0.0); + double velocityJIw = std::max(-(lambdaW * potentialW) * faceArea / volume, 0.0); + double velocityIJw = std::max( (lambdaW * potentialW) * faceArea / volume, 0.0); + double velocityJIn = std::max(-(lambdaN * potentialNW) * faceArea / volume, 0.0); + double velocityIJn = std::max( (lambdaN * potentialNW)* faceArea / volume, 0.0); // for timestep control factor[0] = velocityJIw + velocityJIn; diff --git a/dumux/decoupled/common/impetproblem.hh b/dumux/decoupled/common/impetproblem.hh index 25e375ba9a..c66d5c93d1 100644 --- a/dumux/decoupled/common/impetproblem.hh +++ b/dumux/decoupled/common/impetproblem.hh @@ -89,8 +89,7 @@ public: bboxMin_(std::numeric_limits<double>::max()), bboxMax_(-std::numeric_limits<double>::max()), timeManager_(verbose), - variables_(gridView), - resultWriter_(asImp_().name()) + variables_(gridView) { // calculate the bounding box of the grid view VertexIterator vIt = gridView.template begin<dim>(); @@ -107,6 +106,7 @@ public: transportModel_ = new TransportModel(asImp_()); model_ = new IMPETModel(asImp_()) ; + resultWriter_ = NULL; } //! destructor @@ -115,6 +115,7 @@ public: delete pressModel_; delete transportModel_; delete model_; + delete resultWriter_; } /*! @@ -275,6 +276,8 @@ public: * This function sets the simulation name, which should be called before * the application porblem is declared! If not, the default name "sim" * will be used. + * + * \param newName The problem's name */ static void setName(const char *newName) { @@ -380,7 +383,7 @@ public: std::cerr << "Serialize to file " << res.fileName() << "\n"; timeManager_.serialize(res); - resultWriter_.serialize(res); + resultWriter_->serialize(res); model().serialize(res); res.serializeEnd(); @@ -401,7 +404,7 @@ public: std::cerr << "Deserialize from file " << res.fileName() << "\n"; timeManager_.deserialize(res); - resultWriter_.deserialize(res); + resultWriter_->deserialize(res); model().deserialize(res); res.deserializeEnd(); @@ -419,10 +422,12 @@ public: if (gridView().comm().rank() == 0) std::cout << "Writing result file for current time step\n"; - resultWriter_.beginTimestep(timeManager_.time() + timeManager_.timeStepSize(), + if (!resultWriter_) + resultWriter_ = new VtkMultiWriter(asImp_().name()); + resultWriter_->beginTimestep(timeManager_.time() + timeManager_.timeStepSize(), gridView()); asImp_().addOutputVtkFields(); - resultWriter_.endTimestep(); + resultWriter_->endTimestep(); } // \} @@ -464,7 +469,7 @@ private: TransportModel* transportModel_;//!< object including the saturation model IMPETModel* model_; - VtkMultiWriter resultWriter_; + VtkMultiWriter *resultWriter_; }; // definition of the static class member simname_, // which is necessary because it is of type string. diff --git a/dumux/decoupled/common/onemodelproblem.hh b/dumux/decoupled/common/onemodelproblem.hh index 92a2e217d0..f97c0bd87d 100644 --- a/dumux/decoupled/common/onemodelproblem.hh +++ b/dumux/decoupled/common/onemodelproblem.hh @@ -93,8 +93,7 @@ public: bboxMin_(std::numeric_limits<double>::max()), bboxMax_(-std::numeric_limits<double>::max()), timeManager_(verbose), - variables_(gridView), - resultWriter_(asImp_().name()) + variables_(gridView) { // calculate the bounding box of the grid view VertexIterator vIt = gridView.template begin<dim>(); @@ -107,12 +106,15 @@ public: } model_ = new Model(asImp_()) ; + + resultWriter_ = NULL; } //! destructor virtual ~OneModelProblem () { delete model_; + delete resultWriter_; } @@ -215,10 +217,11 @@ public: { if (gridView().comm().rank() == 0) std::cout << "Writing result file for current time step\n"; - - resultWriter_.beginTimestep(timeManager_.time() + timeManager_.timeStepSize(), gridView()); + if (!resultWriter_) + resultWriter_ = new VtkMultiWriter(asImp_().name()); + resultWriter_->beginTimestep(timeManager_.time() + timeManager_.timeStepSize(), gridView()); asImp_().addOutputVtkFields(); - resultWriter_.endTimestep(); + resultWriter_->endTimestep(); } /*! @@ -338,7 +341,7 @@ public: std::cerr << "Serialize to file " << res.fileName() << "\n"; timeManager_.serialize(res); - resultWriter_.serialize(res); + resultWriter_->serialize(res); model().serialize(res); res.serializeEnd(); @@ -359,7 +362,7 @@ public: std::cerr << "Deserialize from file " << res.fileName() << "\n"; timeManager_.deserialize(res); - resultWriter_.deserialize(res); + resultWriter_->deserialize(res); model().deserialize(res); res.deserializeEnd(); @@ -401,7 +404,7 @@ private: Model* model_; - VtkMultiWriter resultWriter_; + VtkMultiWriter *resultWriter_; }; // definition of the static class member simname_, // which is necessary because it is of type string. -- GitLab