-
Notifications
You must be signed in to change notification settings - Fork 62
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
Initial implementation of support for complex fields #234
base: develop
Are you sure you want to change the base?
Conversation
…ds to be made about apf::Field becuase it assumes that the data it is storing is of type double
apf/apfComplex.h
Outdated
#include <complex.h> | ||
#endif | ||
|
||
#define CXX_COMPLEX 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, need to add this as a CMake option rather that just hard defining it to be CXX_COMPLEX for now.
Oh yeah I need to add a couple functions to the apf Simmetrix mesh class. @cwsmith aside from mds and simmetrix do we wrap any other mesh types that I'll need to modify either in CORE or downstream in associated projects? I could swap the functions from being pure-virtual to just virtual with a default that fail("Unimplemented")-s |
pumi/pumi_ghost.cc
Outdated
@@ -400,7 +400,7 @@ void pumi_ghost_create(pMesh m, Ghosting* plan) | |||
std::vector<apf::Field*> frozen_fields; | |||
for (int i=0; i<m->countFields(); ++i) | |||
{ | |||
pField f = m->getField(i); | |||
apf::Field * f = m->getField(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should revert this, it crept in while I was working on an issue with freezing fields with FieldDataOf where T != double.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should keep the new version since it is consistent with the rest of the (non pumi) codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a reasonable approach that follows what was done for the other field types.
apf/apf.h
Outdated
@@ -704,6 +706,9 @@ bool isPrintable(Field* f); | |||
*/ | |||
void fail(const char* why) __attribute__((noreturn)); | |||
|
|||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there all this extra whitespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just crept into the commit, I've fixed this and once I squash the commits it will not be in the merge
apf/apf.h
Outdated
@@ -713,12 +718,15 @@ void unfreeze(Field* f); | |||
/** \brief Returns true iff the Field uses array storage. */ | |||
bool isFrozen(Field* f); | |||
|
|||
template <typename T> | |||
T* getArrayDataT(Field * f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this go into the cc file and use template specializations, as to not confuse the user space interface? If not possibly add a comment mentioning that this shouldn't be directly called by user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's probably the way to go. Don't necessarily want users exposed to this template function. Wrapping up use of the template function in a couple of interface functions similar to how getArrayData
is now implemented is probably the best short-term solution.
Unfortunately there is a potential for misuse if a user supplies a 'Field' to one of these functions with the wrong underlying type, since we basically have to rely on a reinterpret_cast
to get the underlying data of the different type. I'll see if I can add an assert or something to try to prevent this issue.
pumi/pumi_ghost.cc
Outdated
@@ -400,7 +400,7 @@ void pumi_ghost_create(pMesh m, Ghosting* plan) | |||
std::vector<apf::Field*> frozen_fields; | |||
for (int i=0; i<m->countFields(); ++i) | |||
{ | |||
pField f = m->getField(i); | |||
apf::Field * f = m->getField(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should keep the new version since it is consistent with the rest of the (non pumi) codebase
Switched base branch to develop cause I'm a dummy. Is there a way to restrict users from creating PRs for a branch (master in this case)? |
Cameron,
Yes we have apf and gmi wrappers for capstone. But those are on a separate
private repo. I will take care of those changes if they are needed.
…On Wed, Jul 3, 2019, 12:54 PM Cameron Smith ***@***.***> wrote:
@cwsmith <https://github.com/cwsmith> aside from mds and simmetrix do we
wrap any other mesh types that I'll need to modify either in CORE or
downstream in associated projects?
@mortezah <https://github.com/mortezah> Do we have a capstone
implementation of apf_mesh?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#234?email_source=notifications&email_token=AAKDQVAWJD45FTM7YZY2F33P5TKSVA5CNFSM4H4SQSRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZFBYOA#issuecomment-508173368>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKDQVE4NQO5HBAVZMZH2MTP5TKSVANCNFSM4H4SQSRA>
.
|
@wrtobin The only option I'm seeing in the github interface is to change the 'default' branch: "The default branch is considered the “base” branch in your repository, against which all pull requests and code commits are automatically made, unless you specify a different branch." I don't like this approach though as it will result in users who do a fresh clone getting placed into the |
@cwsmith Well at least only a repo admin can screw it up (looking at me, @wrtobin) Anyway I'm working on cleaning up the implementation and implementing a test case, but have a conceptual issue. While To implement the complex field I added a The issue is somewhat twofold: (1) this new field violates the assumption that all I'm trying to reconcile these issues and come up with the cleanest solution. Unfortunately since the API is built around the |
Without a massive amount of work, the functionality we can get from a complex field would probably be:
Which is largely enough for the motivating use case in M3D-C1. Assuming this all happens with the default Do we have any mechanism to selectively publish/install headers only in specific 'developer' installations? Is having such a mechanism even a good idea or is it another giant can of worms? @cwsmith any thoughts? |
apf/apf.cc
Outdated
@@ -163,13 +161,15 @@ void destroyField(Field* f) | |||
|
|||
void setScalar(Field* f, MeshEntity* e, int node, double value) | |||
{ | |||
PCU_DEBUG_ASSERT(f->getValueType() == SCALAR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are now allowing c++11 in CORE can this be done with a static assert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core has been C++11 for a while IIRC. I've been using auto
and range-based for's for a while no one has complained so far.
This assert has to be runtime though.
apf/apf.h
Outdated
\note If the underlying field data type is NOT double, | ||
this will cause an assert fail in all compile modes. | ||
*/ | ||
double* getArrayData(Field* f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a mechanism for depreciation? If so, this should probably be depreciated and replaced with getDoubleArrayData
to have a consistent API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since C++14 we have [[deprecated]], though this codebase is explicitly only up to C++11 IIRC and we haven't put in a deprecation mechanism as far as I know.
C++14 was basically just a small step from 11 so moving core to that should be possible, but is a different issue.
For the time being I will introduce a more consistent API function and not in the doxygen this is deprecated (see apfNumbering.h near the bottom for the only other place this has been done I think).
…implementing ability to get Element nodes for a packed field, restricting ElementOf<T> to be standard layout so the underlying data retrieval cast is valid (see issue #239)
…r to the FieldBase->(Real)Field/ComplexField hierarchy
… of the Mesh API (though no downstream changes should be required)
Unfortunately the most effective way to get the desired functionality in without too much work cost is to basically replicate core portions of the field API for specifically complex fields since the Under the hood where all the templating is, things were easier to implement, moving some things around, creating a few superclasses, and generalizing a few pieces of functionality, before unifying how the API uses the new structures to ensure the only real code duplication going on is the surface level API, since it is 100% the same except for some data types. In fact I kept the function names the same so porting existing algorithms can be a bit easier, just have to change the Field to ComplexField and any double arrays to double_complex. Still need to write a robust test case and fix some bugs, I'm sure, along with adding the double_complex/std::complex cmake option. |
…citons, changing field zeroing and the element/elementof class hierarchy, adding complex field api to the mesh class, etc
…t, had to change all occurences of the symbol 'I' in the codebase because the c-complex header defines a macro with that name, so we cannot use that symbol anywhere in the codebase
Okay, everything should be done with this PR. All existing test cases are passing, including the new complex test case. We have a cmake option to determine which type of complex to use, and all tests pass in both cases. |
I'm looking into the travis CI issue and hope to resolve it soon. |
Okay now that the automated tests are passing I'm going to squash the commits to clean this up before we consider merging things in. |
Ah okay the squash will happen during the merge of this PR since we have force-pushing disabled on this repo (a smart move). @cwsmith When you get a chance can you approve the PR/clear your review so I can merge? |
…nstream without needing to carry along a configuration flag
Oh I still need to modify apfSIMMesh, let me see about that. |
So the additions to the simmetrix mesh type are fairly straightforward, except for the migration of complex tags, since simmetrix doesn't provide a general callback function for send/recv of tags in migration, only for integer tags and double tags so far as I can tell. Creating a new callback function would be feasible... if I knew enough about what the functions actually have to accomplish... |
Do we have anyone who knows about the simmetrix data migration callback functions? Or would it be best to submit a ticket? Theoretically a user with a simmetrix mesh can still create complex fields, they just can't move meshes entities around at all... |
@wrtobin One of Onkar's students may have used it. This example may be helpful: |
Yeah the issue is these functions:
We can get the signature of the Simmetrix implements Cursory searches through the relevant documentation don't come up with anything either. Unless we have someone who has written their own version of these callback functions I'm likely going to submit a low-level ticket with simmetrix before the end of the day. |
@wrtobin OK. Let's submit a ticket. |
Need to:
Just wanted to get eyes on this to see if anyone can spot something I'm breaking or should do differently that isn't obvious to me.