-
Notifications
You must be signed in to change notification settings - Fork 65
Initial implementation of support for complex fields #234
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
base: develop
Are you sure you want to change the base?
Changes from 2 commits
e72dfe2
c8ac116
dc9324c
1f09105
246a843
80c1c68
07965d0
97a6412
b587a25
91f67a9
99423cc
63744be
0b151f8
e8c761b
5624ba1
3aa1ebe
a9ebda5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,8 @@ enum ValueType { | |
MATRIX, | ||
/** \brief a user-defined set of components */ | ||
PACKED, | ||
/** \brief a user-defined set of complex-components */ | ||
COMPLEX_PACKED, | ||
/** \brief placeholder used to set array sizes */ | ||
VALUE_TYPES | ||
}; | ||
|
@@ -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 commentThe 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 commentThe 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 |
||
/** \brief Convert a Field from Tag to array storage. */ | ||
void freeze(Field* f); | ||
|
||
|
@@ -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 commentThe 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 commentThe 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 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 |
||
|
||
/** \brief Return the contiguous array storing this field. | ||
\details This function is only defined for fields | ||
which are using array storage, for which apf::isFrozen | ||
returns true. | ||
*/ | ||
double* getArrayData(Field* f); | ||
inline double * getArrayData(Field* f) { return getArrayDataT<double>(f); } | ||
|
||
/** \brief Initialize all nodal values with all-zero components */ | ||
void zeroField(Field* f); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef APFCOMPLEX_H_ | ||
#define APFCOMPLEX_H_ | ||
|
||
#ifdef C_COMPLEX | ||
#include <complex.h> | ||
#endif | ||
|
||
#define CXX_COMPLEX 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
#ifdef CXX_COMPLEX | ||
#include <complex> | ||
using double_complex = std::complex<double>; | ||
#endif | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "apfComplexField.h" | ||
#include "apfElement.h" | ||
|
||
namespace apf { | ||
|
||
Element * ComplexPackedField::getElement(VectorElement * e) | ||
{ | ||
return new Element(this,e); | ||
} | ||
|
||
void ComplexPackedField::project(Field*) | ||
{ | ||
fail("ComplexPackedField::project unimplemented"); | ||
} | ||
|
||
void ComplexPackedField::axpy(double, Field*) | ||
{ | ||
fail("ComplexPackedField::axpy unimplemented"); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef APFCOMPLEXFIELD_H_ | ||
#define APFCOMPLEXFIELD_H_ | ||
|
||
#include "apfField.h" | ||
#include "apf.h" | ||
|
||
namespace apf | ||
{ | ||
class ComplexPackedField : public Field | ||
{ | ||
public: | ||
ComplexPackedField(int c) : components(c) {} | ||
virtual ~ComplexPackedField() {} | ||
virtual Element * getElement(VectorElement*); | ||
virtual int getValueType() const { return COMPLEX_PACKED; } | ||
virtual int countComponents() const { return components; } | ||
virtual void project(Field * frm); | ||
virtual void axpy(double a, Field * x); | ||
private: | ||
int components; | ||
}; | ||
|
||
} | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,8 @@ Field* makeField( | |
FieldShape* shape, | ||
FieldData* data); | ||
|
||
bool isFrozen(FieldBase * fb); | ||
|
||
} //namespace apf | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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 |
||
if (isFrozen(f)) | ||
{ | ||
frozen_fields.push_back(f); // turn field data from tag to array | ||
|
Uh oh!
There was an error while loading. Please reload this page.