27#if BITPIT_ENABLE_MPI==1
31#include "bitpit_common.hpp"
33#include "volcartesian.hpp"
67#if BITPIT_ENABLE_MPI==1
68 :
VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
85 const std::array<double, 3> &origin,
86 const std::array<double, 3> &lengths,
87 const std::array<int, 3> &nCells)
102 const std::array<double, 3> &origin,
103 const std::array<double, 3> &lengths,
104 const std::array<int, 3> &nCells)
105#if BITPIT_ENABLE_MPI==1
106 :
VolumeKernel(
id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
116 setDiscretization(nCells);
128 const std::array<double, 3> &origin,
129 double length,
int nCells)
144 const std::array<double, 3> &origin,
145 double length,
int nCells)
146#if BITPIT_ENABLE_MPI==1
147 :
VolumeKernel(
id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
155 setLengths({{length, length, length}});
157 setDiscretization({{nCells, nCells, nCells}});
169 const std::array<double, 3> &origin,
170 double length,
double dh)
185 const std::array<double, 3> &origin,
186 double length,
double dh)
187#if BITPIT_ENABLE_MPI==1
188 :
VolumeKernel(
id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
196 setLengths({{length, length, length}});
198 int nCells = (int) std::ceil(length / dh);
199 setDiscretization({{nCells, nCells, nCells}});
208#if BITPIT_ENABLE_MPI==1
209 :
VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED)
225 return std::unique_ptr<VolCartesian>(
new VolCartesian(*
this));
237 m_minCoords = {{0., 0., 0.}};
238 m_maxCoords = {{1., 1., 1.}};
240 m_nCells1D = {{0, 0, 0}};
241 m_nVertices1D = {{0, 0, 0}};
242 m_cellSpacings = {{0., 0., 0.}};
244 for (
int n = 0; n < 3; ++n) {
245 std::vector<double>().swap(m_vertexCoords[n]);
246 std::vector<double>().swap(m_cellCenters[n]);
274 bool partialUpdate =
false;
275 for (
CellConstIterator cellIterator = beginItr; cellIterator != endItr; ++cellIterator) {
276 long cellId = cellIterator.getId();
278 partialUpdate =
true;
284 log::cout() <<
" It is not possible to partially update the adjacencies.";
285 log::cout() <<
" All adjacencies will be updated.";
292 if (cell.getAdjacencyCount() != 0) {
293 cell.resetAdjacencies();
297 long cellId = cell.getId();
298 for (
int face = 0; face < nCellFaces; ++face) {
306 cell.pushAdjacency(face, neighId);
323 bool partialUpdate =
false;
324 for (
CellConstIterator cellIterator = beginItr; cellIterator != endItr; ++cellIterator) {
325 long cellId = cellIterator.getId();
327 partialUpdate =
true;
333 log::cout() <<
" It is not possible to partially update the interfaces.";
334 log::cout() <<
" All interfaces will be updated.";
345 const int nInterfaceVertices = interfaceTypeInfo.nVertices;
358 long cellId = cell.getId();
359 for (
int face = 0; face < nCellFaces; ++face) {
367 if (cell.getAdjacencyCount(face) > 0) {
368 neighId = cell.getAdjacencies(face)[0];
369 if (neighId < cellId) {
373 neighId = Cell::NULL_ID;
378 Interface &
interface = *interfaceIterator;
379 long interfaceId = interface.
getId();
383 int connectSize = faceConnect.
size();
385 std::unique_ptr<long[]> connect = std::unique_ptr<long[]>(
new long[nInterfaceVertices]);
386 for (
int k = 0; k < connectSize; ++k) {
387 connect[k] = faceConnect[k];
389 interface.setConnect(std::move(connect));
392 interface.setOwner(cellId, face);
393 cell.setInterface(face, 0, interfaceId);
398 int neighFace = 2 *
static_cast<int>(std::floor(face / 2.)) + (1 - face % 2);
400 interface.setNeigh(neighId, neighFace);
403 interface.unsetNeigh();
416void VolCartesian::initialize()
420 for (
int n = 0; n < 3; n++) {
421 for (
int k = -1; k <= 1; k += 2) {
422 std::array<double, 3> normal = {{0.0, 0.0, 0.0}};
425 m_normals[i++] = normal;
430 m_vertexNeighDeltas = std::vector<std::array<int, 3>>(8);
431 m_vertexNeighDeltas[0] = {{ 0, 0, 0}};
432 m_vertexNeighDeltas[1] = {{-1, 0, 0}};
433 m_vertexNeighDeltas[2] = {{ 0, -1, 0}};
434 m_vertexNeighDeltas[3] = {{-1, -1, 0}};
435 m_vertexNeighDeltas[4] = {{ 0, 0, -1}};
436 m_vertexNeighDeltas[5] = {{-1, 0, -1}};
437 m_vertexNeighDeltas[6] = {{ 0, -1, -1}};
438 m_vertexNeighDeltas[7] = {{-1, -1, -1}};
441 m_edgeNeighDeltas = std::vector<std::array<int, 3>>(12);
442 m_edgeNeighDeltas[ 0] = {{-1, 0, -1}};
443 m_edgeNeighDeltas[ 1] = {{ 1, 0, -1}};
444 m_edgeNeighDeltas[ 2] = {{ 0, -1, -1}};
445 m_edgeNeighDeltas[ 3] = {{ 0, 1, -1}};
446 m_edgeNeighDeltas[ 4] = {{-1, -1, 0}};
447 m_edgeNeighDeltas[ 5] = {{ 1, -1, 0}};
448 m_edgeNeighDeltas[ 6] = {{-1, 1, 0}};
449 m_edgeNeighDeltas[ 7] = {{ 1, 1, 0}};
450 m_edgeNeighDeltas[ 8] = {{-1, 0, 1}};
451 m_edgeNeighDeltas[ 9] = {{ 1, 0, 1}};
452 m_edgeNeighDeltas[10] = {{ 0, -1, 1}};
453 m_edgeNeighDeltas[11] = {{ 0, 1, 1}};
456 m_edgeFaces = std::vector<std::array<int, 2>>(12);
457 m_edgeFaces[ 0] = {{ 0, 4}};
458 m_edgeFaces[ 1] = {{ 1, 4}};
459 m_edgeFaces[ 2] = {{ 2, 4}};
460 m_edgeFaces[ 3] = {{ 3, 4}};
461 m_edgeFaces[ 4] = {{ 0, 2}};
462 m_edgeFaces[ 5] = {{ 1, 2}};
463 m_edgeFaces[ 6] = {{ 0, 3}};
464 m_edgeFaces[ 7] = {{ 1, 3}};
465 m_edgeFaces[ 8] = {{ 0, 5}};
466 m_edgeFaces[ 9] = {{ 1, 5}};
467 m_edgeFaces[10] = {{ 2, 5}};
468 m_edgeFaces[11] = {{ 3, 5}};
474 setMemoryMode(MemoryMode::MEMORY_LIGHT);
483void VolCartesian::initializeCellVolume()
487 if (m_directionOrdering[d] >= 0) {
488 m_cellVolume *= m_cellSpacings[d];
496void VolCartesian::initializeCellSize()
498 m_cellSize = std::pow(m_cellVolume, 1. /
getDimension());
504void VolCartesian::initializeInterfaceArea()
507 if (m_directionOrdering[d] >= 0) {
508 m_interfaceArea[d] = m_cellVolume / m_cellSpacings[d];
510 m_interfaceArea[d] = 0.;
520void VolCartesian::setDiscretization(
const std::array<int, 3> &nCells)
526 m_nCells1D[d] = nCells[d];
527 m_cellSpacings[d] = (m_maxCoords[d] - m_minCoords[d]) / m_nCells1D[d];
529 m_cellCenters[d].resize(m_nCells1D[d]);
530 for (
int i = 0; i < m_nCells1D[d]; i++) {
531 m_cellCenters[d][i] = m_minCoords[d] + (0.5 + i) * m_cellSpacings[d];
535 m_cellSpacings[d] = 0.;
538 log::cout() <<
" - Cell count along direction " << d <<
" : " << m_nCells1D[d] <<
"\n";
541 m_nVertices1D[d] = m_nCells1D[d] + 1;
543 m_vertexCoords[d].resize(m_nVertices1D[d]);
544 for (
int i = 0; i < m_nVertices1D[d]; i++) {
545 m_vertexCoords[d][i] = m_minCoords[d] + i * m_cellSpacings[d];
551 m_cellSpacings[d] = 0.;
553 m_nVertices1D[d] = 1;
564 for (
int d = 0; d < 3; ++d) {
566 m_directionOrdering[d] = 0;
568 int previousDirection = m_directionOrdering[d - 1];
569 if (previousDirection < 0 || previousDirection >= 2) {
570 m_directionOrdering[d] = -1;
574 m_directionOrdering[d] = previousDirection + 1;
577 while (m_nCells1D[m_directionOrdering[d]] == 0) {
578 if (m_directionOrdering[d] == 2) {
579 m_directionOrdering[d] = -1;
583 ++m_directionOrdering[d];
590 m_nVertices *= m_nVertices1D[n];
592 log::cout() <<
" - Total vertex count: " << m_nVertices <<
"\n";
597 if (m_directionOrdering[d] >= 0) {
598 m_nCells *= m_nCells1D[d];
602 log::cout() <<
" - Total cell count: " << m_nCells <<
"\n";
607 int nDirectionInterfaces = 1;
609 int nDirectionInterfaces1D = m_nCells1D[n];
611 ++nDirectionInterfaces1D;
614 nDirectionInterfaces *= nDirectionInterfaces1D;
616 m_nInterfaces += nDirectionInterfaces;
619 log::cout() <<
" - Total interface count: " << m_nInterfaces <<
"\n";
622 initializeCellVolume();
625 initializeCellSize();
628 initializeInterfaceArea();
658 return m_nVertices1D[direction];
679 return m_nCells1D[direction];
703 return ElementType::VOXEL;
705 return ElementType::PIXEL;
716 return m_nInterfaces;
740 return ElementType::PIXEL;
742 return ElementType::LINE;
767 std::array<double, 3> coords;
768 for (
int d = 0; d < 3; ++d) {
770 coords[d] = m_vertexCoords[d][ijk[d]];
772 coords[d] = m_minCoords[d];
789 return m_vertexCoords[direction];
798double VolCartesian::evalCellVolume(
long id)
const
811double VolCartesian::evalCellVolume(
const std::array<int, 3> &ijk)
const
825double VolCartesian::evalCellVolume()
const
836double VolCartesian::evalCellSize(
long id)
const
849double VolCartesian::evalCellSize(
const std::array<int, 3> &ijk)
const
863double VolCartesian::evalCellSize()
const
878 for (
int d = 0; d < 3; ++d) {
879 (*minPoint)[d] = cellCentroid[d] - 0.5 * m_cellSpacings[d];
880 (*maxPoint)[d] = cellCentroid[d] + 0.5 * m_cellSpacings[d];
892 const Interface &
interface = getInterface(id);
894 int direction =
static_cast<int>(std::floor(ownerFace / 2.));
896 return m_interfaceArea[direction];
907 const Interface &
interface = getInterface(id);
910 return m_normals[ownerFace];
920 return m_cellSpacings;
938 case MemoryMode::MEMORY_NORMAL:
954 case MemoryMode::MEMORY_LIGHT:
977void VolCartesian::setMemoryMode(MemoryMode mode)
1001 return m_cellSpacings[direction];
1007void VolCartesian::addVertices()
1009 log::cout() <<
" >> Creating vertices\n";
1011 log::cout() <<
" - Vertex count: " << m_nVertices <<
"\n";
1013 m_vertices.reserve(m_nVertices);
1014 for (
int k = 0; (
isThreeDimensional()) ? (k < m_nVertices1D[Vertex::COORD_Z]) : (k <= 0); k++) {
1015 for (
int j = 0; j < m_nVertices1D[Vertex::COORD_Y]; j++) {
1016 for (
int i = 0; i < m_nVertices1D[Vertex::COORD_X]; i++) {
1033void VolCartesian::addCells()
1041 log::cout() <<
" - Cell count: " << m_nCells <<
"\n";
1043 m_cells.reserve(m_nCells);
1044 for (
int k = 0; (
isThreeDimensional()) ? (k < m_nCells1D[Vertex::COORD_Z]) : (k <= 0); k++) {
1045 for (
int j = 0; j < m_nCells1D[Vertex::COORD_Y]; j++) {
1046 for (
int i = 0; i < m_nCells1D[Vertex::COORD_X]; i++) {
1049 Cell &cell = *cellIterator;
1052 long *cellConnect = cell.getConnect();
1058 if (cellType == ElementType::VOXEL) {
1076 const int DUMP_VERSION = 2;
1078 return DUMP_VERSION;
1102 if (m_memoryMode == MEMORY_NORMAL) {
1108 if (m_memoryMode == MEMORY_NORMAL) {
1123 std::array<double, 3> origin;
1131 std::array<double, 3> lengths;
1139 std::array<int, 3> nCells;
1144 setDiscretization(nCells);
1147 MemoryMode memoryMode;
1152 if (m_memoryMode == MEMORY_NORMAL) {
1161 if (m_memoryMode == MEMORY_NORMAL) {
1165 interface.setPID(PID);
1181 const double EPS =
getTol();
1182 for (
int d = 0; d < 3; ++d){
1183 long index = cellIjk[d];
1185 double spacing = m_cellSpacings[d];
1186 double cellMin = m_cellCenters[d][index] - 0.5 * spacing;
1187 double cellMax = m_cellCenters[d][index] + 0.5 * spacing;
1189 if (point[d]< cellMin - EPS || point[d] > cellMax + EPS) {
1205 const double EPS =
getTol();
1208 if (point[n] < m_minCoords[n] - EPS || point[n] > m_maxCoords[n] + EPS) {
1233 return Element::NULL_ID;
1249 std::array<int, 3> ijk;
1258 ijk[0] =
static_cast<int>(std::floor((point[Vertex::COORD_X] - m_minCoords[Vertex::COORD_X]) / m_cellSpacings[Vertex::COORD_X]));
1259 ijk[1] =
static_cast<int>(std::floor((point[Vertex::COORD_Y] - m_minCoords[Vertex::COORD_Y]) / m_cellSpacings[Vertex::COORD_Y]));
1261 ijk[2] =
static_cast<int>(std::floor((point[Vertex::COORD_Z] - m_minCoords[Vertex::COORD_Z]) / m_cellSpacings[Vertex::COORD_Z]));
1289 std::array<int, 3> ijk;
1291 ijk[n] = std::min(m_nVertices1D[n] - 1, std::max(0, (
int) round((point[n] - m_minCoords[n]) / m_cellSpacings[n])));
1295 ijk[Vertex::COORD_Z] = -1;
1327 std::array<int,3> ijk({{0,0,0}});
1330 ijk[i] =
static_cast<int>(std::floor((point[i] - m_minCoords[i]) / m_cellSpacings[i]));
1331 ijk[i] = std::max( ijk[i], 0 );
1332 ijk[i] = std::min( ijk[i], m_nCells1D[i]-1 );
1371 int l = m_directionOrdering[0];
1372 int m = m_directionOrdering[1];
1373 int n = m_directionOrdering[2];
1376 return Cell::NULL_ID;
1381 id += m_nCells1D[l] * ijk[m];
1383 id += m_nCells1D[l] * m_nCells1D[m] * ijk[n];
1405 int l = m_directionOrdering[0];
1406 int m = m_directionOrdering[1];
1407 int n = m_directionOrdering[2];
1409 std::array<int, 3> ijk = {{-1, -1, -1}};
1412 }
else if (l >= 0) {
1413 int offset_lm = m_nCells1D[l] * m_nCells1D[m];
1414 int index_n =
id / offset_lm;
1416 ijk[m] = (
id - index_n * offset_lm) / m_nCells1D[l];
1417 ijk[l] =
id - (
id / m_nCells1D[l]) * m_nCells1D[l];
1435 if (ijk[k] < 0 || ijk[k] >= m_nCells1D[k]) {
1476 int l = m_directionOrdering[0];
1477 int m = m_directionOrdering[1];
1478 int n = m_directionOrdering[2];
1481 return Vertex::NULL_ID;
1486 id += m_nVertices1D[l] * ijk[m];
1488 id += m_nVertices1D[l] * m_nVertices1D[m] * ijk[n];
1510 int l = m_directionOrdering[0];
1511 int m = m_directionOrdering[1];
1512 int n = m_directionOrdering[2];
1514 std::array<int, 3> ijk = {{-1, -1, -1}};
1517 }
else if (l >= 0) {
1518 int offset_lm = m_nVertices1D[l] * m_nVertices1D[m];
1519 int index_n =
id / offset_lm;
1521 ijk[m] = (
id - index_n * offset_lm) / m_nVertices1D[l];
1522 ijk[l] =
id - (
id / m_nVertices1D[l]) * m_nVertices1D[l];
1566 std::bitset<3> vertexBitset(vertex);
1567 std::array<int, 3> vertexIjk(cellIjk);
1568 for (
int k = 0; k < 3; ++k) {
1569 vertexIjk[k] += vertexBitset[k];
1584 if (ijk[k] < 0 || ijk[k] >= m_nVertices1D[k]) {
1609 }
else if (blackList && utils::findInOrderedVector<long>(neighId, *blackList) != blackList->end()) {
1613 neighs->push_back(neighId);
1642 if (!blackList || utils::findInOrderedVector<long>(diagNeighId, *blackList) == blackList->end()) {
1643 utils::addToOrderedVector<long>(diagNeighId, *neighs);
1648 for (
int face : m_edgeFaces[edge]) {
1671 for (
const auto &delta : m_vertexNeighDeltas) {
1673 std::array<int, 3> neighIjk(vertexIjk + delta);
1674 if (neighIjk == cellIjk) {
1683 if (!blackList || utils::findInOrderedVector<long>(neighId, *blackList) == blackList->end()) {
1684 utils::addToOrderedVector<long>(neighId, *neighs);
1698 int nSubsetCells_x = ijkMax[0] - ijkMin[0] + 1;
1699 int nSubsetCells_y = ijkMax[1] - ijkMin[1] + 1;
1700 int nSubsetCells_z = ijkMax[2] - ijkMin[2] + 1;
1702 std::vector<long> ids;
1703 ids.resize(nSubsetCells_x * nSubsetCells_y * nSubsetCells_z);
1705 std::vector<long>::iterator it = ids.begin();
1706 for (
int k = ijkMin[2]; k <= ijkMax[2]; ++k) {
1707 for (
int j = ijkMin[1]; j <= ijkMax[1]; ++j) {
1708 for (
int i = ijkMin[0]; i <= ijkMax[0]; ++i) {
1751 int nSubsetVertices_x = ijkMax[0] - ijkMin[0] + 1;
1752 int nSubsetVertices_y = ijkMax[1] - ijkMin[1] + 1;
1753 int nSubsetVertices_z = ijkMax[2] - ijkMin[2] + 1;
1755 std::vector<long> ids;
1756 ids.resize(nSubsetVertices_x * nSubsetVertices_y * nSubsetVertices_z);
1758 std::vector<long>::iterator it = ids.begin();
1759 for (
int k = ijkMin[2]; k <= ijkMax[2]; ++k) {
1760 for (
int j = ijkMin[1]; j <= ijkMax[1]; ++j) {
1761 for (
int i = ijkMin[0]; i <= ijkMax[0]; ++i) {
1817 std::array<double, 3> translation = origin -
getOrigin();
1828 for (
int n = 0; n < 3; ++n) {
1829 m_minCoords[n] += translation[n];
1830 m_maxCoords[n] += translation[n];
1832 for (
int i = 1; i < m_nVertices1D[n]; ++i) {
1833 m_vertexCoords[n][i] += translation[n];
1836 for (
int i = 1; i < m_nCells1D[n]; ++i) {
1837 m_cellCenters[n][i] += translation[n];
1860 throw std::runtime_error(
"It is not possible to rotate a Cartesian patch.");
1870 return (m_maxCoords - m_minCoords);
1882 m_maxCoords = m_minCoords + lengths;
1888 if (m_nVertices > 0) {
1890 setDiscretization(m_nCells1D);
1893 for (
Vertex vertex : m_vertices) {
1894 long id = vertex.getId();
1908 for (
int n = 0; n < 3; ++n) {
1909 m_minCoords[n] = center[n] + scaling[n] * (m_minCoords[n] - center[n]);
1910 m_maxCoords[n] = center[n] + scaling[n] * (m_maxCoords[n] - center[n]);
1912 for (
int i = 1; i < m_nVertices1D[n]; ++i) {
1913 m_vertexCoords[n][i] = center[n] + scaling[n] * (m_vertexCoords[n][i] - center[n]);
1916 for (
int i = 1; i < m_nCells1D[n]; ++i) {
1917 m_cellCenters[n][i] = center[n] + scaling[n] * (m_cellCenters[n][i] - center[n]);
1920 m_cellSpacings[n] *= scaling[n];
1923 initializeCellVolume();
1925 initializeCellSize();
1927 initializeInterfaceArea();
1945 int nContribs_x = 2;
1946 int nContribs_y = 2;
1947 int nContribs_z = dimension - 1;
1951 std::fill (vertexData.begin(), vertexData.end(), 0.);
1953 for (
int k = 0; (
isThreeDimensional()) ? (k < m_nCells1D[Vertex::COORD_Z]) : (k < 1); k++) {
1954 for (
int j = 0; j < m_nCells1D[Vertex::COORD_Y]; ++j) {
1955 for (
int i = 0; i < m_nCells1D[Vertex::COORD_X]; ++i) {
1958 double cellContrib = cellData[cellId];
1961 for (
int n = 0; n < nContribs_z; n++) {
1963 for (
int m = 0; m < nContribs_y; ++m) {
1965 for (
int l = 0; l < nContribs_x; ++l) {
1972 vertexData[vertexId] += cellContrib;
1973 nodeCounter[vertexId]++;
1983 vertexData[i] /= nodeCounter[i];
2000 int nContribs_x = 2;
2001 int nContribs_y = 2;
2002 int nContribs_z = dimension - 1;
2005 std::fill (cellData.begin(), cellData.end(), 0.);
2007 for (
int k = 0; (
isThreeDimensional()) ? (k < m_nCells1D[Vertex::COORD_Z]) : (k < 1); k++) {
2008 for (
int j = 0; j < m_nCells1D[Vertex::COORD_Y]; ++j) {
2009 for (
int i = 0; i < m_nCells1D[Vertex::COORD_X]; ++i) {
2012 for (
int n = 0; n < nContribs_z; ++n) {
2014 for (
int m = 0; m < nContribs_y; ++m) {
2016 for (
int l = 0; l < nContribs_x; ++l) {
2021 double vertexContrib = vertexData[vertexId];
2024 cellData[cellId] += vertexContrib;
2032 double weight =
pow(0.5, dimension);
2034 cellData[i] *= weight;
2055 std::vector<int> *stencil, std::vector<double> *weights)
const
2058 if (ijk_point[0] < 0) {
2066 int nContribs_x = 1;
2067 int nContribs_y = 1;
2068 int nContribs_z = 1;
2070 std::array< std::array<int,2>, 3> cStencil;
2071 std::array< std::array<double,2>, 3> cWeights;
2072 for (
int d = 0; d < dimension; ++d) {
2074 int index_point = ijk_point[d];
2075 if (point[d] < m_cellCenters[d][index_point]) {
2076 index_point = index_point - 1;
2079 int index_next = index_point + 1;
2081 if (index_point < 0) {
2083 cWeights[d][0] = 1.;
2084 }
else if (index_next > m_nCells1D[d] - 1) {
2085 cStencil[d][0] = m_nCells1D[d] - 1;
2086 cWeights[d][0] = 1.;
2090 }
else if (d == 1) {
2096 cStencil[d][0] = index_point;
2097 cStencil[d][1] = index_next;
2099 cWeights[d][1] = (point[d] - m_cellCenters[d][index_point]) / m_cellSpacings[d] ;
2100 cWeights[d][0] = 1.0 - cWeights[d][1];
2104 for (
int d = dimension; d < 3; ++d) {
2106 cWeights[d][0] = 1.;
2109 int stencilSize = nContribs_x * nContribs_y * nContribs_z;
2110 stencil->resize(stencilSize);
2111 weights->resize(stencilSize);
2113 std::vector<int>::iterator itrStencil = stencil->begin();
2114 std::vector<double>::iterator itrWeights = weights->begin();
2115 for (
int k = 0; k < nContribs_z; ++k) {
2116 for (
int j = 0; j < nContribs_y; ++j) {
2117 for (
int i = 0; i < nContribs_x; ++i) {
2118 int &is = cStencil[0][i];
2119 int &js = cStencil[1][j];
2120 int &ks = cStencil[2][k];
2122 double &iw = cWeights[0][i];
2123 double &jw = cWeights[1][j];
2124 double &kw = cWeights[2][k];
2127 *itrWeights = iw *jw * kw;
2152 std::vector<int> *stencil, std::vector<double> *weights)
const
2155 if (ijk_point[0] < 0) {
2163 int nContribs_x = 2;
2164 int nContribs_y = 2;
2165 int nContribs_z = dimension - 1;
2167 std::array< std::array<int,2>, 3> cStencil;
2168 std::array< std::array<double,2>, 3> cWeights;
2169 for (
int d = 0; d < dimension; ++d) {
2170 int index_point = ijk_point[d];
2171 int index_next = index_point +1;
2173 cStencil[d][0] = index_point;
2174 cStencil[d][1] = index_next;
2176 cWeights[d][1] = (point[d] - m_vertexCoords[d][index_point]) / m_cellSpacings[d];
2177 cWeights[d][0] = 1.0 - cWeights[d][1];
2180 for (
int d = dimension; d < 3; ++d) {
2182 cWeights[d][0] = 1.;
2185 int stencilSize =
uipow(2, dimension);
2186 stencil->resize(stencilSize);
2187 weights->resize(stencilSize);
2189 std::vector<int>::iterator itrStencil = stencil->begin();
2190 std::vector<double>::iterator itrWeights = weights->begin();
2191 for (
int k = 0; k < nContribs_z; ++k) {
2192 for (
int j = 0; j < nContribs_y; ++j) {
2193 for (
int i = 0; i < nContribs_x; ++i) {
2194 int &is = cStencil[0][i];
2195 int &js = cStencil[1][j];
2196 int &ks = cStencil[2][k];
2198 double &iw = cWeights[0][i];
2199 double &jw = cWeights[1][j];
2200 double &kw = cWeights[2][k];
2203 *itrWeights = iw * jw * kw;
2235 std::array<double, 3> centroid;
2236 for (
int d = 0; d < 3; ++d) {
2238 centroid[d] = m_cellCenters[d][ijk[d]];
2240 centroid[d] = m_minCoords[d];
2255 return m_cellCenters[direction];
2267 int neighSide = face % 2;
2268 int neighDirection =
static_cast<int>(std::floor(face / 2));
2271 if (neighSide == 0) {
2272 neighIjk[neighDirection]--;
2274 neighIjk[neighDirection]++;
2295 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
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)
virtual void resetInterfaces()
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
Iterator for the class PiercedStorage.
Metafunction for generating a list of elements that can be either stored in an external vectror or,...
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.
The VolCartesian defines a Cartesian patch.
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 resetInterfaces() override
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
The VolumeKernel class provides an interface for defining volume patches.
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)