Skip to content
Snippets Groups Projects
Commit 0846dc83 authored by Sina Ackermann's avatar Sina Ackermann Committed by Kilian Weishaupt
Browse files

[staggeredGrid][nonisothermal] Add diffusion test problem

* simple test problem, diffusion only
parent 46de5054
No related branches found
No related tags found
2 merge requests!617[WIP] Next,!483Feature/staggered energy
...@@ -2,8 +2,14 @@ add_input_file_links() ...@@ -2,8 +2,14 @@ add_input_file_links()
add_dumux_test(test_channel_ni test_channel_ni test_channel_ni.cc ./test_channel_ni) add_dumux_test(test_channel_ni test_channel_ni test_channel_ni.cc ./test_channel_ni)
add_dumux_test(test_diffusion_ni test_diffusion_ni test_diffusion_ni.cc ./test_diffusion_ni)
set(CMAKE_BUILD_TYPE Debug)
#install sources #install sources
install(FILES install(FILES
test_channel_ni.cc test_channel_ni.cc
channeltestproblem.hh channeltestproblem.hh
test_diffusion_ni.cc
diffusiontestproblem.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/test/freeflow/staggeredni) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/test/freeflow/staggeredni)
// -*- 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 Diffusion test for the nonisothermal staggered grid (Navier-)Stokes model
*/
#ifndef DUMUX_DIFFUSION_NI_TEST_PROBLEM_HH
#define DUMUX_DIFFUSION_NI_TEST_PROBLEM_HH
#include <dumux/implicit/staggered/properties.hh>
#include <dumux/freeflow/staggeredni/model.hh>
#include <dumux/implicit/problem.hh>
#include <dumux/material/fluidsystems/liquidphase.hh>
#include <dumux/material/components/simpleh2o.hh>
namespace Dumux
{
template <class TypeTag>
class DiffusionNITestProblem;
namespace Capabilities
{
template<class TypeTag>
struct isStationary<DiffusionNITestProblem<TypeTag>>
{ static const bool value = false; };
}
namespace Properties
{
NEW_TYPE_TAG(DiffusionNITestProblem, INHERITS_FROM(StaggeredModel, NavierStokesNI));
SET_PROP(DiffusionNITestProblem, Fluid)
{
private:
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
public:
typedef FluidSystems::LiquidPhase<Scalar, Dumux::SimpleH2O<Scalar> > type;
};
// Set the grid type
SET_TYPE_PROP(DiffusionNITestProblem, Grid, Dune::YaspGrid<2>);
// Set the problem property
SET_TYPE_PROP(DiffusionNITestProblem, Problem, Dumux::DiffusionNITestProblem<TypeTag> );
SET_BOOL_PROP(DiffusionNITestProblem, EnableGlobalFVGeometryCache, true);
SET_BOOL_PROP(DiffusionNITestProblem, EnableGlobalFluxVariablesCache, true);
SET_BOOL_PROP(DiffusionNITestProblem, EnableGlobalVolumeVariablesCache, true);
// Enable gravity
SET_BOOL_PROP(DiffusionNITestProblem, ProblemEnableGravity, true);
//#if ENABLE_NAVIERSTOKES
SET_BOOL_PROP(DiffusionNITestProblem, EnableInertiaTerms, true);
//#else
//SET_BOOL_PROP(DiffusionNITestProblem, EnableInertiaTerms, false);
//#endif
}
/*!
* \brief Test problem for the one-phase model:
\todo doc me!
*/
template <class TypeTag>
class DiffusionNITestProblem : public NavierStokesProblem<TypeTag>
{
typedef NavierStokesProblem<TypeTag> ParentType;
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
// copy some indices for convenience
typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
enum {
// Grid and world dimension
dim = GridView::dimension,
dimWorld = GridView::dimensionworld
};
enum {
massBalanceIdx = Indices::massBalanceIdx,
momentumBalanceIdx = Indices::momentumBalanceIdx,
momentumXBalanceIdx = Indices::momentumXBalanceIdx,
momentumYBalanceIdx = Indices::momentumYBalanceIdx,
energyBalanceIdx = Indices::energyBalanceIdx,
pressureIdx = Indices::pressureIdx,
velocityXIdx = Indices::velocityXIdx,
velocityYIdx = Indices::velocityYIdx,
temperatureIdx = Indices::temperatureIdx
};
typedef typename GET_PROP_TYPE(TypeTag, BoundaryTypes) BoundaryTypes;
typedef typename GET_PROP_TYPE(TypeTag, TimeManager) TimeManager;
typedef typename GridView::template Codim<0>::Entity Element;
typedef typename GridView::Intersection Intersection;
typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry;
typedef typename GET_PROP_TYPE(TypeTag, SubControlVolume) SubControlVolume;
typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition;
using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables);
using BoundaryValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
using InitialValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
using SourceValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
public:
DiffusionNITestProblem(TimeManager &timeManager, const GridView &gridView)
: ParentType(timeManager, gridView)
{
name_ = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag,
std::string,
Problem,
Name);
}
/*!
* \name Problem parameters
*/
// \{
/*!
* \brief The problem name.
*
* This is used as a prefix for files generated by the simulation.
*/
std::string name() const
{
return name_;
}
bool shouldWriteRestartFile() const
{
return false;
}
/*!
* \brief Return the sources within the domain.
*
* \param globalPos The global position
*/
SourceValues sourceAtPos(const GlobalPosition &globalPos) const
{
return SourceValues(0.0);
}
// \}
/*!
* \name Boundary conditions
*/
// \{
/*!
* \brief Specifies which kind of boundary condition should be
* used for which equation on a given boundary control volume.
*
* \param globalPos The position of the center of the finite volume
*/
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
{
BoundaryTypes values;
if(isInlet(globalPos))
{
values.setDirichlet(momentumBalanceIdx);
values.setOutflow(massBalanceIdx);
values.setDirichlet(energyBalanceIdx);
}
else if(isOutlet(globalPos))
{
values.setOutflow(momentumBalanceIdx);
values.setDirichlet(massBalanceIdx);
values.setOutflow(energyBalanceIdx);
}
else
{
// set Dirichlet values for the velocity everywhere
values.setDirichlet(momentumBalanceIdx);
values.setOutflow(massBalanceIdx);
values.setOutflow(energyBalanceIdx);
}
return values;
}
/*!
* \brief Evaluate the boundary conditions for a dirichlet
* control volume.
*
* \param globalPos The center of the finite volume which ought to be set.
*/
BoundaryValues dirichletAtPos(const GlobalPosition &globalPos) const
{
BoundaryValues values = initialAtPos(globalPos);
if(isInlet(globalPos))
{
values[energyBalanceIdx] = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, Problem, InletTemp);
}
return values;
}
// \}
/*!
* \name Volume terms
*/
// \{
/*!
* \brief Evaluate the initial value for a control volume.
*
* \param globalPos The global position
*/
InitialValues initialAtPos(const GlobalPosition &globalPos) const
{
InitialValues values;
values[pressureIdx] = 1.1e+5;
values[velocityXIdx] = 0.0;
values[velocityYIdx] = 0.0;
values[temperatureIdx] = 283.15;
return values;
}
// \}
private:
bool isInlet(const GlobalPosition& globalPos) const
{
return globalPos[0] < eps_;
}
bool isOutlet(const GlobalPosition& globalPos) const
{
return globalPos[0] > this->bBoxMax()[0] - eps_;
}
bool isWall(const GlobalPosition& globalPos) const
{
return globalPos[0] > eps_ || globalPos[0] < this->bBoxMax()[0] - eps_;
}
const Scalar eps_{1e-6};
Scalar inletVelocity_;
std::string name_;
};
} //end namespace
#endif
// -*- 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 staggered grid non-isothermal (Navier-)Stokes model
*/
#include <config.h>
#include "diffusiontestproblem.hh"
#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 arguments 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.LensLowerLeftX x-coordinate of the lower left corner of the lens [m] \n"
"\t-SpatialParams.LensLowerLeftY y-coordinate of the lower left corner of the lens [m] \n"
"\t-SpatialParams.LensUpperRightX x-coordinate of the upper right corner of the lens [m] \n"
"\t-SpatialParams.LensUpperRightY y-coordinate of the upper right corner of the lens [m] \n"
"\t-SpatialParams.Permeability Permeability of the domain [m^2] \n"
"\t-SpatialParams.PermeabilityLens Permeability of the lens [m^2] \n";
std::cout << errorMessageOut
<< "\n";
}
}
int main(int argc, char** argv)
{
typedef TTAG(DiffusionNITestProblem) ProblemTypeTag;
return Dumux::start<ProblemTypeTag>(argc, argv, usage);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment