Skip to content

Commit

Permalink
still many errors to go...
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarruscag committed Apr 30, 2020
1 parent 6fb089e commit 9f4d95b
Show file tree
Hide file tree
Showing 58 changed files with 3,960 additions and 4,003 deletions.
2 changes: 1 addition & 1 deletion Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CGeometry {
CPrimalGrid** elem; /*!< \brief Element vector (primal grid information). */
CPrimalGrid** face; /*!< \brief Face vector (primal grid information). */
CPrimalGrid*** bound; /*!< \brief Boundary vector (primal grid information). */
CPoint** node; /*!< \brief Node vector (dual grid information). */
CPoint* nodes; /*!< \brief Node vector (dual grid information). */
CEdge* edges; /*!< \brief Edge vector (dual grid information). */
CVertex*** vertex; /*!< \brief Boundary Vertex vector (dual grid information). */
CTurboVertex**** turbovertex; /*!< \brief Boundary Vertex vector ordered for turbomachinery calculation(dual grid information). */
Expand Down
2 changes: 1 addition & 1 deletion Common/include/geometry/CPhysicalGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ class CPhysicalGeometry final : public CGeometry {
*/
void SetWallDistance(su2double val) override {
for (unsigned long iPoint = 0; iPoint < GetnPoint(); iPoint++){
node[iPoint]->SetWall_Distance(val);
nodes->SetWall_Distance(iPoint,val);
}
}

Expand Down
660 changes: 355 additions & 305 deletions Common/include/geometry/dual_grid/CPoint.hpp

Large diffs are not rendered by default.

51 changes: 39 additions & 12 deletions Common/include/toolboxes/C2DContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,45 @@ class C2DContainer :
}
};

/*!
* \brief Useful typedefs with default template parameters
*/
template<class T> using su2vector = C2DContainer<unsigned long, T, StorageType::ColumnMajor, 64, DynamicSize, 1>;
template<class T> using su2matrix = C2DContainer<unsigned long, T, StorageType::RowMajor, 64, DynamicSize, DynamicSize>;

using su2activevector = su2vector<su2double>;
using su2activematrix = su2matrix<su2double>;

using su2passivevector = su2vector<passivedouble>;
using su2passivematrix = su2matrix<passivedouble>;

/*!
* \class CVectorOfMatrix
* \brief This contrived container is used to store matrices in a contiguous manner
* but still present the "su2double**" interface to the outside world,
* it will be replaced by something more efficient (at some point...).
*/
struct CVectorOfMatrix {
su2activevector storage;
su2matrix<su2double*> interface;
unsigned long M, N;

void resize(unsigned long length, unsigned long rows, unsigned long cols, su2double value) {
M = rows;
N = cols;
storage.resize(length*rows*cols) = value;
interface.resize(length,rows);

for(unsigned long i=0; i<length; ++i)
for(unsigned long j=0; j<rows; ++j)
interface(i,j) = &(*this)(i,j,0);
}

su2double& operator() (unsigned long i, unsigned long j, unsigned long k) { return storage(i*M*N + j*N + k); }
const su2double& operator() (unsigned long i, unsigned long j, unsigned long k) const { return storage(i*M*N + j*N + k); }

su2double** operator[] (unsigned long i) { return interface[i]; }
};

/*!
* \class C2DDummyLastView
Expand Down Expand Up @@ -549,15 +588,3 @@ struct C3DDummyMiddleView
return data(i,k);
}
};

/*!
* \brief Useful typedefs with default template parameters
*/
template<class T> using su2vector = C2DContainer<unsigned long, T, StorageType::ColumnMajor, 64, DynamicSize, 1>;
template<class T> using su2matrix = C2DContainer<unsigned long, T, StorageType::RowMajor, 64, DynamicSize, DynamicSize>;

using su2activevector = su2vector<su2double>;
using su2activematrix = su2matrix<su2double>;

