29#ifndef CUBOID_GEOMETRY_3D_H
30#define CUBOID_GEOMETRY_3D_H
49template<
typename T>
class Cuboid3D;
50template <
typename T>
class IndicatorF3D;
51template <
typename T>
class LoadBalancer;
76 std::vector<Cuboid3D<T> > _cuboids;
88 CuboidGeometry3D(T originX, T originY, T originZ, T deltaR,
int nX,
int nY,
int nZ,
int nC=1);
90 CuboidGeometry3D(std::vector<T> origin, T deltaR, std::vector<int> extent,
int nC=1);
112 void setPeriodicity(
bool periodicityX,
bool periodicityY,
bool periodicityZ);
120 int get_iC(T globX, T globY, T globZ,
int offset = 0)
const;
129 int get_iC(T globX, T globY, T globZ,
int orientationX,
int orientationY,
int orientationZ)
const;
131 bool getC(T physR[3],
int& iC)
const;
133 bool getC(std::vector<T> physR,
int& iC)
const;
137 bool getLatticeR(
int latticeR[4],
const T physR[3])
const;
139 bool getFloorLatticeR(
const std::vector<T>& physR, std::vector<int>& latticeR)
const;
143 void getPhysR(T physR[3],
const int& iCglob,
const int& iX,
const int& iY,
const int& iZ)
const;
145 void getPhysR(T physR[3],
const int latticeR[4])
const;
150 void getNeighbourhood(
int cuboid, std::vector<int>& neighbours,
int overlap = 0);
201 void split(
int iC,
int p);
229 bool*
getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool loadingMode)
override;
243 std::string _cuboidParameters(
Cuboid3D<T> const& cub);
255 std::vector<S> values(nData, S());
256 std::stringstream extstr(reader.
getAttribute(attrName));
257 for (
auto& valueI: values) {
271 std::vector<T> origin = getDataFromTag<T>(reader[
"CuboidGeometry"],
"origin", 3);
272 std::vector<int> extent = getDataFromTag<int>(reader[
"CuboidGeometry"],
"extent", 3);
273 T deltaR = getDataFromTag<T>(reader[
"CuboidGeometry"],
"deltaR", 1)[0];
274 size_t weight = getDataFromTag<size_t>(reader[
"CuboidGeometry"],
"weight", 1)[0];
280 for (
XMLreader* cub: reader[
"CuboidGeometry"] ) {
281 origin = getDataFromTag<T>(*cub,
"origin", 3);
282 extent = getDataFromTag<int>(*cub,
"extent", 3);
283 deltaR = getDataFromTag<T>(*cub,
"deltaR", 1)[0];
284 weight = getDataFromTag<int>(*cub,
"weight", 1)[0];
287 cGeo->
get(cGeo->
getNc() - 1).setWeight(weight);
297 std::map<
int,std::vector<int>>& neighbourhood,
300 for (
int iC=0; iC<cuboidGeometry.
getNc(); ++iC){
302 std::vector<int> neighbours;
304 neighbourhood[iC]=neighbours;
313 std::map<
int,std::vector<int>>& neighbourhood,
314 bool correct =
false,
315 bool verbose =
false)
317 bool consistent =
true;
318 for (
auto cuboidNeighbourPair : neighbourhood){
320 int iC = cuboidNeighbourPair.first;
321 std::vector<int>& neighbours = cuboidNeighbourPair.second;
323 for (
int iCN : neighbours){
325 std::vector<int>& neighboursNeighbours = neighbourhood[iCN];
326 bool iCfound =
false;
328 for (
int iCNN : neighboursNeighbours ){
339 std::cout <<
"iC " << iC <<
" not found in list of neighbour iC "
344 neighbourhood[iCN].push_back(iC);
Base class for serializable objects of dynamic size
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
A cuboid geometry represents a voxel mesh.
void splitByWeight(int iC, int p, IndicatorF3D< T > &indicatorF)
Splits cuboid iC, removes it and adds p cuboids of same weight.
std::size_t replaceContainedBy(Cuboid3D< T > mother)
T getMinRatio() const
Returns the minimum of the ratio nX/NY in the structure.
Cuboid3D< T > & get(int iC)
Read and write access to a single cuboid.
void swap(CuboidGeometry3D< T > &rhs)
Swaps data from input into object.
size_t getSerializableSize() const override
Binary size for the serializer interface.
bool operator==(CuboidGeometry3D< T > &rhs)
Compares two CuboidGeometries.
T getMaxRatio() const
Returns the maximum of the ratio nX/NY in the structure.
void refine(int factor)
Refines mesh by splitting each cell into factor^3 cells.
bool getFloorLatticeR(const std::vector< T > &physR, std::vector< int > &latticeR) const
Returns true and the util::floor lattice position to the given physical position if the physical posi...
void writeToFile(std::string fileName, LoadBalancer< T > &loadBalancer)
Save CuboidGeometry into XML File.
void shrink(int iC, IndicatorF3D< T > &indicatorF)
Shrink cuboid iC so that no empty planes are left.
size_t getNblock() const override
Number of data blocks for the serializer interface.
std::vector< Cuboid3D< T > > & cuboids()
void swapCuboids(std::vector< Cuboid3D< T > > &cuboids)
Swaps the vector of cuboids.
void replaceCuboids(std::vector< Cuboid3D< T > > &cuboids)
Replace the vector of cuboids.
int get_iC(T globX, T globY, T globZ, int offset=0) const
Gives for a given point (globX/globY/globZ) the related cuboidID and _p if the point is not in any of...
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Return a pointer to the memory of the current block and its size for the serializable interface.
T getMaxDeltaR() const
Returns the maximum delta in the structure.
void print() const
Prints cuboid geometry details.
bool getC(T physR[3], int &iC) const
Returns true and the cuboid number of the nearest lattice position to the given physical position if ...
void split(int iC, int p)
Splits cuboid iC, removes it and adds p cuboids of same volume.
bool tryRefineTo(T deltaR)
Tries to refine mesh to given deltaR.
Vector< T, 3 > getMinPhysR() const
Returns the minimum coordinate in the structure.
virtual ~CuboidGeometry3D()
Destructs CuboidGeometry.
size_t getMaxLatticeVolume() const
Returns the maximum number of nodes in the structure.
bool getLatticeR(int latticeR[4], const T physR[3]) const
Returns true and the nearest lattice position to the given physical position if the physical position...
void remove(int iC)
Removes the cuboid iC.
void writeToExistingFile(std::string completeFileName, LoadBalancer< T > &loadBalancer)
Save CuboidGeometry into an existing XML File.
T getMinPhysVolume() const
Returns the minimum volume in the structure.
int getNc() const
Returns the number of cuboids in the structure.
std::size_t hypotheticalReplaceContainedBy(Cuboid3D< T > mother)
void setWeights(IndicatorF3D< T > &indicatorF)
Sets the number of full cells of each cuboid.
Vector< T, 3 > getMaxPhysR() const
Returns the maximum coordinate in the structure.
void splitRegular(int iC, int width)
Splits cuboid iC, removes it, adds approx. width^3 sized new cuboids.
Cuboid3D< T > getMotherCuboid()
Returns the smallest cuboid that includes all cuboids of the structure.
CuboidGeometry3D()
Constructs empty Geometry.
void add(Cuboid3D< T > cuboid)
Adds a cuboid.
size_t getMinLatticeVolume() const
Returns the minimum number of nodes in the structure.
void clearCuboids()
Resets the cuboid array.
void removeByWeight()
Removes all cuboids where weight = 0.
void printExtended()
Prints cuboid geometry details plus details of all cuboids.
size_t getMaxLatticeWeight() const
Returns the maximum number of nodes in the structure inside the indicator.
T getMinDeltaR() const
Returns the minimum delta in the structure.
size_t getMinLatticeWeight() const
Returns the minimum number of nodes in the structure inside the indicator.
void getPhysR(T physR[3], const int &iCglob, const int &iX, const int &iY, const int &iZ) const
Returns the physical position to the given lattice position respecting periodicity for the overlap no...
void splitFractional(int iC, int iD, std::vector< T > fractions)
Splits cuboid iC along dimension iD into cuboids of fractions.
T getMaxPhysVolume() const
Returns the maximum volume in the structure.
void getNeighbourhood(int cuboid, std::vector< int > &neighbours, int overlap=0)
Stores the iC of the neighbouring cuboids in a vector;.
void setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ)
Set flag to enable/disable periodicity depending of direction. Be aware that not all directions are t...
IndicatorF3D is an application from .
Base class for all LoadBalancer.
class for marking output with some text
std::string getAttribute(const std::string &aName) const
The description of a single 3D cuboid – header file.
Top level namespace for all of OpenLB.
std::vector< S > getDataFromTag(XMLreader const &reader, std::string attrName, int nData)
Helper Function to retrieve nData-dimensional std::vector of type S from space separated tag.
void evaluateCuboidGeometryNeighbourhood(CuboidGeometry2D< T > &cuboidGeometry, std::map< int, std::vector< int > > &neighbourhood, int offset=0)
Evaluate complete neighbourhood and store in std::map.
CuboidGeometry3D< T > * createCuboidGeometry(std::string fileName)
Load CuboidGeometry from XML File.
bool checkCuboidNeighbourhoodConsistency(std::map< int, std::vector< int > > &neighbourhood, bool correct=false, bool verbose=false)
Consistency check for neighbour retrieval.
Definition of singletons: global, publicly available information.
efficient implementation of a vector class
Input/Output in XML format – header file.