-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from gsb76/gab_add_brick
Add Brick and test
- Loading branch information
Showing
6 changed files
with
365 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#include "Domain/DomainCreators/Brick.hpp" | ||
|
||
#include <array> | ||
#include <unordered_set> | ||
#include <vector> | ||
|
||
#include "Domain/Block.hpp" | ||
#include "Domain/BlockNeighbor.hpp" | ||
#include "Domain/CoordinateMaps/AffineMap.hpp" | ||
#include "Domain/CoordinateMaps/ProductMaps.hpp" | ||
#include "Domain/Direction.hpp" | ||
#include "Domain/Domain.hpp" | ||
#include "Options/Options.hpp" | ||
#include "Utilities/MakeVector.hpp" | ||
|
||
namespace DomainCreators { | ||
|
||
Brick::Brick( | ||
typename LowerBound::type lower_xyz, typename UpperBound::type upper_xyz, | ||
typename IsPeriodicIn::type is_periodic_in_xyz, | ||
typename InitialRefinement::type initial_refinement_level_xyz, | ||
typename InitialGridPoints::type initial_number_of_grid_points_in_xyz, | ||
const OptionContext& /*context*/) noexcept | ||
// clang-tidy: trivially copyable | ||
: lower_xyz_(std::move(lower_xyz)), // NOLINT | ||
upper_xyz_(std::move(upper_xyz)), // NOLINT | ||
is_periodic_in_xyz_(std::move(is_periodic_in_xyz)), // NOLINT | ||
initial_refinement_level_xyz_( // NOLINT | ||
std::move(initial_refinement_level_xyz)), // NOLINT | ||
initial_number_of_grid_points_in_xyz_( // NOLINT | ||
std::move(initial_number_of_grid_points_in_xyz)) {} // NOLINT | ||
|
||
Domain<3, Frame::Inertial> Brick::create_domain() const noexcept { | ||
using AffineMap = CoordinateMaps::AffineMap; | ||
using AffineMap3D = | ||
CoordinateMaps::ProductOf3Maps<AffineMap, AffineMap, AffineMap>; | ||
std::vector<PairOfFaces> identifications{}; | ||
if (is_periodic_in_xyz_[0]) { | ||
identifications.push_back({{0, 4, 2, 6}, {1, 5, 3, 7}}); | ||
} | ||
if (is_periodic_in_xyz_[1]) { | ||
identifications.push_back({{0, 1, 4, 5}, {2, 3, 6, 7}}); | ||
} | ||
if (is_periodic_in_xyz_[2]) { | ||
identifications.push_back({{0, 1, 2, 3}, {4, 5, 6, 7}}); | ||
} | ||
|
||
return Domain<3, Frame::Inertial>{ | ||
make_vector<std::unique_ptr< | ||
CoordinateMapBase<Frame::Logical, Frame::Inertial, 3>>>( | ||
std::make_unique< | ||
CoordinateMap<Frame::Logical, Frame::Inertial, AffineMap3D>>( | ||
AffineMap3D{AffineMap{-1., 1., lower_xyz_[0], upper_xyz_[0]}, | ||
AffineMap{-1., 1., lower_xyz_[1], upper_xyz_[1]}, | ||
AffineMap{-1., 1., lower_xyz_[2], upper_xyz_[2]}})), | ||
std::vector<std::array<size_t, 8>>{{{0, 1, 2, 3, 4, 5, 6, 7}}}, | ||
identifications}; | ||
} | ||
|
||
std::array<size_t, 3> Brick::initial_extents(const size_t block_index) const | ||
noexcept { | ||
ASSERT(0 == block_index, "index = " << block_index); | ||
return initial_number_of_grid_points_in_xyz_; | ||
} | ||
|
||
std::array<size_t, 3> Brick::initial_refinement_levels( | ||
const size_t block_index) const noexcept { | ||
ASSERT(0 == block_index, "index = " << block_index); | ||
return initial_refinement_level_xyz_; | ||
} | ||
} // namespace DomainCreators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
/// \file | ||
/// Defines class Brick. | ||
|
||
#pragma once | ||
|
||
#include "Domain/DomainCreators/DomainCreator.hpp" | ||
#include "Options/Options.hpp" | ||
|
||
namespace DomainCreators { | ||
|
||
/// \ingroup DomainCreatorsGroup | ||
/// Create a 3D Domain consisting of a single Block. | ||
class Brick : public DomainCreator<3, Frame::Inertial> { | ||
public: | ||
struct LowerBound { | ||
using type = std::array<double, 3>; | ||
static constexpr OptionString_t help = { | ||
"Sequence of [x,y,z] for lower bounds."}; | ||
}; | ||
|
||
struct UpperBound { | ||
using type = std::array<double, 3>; | ||
static constexpr OptionString_t help = { | ||
"Sequence of [x,y,z] for upper bounds."}; | ||
}; | ||
struct IsPeriodicIn { | ||
using type = std::array<bool, 3>; | ||
static constexpr OptionString_t help = { | ||
"Sequence for [x,y,z], true if periodic."}; | ||
static type default_value() { return make_array<3>(false); } | ||
}; | ||
|
||
struct InitialRefinement { | ||
using type = std::array<size_t, 3>; | ||
static constexpr OptionString_t help = { | ||
"Initial refinement level in [x,y,z]."}; | ||
}; | ||
|
||
struct InitialGridPoints { | ||
using type = std::array<size_t, 3>; | ||
static constexpr OptionString_t help = { | ||
"Initial number of grid points in [x,y,z]."}; | ||
}; | ||
using options = tmpl::list<LowerBound, UpperBound, IsPeriodicIn, | ||
InitialRefinement, InitialGridPoints>; | ||
|
||
static constexpr OptionString_t help{"Creates a 3D brick."}; | ||
|
||
Brick(typename LowerBound::type lower_xyz, | ||
typename UpperBound::type upper_xyz, | ||
typename IsPeriodicIn::type is_periodic_in_xyz, | ||
typename InitialRefinement::type initial_refinement_level_xyz, | ||
typename InitialGridPoints::type initial_number_of_grid_points_in_xyz, | ||
const OptionContext& context = {}) noexcept; | ||
|
||
Brick() = default; | ||
Brick(const Brick&) = delete; | ||
Brick(Brick&&) noexcept = default; | ||
Brick& operator=(const Brick&) = delete; | ||
Brick& operator=(Brick&&) noexcept = default; | ||
~Brick() noexcept override = default; | ||
|
||
Domain<3, Frame::Inertial> create_domain() const noexcept override; | ||
|
||
std::array<size_t, 3> initial_extents(size_t block_index) const | ||
noexcept override; | ||
|
||
std::array<size_t, 3> initial_refinement_levels(size_t block_index) const | ||
noexcept override; | ||
|
||
private: | ||
typename LowerBound::type lower_xyz_{}; | ||
typename UpperBound::type upper_xyz_{}; | ||
typename IsPeriodicIn::type is_periodic_in_xyz_{}; | ||
typename InitialRefinement::type initial_refinement_level_xyz_{}; | ||
typename InitialGridPoints::type initial_number_of_grid_points_in_xyz_{}; | ||
}; | ||
} // namespace DomainCreators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
set(LIBRARY DomainCreators) | ||
|
||
set(LIBRARY_SOURCES | ||
Brick.cpp | ||
Interval.cpp | ||
Rectangle.cpp | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.