using su2passivevector = su2vector<passivedouble>;
using su2passivematrix = su2matrix<passivedouble>;
10 changes: 4 additions & 6 deletions Common/include/toolboxes/graph_toolbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,12 @@ CCompressedSparsePattern<Index_t> buildCSRPattern(Geometry_t& geometry,
* neighbors, not duplicating any existing neighbor. ---*/
for(auto jPoint : addedNeighbors)
{
auto point = geometry.node[jPoint];

if(type == ConnectivityType::FiniteVolume)
{
/*--- For FVM we know the neighbors of point j directly. ---*/
for(unsigned short iNeigh = 0; iNeigh < point->GetnPoint(); ++iNeigh)
for(unsigned short iNeigh = 0; iNeigh < geometry.nodes->GetnPoint(jPoint); ++iNeigh)
{
Index_t kPoint = point->GetPoint(iNeigh);
Index_t kPoint = geometry.nodes->GetPoint(jPoint,iNeigh);

if(neighbors.count(kPoint) == 0) // no duplication
newNeighbors.insert(kPoint);
Expand All @@ -351,9 +349,9 @@ CCompressedSparsePattern<Index_t> buildCSRPattern(Geometry_t& geometry,
else // FiniteElement
{
/*--- For FEM we need the nodes of all elements that contain point j. ---*/
for(unsigned short iNeigh = 0; iNeigh < point->GetnElem(); ++iNeigh)
for(unsigned short iNeigh = 0; iNeigh < geometry.nodes->GetnElem(jPoint); ++iNeigh)
{
auto elem = geometry.elem[point->GetElem(iNeigh)];
auto elem = geometry.elem[geometry.nodes->GetElem(jPoint,iNeigh)];

for(unsigned short iNode = 0; iNode < elem->GetnNodes(); ++iNode)
{
Expand Down
98 changes: 49 additions & 49 deletions Common/src/CMultiGridQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2020, SU2 Contributors (cf. AUTHORS.md)
Expand All @@ -29,154 +29,154 @@

CMultiGridQueue::CMultiGridQueue(unsigned long val_npoint) {
unsigned long iPoint;

nPoint = val_npoint;
Priority = new short[nPoint];
RightCV = new bool[nPoint];

QueueCV.resize(1);

/*--- Queue initialization with all the points in the finer grid ---*/
for (iPoint = 0; iPoint < nPoint; iPoint ++) {
QueueCV[0].push_back(iPoint);
Priority[iPoint] = 0;
RightCV[iPoint] = true;
}

}

CMultiGridQueue::~CMultiGridQueue(void) {

delete[] Priority;
delete[] RightCV;

}

void CMultiGridQueue::AddCV(unsigned long val_new_point, unsigned short val_number_neighbors) {

unsigned short Max_Neighbors = QueueCV.size()-1;

/*--- Basic check ---*/
if (val_new_point > nPoint) {
SU2_MPI::Error("The index of the CV is greater than the size of the priority list.", CURRENT_FUNCTION);
}

/*--- Resize the list ---*/
if (val_number_neighbors > Max_Neighbors)
QueueCV.resize(val_number_neighbors+1);

/*--- Find the point in the queue ---*/
bool InQueue = false;
if (Priority[val_new_point] == val_number_neighbors) InQueue = true;

if (!InQueue) {
/*--- Add the control volume, and update the priority list ---*/
QueueCV[val_number_neighbors].push_back(val_new_point);
Priority[val_new_point] = val_number_neighbors;
}

}

void CMultiGridQueue::RemoveCV(unsigned long val_remove_point) {
unsigned short iPoint;
bool check;

/*--- Basic check ---*/
if (val_remove_point > nPoint) {
SU2_MPI::Error("The index of the CV is greater than the size of the priority list." , CURRENT_FUNCTION);
}

/*--- Find priority of the Control Volume ---*/
short Number_Neighbors = Priority[val_remove_point];
if (Number_Neighbors == -1) {
char buf[200];
SPRINTF(buf, "The CV %lu is not in the priority list.", val_remove_point);
SU2_MPI::Error(string(buf), CURRENT_FUNCTION);
}

/*--- Find the point in the queue ---*/
vector<unsigned long>::iterator ItQueue = find(QueueCV[Number_Neighbors].begin(),
QueueCV[Number_Neighbors].end(),
val_remove_point);
if ( ItQueue != QueueCV[Number_Neighbors].end() ) QueueCV[Number_Neighbors].erase(ItQueue);

Priority[val_remove_point] = -1;

/*--- Check that the size of the queue is the right one ---*/
unsigned short Size_QueueCV = 0;
check = false;
for (iPoint = 0; iPoint < QueueCV.size(); iPoint ++)
if (QueueCV[iPoint].size() != 0) { Size_QueueCV = iPoint; check = true;}

/*--- Resize the queue, if check = false, the queue is empty, at least
we need one element in the queue ---*/
if (check) QueueCV.resize(Size_QueueCV+1);
else QueueCV.resize(1);

}

void CMultiGridQueue::MoveCV(unsigned long val_move_point, short val_number_neighbors) {

if (val_number_neighbors < 0) {
val_number_neighbors = 0;
RightCV[val_move_point] = false;
}
else {
RightCV[val_move_point] = true;
}

/*--- Remove the control volume ---*/
RemoveCV(val_move_point);

/*--- Add a new control volume ---*/
AddCV(val_move_point, val_number_neighbors);

}

void CMultiGridQueue::IncrPriorityCV(unsigned long val_incr_point) {

/*--- Find the priority list ---*/
short Number_Neighbors = Priority[val_incr_point];
if (Number_Neighbors == -1) {
char buf[200];
SPRINTF(buf, "The CV %lu is not in the priority list.", val_incr_point);
SU2_MPI::Error(string(buf), CURRENT_FUNCTION);
}

/*--- Remove the control volume ---*/
RemoveCV(val_incr_point);

/*--- Increase the priority ---*/
AddCV(val_incr_point, Number_Neighbors+1);

}

void CMultiGridQueue::RedPriorityCV(unsigned long val_red_point) {

/*--- Find the priority list ---*/
short Number_Neighbors = Priority[val_red_point];
if (Number_Neighbors == -1) {
char buf[200];
SPRINTF(buf, "The CV %lu is not in the priority list.", val_red_point);
SU2_MPI::Error(string(buf), CURRENT_FUNCTION);
}

if (Number_Neighbors != 0) {

/*--- Remove the control volume ---*/
RemoveCV(val_red_point);

/*--- Increase the priority ---*/
AddCV(val_red_point, Number_Neighbors-1);

}

}

void CMultiGridQueue::VisualizeQueue(void) {
unsigned short iPoint;
unsigned long jPoint;

cout << endl;
for (iPoint = 0; iPoint < QueueCV.size(); iPoint ++) {
cout << "Number of neighbors " << iPoint <<": ";
Expand All @@ -185,15 +185,15 @@ void CMultiGridQueue::VisualizeQueue(void) {
}
cout << endl;
}

}

void CMultiGridQueue::VisualizePriority(void) {
unsigned long iPoint;

for (iPoint = 0; iPoint < nPoint; iPoint ++)
cout << "Control Volume: " << iPoint <<" Priority: " << Priority[iPoint] << endl;

}

long CMultiGridQueue::NextCV(void) {
Expand All @@ -203,11 +203,11 @@ long CMultiGridQueue::NextCV(void) {

bool CMultiGridQueue::EmptyQueue(void) {
unsigned short iPoint;

/*--- In case there is only the no agglomerated elements,
check if they can be agglomerated or we have already finished ---*/
bool check = true;

if ( QueueCV.size() == 1 ) {
for (iPoint = 0; iPoint < QueueCV[0].size(); iPoint ++) {
if (RightCV[QueueCV[0][iPoint]]) { check = false; break; }
Expand All @@ -217,30 +217,30 @@ bool CMultiGridQueue::EmptyQueue(void) {
for (iPoint = 1; iPoint < QueueCV.size(); iPoint ++)
if (QueueCV[iPoint].size() != 0) { check = false; break;}
}

return check;
}

unsigned long CMultiGridQueue::TotalCV(void) {
unsigned short iPoint;
unsigned long TotalCV;

TotalCV = 0;
for (iPoint = 0; iPoint < QueueCV.size(); iPoint ++)
if (QueueCV[iPoint].size() != 0) { TotalCV += QueueCV[iPoint].size(); }

return TotalCV;
}

void CMultiGridQueue::Update(unsigned long iPoint, CGeometry *fine_grid) {
unsigned short iNode;
unsigned long jPoint;

RemoveCV(iPoint);
for (iNode = 0; iNode < fine_grid->node[iPoint]->GetnPoint(); iNode ++) {
jPoint = fine_grid->node[iPoint]->GetPoint(iNode);
if (fine_grid->node[jPoint]->GetAgglomerate() == false)
IncrPriorityCV(jPoint);
for (iNode = 0; iNode < fine_grid->nodes->GetnPoint(iPoint); iNode ++) {
jPoint = fine_grid->nodes->GetPoint(iPoint,iNode);
if (!fine_grid->nodes->GetAgglomerate(jPoint))
IncrPriorityCV(jPoint);
}

}
Loading

0 comments on commit 9f4d95b

Please sign in to comment.