27#ifndef DUMUX_FACETCOUPLING_BOX_GRID_FVGEOMETRY_HH
28#define DUMUX_FACETCOUPLING_BOX_GRID_FVGEOMETRY_HH
33#include <dune/grid/common/mcmgmapper.hh>
34#include <dune/localfunctions/lagrange/lagrangelfecache.hh>
57template<
class Gr
idView>
64 template<
class Gr
idGeometry,
bool enableCache>
68 using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
72 using FacetMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
84 bool enableGridGeometryCache =
false,
95template<
class Scalar,
class GV,
class Traits>
104 using Element =
typename GV::template Codim<0>::Entity;
105 using CoordScalar =
typename GV::ctype;
106 static const int dim = GV::dimension;
107 static const int dimWorld = GV::dimensionworld;
127 using FeCache = Dune::LagrangeLocalFiniteElementCache<CoordScalar, Scalar, dim, 1>;
132 [[deprecated(
"Use BoxFacetCouplingFVGridGeometry(gridView, facetGridView, codimOneGridAdapter) instead! Will be removed after release 3.5.")]]
136 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
138 const FacetGridView& facetGridView,
140 bool verbose =
false)
143 update_(facetGridView, codimOneGridAdapter, verbose);
161 {
return numBoundaryScvf_; }
178 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
179 [[deprecated(
"Use update(gridView, facetGridView, codimOneGridAdapter) instead! Will be removed after release 3.5.")]]
180 void update(
const FacetGridView& facetGridView,
182 bool verbose =
false)
186 update_(facetGridView, codimOneGridAdapter, verbose);
202 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
204 const FacetGridView& facetGridView,
206 bool verbose =
false)
209 update_(facetGridView, codimOneGridAdapter, verbose);
213 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
215 const FacetGridView& facetGridView,
217 bool verbose =
false)
220 update_(facetGridView, codimOneGridAdapter, verbose);
228 const std::vector<SubControlVolume>&
scvs(GridIndexType eIdx)
const
229 {
return scvs_[eIdx]; }
232 const std::vector<SubControlVolumeFace>&
scvfs(GridIndexType eIdx)
const
233 {
return scvfs_[eIdx]; }
237 {
return boundaryDofIndices_[dofIdx]; }
241 {
return interiorBoundaryDofIndices_[dofIdx]; }
249 { DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme"); }
253 {
return std::unordered_map<GridIndexType, GridIndexType>(); }
257 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
258 void update_(
const FacetGridView& facetGridView,
260 bool verbose =
false)
263 this->vertexMapper().enrich(facetGridView, codimOneGridAdapter, verbose);
266 const auto numDof = numDofs();
267 const auto numElements = this->gridView().size(0);
270 scvs_.resize(numElements);
271 scvfs_.resize(numElements);
272 boundaryDofIndices_.assign(numDof,
false);
273 interiorBoundaryDofIndices_.assign(numDof,
false);
278 numBoundaryScvf_ = 0;
279 for (
const auto& element : elements(this->gridView()))
281 auto eIdx = this->elementMapper().index(element);
284 numScv_ += element.subEntities(dim);
285 numScvf_ += element.subEntities(dim-1);
288 auto elementGeometry = element.geometry();
289 const auto refElement = referenceElement(elementGeometry);
292 GeometryHelper geometryHelper(elementGeometry);
296 scvs_[eIdx].reserve(elementGeometry.corners());
297 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
298 scvs_[eIdx].emplace_back(geometryHelper,
301 this->vertexMapper().subIndex(element, scvLocalIdx, dim));
304 LocalIndexType scvfLocalIdx = 0;
305 scvfs_[eIdx].clear();
306 scvfs_[eIdx].reserve(element.subEntities(dim-1));
307 for (; scvfLocalIdx < element.subEntities(dim-1); ++scvfLocalIdx)
310 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
311 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
314 scvfs_[eIdx].emplace_back(geometryHelper,
318 std::move(localScvIndices));
323 std::vector<unsigned int> handledFacets;
324 for (
const auto& intersection : intersections(this->gridView(), element))
326 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
329 handledFacets.push_back(intersection.indexInInside());
332 const auto isGeometry = intersection.geometry();
333 const auto numFaceCorners = isGeometry.corners();
334 const auto idxInInside = intersection.indexInInside();
335 const auto boundary = intersection.boundary();
337 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
338 for (
int i = 0; i < numFaceCorners; ++i)
339 vIndicesLocal[i] =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
341 std::vector<LocalIndexType> gridVertexIndices(numFaceCorners);
342 for (
int i = 0; i < numFaceCorners; ++i)
343 gridVertexIndices[i] = this->vertexMapper().vertexIndex(element, vIndicesLocal[i], dim);
349 if (boundary && intersection.neighbor())
350 DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme");
353 if (isOnFacet || boundary)
356 numScvf_ += numFaceCorners;
357 numBoundaryScvf_ += int(boundary)*numFaceCorners;
359 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < numFaceCorners; ++isScvfLocalIdx)
362 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
365 scvfs_[eIdx].emplace_back(geometryHelper,
370 std::move(localScvIndices),
375 const auto dofIndex = this->vertexMapper().subIndex(element, vIndicesLocal[isScvfLocalIdx], dim);
376 if (boundary) boundaryDofIndices_[ dofIndex ] = boundary;
377 if (isOnFacet) interiorBoundaryDofIndices_[ dofIndex ] = isOnFacet;
387 const FeCache feCache_;
389 std::vector<std::vector<SubControlVolume>> scvs_;
390 std::vector<std::vector<SubControlVolumeFace>> scvfs_;
394 std::size_t numScvf_;
395 std::size_t numBoundaryScvf_;
398 std::vector<bool> boundaryDofIndices_;
399 std::vector<bool> interiorBoundaryDofIndices_;
409template<
class Scalar,
class GV,
class Traits>
418 static const int dim = GV::dimension;
419 static const int dimWorld = GV::dimensionworld;
421 using Element =
typename GV::template Codim<0>::Entity;
422 using Intersection =
typename GV::Intersection;
423 using CoordScalar =
typename GV::ctype;
441 using FeCache = Dune::LagrangeLocalFiniteElementCache<CoordScalar, Scalar, dim, 1>;
446 [[deprecated(
"Use BoxFacetCouplingFVGridGeometry(gridView, facetGridView, codimOneGridAdapter) instead! Will be removed after release 3.5.")]]
452 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
454 const FacetGridView& facetGridView,
456 bool verbose =
false)
460 update_(facetGridView, codimOneGridAdapter, verbose);
479 {
return numBoundaryScvf_; }
496 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
497 [[deprecated(
"Use update(gridView, facetGridView, codimOneGridAdapter) instead! Will be removed after release 3.5.")]]
498 void update(
const FacetGridView& facetGridView,
500 bool verbose =
false)
504 updateFacetMapper_();
505 update_(facetGridView, codimOneGridAdapter, verbose);
521 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
523 const FacetGridView& facetGridView,
525 bool verbose =
false)
528 updateFacetMapper_();
529 update_(facetGridView, codimOneGridAdapter, verbose);
533 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
535 const FacetGridView& facetGridView,
537 bool verbose =
false)
540 updateFacetMapper_();
541 update_(facetGridView, codimOneGridAdapter, verbose);
550 {
return boundaryDofIndices_[dofIdx]; }
554 {
return interiorBoundaryDofIndices_[dofIdx]; }
558 {
return facetIsOnInteriorBoundary_[ facetMapper_.subIndex(
element, intersection.indexInInside(), 1) ]; }
566 { DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the facet coupling scheme"); }
570 {
return std::unordered_map<GridIndexType, GridIndexType>(); }
574 void updateFacetMapper_()
576 if constexpr (Deprecated::hasUpdateGridView<typename Traits::FacetMapper, GridView>())
577 facetMapper_.update(this->gridView());
579 Deprecated::update(facetMapper_);
582 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
583 void update_(
const FacetGridView& facetGridView,
584 const CodimOneGridAdapter& codimOneGridAdapter,
588 this->vertexMapper().enrich(facetGridView, codimOneGridAdapter, verbose);
594 numBoundaryScvf_ = 0;
596 const auto numDof = numDofs();
597 boundaryDofIndices_.assign(numDof,
false);
598 interiorBoundaryDofIndices_.assign(numDof,
false);
599 facetIsOnInteriorBoundary_.assign(this->gridView().size(1),
false);
600 for (
const auto& element : elements(this->gridView()))
602 numScv_ += element.subEntities(dim);
603 numScvf_ += element.subEntities(dim-1);
605 const auto elementGeometry = element.geometry();
606 const auto refElement = referenceElement(elementGeometry);
610 std::vector<unsigned int> handledFacets;
611 for (
const auto& intersection : intersections(this->gridView(), element))
613 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
616 handledFacets.push_back(intersection.indexInInside());
619 const auto isGeometry = intersection.geometry();
620 const auto numFaceCorners = isGeometry.corners();
621 const auto idxInInside = intersection.indexInInside();
622 const auto boundary = intersection.boundary();
624 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
625 for (
int i = 0; i < numFaceCorners; ++i)
626 vIndicesLocal[i] =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
628 std::vector<GridIndexType> gridVertexIndices(numFaceCorners);
629 for (
int i = 0; i < numFaceCorners; ++i)
630 gridVertexIndices[i] = this->vertexMapper().vertexIndex(element, vIndicesLocal[i], dim);
633 const bool isOnFacet = codimOneGridAdapter.composeFacetElement(gridVertexIndices);
636 if (boundary && intersection.neighbor())
637 DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme");
639 if (isOnFacet || boundary)
641 numScvf_ += numFaceCorners;
642 numBoundaryScvf_ += int(boundary)*numFaceCorners;
645 for (
int i = 0; i < numFaceCorners; ++i)
647 const auto dofIndex = this->vertexMapper().subIndex(element, vIndicesLocal[i], dim);
648 if (boundary) boundaryDofIndices_[ dofIndex ] =
true;
651 interiorBoundaryDofIndices_[ dofIndex ] =
true;
652 facetIsOnInteriorBoundary_[ facetMapper_.subIndex(element, idxInInside, 1) ] =
true;
660 const FeCache feCache_;
665 std::size_t numScvf_;
666 std::size_t numBoundaryScvf_;
669 std::vector<bool> boundaryDofIndices_;
670 std::vector<bool> interiorBoundaryDofIndices_;
673 typename Traits::FacetMapper facetMapper_;
674 std::vector<bool> facetIsOnInteriorBoundary_;
A vertex mapper that allows for enrichment of nodes. Indication on where to enrich the nodes is done ...
Defines the index types used for grid and local indices.
The available discretization methods in Dumux.
Helper classes to compute the integration elements.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Base class for grid geometries.
BaseGridGeometry(const GridView &gridView)
Constructor computes the bounding box of the entire domain, for e.g. setting boundary conditions.
Definition basegridgeometry.hh:79
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:177
Definition common/pdesolver.hh:36
typename GridView::IndexSet::IndexType GridIndex
Definition indextraits.hh:39
unsigned int LocalIndex
Definition indextraits.hh:40
Element element(GridIndexType eIdx) const
Get an element from a global element index.
Definition basegridgeometry.hh:162
const VertexMapper & vertexMapper() const
Returns the mapper for vertices to indices for constant grids.
Definition basegridgeometry.hh:126
const GridView & gridView() const
Return the gridView this grid geometry object lives on.
Definition basegridgeometry.hh:120
void update()
Update all fvElementGeometries (do this again after grid adaption).
Definition basegridgeometry.hh:94
Create sub control volumes and sub control volume face geometries.
Definition boxgeometryhelper.hh:36
the sub control volume for the box scheme
Definition discretization/box/subcontrolvolume.hh:89
Base class for the element-local finite volume geometry for box models in the context of models consi...
Definition multidomain/facet/box/fvelementgeometry.hh:48
The default traits for the finite volume grid geometry of the box scheme with coupling occuring acros...
Definition multidomain/facet/box/fvgridgeometry.hh:59
BoxFacetCouplingFVElementGeometry< GridGeometry, enableCache > LocalView
Definition multidomain/facet/box/fvgridgeometry.hh:65
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > FacetMapper
Definition multidomain/facet/box/fvgridgeometry.hh:72
BoxFacetCouplingSubControlVolumeFace< GridView > SubControlVolumeFace
Definition multidomain/facet/box/fvgridgeometry.hh:62
EnrichedVertexDofMapper< GridView > VertexMapper
Definition multidomain/facet/box/fvgridgeometry.hh:70
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > ElementMapper
Definition multidomain/facet/box/fvgridgeometry.hh:68
BoxSubControlVolume< GridView > SubControlVolume
Definition multidomain/facet/box/fvgridgeometry.hh:61
Base class for the finite volume geometry vector for box schemes in the context of coupled models whe...
Definition multidomain/facet/box/fvgridgeometry.hh:86
bool dofOnInteriorBoundary(GridIndexType dofIdx) const
If a d.o.f. is on an interior boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:240
GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
The index of the vertex / d.o.f. on the other side of the periodic boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:248
void update(const GridView &gridView, const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
update all fvElementGeometries (call this after grid adaption)
Definition multidomain/facet/box/fvgridgeometry.hh:203
Dune::LagrangeLocalFiniteElementCache< CoordScalar, Scalar, dim, 1 > FeCache
export the finite element cache type
Definition multidomain/facet/box/fvgridgeometry.hh:127
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition multidomain/facet/box/fvgridgeometry.hh:123
const std::vector< SubControlVolume > & scvs(GridIndexType eIdx) const
Get the local scvs for an element.
Definition multidomain/facet/box/fvgridgeometry.hh:228
static constexpr DiscretizationMethod discMethod
Definition multidomain/facet/box/fvgridgeometry.hh:114
GV GridView
export the grid view type
Definition multidomain/facet/box/fvgridgeometry.hh:129
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvgridgeometry.hh:151
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
Periodic boundaries are not supported for the box facet coupling scheme.
Definition multidomain/facet/box/fvgridgeometry.hh:244
bool dofOnBoundary(GridIndexType dofIdx) const
If a d.o.f. is on the boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:236
typename Traits::VertexMapper DofMapper
export dof mapper type
Definition multidomain/facet/box/fvgridgeometry.hh:125
std::size_t numBoundaryScvf() const
Definition multidomain/facet/box/fvgridgeometry.hh:160
void update(const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
update all fvElementGeometries (do this again after grid adaption)
Definition multidomain/facet/box/fvgridgeometry.hh:180
const DofMapper & dofMapper() const
the vertex mapper is the dofMapper
Definition multidomain/facet/box/fvgridgeometry.hh:147
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:119
std::size_t numScvf() const
The total number of sun control volume faces.
Definition multidomain/facet/box/fvgridgeometry.hh:155
void update(GridView &&gridView, const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
update all fvElementGeometries (call this after grid adaption)
Definition multidomain/facet/box/fvgridgeometry.hh:214
const FeCache & feCache() const
The finite element cache for creating local FE bases.
Definition multidomain/facet/box/fvgridgeometry.hh:224
std::size_t numDofs() const
The total number of degrees of freedom.
Definition multidomain/facet/box/fvgridgeometry.hh:164
BoxFacetCouplingFVGridGeometry(const GridView &gridView, const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
Definition multidomain/facet/box/fvgridgeometry.hh:137
typename Traits::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition multidomain/facet/box/fvgridgeometry.hh:117
BoxFacetCouplingFVGridGeometry(const GridView &gridView)
Constructor.
Definition multidomain/facet/box/fvgridgeometry.hh:133
std::unordered_map< GridIndexType, GridIndexType > periodicVertexMap() const
Returns the map between dofs across periodic boundaries.
Definition multidomain/facet/box/fvgridgeometry.hh:252
const std::vector< SubControlVolumeFace > & scvfs(GridIndexType eIdx) const
Get the local scvfs for an element.
Definition multidomain/facet/box/fvgridgeometry.hh:232
DiscretizationMethods::Box DiscretizationMethod
export the discretization method this geometry belongs to
Definition multidomain/facet/box/fvgridgeometry.hh:113
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:121
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:433
BoxFacetCouplingFVGridGeometry(const GridView &gridView, const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
Definition multidomain/facet/box/fvgridgeometry.hh:453
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvgridgeometry.hh:469
std::size_t numScvf() const
The total number of sun control volume faces.
Definition multidomain/facet/box/fvgridgeometry.hh:473
GV GridView
export the grid view type
Definition multidomain/facet/box/fvgridgeometry.hh:443
DiscretizationMethods::Box DiscretizationMethod
export the discretization method this geometry belongs to
Definition multidomain/facet/box/fvgridgeometry.hh:427
std::size_t numDofs() const
The total number of degrees of freedom.
Definition multidomain/facet/box/fvgridgeometry.hh:482
std::unordered_map< GridIndexType, GridIndexType > periodicVertexMap() const
Returns the map between dofs across periodic boundaries.
Definition multidomain/facet/box/fvgridgeometry.hh:569
void update(GridView &&gridView, const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
update all fvElementGeometries (call this after grid adaption)
Definition multidomain/facet/box/fvgridgeometry.hh:534
std::size_t numBoundaryScvf() const
Definition multidomain/facet/box/fvgridgeometry.hh:478
Dune::LagrangeLocalFiniteElementCache< CoordScalar, Scalar, dim, 1 > FeCache
export the finite element cache type
Definition multidomain/facet/box/fvgridgeometry.hh:441
const FeCache & feCache() const
The finite element cache for creating local FE bases.
Definition multidomain/facet/box/fvgridgeometry.hh:545
typename Traits::VertexMapper DofMapper
export dof mapper type
Definition multidomain/facet/box/fvgridgeometry.hh:439
void update(const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
update all fvElementGeometries (do this again after grid adaption)
Definition multidomain/facet/box/fvgridgeometry.hh:498
const DofMapper & dofMapper() const
Definition multidomain/facet/box/fvgridgeometry.hh:465
static constexpr DiscretizationMethod discMethod
Definition multidomain/facet/box/fvgridgeometry.hh:428
typename Traits::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition multidomain/facet/box/fvgridgeometry.hh:431
GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
The index of the vertex / d.o.f. on the other side of the periodic boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:565
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
Periodic boundaries are not supported for the box facet coupling scheme.
Definition multidomain/facet/box/fvgridgeometry.hh:561
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:435
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition multidomain/facet/box/fvgridgeometry.hh:437
bool dofOnBoundary(unsigned int dofIdx) const
If a d.o.f. is on the boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:549
void update(const GridView &gridView, const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
update all fvElementGeometries (call this after grid adaption)
Definition multidomain/facet/box/fvgridgeometry.hh:522
bool dofOnInteriorBoundary(unsigned int dofIdx) const
If a d.o.f. is on an interior boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:553
BoxFacetCouplingFVGridGeometry(const GridView gridView)
Constructor.
Definition multidomain/facet/box/fvgridgeometry.hh:447
bool isOnInteriorBoundary(const Element &element, const Intersection &intersection) const
returns true if an intersection is on an interior boundary
Definition multidomain/facet/box/fvgridgeometry.hh:557
Class for a sub control volume face in the box method, i.e a part of the boundary of a sub control vo...
Definition multidomain/facet/box/subcontrolvolumeface.hh:52
Adapter that allows retrieving information on a d-dimensional grid for entities of a (d-1)-dimensiona...
Definition codimonegridadapter.hh:52
bool composeFacetElement(const IndexStorage &bulkVertexIndices) const
Returns true if a given set of bulk vertex indices make up a facet grid element.
Definition codimonegridadapter.hh:192
A vertex mapper that allows for enrichment of nodes. Indication on where to enrich the nodes is done ...
Definition vertexmapper.hh:142
Base class for the element-local finite volume geometry for box models in the context of models consi...
Base class for a sub control volume face of the box method in the context of of models considering co...
the sub control volume for the box scheme