Skip to content

Commit

Permalink
add port hashmap to dofmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
halbux committed May 30, 2021
1 parent 7c1fdc7 commit fcf8203
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/formulation/dofmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ void dofmanager::synchronize(void)
int selectedfieldnumberbkp = selectedfieldnumber;
selectedfieldnumber = -1;
myfieldorders = {};
myrawportmap.clear();
rangebegin = {};
rangeend = {};

// Rebuild the structure:
for (int i = 0; i < myportstructuretracker.size(); i++)
addtostructure(myportstructuretracker[i]);
for (int i = 0; i < mystructuretracker.size(); i++)
addtostructure(mystructuretracker[i].first, mystructuretracker[i].second);

Expand Down Expand Up @@ -121,6 +124,10 @@ void dofmanager::addtostructure(std::shared_ptr<rawport> porttoadd)
{
synchronize();

// Keep track of the calls to 'addtostructure':
if (issynchronizing == false)
myportstructuretracker.push_back(porttoadd);

// NOT COMPLETE YET
}

Expand Down Expand Up @@ -202,7 +209,17 @@ int dofmanager::getaddress(std::shared_ptr<rawport> prt)
{
synchronize();

// NOT COMPLETE YET
bool isnotthere = (myrawportmap.find(prt.get()) == myrawportmap.end());
if (isnotthere == false)
return myrawportmap[prt.get()];
else
{
std::string pn = prt->getname();
if (pn.size() > 0)
pn = "'"+pn+"' ";
std::cout << "Error in 'dofmanager' object: requested port " << pn << "could not be found in the dof structure" << std::endl;
abort();
}
}

bool dofmanager::isdefined(int disjreg, int formfunc)
Expand Down Expand Up @@ -526,6 +543,13 @@ std::vector<int> dofmanager::getselectedfieldorders(void)
return myfieldorders[selectedfieldnumber];
}

int dofmanager::countports(void)
{
synchronize();

return myrawportmap.size();
}

int dofmanager::countdofs(void)
{
synchronize();
Expand Down
8 changes: 8 additions & 0 deletions src/formulation/dofmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "disjointregions.h"
#include "intdensematrix.h"
#include <memory>
#include <unordered_map>
#include "selector.h"
#include "rawport.h"

Expand All @@ -38,6 +39,9 @@ class dofmanager
// Order of each field on each disjoint region:
std::vector<std::vector<int>> myfieldorders = {};

// Map every added port to its dof index:
std::unordered_map<rawport*, int> myrawportmap;

// 'rangebegin[selectedfieldnumber][12][2]' gives the index of
// the first row/column in the matrix at which the data for
//
Expand All @@ -58,6 +62,7 @@ class dofmanager
int mymeshnumber = 0;

// Track the calls to 'addtostructure'.
std::vector<std::shared_ptr<rawport>> myportstructuretracker = {};
std::vector<std::pair<std::shared_ptr<rawfield>, int>> mystructuretracker = {};

// Synchronize with the hp-adapted mesh:
Expand Down Expand Up @@ -120,6 +125,9 @@ class dofmanager

std::vector<int> getselectedfieldorders(void);

// Count the total number of ports (primal, dual and not-associated):
int countports(void);

int countdofs(void);
long long int allcountdofs(void);
int countformfunctions(int disjointregion);
Expand Down

0 comments on commit fcf8203

Please sign in to comment.