/*
* vmg - a versatile multigrid solver
* Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
*
* vmg 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 3 of the License, or
* (at your option) any later version.
*
* vmg 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 .
*/
/**
* @file grid_properties.hpp
* @author Julian Iseringhausen
* @date Mon Apr 18 12:54:05 2011
*
* @brief VMG::GlobalIndices, VMG::LocalIndices and VMG::SpatialExtent
*
*/
#ifndef GRID_PROPERTIES_HPP_
#define GRID_PROPERTIES_HPP_
#include "base/defs.hpp"
#include "base/index.hpp"
#include "base/vector.hpp"
namespace VMG
{
class GlobalIndices
{
public:
GlobalIndices() :
local_begin(0), local_end(0), local_size(0),
global_begin(0), global_end(0), global_size(0),
global_begin_finest(0), global_end_finest(0), global_size_finest(0),
boundary(EmptyGrid)
{}
GlobalIndices(const GlobalIndices& other) :
local_begin(other.local_begin), local_end(other.local_end), local_size(other.local_size),
global_begin(other.global_begin), global_end(other.global_end), global_size(other.global_size),
global_begin_finest(other.global_begin_finest), global_end_finest(other.global_end_finest), global_size_finest(other.global_size_finest),
boundary(other.boundary)
{}
Index& LocalBegin() {return local_begin;}
Index& LocalEnd() {return local_end;}
Index& LocalSize() {return local_size;}
const Index& LocalBegin() const {return local_begin;}
const Index& LocalEnd() const {return local_end;}
const Index& LocalSize() const {return local_size;}
Index& GlobalBegin() {return global_begin;}
Index& GlobalEnd() {return global_end;}
Index& GlobalSize() {return global_size;}
const Index& GlobalBegin() const {return global_begin;}
const Index& GlobalEnd() const {return global_end;}
const Index& GlobalSize() const {return global_size;}
Index& GlobalBeginFinest() {return global_begin_finest;}
Index& GlobalEndFinest() {return global_end_finest;}
Index& GlobalSizeFinest() {return global_size_finest;}
const Index& GlobalBeginFinest() const {return global_begin_finest;}
const Index& GlobalEndFinest() const {return global_end_finest;}
const Index& GlobalSizeFinest() const {return global_size_finest;}
BT& BoundaryType() {return boundary;}
const BT& BoundaryType() const {return boundary;}
private:
Index local_begin, local_end, local_size;
Index global_begin, global_end, global_size;
Index global_begin_finest, global_end_finest, global_size_finest;
BT boundary;
};
class LocalIndices
{
public:
LocalIndices() :
begin(0), end(0), size(0), size_total(0),
halo_begin_1(0), halo_end_1(0), halo_size_1(0),
halo_begin_2(0), halo_end_2(0), halo_size_2(0),
boundary_begin_1(0), boundary_end_1(0), boundary_size_1(0),
boundary_begin_2(0), boundary_end_2(0), boundary_size_2(0)
{}
LocalIndices(const LocalIndices& other) :
begin(other.begin), end(other.end), size(other.size), size_total(other.size_total),
halo_begin_1(other.halo_begin_1), halo_end_1(other.halo_end_1), halo_size_1(other.halo_size_1),
halo_begin_2(other.halo_begin_2), halo_end_2(other.halo_end_2), halo_size_2(other.halo_size_2),
boundary_begin_1(other.boundary_begin_1), boundary_end_1(other.boundary_end_1), boundary_size_1(other.boundary_size_1),
boundary_begin_2(other.boundary_begin_2), boundary_end_2(other.boundary_end_2), boundary_size_2(other.boundary_size_2)
{}
Index& Begin() {return begin;} ///< Index of first local grid point
Index& End() {return end;} ///< Index of first non-local grid point
Index& Size() {return size;} ///< Local grid size excluding halo
Index& SizeTotal() {return size_total;} ///< Local grid size including halo and boundary
const Index& Begin() const {return begin;} ///< Index of first local grid point
const Index& End() const {return end;} ///< Index of first non-local grid point
const Index& Size() const {return size;} ///< Local grid size excluding halo
const Index& SizeTotal() const {return size_total;} ///< Local grid size including halo and boundary
Index& HaloBegin1() {return halo_begin_1;} ///< Index of first halo point
Index& HaloEnd1() {return halo_end_1;} ///< Index of first non-halo point
Index& HaloSize1() {return halo_size_1;} ///< Size of halo
Index& HaloBegin2() {return halo_begin_2;} ///< Index of first halo point
Index& HaloEnd2() {return halo_end_2;} ///< Index of first non-halo point
Index& HaloSize2() {return halo_size_2;} ///< Size of halo
const Index& HaloBegin1() const {return halo_begin_1;} ///< Index of first halo point
const Index& HaloEnd1() const {return halo_end_1;} ///< Index of first non-halo point
const Index& HaloSize1() const {return halo_size_1;} ///< Size of halo
const Index& HaloBegin2() const {return halo_begin_2;} ///< Index of first halo point
const Index& HaloEnd2() const {return halo_end_2;} ///< Index of first non-halo point
const Index& HaloSize2() const {return halo_size_2;} ///< Size of halo
Index& BoundaryBegin1() {return boundary_begin_1;} ///< Index of first boundary point
Index& BoundaryEnd1() {return boundary_end_1;} ///< Index of first non-boundary point
Index& BoundarySize1() {return boundary_size_1;} ///< Size of boundary
Index& BoundaryBegin2() {return boundary_begin_2;} ///< Index of first boundary point
Index& BoundaryEnd2() {return boundary_end_2;} ///< Index of first non-boundary point
Index& BoundarySize2() {return boundary_size_2;} ///< Size of boundary
const Index& BoundaryBegin1() const {return boundary_begin_1;} ///< Index of first boundary point
const Index& BoundaryEnd1() const {return boundary_end_1;} ///< Index of first non-boundary point
const Index& BoundarySize1() const {return boundary_size_1;} ///< Size of boundary
const Index& BoundaryBegin2() const {return boundary_begin_2;} ///< Index of first boundary point
const Index& BoundaryEnd2() const {return boundary_end_2;} ///< Index of first non-boundary point
const Index& BoundarySize2() const {return boundary_size_2;} ///< Size of boundary
private:
Index begin, end, size, size_total;
Index halo_begin_1, halo_end_1, halo_size_1;
Index halo_begin_2, halo_end_2, halo_size_2;
Index boundary_begin_1, boundary_end_1, boundary_size_1;
Index boundary_begin_2, boundary_end_2, boundary_size_2;
};
class SpatialExtent
{
public:
SpatialExtent() :
begin(0.0),
end(0.0),
size(0.0),
mesh_width(0.0)
{}
SpatialExtent(const SpatialExtent& other) :
begin(other.begin),
end(other.end),
size(other.size),
mesh_width(other.mesh_width)
{}
Vector& Begin() {return begin;}
const Vector& Begin() const {return begin;}
Vector& End() {return end;}
const Vector& End() const {return end;}
Vector& Size() {return size;}
const Vector& Size() const {return size;}
Vector& MeshWidth() {return mesh_width;}
const Vector& MeshWidth() const {return mesh_width;}
private:
Vector begin, end, size;
Vector mesh_width;
};
}
#endif /* GRID_PROPERTIES_HPP_ */