Skip to content

Commit

Permalink
rawfield store rawportptr
Browse files Browse the repository at this point in the history
  • Loading branch information
halbux committed May 31, 2021
1 parent fcf8203 commit 3963ab5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
38 changes: 26 additions & 12 deletions src/field/rawfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void rawfield::synchronize(std::vector<int> physregsfororder, std::vector<int> d
mydisjregconstraints = std::vector<std::shared_ptr<integration>>( (universe::mymesh->getdisjointregions())->count(), NULL);
myconditionalconstraints = std::vector<std::vector<expression>>( (universe::mymesh->getdisjointregions())->count(), std::vector<expression>(0));
isitgauged = std::vector<bool>( (universe::mymesh->getdisjointregions())->count(), false);
isitported = std::vector<bool>( (universe::mymesh->getdisjointregions())->count(), false);
myassociatedports = std::vector<std::shared_ptr<rawport>>( (universe::mymesh->getdisjointregions())->count(), NULL);

// Rebuild the containers:
if (disjregsfororder.size() == 0)
Expand Down Expand Up @@ -91,12 +91,12 @@ void rawfield::updateshapefunctions(std::shared_ptr<rawfield> originalthis, bool
std::vector<std::shared_ptr<integration>> mydisjregconstraintsbkp = mydisjregconstraints;
std::vector<std::vector<expression>> myconditionalconstraintsbkp = myconditionalconstraints;
std::vector<bool> isitgaugedbkp = isitgauged;
std::vector<bool> isitportedbkp = isitported;
std::vector<std::shared_ptr<rawport>> myassociatedportsbkp = myassociatedports;

mydisjregconstraints = std::vector<std::shared_ptr<integration>>( (universe::mymesh->getdisjointregions())->count(), NULL);
myconditionalconstraints = std::vector<std::vector<expression>>( (universe::mymesh->getdisjointregions())->count(), std::vector<expression>(0));
isitgauged = std::vector<bool>( (universe::mymesh->getdisjointregions())->count(), false);
isitported = std::vector<bool>( (universe::mymesh->getdisjointregions())->count(), false);
myassociatedports = std::vector<std::shared_ptr<rawport>>( (universe::mymesh->getdisjointregions())->count(), NULL);


wallclock clkn;
Expand Down Expand Up @@ -124,7 +124,7 @@ void rawfield::updateshapefunctions(std::shared_ptr<rawfield> originalthis, bool
mydisjregconstraints = mydisjregconstraintsbkp;
myconditionalconstraints = myconditionalconstraintsbkp;
isitgauged = isitgaugedbkp;
isitported = isitportedbkp;
myassociatedports = myassociatedportsbkp;
}

void rawfield::updatenodalshapefunctions(std::shared_ptr<rawfield> originalthis)
Expand Down Expand Up @@ -401,7 +401,7 @@ rawfield::rawfield(std::string fieldtypename, const std::vector<int> harmonicnum

isitgauged = std::vector<bool>( (universe::mymesh->getdisjointregions())->count(), false);

isitported = std::vector<bool>( (universe::mymesh->getdisjointregions())->count(), false);
myassociatedports = std::vector<std::shared_ptr<rawport>>( (universe::mymesh->getdisjointregions())->count(), NULL);

mycoefmanager = std::shared_ptr<coefmanager>(new coefmanager(mytypename, universe::mymesh->getdisjointregions()));
}
Expand All @@ -426,7 +426,7 @@ rawfield::rawfield(dofmanager* dm, std::shared_ptr<rawmesh> rm, std::shared_ptr<
mydisjregconstraints = std::vector<std::shared_ptr<integration>>(numdrs, NULL);
myconditionalconstraints = std::vector<std::vector<expression>>(numdrs, std::vector<expression>(0));
isitgauged = std::vector<bool>(numdrs, false);
isitported = std::vector<bool>(numdrs, false);
myassociatedports = std::vector<std::shared_ptr<rawport>>(numdrs, NULL);

for (int i = 0; i < numdrs; i++)
mycoefmanager->fitinterpolationorder(i, interpolationorder[i]);
Expand Down Expand Up @@ -686,7 +686,7 @@ void rawfield::setorder(int physreg, int interpolorder, bool iscalledbyuser)

for (int i = 0; i < selecteddisjregs.size(); i++)
{
if (isitported[selecteddisjregs[i]] && interpolorder > lowestfieldorder)
if (myassociatedports[selecteddisjregs[i]] != NULL && interpolorder > lowestfieldorder)
{
std::cout << "Error in 'rawfield' object: lowest field order must be used on port regions" << std::endl;
abort();
Expand Down Expand Up @@ -788,7 +788,7 @@ void rawfield::setport(int physreg, std::shared_ptr<rawport> primal, std::shared
fh->mydisjregconstraints[cdr] = NULL;
fh->myconditionalconstraints[cdr] = {};
fh->isitgauged[cdr] = false;
fh->isitported[cdr] = true;
fh->myassociatedports[cdr] = ph;

// Keep track of the calls to 'setport':
if (issynchronizing == false)
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void rawfield::setdisjregconstraint(int physreg, int numfftharms, expression* me
for (int i = 0; i < selecteddisjregs.size(); i++)
{
// Ports have priority over the disjreg constraints!
if (isitported[selecteddisjregs[i]] == false)
if (myassociatedports[selecteddisjregs[i]] == NULL)
{
mydisjregconstraints[selecteddisjregs[i]] = disjregconstraintcomputation;
myconditionalconstraints[selecteddisjregs[i]] = {};
Expand All @@ -1173,7 +1173,7 @@ void rawfield::setdisjregconstraint(int physreg, int numfftharms, expression* me
for (int i = 0; i < selecteddisjregs.size(); i++)
{
// Ports have priority over the disjreg constraints!
if (myharmonics[h][0]->isitported[selecteddisjregs[i]] == false)
if (myharmonics[h][0]->myassociatedports[selecteddisjregs[i]] == NULL)
{
myharmonics[h][0]->mydisjregconstraints[selecteddisjregs[i]] = disjregconstraintcomputation;
myharmonics[h][0]->myconditionalconstraints[selecteddisjregs[i]] = {};
Expand Down Expand Up @@ -1246,7 +1246,7 @@ void rawfield::setconditionalconstraint(int physreg, expression condexpr, expres
for (int i = 0; i < selecteddisjregs.size(); i++)
{
// Ports and disjreg constraints have priority over the conditional constraints!
if (isitported[selecteddisjregs[i]] == false && mydisjregconstraints[selecteddisjregs[i]] == NULL)
if (myassociatedports[selecteddisjregs[i]] == NULL && mydisjregconstraints[selecteddisjregs[i]] == NULL)
myconditionalconstraints[selecteddisjregs[i]] = {condexpr, valexpr};
}
}
Expand Down Expand Up @@ -1278,7 +1278,7 @@ void rawfield::setgauge(int physreg)
for (int i = 0; i < selecteddisjregs.size(); i++)
{
// Ports and disjreg constraints have priority over the gauge!
if (isitported[selecteddisjregs[i]] == false && mydisjregconstraints[selecteddisjregs[i]] == NULL)
if (myassociatedports[selecteddisjregs[i]] == NULL && mydisjregconstraints[selecteddisjregs[i]] == NULL)
isitgauged[selecteddisjregs[i]] = true;
}
}
Expand Down Expand Up @@ -1700,6 +1700,20 @@ bool rawfield::isgauged(int disjreg)
return isitgauged[disjreg];
}

bool rawfield::isported(int disjreg)
{
synchronize();

return (myassociatedports[disjreg] != NULL);
}

std::vector<std::shared_ptr<rawport>> rawfield::getrawports(void)
{
synchronize();

return myassociatedports;
}

int rawfield::getinterpolationorder(int disjreg)
{
synchronize();
Expand Down
7 changes: 5 additions & 2 deletions src/field/rawfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class rawfield : public std::enable_shared_from_this<rawfield>
// isitgauged[disjreg] is true if disjoint region 'disjreg' is gauged.
std::vector<bool> isitgauged = {};

// isitported[disjreg] is true if a port is associated to the disjoint region.
std::vector<bool> isitported = {};
// Hold the rawport associated to the disjoint region (NULL if none).
std::vector<std::shared_ptr<rawport>> myassociatedports = {};



Expand Down Expand Up @@ -235,6 +235,9 @@ class rawfield : public std::enable_shared_from_this<rawfield>
std::vector<std::vector<expression>> getconditionalconstraints(void);

bool isgauged(int disjreg);

bool isported(int disjreg);
std::vector<std::shared_ptr<rawport>> getrawports(void);

// Get the interpolation order on a disjoint region.
// Only valid for fields without subfields.
Expand Down

0 comments on commit 3963ab5

Please sign in to comment.