FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
domain_helper.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
8#include <kernel/util/tiny_algebra.hpp>
9#include <kernel/util/math.hpp>
10#include <kernel/util/dist.hpp>
11
13{
14
18 template<typename DomainControl_>
20 {
21 typedef typename DomainControl_::LevelType::MeshType::CoordType DataType;
22 static constexpr int dim = DomainControl_::LevelType::MeshType::shape_dim;
24
35 static std::pair<CoordVecType, CoordVecType> calculate_global_boundingbox(const DomainControl_& domain, const Index level = Index(0))
36 {
37 XASSERTM(domain.size_virtual() >= level, "Chosen level is larger than virtual size");
38 // calculate local boundingbox for all relevant domain level
40 if(level < domain.size_physical())
41 {
42 // calculate local boundingbox
43 const auto& mesh = domain.at(level)->get_mesh();
44 const auto& vtx_set = mesh.get_vertex_set();
45
46 const Index n = vtx_set.get_num_vertices();
47 for(Index i(0); i < n; ++i)
48 {
49 for(int k = 0; k < dim; ++k)
50 {
51 bb_min[k] = Math::min(bb_min[k], vtx_set[i][k]);
52 bb_max[k] = Math::max(bb_max[k], vtx_set[i][k]);
53 }
54 }
55 }
56 // and now do a communication over all processes
57 const Dist::Comm& comm = domain.comm();
58 comm.allreduce(static_cast<DataType*>(&bb_min[0]), static_cast<DataType*>(&bb_min[0]), std::size_t(dim), Dist::op_min);
59 comm.allreduce(static_cast<DataType*>(&bb_max[0]), static_cast<DataType*>(&bb_max[0]), std::size_t(dim), Dist::op_max);
60
61 return std::make_pair(bb_min, bb_max);
62 }
63 };
64
68 template<typename DomainLevel_>
70 {
71 typedef typename DomainLevel_::MeshType::CoordType DataType;
72 static constexpr int dim = DomainLevel_::MeshType::shape_dim;
74
85 static std::pair<CoordVecType, CoordVecType> calculate_global_boundingbox(const Control::Domain::DeslaggedDomainControl<DomainLevel_>& domain, [[maybe_unused]] const Index level = Index(0))
86 {
87 XASSERTM(domain.size_virtual() > level, "Chosen level is larger than virtual size");
88 // calculate local boundingbox for all relevant domain level
89 return std::make_pair(domain.get_bounding_box_min(), domain.get_bounding_box_max());
90 }
91 };
92
93}
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
FEAT Kernel base header.
Hierarchical partitioned Slagged Domain Control.
Communicator class.
Definition: dist.hpp:1657
void allreduce(const void *sendbuf, void *recvbuf, std::size_t count, const Datatype &datatype, const Operation &op) const
Blocking All-Reduce.
Definition: dist.cpp:658
MPI_Comm comm
our MPI communicator handle
Definition: dist.hpp:1661
Math Limits class template.
Definition: math.hpp:1475
Tiny Vector class template.
const Operation op_min(MPI_MIN)
Operation wrapper for MPI_MIN.
Definition: dist.hpp:575
const Operation op_max(MPI_MAX)
Operation wrapper for MPI_MAX.
Definition: dist.hpp:573
T_ min(T_ a, T_ b)
Returns the minimum of two values.
Definition: math.hpp:123
T_ max(T_ a, T_ b)
Returns the maximum of two values.
Definition: math.hpp:137
std::uint64_t Index
Index data type.
static std::pair< CoordVecType, CoordVecType > calculate_global_boundingbox(const Control::Domain::DeslaggedDomainControl< DomainLevel_ > &domain, const Index level=Index(0))
Helper function to calculate global boundingbox on current layer.
Helper class to calculate the global boundingbox of a domain.
static std::pair< CoordVecType, CoordVecType > calculate_global_boundingbox(const DomainControl_ &domain, const Index level=Index(0))
Helper function to calculate global boundingbox on current layer.