Commit 6dbfb319 authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[2p][adaptive] reintroduce pointsources test

For this test one needs to be able to update the point source map from outside.
As a first workaround, the computePointSourceMap() function in the FvProblem
does not get a map as input anymore but takes its own map. We should discuss
how this should look in general.
parent b8231625
......@@ -91,7 +91,7 @@ public:
problemName_ = getParamFromGroup<std::string>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "Problem.Name");
// compute which scvs contain point sources
computePointSourceMap(pointSourceMap_);
computePointSourceMap();
}
/*!
......@@ -432,11 +432,10 @@ public:
}
//! Compute the point source map, i.e. which scvs have point source contributions
template<class PointSourceMap>
void computePointSourceMap(PointSourceMap& pointSourceMap)
void computePointSourceMap()
{
// clear the given point source maps in case it's not empty
pointSourceMap.clear();
pointSourceMap_.clear();
// get and apply point sources if any given in the problem
std::vector<PointSource> sources;
......@@ -448,7 +447,7 @@ public:
// calculate point source locations and save them in a map
PointSourceHelper::computePointSourceMap(*fvGridGeometry_,
sources,
pointSourceMap);
pointSourceMap_);
}
}
......
......@@ -321,7 +321,7 @@ public:
volVars.update(elemSolSon, *problem_, element, scv);
const auto dofIdxGlobal = scv.dofIndex();
const auto scvVolume = scv.volume(); //std::cout << "ratio = " << scvVolume / fatherElementVolume << std::endl;
const auto scvVolume = scv.volume();
if (int(formulation) == pwsn)
{
massCoeff[dofIdxGlobal] += scvVolume * volVars.density(nPhaseIdx) * volVars.porosity();
......
#add_subdirectory(pointsources)
add_subdirectory(adaptive)
add_subdirectory(fracture)
add_subdirectory(incompressible)
......
......@@ -8,9 +8,20 @@ dune_add_test(NAME test_2p_adaptive_tpfa
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/lensccadaptive-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/2p_adaptive_tpfa-00008.vtu
${CMAKE_CURRENT_BINARY_DIR}/2p_adaptive_tpfa-00016.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_adaptive_tpfa test_2p_adaptive.input -Problem.Name 2p_adaptive_tpfa")
# using tpfa and point source
dune_add_test(NAME test_2p_adaptive_ps_tpfa
SOURCES test_2p_adaptive_fv.cc
COMPILE_DEFINITIONS TYPETAG=TwoPAdaptivePointSource
CMAKE_GUARD dune-alugrid_FOUND
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/lensccadaptivepointsource-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/2p_adaptive_ps_tpfa-00018.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_adaptive_ps_tpfa test_2p_adaptive.input -Problem.Name 2p_adaptive_ps_tpfa")
# using mpfa
dune_add_test(NAME test_2p_adaptive_mpfa
SOURCES test_2p_adaptive_fv.cc
......@@ -30,7 +41,7 @@ dune_add_test(NAME test_2p_adaptive_box
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/lensboxadaptive-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/2p_adaptive_box-00008.vtu
${CMAKE_CURRENT_BINARY_DIR}/2p_adaptive_box-00011.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_adaptive_box test_2p_adaptive.input -Problem.Name 2p_adaptive_box")
set(CMAKE_BUILD_TYPE Release)
......@@ -26,85 +26,20 @@
#ifndef DUMUX_LENSPROBLEM_POINTSOURCE_HH
#define DUMUX_LENSPROBLEM_POINTSOURCE_HH
#include "../lensproblem.hh"
#include "../incompressible/problem.hh"
#if HAVE_UG
namespace Dumux
{
template <class TypeTag>
class LensProblemPointSource;
//////////
// Specify the properties for the lens problem
//////////
namespace Properties
{
NEW_TYPE_TAG(LensProblemPointSource, INHERITS_FROM(LensCCAdaptiveProblem));
NEW_PROP_TAG(BaseProblem);
SET_TYPE_PROP(LensProblemPointSource, BaseProblem, ImplicitPorousMediaProblem<TypeTag>);
SET_BOOL_PROP(LensProblemPointSource, AdaptiveGrid, true);
SET_TYPE_PROP(LensProblemPointSource, AdaptionIndicator, TwoPImplicitGridAdaptIndicator<TypeTag>);
SET_TYPE_PROP(LensProblemPointSource, AdaptionInitializationIndicator, ImplicitGridAdaptInitializationIndicator<TypeTag>);
SET_TYPE_PROP(LensProblemPointSource, Grid, Dune::UGGrid<2>);
SET_TYPE_PROP(LensProblemPointSource, Problem, LensProblemPointSource<TypeTag>);
}
/*!
* \ingroup TwoPModel
* \ingroup ImplicitTestProblems
* \brief Soil contamination problem where DNAPL infiltrates a fully
* water saturated medium.
*
* The domain is sized 6m times 4m and features a rectangular lens
* with low permeablility which spans from (1 m , 2 m) to (4 m, 3 m)
* and is surrounded by a medium with higher permability. Note that
* this problem is discretized using only two dimensions, so from the
* point of view of the two-phase model, the depth of the domain
* implicitly is 1 m everywhere.
*
* On the top and the bottom of the domain neumann boundary conditions
* are used, while dirichlet conditions apply on the left and right
* boundaries.
*
* DNAPL is injected at the top boundary from 3m to 4m at a rate of
* 0.04 kg/(s m^2), the remaining neumann boundaries are no-flow
* boundaries.
*
* The dirichlet boundaries on the left boundary is the hydrostatic
* pressure scaled by a factor of 1.125, while on the right side it is
* just the hydrostatic pressure. The DNAPL saturation on both sides
* is zero.
*
* This problem uses the \ref TwoPModel.
*
* This problem should typically be simulated until \f$t_{\text{end}}
* \approx 20\,000\;s\f$ is reached. A good choice for the initial time step
* size is \f$t_{\text{inital}} = 250\;s\f$.
*
* To run the simulation execute the following line in shell:
* <tt>./test_box2p -parameterFile test_box2p.input</tt> or
* <tt>./test_cc2p -parameterFile test_cc2p.input</tt>
*/
template <class TypeTag >
class LensProblemPointSource : public LensProblem<TypeTag>
class PointSourceTestProblem : public TwoPTestProblem<TypeTag>
{
typedef LensProblem<TypeTag> ParentType;
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef typename GET_PROP_TYPE(TypeTag, PointSource) PointSource;
typedef typename GET_PROP_TYPE(TypeTag, TimeManager) TimeManager;
using ParentType = TwoPTestProblem<TypeTag>;
using PointSource = typename GET_PROP_TYPE(TypeTag, PointSource);
public:
/*!
* \brief The constructor
*
* \param timeManager The time manager
* \param gridView The grid view
*/
LensProblemPointSource(TimeManager &timeManager, const GridView &gridView)
: ParentType(timeManager, gridView)
{}
//! Use parent's constructor
using ParentType::ParentType;
/*!
* \brief Applies a vector of point sources. The point sources
......@@ -127,6 +62,4 @@ public:
} //end namespace
#endif // HAVE_UG
#endif
......@@ -32,8 +32,9 @@
#include <dune/grid/io/file/vtk.hh>
#include <dune/istl/io.hh>
//! Use the incompressible problem for this adaptive test
//! Use the incompressible or point source problem for this adaptive test
#include <test/porousmediumflow/2p/implicit/incompressible/problem.hh>
#include "pointsourceproblem.hh"
#include <dumux/common/propertysystem.hh>
#include <dumux/common/parameters.hh>
......@@ -66,11 +67,13 @@ namespace Dumux {
NEW_TYPE_TAG(TwoPIncompressibleAdaptiveTpfa, INHERITS_FROM(TwoPIncompressibleTpfa));
NEW_TYPE_TAG(TwoPIncompressibleAdaptiveMpfa, INHERITS_FROM(TwoPIncompressibleMpfa));
NEW_TYPE_TAG(TwoPIncompressibleAdaptiveBox, INHERITS_FROM(TwoPIncompressibleBox));
NEW_TYPE_TAG(TwoPAdaptivePointSource, INHERITS_FROM(TwoPIncompressibleAdaptiveTpfa));
//! Use non-conforming refinement in the cell-centered tests, conforming for box
SET_TYPE_PROP(TwoPIncompressibleAdaptiveTpfa, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>);
SET_TYPE_PROP(TwoPIncompressibleAdaptiveMpfa, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>);
SET_TYPE_PROP(TwoPIncompressibleAdaptiveBox, Grid, Dune::UGGrid<2>);
SET_TYPE_PROP(TwoPAdaptivePointSource, Problem, PointSourceTestProblem<TypeTag>);
}
}
......@@ -146,8 +149,9 @@ int main(int argc, char** argv) try
// update grid data after adaption
if (wasAdapted)
{
xOld = x; //! Overwrite the old solution with the new (resized & interpolated) one
gridVariables->init(x, xOld); //! Initialize the secondary variables to the new (and "new old") solution
xOld = x; //! Overwrite the old solution with the new (resized & interpolated) one
gridVariables->init(x, xOld); //! Initialize the secondary variables to the new (and "new old") solution
problem->computePointSourceMap(); //! Update the point source map
}
}
......@@ -161,8 +165,9 @@ int main(int argc, char** argv) try
// update grid data after adaption
if (wasAdapted)
{
xOld = x; //! Overwrite the old solution with the new (resized & interpolated) one
gridVariables->init(x, xOld); //! Initialize the secondary variables to the new (and "new old") solution
xOld = x; //! Overwrite the old solution with the new (resized & interpolated) one
gridVariables->init(x, xOld); //! Initialize the secondary variables to the new (and "new old") solution
problem->computePointSourceMap(); //! Update the point source map
}
// get some time loop parameters
......@@ -215,10 +220,11 @@ int main(int argc, char** argv) try
if (wasAdapted)
{
//! Note that if we were using point sources, we would have to update the map here as well
xOld = x; //! Overwrite the old solution with the new (resized & interpolated) one
assembler->setJacobianPattern(); //! Tell the assembler to resize the matrix and set pattern
assembler->setResidualSize(); //! Tell the assembler to resize the residual
gridVariables->init(x, xOld); //! Initialize the secondary variables to the new (and "new old") solution
xOld = x; //! Overwrite the old solution with the new (resized & interpolated) one
assembler->setJacobianPattern(); //! Tell the assembler to resize the matrix and set pattern
assembler->setResidualSize(); //! Tell the assembler to resize the residual
gridVariables->init(x, xOld); //! Initialize the secondary variables to the new (and "new old") solution
problem->computePointSourceMap(); //! Update the point source map
}
// set previous solution for storage evaluations
......
add_dumux_test(test_ccadaptive2ppointsource test_ccadaptive2ppointsource test_ccadaptive2ppointsource.cc
python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
--script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/lensccadaptivepointsource-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/lensccadaptive-00010.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_ccadaptive2ppointsource")
#install sources
install(FILES
lensproblem.hh
test_ccadaptive2ppointsource.cc
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/test/implicit/2p/pointsources)
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief Test for the two-phase CC model with point source
*/
#include <config.h>
#if HAVE_UG
#include "lensproblem.hh"
#endif
#include <dumux/common/start.hh>
/*!
* \brief Provides an interface for customizing error messages associated with
* reading in parameters.
*
* \param progName The name of the program, that was tried to be started.
* \param errorMsg The error message that was issued by the start function.
* Comprises the thing that went wrong and a general help message.
*/
void usage(const char *progName, const std::string &errorMsg)
{
if (errorMsg.size() > 0) {
std::string errorMessageOut = "\nUsage: ";
errorMessageOut += progName;
errorMessageOut += " [options]\n";
errorMessageOut += errorMsg;
errorMessageOut += "\n\nThe list of mandatory options for this program is:\n"
"\t-TimeManager.TEnd End of the simulation [s] \n"
"\t-TimeManager.DtInitial Initial timestep size [s] \n"
"\t-Grid.File Name of the file containing the grid \n"
"\t definition in DGF format\n"
"\t-SpatialParams.LensLowerLeft coordinates of the lower left corner of the lens [m] \n"
"\t-SpatialParams.LensUpperRight coordinates of the upper right corner of the lens [m] \n"
"\t-Problem.Name String for naming of the output files \n"
"\n";
std::cout << errorMessageOut << std::endl;
}
}
////////////////////////
// the main function
////////////////////////
int main(int argc, char** argv)
{
#if HAVE_UG
typedef TTAG(LensProblemPointSource) TypeTag;
return Dumux::start<TypeTag>(argc, argv, usage);
#else
#warning You need UGGrid to run this test.
std::cerr << "You need UGGrid to run this test." << std::endl;
return 77;
#endif
}
[TimeManager]
DtInitial = 25 # [s]
TEnd = 500 # [s]
[Grid]
LowerLeft = 0 0
UpperRight = 6 4
Cells = 48 32
[SpatialParams]
LensLowerLeft = 1.0 2.0 # [m] coordinates of the lower left lens corner
LensUpperRight = 4.0 3.0 # [m] coordinate of the upper right lens corner
[Problem]
Name = lensccadaptive # name passed to the output routines
[Implicit]
EnablePartialReassemble = 1 # enable partial reassembly of the jacobian matrix?
EnableJacobianRecycling = 1 # Enable reuse of jacobian matrices?
[GridAdapt]
EnableInitializationIndicator = 1
RefineAtDirichletBC = 1
RefineAtFluxBC = 1
MinLevel = 0
MaxLevel = 2
CoarsenTolerance = 1.0e-4
RefineTolerance = 1.0e-4
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment