27#if BITPIT_ENABLE_MPI==1
31#include "bitpit_common.hpp"
33#include "volcartesian.hpp"
68#if BITPIT_ENABLE_MPI==1
69 :
VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
86 const std::array<double, 3> &origin,
87 const std::array<double, 3> &lengths,
88 const std::array<int, 3> &nCells)
103 const std::array<double, 3> &origin,
104 const std::array<double, 3> &lengths,
105 const std::array<int, 3> &nCells)
106#if BITPIT_ENABLE_MPI==1
107 :
VolumeKernel(
id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
117 setDiscretization(nCells);
129 const std::array<double, 3> &origin,
130 double length,
int nCells)
145 const std::array<double, 3> &origin,
146 double length,
int nCells)
147#if BITPIT_ENABLE_MPI==1
148 :
VolumeKernel(
id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
158 setDiscretization({{nCells, nCells, nCells}});
170 const std::array<double, 3> &origin,
171 double length,
double dh)
186 const std::array<double, 3> &origin,
187 double length,
double dh)
188#if BITPIT_ENABLE_MPI==1
189 :
VolumeKernel(
id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
199 int nCells = (int) std::ceil(length / dh);
200 setDiscretization({{nCells, nCells, nCells}});
209#if BITPIT_ENABLE_MPI==1
210 :
VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
226 return std::unique_ptr<VolCartesian>(
new VolCartesian(*
this));
238 m_minCoords = {{0., 0., 0.}};
239 m_maxCoords = {{1., 1., 1.}};
241 m_nCells1D = {{0, 0, 0}};
242 m_nVertices1D = {{0, 0, 0}};
243 m_cellSpacings = {{0., 0., 0.}};
245 for (
int n = 0; n < 3; ++n) {
246 std::vector<double>().swap(m_vertexCoords[n]);
247 std::vector<double>().swap(m_cellCenters[n]);
266 bool partialUpdate =
false;
267 for (CellConstIterator cellIterator = beginItr; cellIterator != endItr; ++cellIterator) {
268 long cellId = cellIterator.getId();
270 partialUpdate =
true;
276 log::cout() <<
" It is not possible to partially update the adjacencies.";
277 log::cout() <<
" All adjacencies will be updated.";
284 if (cell.getAdjacencyCount() != 0) {
285 cell.resetAdjacencies();
289 long cellId = cell.getId();
290 for (
int face = 0; face < nCellFaces; ++face) {
298 cell.pushAdjacency(face, neighId);
315 bool partialUpdate =
false;
316 for (CellConstIterator cellIterator = beginItr; cellIterator != endItr; ++cellIterator) {
317 long cellId = cellIterator.getId();
319 partialUpdate =
true;
325 log::cout() <<
" It is not possible to partially update the interfaces.";
326 log::cout() <<
" All interfaces will be updated.";
337 const int nInterfaceVertices = interfaceTypeInfo.nVertices;
350 long cellId = cell.getId();
351 for (
int face = 0; face < nCellFaces; ++face) {
359 if (cell.getAdjacencyCount(face) > 0) {
360 neighId = cell.getAdjacencies(face)[0];
361 if (neighId < cellId) {
365 neighId = Cell::NULL_ID;
370 Interface &
interface = *interfaceIterator;
371 long interfaceId = interface.
getId();
374 ConstProxyVector<long> faceConnect = cell.getFaceConnect(face);
375 int connectSize = faceConnect.
size();
377 std::unique_ptr<long[]> connect = std::unique_ptr<long[]>(
new long[nInterfaceVertices]);
378 for (
int k = 0; k < connectSize; ++k) {
379 connect[k] = faceConnect[k];
381 interface.setConnect(std::move(connect));
384 interface.setOwner(cellId, face);
385 cell.setInterface(face, 0, interfaceId);
390 int neighFace = 2 *
static_cast<int>(std::floor(face / 2.)) + (1 - face % 2);
392 interface.setNeigh(neighId, neighFace);
395 interface.unsetNeigh();
408void VolCartesian::initialize()
412 for (
int n = 0; n < 3; n++) {
413 for (
int k = -1; k <= 1; k += 2) {
414 std::array<double, 3> normal = {{0.0, 0.0, 0.0}};
417 m_normals[i++] = normal;
422 m_vertexNeighDeltas = std::vector<std::array<int, 3>>(8);
423 m_vertexNeighDeltas[0] = {{ 0, 0, 0}};
424 m_vertexNeighDeltas[1] = {{-1, 0, 0}};
425 m_vertexNeighDeltas[2] = {{ 0, -1, 0}};
426 m_vertexNeighDeltas[3] = {{-1, -1, 0}};
427 m_vertexNeighDeltas[4] = {{ 0, 0, -1}};
428 m_vertexNeighDeltas[5] = {{-1, 0, -1}};
429 m_vertexNeighDeltas[6] = {{ 0, -1, -1}};
430 m_vertexNeighDeltas[7] = {{-1, -1, -1}};
433 m_edgeNeighDeltas = std::vector<std::array<int, 3>>(12);
434 m_edgeNeighDeltas[ 0] = {{-1, 0, -1}};
435 m_edgeNeighDeltas[ 1] = {{ 1, 0, -1}};
436 m_edgeNeighDeltas[ 2] = {{ 0, -1, -1}};
437 m_edgeNeighDeltas[ 3] = {{ 0, 1, -1}};
438 m_edgeNeighDeltas[ 4] = {{-1, -1, 0}};
439 m_edgeNeighDeltas[ 5] = {{ 1, -1, 0}};
440 m_edgeNeighDeltas[ 6] = {{-1, 1, 0}};
441 m_edgeNeighDeltas[ 7] = {{ 1, 1, 0}};
442 m_edgeNeighDeltas[ 8] = {{-1, 0, 1}};
443 m_edgeNeighDeltas[ 9] = {{ 1, 0, 1}};
444 m_edgeNeighDeltas[10] = {{ 0, -1, 1}};
445 m_edgeNeighDeltas[11] = {{ 0, 1, 1}};
448 m_edgeFaces = std::vector<std::array<int, 2>>(12);
449 m_edgeFaces[ 0] = {{ 0, 4}};
450 m_edgeFaces[ 1] = {{ 1, 4}};
451 m_edgeFaces[ 2] = {{ 2, 4}};
452 m_edgeFaces[ 3] = {{ 3, 4}};
453 m_edgeFaces[ 4] = {{ 0, 2}};
454 m_edgeFaces[ 5] = {{ 1, 2}};
455 m_edgeFaces[ 6] = {{ 0, 3}};
456 m_edgeFaces[ 7] = {{ 1, 3}};
457 m_edgeFaces[ 8] = {{ 0, 5}};
458 m_edgeFaces[ 9] = {{ 1, 5}};
459 m_edgeFaces[10] = {{ 2, 5}};
460 m_edgeFaces[11] = {{ 3, 5}};
466 setMemoryMode(MemoryMode::MEMORY_LIGHT);
475void VolCartesian::initializeCellVolume()
479 if (m_directionOrdering[d] >= 0) {
480 m_cellVolume *= m_cellSpacings[d];
488void VolCartesian::initializeCellSize()
490 m_cellSize = std::pow(m_cellVolume, 1. /
getDimension());
496void VolCartesian::initializeInterfaceArea()
499 if (m_directionOrdering[d] >= 0) {
500 m_interfaceArea[d] = m_cellVolume / m_cellSpacings[d];
502 m_interfaceArea[d] = 0.;
512void VolCartesian::setDiscretization(
const std::array<int, 3> &nCells)
518 m_nCells1D[d] = nCells[d];
519 m_cellSpacings[d] = (m_maxCoords[d] - m_minCoords[d]) / m_nCells1D[d];
521 m_cellCenters[d].resize(m_nCells1D[d]);
522 for (
int i = 0; i < m_nCells1D[d]; i++) {
523 m_cellCenters[d][i] = m_minCoords[d] + (0.5 + i) * m_cellSpacings[d];
527 m_cellSpacings[d] = 0.;
530 log::cout() <<
" - Cell count along direction " << d <<
" : " << m_nCells1D[d] <<
"\n";
533 m_nVertices1D[d] = m_nCells1D[d] + 1;
535 m_vertexCoords[d].resize(m_nVertices1D[d]);
536 for (
int i = 0; i < m_nVertices1D[d]; i++) {
537 m_vertexCoords[d][i] = m_minCoords[d] + i * m_cellSpacings[d];
543 m_cellSpacings[d] = 0.;
545 m_nVertices1D[d] = 1;
556 for (
int d = 0; d < 3; ++d) {
558 m_directionOrdering[d] = 0;
560 int previousDirection = m_directionOrdering[d - 1];
561 if (previousDirection < 0 || previousDirection >= 2) {
562 m_directionOrdering[d] = -1;
566 m_directionOrdering[d] = previousDirection + 1;
569 while (m_nCells1D[m_directionOrdering[d]] == 0) {
570 if (m_directionOrdering[d] == 2) {
571 m_directionOrdering[d] = -1;
575 ++m_directionOrdering[d];
582 m_nVertices *= m_nVertices1D[n];
584 log::cout() <<
" - Total vertex count: " << m_nVertices <<
"\n";
589 if (m_directionOrdering[d] >= 0) {
590 m_nCells *= m_nCells1D[d];
594 log::cout() <<
" - Total cell count: " << m_nCells <<
"\n";
599 int nDirectionInterfaces = 1;
601 int nDirectionInterfaces1D = m_nCells1D[n];
603 ++nDirectionInterfaces1D;
606 nDirectionInterfaces *= nDirectionInterfaces1D;
608 m_nInterfaces += nDirectionInterfaces;
611 log::cout() <<
" - Total interface count: " << m_nInterfaces <<
"\n";
614 initializeCellVolume();
617 initializeCellSize();
620 initializeInterfaceArea();
650 return m_nVertices1D[direction];
671 return m_nCells1D[direction];
695 return ElementType::VOXEL;
697 return ElementType::PIXEL;
708 return m_nInterfaces;
732 return ElementType::PIXEL;
734 return ElementType::LINE;
759 std::array<double, 3> coords;
760 for (
int d = 0; d < 3; ++d) {
762 coords[d] = m_vertexCoords[d][ijk[d]];
764 coords[d] = m_minCoords[d];
781 return m_vertexCoords[direction];
870 for (
int d = 0; d < 3; ++d) {
871 (*minPoint)[d] = cellCentroid[d] - 0.5 * m_cellSpacings[d];
872 (*maxPoint)[d] = cellCentroid[d] + 0.5 * m_cellSpacings[d];
884 const Interface &
interface = getInterface(id);
886 int direction =
static_cast<int>(std::floor(ownerFace / 2.));
888 return m_interfaceArea[direction];
899 const Interface &
interface = getInterface(id);
902 return m_normals[ownerFace];
912 return m_cellSpacings;
930 case MemoryMode::MEMORY_NORMAL:
946 case MemoryMode::MEMORY_LIGHT:
964 if (mode == MemoryMode::MEMORY_NORMAL) {
976void VolCartesian::setMemoryMode(MemoryMode mode)
1000 return m_cellSpacings[direction];
1006void VolCartesian::addVertices()
1008 log::cout() <<
" >> Creating vertices\n";
1010 log::cout() <<
" - Vertex count: " << m_nVertices <<
"\n";
1012 m_vertices.reserve(m_nVertices);
1013 for (
int k = 0; (
isThreeDimensional()) ? (k < m_nVertices1D[Vertex::COORD_Z]) : (k <= 0); k++) {
1014 for (
int j = 0; j < m_nVertices1D[Vertex::COORD_Y]; j++) {
1015 for (
int i = 0; i < m_nVertices1D[Vertex::COORD_X]; i++) {
1032void VolCartesian::addCells()
1040 log::cout() <<
" - Cell count: " << m_nCells <<
"\n";
1042 m_cells.reserve(m_nCells);
1043 for (
int k = 0; (
isThreeDimensional()) ? (k < m_nCells1D[Vertex::COORD_Z]) : (k <= 0); k++) {
1044 for (
int j = 0; j < m_nCells1D[Vertex::COORD_Y]; j++) {
1045 for (
int i = 0; i < m_nCells1D[Vertex::COORD_X]; i++) {
1048 Cell &cell = *cellIterator;
1051 long *cellConnect = cell.getConnect();
1057 if (cellType == ElementType::VOXEL) {
1075 const int DUMP_VERSION = 2;
1077 return DUMP_VERSION;
1101 if (m_memoryMode == MEMORY_NORMAL) {
1107 if (m_memoryMode == MEMORY_NORMAL) {
1122 std::array<double, 3> origin;
1130 std::array<double, 3> lengths;
1138 std::array<int, 3> nCells;
1143 setDiscretization(nCells);
1146 MemoryMode memoryMode;
1151 if (m_memoryMode == MEMORY_NORMAL) {
1160 if (m_memoryMode == MEMORY_NORMAL) {
1164 interface.setPID(PID);
1180 const double EPS =
getTol();
1181 for (
int d = 0; d < 3; ++d){
1182 long index = cellIjk[d];
1184 double spacing = m_cellSpacings[d];
1185 double cellMin = m_cellCenters[d][index] - 0.5 * spacing;
1186 double cellMax = m_cellCenters[d][index] + 0.5 * spacing;
1188 if (point[d]< cellMin - EPS || point[d] > cellMax + EPS) {
1204 const double EPS =
getTol();
1207 if (point[n] < m_minCoords[n] - EPS || point[n] > m_maxCoords[n] + EPS) {
1232 return Element::NULL_ID;
1248 std::array<int, 3> ijk;
1257 ijk[0] =
static_cast<int>(std::floor((point[Vertex::COORD_X] - m_minCoords[Vertex::COORD_X]) / m_cellSpacings[Vertex::COORD_X]));
1258 ijk[1] =
static_cast<int>(std::floor((point[Vertex::COORD_Y] - m_minCoords[Vertex::COORD_Y]) / m_cellSpacings[Vertex::COORD_Y]));
1260 ijk[2] =
static_cast<int>(std::floor((point[Vertex::COORD_Z] - m_minCoords[Vertex::COORD_Z]) / m_cellSpacings[Vertex::COORD_Z]));
1288 std::array<int, 3> ijk;
1290 ijk[n] = std::min(m_nVertices1D[n] - 1, std::max(0, (
int) round((point[n] - m_minCoords[n]) / m_cellSpacings[n])));
1294 ijk[Vertex::COORD_Z] = -1;
1326 std::array<int,3> ijk({{0,0,0}});
1329 ijk[i] =
static_cast<int>(std::floor((point[i] - m_minCoords[i]) / m_cellSpacings[i]));
1330 ijk[i] = std::max( ijk[i], 0 );
1331 ijk[i] = std::min( ijk[i], m_nCells1D[i]-1 );
1370 int l = m_directionOrdering[0];
1371 int m = m_directionOrdering[1];
1372 int n = m_directionOrdering[2];
1375 return Cell::NULL_ID;
1380 id += m_nCells1D[l] * ijk[m];
1382 id += m_nCells1D[l] * m_nCells1D[m] * ijk[n];
1404 int l = m_directionOrdering[0];
1405 int m = m_directionOrdering[1];
1406 int n = m_directionOrdering[2];
1408 std::array<int, 3> ijk = {{-1, -1, -1}};
1411 }
else if (l >= 0) {
1412 int offset_lm = m_nCells1D[l] * m_nCells1D[m];
1413 int index_n =
id / offset_lm;
1415 ijk[m] = (
id - index_n * offset_lm) / m_nCells1D[l];
1416 ijk[l] =
id - (
id / m_nCells1D[l]) * m_nCells1D[l];
1434 if (ijk[k] < 0 || ijk[k] >= m_nCells1D[k]) {
1475 int l = m_directionOrdering[0];
1476 int m = m_directionOrdering[1];
1477 int n = m_directionOrdering[2];
1480 return Vertex::NULL_ID;
1485 id += m_nVertices1D[l] * ijk[m];
1487 id += m_nVertices1D[l] * m_nVertices1D[m] * ijk[n];
1509 int l = m_directionOrdering[0];
1510 int m = m_directionOrdering[1];
1511 int n = m_directionOrdering[2];
1513 std::array<int, 3> ijk = {{-1, -1, -1}};
1516 }
else if (l >= 0) {
1517 int offset_lm = m_nVertices1D[l] * m_nVertices1D[m];
1518 int index_n =
id / offset_lm;
1520 ijk[m] = (
id - index_n * offset_lm) / m_nVertices1D[l];
1521 ijk[l] =
id - (
id / m_nVertices1D[l]) * m_nVertices1D[l];
1565 std::bitset<3> vertexBitset(vertex);
1566 std::array<int, 3> vertexIjk(cellIjk);
1567 for (
int k = 0; k < 3; ++k) {
1568 vertexIjk[k] += vertexBitset[k];
1583 if (ijk[k] < 0 || ijk[k] >= m_nVertices1D[k]) {
1608 }
else if (blackList && utils::findInOrderedVector<long>(neighId, *blackList) != blackList->end()) {
1612 neighs->push_back(neighId);
1641 if (!blackList || utils::findInOrderedVector<long>(diagNeighId, *blackList) == blackList->end()) {
1642 utils::addToOrderedVector<long>(diagNeighId, *neighs);
1647 for (
int face : m_edgeFaces[edge]) {
1670 for (
const auto &delta : m_vertexNeighDeltas) {
1672 std::array<int, 3> neighIjk(vertexIjk + delta);
1673 if (neighIjk == cellIjk) {
1682 if (!blackList || utils::findInOrderedVector<long>(neighId, *blackList) == blackList->end()) {
1683 utils::addToOrderedVector<long>(neighId, *neighs);
1697 int nSubsetCells_x = ijkMax[0] - ijkMin[0] + 1;
1698 int nSubsetCells_y = ijkMax[1] - ijkMin[1] + 1;
1699 int nSubsetCells_z = ijkMax[2] - ijkMin[2] + 1;
1701 std::vector<long> ids;
1702 ids.resize(nSubsetCells_x * nSubsetCells_y * nSubsetCells_z);
1704 std::vector<long>::iterator it = ids.begin();
1705 for (
int k = ijkMin[2]; k <= ijkMax[2]; ++k) {
1706 for (
int j = ijkMin[1]; j <= ijkMax[1]; ++j) {
1707 for (
int i = ijkMin[0]; i <= ijkMax[0]; ++i) {
1750 int nSubsetVertices_x = ijkMax[0] - ijkMin[0] + 1;
1751 int nSubsetVertices_y = ijkMax[1] - ijkMin[1] + 1;
1752 int nSubsetVertices_z = ijkMax[2] - ijkMin[2] + 1;
1754 std::vector<long> ids;
1755 ids.resize(nSubsetVertices_x * nSubsetVertices_y * nSubsetVertices_z);
1757 std::vector<long>::iterator it = ids.begin();
1758 for (
int k = ijkMin[2]; k <= ijkMax[2]; ++k) {
1759 for (
int j = ijkMin[1]; j <= ijkMax[1]; ++j) {
1760 for (
int i = ijkMin[0]; i <= ijkMax[0]; ++i) {
1816 std::array<double, 3> translation = origin -
getOrigin();
1827 for (
int n = 0; n < 3; ++n) {
1828 m_minCoords[n] += translation[n];
1829 m_maxCoords[n] += translation[n];
1831 for (
int i = 1; i < m_nVertices1D[n]; ++i) {
1832 m_vertexCoords[n][i] += translation[n];
1835 for (
int i = 1; i < m_nCells1D[n]; ++i) {
1836 m_cellCenters[n][i] += translation[n];
1859 throw std::runtime_error(
"It is not possible to rotate a Cartesian patch.");
1869 return (m_maxCoords - m_minCoords);
1881 m_maxCoords = m_minCoords + lengths;
1887 if (m_nVertices > 0) {
1889 setDiscretization(m_nCells1D);
1892 for (
Vertex vertex : m_vertices) {
1893 long id = vertex.getId();
1907 for (
int n = 0; n < 3; ++n) {
1908 m_minCoords[n] = center[n] + scaling[n] * (m_minCoords[n] - center[n]);
1909 m_maxCoords[n] = center[n] + scaling[n] * (m_maxCoords[n] - center[n]);
1911 for (
int i = 1; i < m_nVertices1D[n]; ++i) {
1912 m_vertexCoords[n][i] = center[n] + scaling[n] * (m_vertexCoords[n][i] - center[n]);
1915 for (
int i = 1; i < m_nCells1D[n]; ++i) {
1916 m_cellCenters[n][i] = center[n] + scaling[n] * (m_cellCenters[n][i] - center[n]);
1919 m_cellSpacings[n] *= scaling[n];
1922 initializeCellVolume();
1924 initializeCellSize();
1926 initializeInterfaceArea();
1944 int nContribs_x = 2;
1945 int nContribs_y = 2;
1946 int nContribs_z = dimension - 1;
1950 std::fill (vertexData.begin(), vertexData.end(), 0.);
1952 for (
int k = 0; (
isThreeDimensional()) ? (k < m_nCells1D[Vertex::COORD_Z]) : (k < 1); k++) {
1953 for (
int j = 0; j < m_nCells1D[Vertex::COORD_Y]; ++j) {
1954 for (
int i = 0; i < m_nCells1D[Vertex::COORD_X]; ++i) {
1957 double cellContrib = cellData[cellId];
1960 for (
int n = 0; n < nContribs_z; n++) {
1962 for (
int m = 0; m < nContribs_y; ++m) {
1964 for (
int l = 0; l < nContribs_x; ++l) {
1971 vertexData[vertexId] += cellContrib;
1972 nodeCounter[vertexId]++;
1982 vertexData[i] /= nodeCounter[i];
1999 int nContribs_x = 2;
2000 int nContribs_y = 2;
2001 int nContribs_z = dimension - 1;
2004 std::fill (cellData.begin(), cellData.end(), 0.);
2006 for (
int k = 0; (
isThreeDimensional()) ? (k < m_nCells1D[Vertex::COORD_Z]) : (k < 1); k++) {
2007 for (
int j = 0; j < m_nCells1D[Vertex::COORD_Y]; ++j) {
2008 for (
int i = 0; i < m_nCells1D[Vertex::COORD_X]; ++i) {
2011 for (
int n = 0; n < nContribs_z; ++n) {
2013 for (
int m = 0; m < nContribs_y; ++m) {
2015 for (
int l = 0; l < nContribs_x; ++l) {
2020 double vertexContrib = vertexData[vertexId];
2023 cellData[cellId] += vertexContrib;
2031 double weight =
pow(0.5, dimension);
2033 cellData[i] *= weight;
2054 std::vector<int> *stencil, std::vector<double> *weights)
const
2057 if (ijk_point[0] < 0) {
2065 int nContribs_x = 1;
2066 int nContribs_y = 1;
2067 int nContribs_z = 1;
2069 std::array< std::array<int,2>, 3> cStencil;
2070 std::array< std::array<double,2>, 3> cWeights;
2071 for (
int d = 0; d < dimension; ++d) {
2073 int index_point = ijk_point[d];
2074 if (point[d] < m_cellCenters[d][index_point]) {
2075 index_point = index_point - 1;
2078 int index_next = index_point + 1;
2080 if (index_point < 0) {
2082 cWeights[d][0] = 1.;
2083 }
else if (index_next > m_nCells1D[d] - 1) {
2084 cStencil[d][0] = m_nCells1D[d] - 1;
2085 cWeights[d][0] = 1.;
2089 }
else if (d == 1) {
2095 cStencil[d][0] = index_point;
2096 cStencil[d][1] = index_next;
2098 cWeights[d][1] = (point[d] - m_cellCenters[d][index_point]) / m_cellSpacings[d] ;
2099 cWeights[d][0] = 1.0 - cWeights[d][1];
2103 for (
int d = dimension; d < 3; ++d) {
2105 cWeights[d][0] = 1.;
2108 int stencilSize = nContribs_x * nContribs_y * nContribs_z;
2109 stencil->resize(stencilSize);
2110 weights->resize(stencilSize);
2112 std::vector<int>::iterator itrStencil = stencil->begin();
2113 std::vector<double>::iterator itrWeights = weights->begin();
2114 for (
int k = 0; k < nContribs_z; ++k) {
2115 for (
int j = 0; j < nContribs_y; ++j) {
2116 for (
int i = 0; i < nContribs_x; ++i) {
2117 int &is = cStencil[0][i];
2118 int &js = cStencil[1][j];
2119 int &ks = cStencil[2][k];
2121 double &iw = cWeights[0][i];
2122 double &jw = cWeights[1][j];
2123 double &kw = cWeights[2][k];
2126 *itrWeights = iw *jw * kw;
2151 std::vector<int> *stencil, std::vector<double> *weights)
const
2154 if (ijk_point[0] < 0) {
2162 int nContribs_x = 2;
2163 int nContribs_y = 2;
2164 int nContribs_z = dimension - 1;
2166 std::array< std::array<int,2>, 3> cStencil;
2167 std::array< std::array<double,2>, 3> cWeights;
2168 for (
int d = 0; d < dimension; ++d) {
2169 int index_point = ijk_point[d];
2170 int index_next = index_point +1;
2172 cStencil[d][0] = index_point;
2173 cStencil[d][1] = index_next;
2175 cWeights[d][1] = (point[d] - m_vertexCoords[d][index_point]) / m_cellSpacings[d];
2176 cWeights[d][0] = 1.0 - cWeights[d][1];
2179 for (
int d = dimension; d < 3; ++d) {
2181 cWeights[d][0] = 1.;
2184 int stencilSize =
uipow(2, dimension);
2185 stencil->resize(stencilSize);
2186 weights->resize(stencilSize);
2188 std::vector<int>::iterator itrStencil = stencil->begin();
2189 std::vector<double>::iterator itrWeights = weights->begin();
2190 for (
int k = 0; k < nContribs_z; ++k) {
2191 for (
int j = 0; j < nContribs_y; ++j) {
2192 for (
int i = 0; i < nContribs_x; ++i) {
2193 int &is = cStencil[0][i];
2194 int &js = cStencil[1][j];
2195 int &ks = cStencil[2][k];
2197 double &iw = cWeights[0][i];
2198 double &jw = cWeights[1][j];
2199 double &kw = cWeights[2][k];
2202 *itrWeights = iw * jw * kw;
2234 std::array<double, 3> centroid;
2235 for (
int d = 0; d < 3; ++d) {
2237 centroid[d] = m_cellCenters[d][ijk[d]];
2239 centroid[d] = m_minCoords[d];
2254 return m_cellCenters[direction];
2266 int neighSide = face % 2;
2267 int neighDirection =
static_cast<int>(std::floor(face / 2));
2270 if (neighSide == 0) {
2271 neighIjk[neighDirection]--;
2273 neighIjk[neighDirection]++;
2294 neighId = Cell::NULL_ID;
The Cell class defines the cells.
void setInterface(int face, int index, long interface)
Metafunction for generation of a flattened vector of vectors.
The Interface class defines the interfaces among cells.
CellConstIterator cellConstBegin() const
std::vector< adaption::Info > update(bool trackAdaption=true, bool squeezeStorage=false)
PiercedVector< Cell > & getCells()
AdaptionMode getAdaptionMode() const
InterfaceIterator addInterface(const Interface &source, long id=Element::NULL_ID)
VertexIterator addVertex(const Vertex &source, long id=Vertex::NULL_ID)
void setBoundingBoxFrozen(bool frozen)
CellIterator addCell(const Cell &source, long id=Element::NULL_ID)
CellConstIterator cellConstEnd() const
void scale(const std::array< double, 3 > &scaling)
virtual void translate(const std::array< double, 3 > &translation)
void restore(std::istream &stream, bool reregister=false)
void setAdaptionMode(AdaptionMode mode)
PiercedVector< Interface > & getInterfaces()
bool testCellAlterationFlags(long id, AlterationFlags flags) const
void setBoundingBox(const std::array< double, 3 > &minPoint, const std::array< double, 3 > &maxPoint)
bool isThreeDimensional() const
The PatchManager oversee the handling of the patches.
id_t getId(const id_t &fallback=-1) const noexcept
The ReferenceElementInfo class allows to define information about reference elements.
static BITPIT_PUBLIC_API const ReferenceElementInfo & getInfo(ElementType type)
The Vertex class defines the vertexs.
void _findCellVertexNeighs(long id, int vertex, const std::vector< long > *blackList, std::vector< long > *neighs) const override
std::array< double, 3 > getLengths() const
std::array< int, 3 > getCellFaceNeighsCartesianId(long id, int face) const
long getCellLinearId(int i, int j, int k) const
double evalCellSize(long id) const override
std::array< double, 3 > evalInterfaceNormal(long id) const override
long getCellFaceNeighsLinearId(long id, int face) const
long getInterfaceCount() const override
void setLengths(const std::array< double, 3 > &lengths)
void setOrigin(const std::array< double, 3 > &origin)
bool isPointInside(const std::array< double, 3 > &point) const override
void evalCellBoundingBox(long id, std::array< double, 3 > *minPoint, std::array< double, 3 > *maxPoint) const override
std::vector< long > extractVertexSubSet(std::array< int, 3 > const &ijkMin, std::array< int, 3 > const &ijkMax) const
long locateClosestCell(std::array< double, 3 > const &point) const
std::vector< long > extractCellSubSet(std::array< int, 3 > const &ijkMin, std::array< int, 3 > const &ijkMax) const
std::array< int, 3 > locatePointCartesian(const std::array< double, 3 > &point) const
std::array< int, 3 > locateClosestVertexCartesian(std::array< double, 3 > const &point) const
long locateClosestVertex(std::array< double, 3 > const &point) const
long getCellCount() const override
std::unique_ptr< PatchKernel > clone() const override
std::array< double, 3 > getOrigin() const
void rotate(const std::array< double, 3 > &n0, const std::array< double, 3 > &n1, double angle) override
double evalCellVolume(long id) const override
void _updateAdjacencies() override
std::array< int, 3 > locateClosestCellCartesian(std::array< double, 3 > const &point) const
ElementType getCellType() const
std::array< double, 3 > evalCellCentroid(long id) const override
int _getDumpVersion() const override
bool isVertexCartesianIdValid(const std::array< int, 3 > &ijk) const
std::array< int, 3 > getVertexCartesianId(long id) const
ElementType getInterfaceType() const
long locatePoint(const std::array< double, 3 > &point) const override
const std::vector< double > & getVertexCoords(int direction) const
long getVertexCount() const override
std::vector< double > convertToCellData(const std::vector< double > &vertexData) const
double evalInterfaceArea(long id) const override
void _findCellFaceNeighs(long id, int face, const std::vector< long > *blackList, std::vector< long > *neighs) const override
std::array< int, 3 > getCellCartesianId(long id) const
std::vector< double > convertToVertexData(const std::vector< double > &cellData) const
bool isCellCartesianIdValid(const std::array< int, 3 > &ijk) const
void switchMemoryMode(MemoryMode mode)
int linearCellInterpolation(const std::array< double, 3 > &point, std::vector< int > *stencil, std::vector< double > *weights) const
void _updateInterfaces() override
void _findCellEdgeNeighs(long id, int edge, const std::vector< long > *blackList, std::vector< long > *neighs) const override
int linearVertexInterpolation(const std::array< double, 3 > &point, std::vector< int > *stencil, std::vector< double > *weights) const
long getVertexLinearId(int i, int j, int k) const
void translate(const std::array< double, 3 > &translation) override
const std::vector< double > & getCellCentroids(int direction) const
std::array< double, 3 > evalVertexCoords(long id) const
std::array< double, 3 > getSpacing() const
void _dump(std::ostream &stream) const override
void _restore(std::istream &stream) override
void scale(const std::array< double, 3 > &scaling, const std::array< double, 3 > ¢er) override
MemoryMode getMemoryMode() const
VolumeKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode)
std::array< T, d > pow(std::array< T, d > &x, double p)
T uipow(const T &, unsigned int)
void write(std::ostream &stream, const std::vector< bool > &container)
void read(std::istream &stream, std::vector< bool > &container)
#define BITPIT_UNUSED(variable)
Logger & cout(log::Level defaultSeverity, log::Visibility defaultVisibility)