From fe0dfad9477956ef1905e2843f94d7191b9e369e Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Tue, 31 Jan 2017 13:02:21 +0100 Subject: [PATCH] [3p][model] Use new vtkOutputModule --- dumux/porousmediumflow/3p/implicit/model.hh | 144 ++++---------------- 1 file changed, 27 insertions(+), 117 deletions(-) diff --git a/dumux/porousmediumflow/3p/implicit/model.hh b/dumux/porousmediumflow/3p/implicit/model.hh index bc14affd53..78c6e3ee4b 100644 --- a/dumux/porousmediumflow/3p/implicit/model.hh +++ b/dumux/porousmediumflow/3p/implicit/model.hh @@ -60,136 +60,46 @@ namespace Dumux template<class TypeTag> class ThreePModel: public GET_PROP_TYPE(TypeTag, BaseModel) { - typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; - typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView; - - typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry; - typedef typename GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector; - typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices; + using ParentType = typename GET_PROP_TYPE(TypeTag, BaseModel); + using Problem = typename GET_PROP_TYPE(TypeTag, Problem); + using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); + using Indices = typename GET_PROP_TYPE(TypeTag, Indices);; enum { - dim = GridView::dimension, - dimWorld = GridView::dimensionworld, - - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx, gPhaseIdx = Indices::gPhaseIdx, }; - - enum { isBox = GET_PROP_VALUE(TypeTag, ImplicitIsBox) }; - enum { dofCodim = isBox ? dim : 0 }; - public: + /*! - * \brief Append all quantities of interest which can be derived - * from the solution of the current time step to the VTK - * writer. + * \brief Apply the initial conditions to the model. * - * \param sol The solution vector - * \param writer The writer for multi-file VTK datasets + * \param problem The object representing the problem which needs to + * be simulated. */ - template<class MultiWriter> - void addOutputVtkFields(const SolutionVector &sol, - MultiWriter &writer) + void init(Problem& problem) { - typedef Dune::BlockVector<Dune::FieldVector<double, 1> > ScalarField; - //typedef Dune::BlockVector<Dune::FieldVector<double, dimWorld> > VectorField; - - // get the number of degrees of freedom - unsigned numDofs = this->numDofs(); - - // create the required scalar fields - ScalarField *saturation[numPhases]; - ScalarField *pressure[numPhases]; - ScalarField *density[numPhases]; - - for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { - saturation[phaseIdx] = writer.allocateManagedBuffer(numDofs); - pressure[phaseIdx] = writer.allocateManagedBuffer(numDofs); - density[phaseIdx] = writer.allocateManagedBuffer(numDofs); - } - - ScalarField *temperature = writer.allocateManagedBuffer (numDofs); - ScalarField *poro = writer.allocateManagedBuffer(numDofs); - // VectorField *velocityN = writer.template allocateManagedBuffer<double, dimWorld>(numDofs); - // VectorField *velocityW = writer.template allocateManagedBuffer<double, dimWorld>(numDofs); - // VectorField *velocityG = writer.template allocateManagedBuffer<double, dimWorld>(numDofs); - // ImplicitVelocityOutput<TypeTag> velocityOutput(this->problem_()); - - // if (velocityOutput.enableOutput()) // check if velocity output is demanded - // { - // // initialize velocity fields - // for (unsigned int i = 0; i < numDofs; ++i) - // { - // (*velocityN)[i] = Scalar(0); - // (*velocityW)[i] = Scalar(0); - // (*velocityG)[i] = Scalar(0); - // } - // } - - unsigned numElements = this->gridView_().size(0); - ScalarField *rank = writer.allocateManagedBuffer (numElements); - - for (const auto& element : elements(this->gridView_(), Dune::Partitions::interior)) - { - // make sure FVElementGeometry & vol vars are bound to the element - auto fvGeometry = localView(this->globalFvGeometry()); - fvGeometry.bindElement(element); - - auto elemVolVars = localView(this->curGlobalVolVars()); - elemVolVars.bindElement(element, fvGeometry, this->curSol()); - - for (auto&& scv : scvs(fvGeometry)) - { - auto eIdx = scv.elementIndex(); - auto dofIdxGlobal = scv.dofIndex(); - (*rank)[eIdx] = this->gridView_().comm().rank(); - - const auto& volVars = elemVolVars[scv]; - - for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) - { - (*saturation[phaseIdx])[dofIdxGlobal] = volVars.saturation(phaseIdx); - (*pressure[phaseIdx])[dofIdxGlobal] = volVars.pressure(phaseIdx); - (*density[phaseIdx])[dofIdxGlobal] = volVars.density(phaseIdx); - } - - (*poro)[dofIdxGlobal] = volVars.porosity(); - (*temperature)[dofIdxGlobal] = volVars.temperature(); - - // velocity output - // velocityOutput.calculateVelocity(*velocityW, elemVolVars, fvGeometry, element, wPhaseIdx); - // velocityOutput.calculateVelocity(*velocityN, elemVolVars, fvGeometry, element, nPhaseIdx); - // velocityOutput.calculateVelocity(*velocityN, elemVolVars, fvGeometry, element, gPhaseIdx); - } - } - - writer.attachDofData(*saturation[wPhaseIdx], "sw", isBox); - writer.attachDofData(*saturation[nPhaseIdx], "sn", isBox); - writer.attachDofData(*saturation[gPhaseIdx], "sg", isBox); - writer.attachDofData(*pressure[wPhaseIdx], "pw", isBox); - writer.attachDofData(*pressure[nPhaseIdx], "pn", isBox); - writer.attachDofData(*pressure[gPhaseIdx], "pg", isBox); - writer.attachDofData(*density[wPhaseIdx], "rhow", isBox); - writer.attachDofData(*density[nPhaseIdx], "rhon", isBox); - writer.attachDofData(*density[gPhaseIdx], "rhog", isBox); - - writer.attachDofData(*poro, "porosity", isBox); - writer.attachDofData(*temperature, "temperature", isBox); - - // if (velocityOutput.enableOutput()) // check if velocity output is demanded - // { - // writer.attachDofData(*velocityW, "velocityW", isBox, dim); - // writer.attachDofData(*velocityN, "velocityN", isBox, dim); - // writer.attachDofData(*velocityG, "velocityG", isBox, dim); - // } - - writer.attachCellData(*rank, "process rank"); + ParentType::init(problem); + + // register standardized vtk output fields + auto& vtkOutputModule = problem.vtkOutputModule(); + vtkOutputModule.addSecondaryVariable("Sw", [](const VolumeVariables& v){ return v.saturation(wPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("Sn", [](const VolumeVariables& v){ return v.saturation(nPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("Sg", [](const VolumeVariables& v){ return v.saturation(gPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("pw", [](const VolumeVariables& v){ return v.pressure(wPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("pn", [](const VolumeVariables& v){ return v.pressure(nPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("pg", [](const VolumeVariables& v){ return v.pressure(gPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("rhoW", [](const VolumeVariables& v){ return v.density(wPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("rhoN", [](const VolumeVariables& v){ return v.density(nPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("rhoG", [](const VolumeVariables& v){ return v.density(gPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("mobW", [](const VolumeVariables& v){ return v.mobility(wPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("mobN", [](const VolumeVariables& v){ return v.mobility(nPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("mobG", [](const VolumeVariables& v){ return v.mobility(gPhaseIdx); }); + vtkOutputModule.addSecondaryVariable("temperature", [](const VolumeVariables& v){ return v.temperature(); }); + vtkOutputModule.addSecondaryVariable("porosity", [](const VolumeVariables& v){ return v.porosity(); }); } - }; } -- GitLab