37 #include "base_data_package.h" 39 #include "my_memory_pool.h" 72 BaseMesh(Vecd mesh_lower_bound, Real grid_spacing,
Vecu number_of_grid_points);
76 Vecd MeshLowerBound() {
return mesh_lower_bound_; };
77 Real GridSpacing() {
return grid_spacing_; };
78 Vecu NumberOfGridPoints() {
return number_of_grid_points_; };
79 Vecu NumberOfGridPointsFromNumberOfCells(
const Vecu &number_of_cells) {
return number_of_cells + Vecu(1); };
80 Vecu NumberOfCellsFromNumberOfGridPoints(
const Vecu &number_of_grid_points) {
return number_of_grid_points - Vecu(1); };
81 Vecd GridPositionFromCellPosition(
const Vecd &cell_position) {
return cell_position -
Vecd(0.5 * grid_spacing_); };
83 Vecu CellIndexFromPosition(
const Vecd &position);
84 Vecd CellPositionFromIndex(
const Vecu &cell_index);
86 Vecd GridPositionFromIndex(
const Vecu &grid_index);
87 Vecu transfer1DtoMeshIndex(
const Vecu &number_of_mesh_indexes,
size_t i);
88 size_t transferMeshIndexTo1D(
const Vecu &number_of_mesh_indexes,
const Vecu &mesh_index);
94 size_t MortonCode(
const size_t &i);
96 size_t transferMeshIndexToMortonOrder(
const Vecu &mesh_index);
112 void copyMeshProperties(
Mesh *another_mesh);
115 Mesh(
BoundingBox tentative_bounds, Real grid_spacing,
size_t buffer_width);
116 Mesh(Vecd mesh_lower_bound,
Vecu number_of_cells, Real grid_spacing);
119 Vecu NumberOfCells() {
return number_of_cells_; };
120 size_t MeshBufferSize() {
return buffer_width_; };
121 virtual Real DataSpacing() {
return grid_spacing_; };
134 explicit BaseMeshField(
const std::string &name) : name_(name){};
137 std::string Name() {
return name_; };
139 virtual void writeMeshFieldToPlt(std::ofstream &output_file) = 0;
147 template <
class CoarseMeshType>
151 template <
typename... Args>
153 : CoarseMeshType(tentative_bounds, 0.5 * coarse_mesh.DataSpacing(), std::forward<Args>(args)...),
154 coarse_mesh_(coarse_mesh){};
158 CoarseMeshType &coarse_mesh_;
165 template <
class MeshFieldType,
class CoarsestMeshType,
class RefinedMeshType>
173 StdVec<CoarsestMeshType *> mesh_levels_;
178 template <
typename... Args>
182 Real coarsest_spacing = reference_spacing;
183 mesh_levels_.push_back(
184 mesh_level_ptr_vector_keeper_
185 .
template createPtr<CoarsestMeshType>(tentative_bounds, coarsest_spacing, std::forward<Args>(args)...));
187 for (
size_t level = 1; level != total_levels_; ++level)
190 mesh_levels_.push_back(
191 mesh_level_ptr_vector_keeper_
192 .
template createPtr<RefinedMeshType>(tentative_bounds, *mesh_levels_.back(), std::forward<Args>(args)...));
198 StdVec<CoarsestMeshType *> getMeshLevels() {
return mesh_levels_; };
200 void writeMeshFieldToPlt(std::ofstream &output_file)
override 202 for (
size_t l = 0; l != total_levels_; ++l)
204 mesh_levels_[l]->writeMeshFieldToPlt(output_file);
std::function< void(const Vecu &, Real)> MeshFunctor
Definition: base_mesh.h:50
Vecu number_of_cells_
Definition: base_mesh.h:110
void MeshIterator_parallel(const Vecu &index_begin, const Vecu &index_end, MeshFunctor &mesh_functor, Real dt)
Definition: base_mesh_supplementary.cpp:19
Definition: base_data_type.h:43
size_t total_levels_
Definition: base_mesh.h:172
Abstract base class for cell-based mesh by introducing number of cells, buffer width and mesh-based d...
Definition: base_mesh.h:106
Vecu number_of_grid_points_
Definition: base_mesh.h:68
Base class for all structured meshes which may be grid or cell based. The basic properties of the mes...
Definition: base_mesh.h:63
Abstract base class for the field data saved on a mesh.
Definition: base_mesh.h:128
size_t buffer_width_
Definition: base_mesh.h:109
Multi-level Meshes with successively double the resolution.
Definition: base_mesh.h:166
Vecd mesh_lower_bound_
Definition: base_mesh.h:66
Abstract base class derived from the coarse mesh but has double resolution. Currently, the design is simple but can be extending for more inter-mesh operations.
Definition: base_mesh.h:148
void MeshIterator(const Vecu &index_begin, const Vecu &index_end, MeshFunctor &mesh_functor, Real dt)
Definition: base_mesh_supplementary.cpp:11
Set up of basic data structure.
Real grid_spacing_
Definition: base_mesh.h:67
MultilevelMesh(BoundingBox tentative_bounds, Real reference_spacing, size_t total_levels, Args &&...args)
Definition: base_mesh.h:179
Definition: solid_body_supplementary.cpp:9