Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apf::getElementNumbers should return size #11

Closed
YetAnotherMinion opened this issue Aug 13, 2015 · 3 comments
Closed

apf::getElementNumbers should return size #11

YetAnotherMinion opened this issue Aug 13, 2015 · 3 comments

Comments

@YetAnotherMinion
Copy link
Contributor

I believe the apf::getElementNumbers should return the integer. Right now this function is just a wrapper over numbering->getData()->getElementData used as some template wizardry.

getElementData takes a NewArray and will dynamically resize it, then returns the new size of the array. Now NewArray has no internal representation of size, so this return is very necessary to keep track of the size of the array. Right now the apf::getElementNumbers black boxes the new size and there is no way to tell the new size if reallocation occurs.

This is the proposed change:

diff --git a/apf/apfNumbering.cc b/apf/apfNumbering.cc
index cd39870..538943c 100644
--- a/apf/apfNumbering.cc
+++ b/apf/apfNumbering.cc
@@ -180,9 +180,9 @@ int countComponents(Numbering* n)
   return n->countComponents();
 }

-void getElementNumbers(Numbering* n, MeshEntity* e, NewArray<int>& numbers)
+int getElementNumbers(Numbering* n, MeshEntity* e, NewArray<int>& numbers)
 {
-  n->getData()->getElementData(e,numbers);
+  return n->getData()->getElementData(e,numbers);
 }

 int countFixed(Numbering* n)
diff --git a/apf/apfNumbering.h b/apf/apfNumbering.h
index 9a9a016..909c417 100644
--- a/apf/apfNumbering.h
+++ b/apf/apfNumbering.h
@@ -81,7 +81,7 @@ int countComponents(Numbering* n);
 /** \brief returns the node numbers of an element
   \details numbers are returned in the standard
            element node ordering for its shape functions */
-void getElementNumbers(Numbering* n, MeshEntity* e, NewArray<int>& numbers);
+int getElementNumbers(Numbering* n, MeshEntity* e, NewArray<int>& numbers);

 /** \brief return the number of fixed degrees of freedom */ 
 int countFixed(Numbering* n);
@zaidedan
Copy link
Contributor

*proposed

On Thu, Aug 13, 2015 at 1:02 PM, Another Minion notifications@github.com
wrote:

I believe the apf::getElementNumbers should return the integer. Right now
this function is just a wrapper over numbering->getData()->getElementData
used as some template wizardry.

getElementData takes a NewArray and will dynamically resize it, then
returns the new size of the array. Now NewArray has no internal
representation of size, so this return is very necessary to keep track of
the size of the array. Right now the apf::getElementNumbers black boxes the
new size and there is no way to tell the new size if reallocation occurs.

This is the purposed change:

diff --git a/apf/apfNumbering.cc b/apf/apfNumbering.cc
index cd39870..538943c 100644
--- a/apf/apfNumbering.cc
+++ b/apf/apfNumbering.cc
@@ -180,9 +180,9 @@ int countComponents(Numbering* n)
return n->countComponents();
}

-void getElementNumbers(Numbering* n, MeshEntity* e, NewArray& numbers)
+int getElementNumbers(Numbering* n, MeshEntity* e, NewArray& numbers)
{

  • n->getData()->getElementData(e,numbers);
  • return n->getData()->getElementData(e,numbers);
    }

int countFixed(Numbering* n)
diff --git a/apf/apfNumbering.h b/apf/apfNumbering.h
index 9a9a016..909c417 100644
--- a/apf/apfNumbering.h
+++ b/apf/apfNumbering.h
@@ -81,7 +81,7 @@ int countComponents(Numbering* n);
/** \brief returns the node numbers of an element \details numbers are returned in the standard element node ordering for its shape functions /
-void getElementNumbers(Numbering
n, MeshEntity* e, NewArray& numbers);
+int getElementNumbers(Numbering* n, MeshEntity* e, NewArray& numbers);

/** \brief return the number of fixed degrees of freedom /
int countFixed(Numbering
n);


Reply to this email directly or view it on GitHub
#11.

Dr. Daniel W. Zaide (偉明),
Researcher, Rensselaer Polytechnic Institute
B.A.Sc. University of Toronto (2007)
M.S.E, M.S. Ph.D., University of Michigan (2009,2011,2012)
www.danielzaide.com http://www.danielzaide.com

@zaidedan
Copy link
Contributor

Chances are, if you are asking for the numbers, you already know how many
you should get,
returning an int telling you that seems superfluous, IMO.
(Maybe an unsigned const would be preferred).

What is your use of it in this case?

On Thu, Aug 13, 2015 at 1:22 PM, Daniel Zaide dan.zaide@gmail.com wrote:

*proposed

On Thu, Aug 13, 2015 at 1:02 PM, Another Minion notifications@github.com
wrote:

I believe the apf::getElementNumbers should return the integer. Right now
this function is just a wrapper over numbering->getData()->getElementData
used as some template wizardry.

getElementData takes a NewArray and will dynamically resize it, then
returns the new size of the array. Now NewArray has no internal
representation of size, so this return is very necessary to keep track of
the size of the array. Right now the apf::getElementNumbers black boxes the
new size and there is no way to tell the new size if reallocation occurs.

This is the purposed change:

diff --git a/apf/apfNumbering.cc b/apf/apfNumbering.cc
index cd39870..538943c 100644
--- a/apf/apfNumbering.cc
+++ b/apf/apfNumbering.cc
@@ -180,9 +180,9 @@ int countComponents(Numbering* n)
return n->countComponents();
}

-void getElementNumbers(Numbering* n, MeshEntity* e, NewArray& numbers)
+int getElementNumbers(Numbering* n, MeshEntity* e, NewArray& numbers)
{

  • n->getData()->getElementData(e,numbers);
  • return n->getData()->getElementData(e,numbers);
    }

int countFixed(Numbering* n)
diff --git a/apf/apfNumbering.h b/apf/apfNumbering.h
index 9a9a016..909c417 100644
--- a/apf/apfNumbering.h
+++ b/apf/apfNumbering.h
@@ -81,7 +81,7 @@ int countComponents(Numbering* n);
/** \brief returns the node numbers of an element \details numbers are returned in the standard element node ordering for its shape functions /
-void getElementNumbers(Numbering
n, MeshEntity* e, NewArray& numbers);
+int getElementNumbers(Numbering* n, MeshEntity* e, NewArray& numbers);

/** \brief return the number of fixed degrees of freedom /
int countFixed(Numbering
n);


Reply to this email directly or view it on GitHub
#11.

Dr. Daniel W. Zaide (偉明),
Researcher, Rensselaer Polytechnic Institute
B.A.Sc. University of Toronto (2007)
M.S.E, M.S. Ph.D., University of Michigan (2009,2011,2012)
www.danielzaide.com http://www.danielzaide.com

Dr. Daniel W. Zaide (偉明),
Researcher, Rensselaer Polytechnic Institute
B.A.Sc. University of Toronto (2007)
M.S.E, M.S. Ph.D., University of Michigan (2009,2011,2012)
www.danielzaide.com http://www.danielzaide.com

@ibaned
Copy link
Contributor

ibaned commented Aug 13, 2015

eh, this is actually consistent with the behavior of that function for global numberings.
I was just slow to respond due to commuting

c37b233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants