-
Notifications
You must be signed in to change notification settings - Fork 67
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 3 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 |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| #include "apfMatrixField.h" | ||
| #include "apfMatrixElement.h" | ||
| #include "apfPackedField.h" | ||
| #include "apfComplexField.h" | ||
| #include "apfIntegrate.h" | ||
| #include "apfArrayData.h" | ||
| #include "apfTagData.h" | ||
|
|
@@ -160,13 +161,15 @@ void destroyField(Field* f) | |
|
|
||
| void setScalar(Field* f, MeshEntity* e, int node, double value) | ||
| { | ||
| PCU_DEBUG_ASSERT(f->getValueType() == SCALAR); | ||
|
Contributor
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. If we are now allowing c++11 in CORE can this be done with a static assert?
Collaborator
Author
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. Core has been C++11 for a while IIRC. I've been using This assert has to be runtime though. |
||
| ScalarField* field = static_cast<ScalarField*>(f); | ||
| double tmp[1] = {value}; | ||
| field->setNodeValue(e,node,tmp); | ||
| } | ||
|
|
||
| double getScalar(Field* f, MeshEntity* e, int node) | ||
| { | ||
| PCU_DEBUG_ASSERT(f->getValueType() == SCALAR); | ||
| ScalarField* field = static_cast<ScalarField*>(f); | ||
| double value[1]; | ||
| field->getNodeValue(e,node,value); | ||
|
|
@@ -175,13 +178,15 @@ double getScalar(Field* f, MeshEntity* e, int node) | |
|
|
||
| void setVector(Field* f, MeshEntity* e, int node, Vector3 const& value) | ||
| { | ||
| PCU_DEBUG_ASSERT(f->getValueType() == VECTOR); | ||
| VectorField* field = static_cast<VectorField*>(f); | ||
| Vector3 tmp[1] = {value}; | ||
| field->setNodeValue(e,node,tmp); | ||
| } | ||
|
|
||
| void getVector(Field* f, MeshEntity* e, int node, Vector3& value) | ||
| { | ||
| PCU_DEBUG_ASSERT(f->getValueType() == VECTOR); | ||
| VectorField* field = static_cast<VectorField*>(f); | ||
| Vector3 tmp[1]; | ||
| field->getNodeValue(e,node,tmp); | ||
|
|
@@ -190,13 +195,15 @@ void getVector(Field* f, MeshEntity* e, int node, Vector3& value) | |
|
|
||
| void setMatrix(Field* f, MeshEntity* e, int node, Matrix3x3 const& value) | ||
| { | ||
| PCU_DEBUG_ASSERT(f->getValueType() == MATRIX); | ||
| MatrixField* field = static_cast<MatrixField*>(f); | ||
| Matrix3x3 tmp[1] = {value}; | ||
| field->setNodeValue(e,node,tmp); | ||
| } | ||
|
|
||
| void getMatrix(Field* f, MeshEntity* e, int node, Matrix3x3& value) | ||
| { | ||
| PCU_DEBUG_ASSERT(f->getValueType() == MATRIX); | ||
| MatrixField* field = static_cast<MatrixField*>(f); | ||
| Matrix3x3 tmp[1]; | ||
| field->getNodeValue(e,node,tmp); | ||
|
|
@@ -205,11 +212,15 @@ void getMatrix(Field* f, MeshEntity* e, int node, Matrix3x3& value) | |
|
|
||
| void setComponents(Field* f, MeshEntity* e, int node, double const* components) | ||
| { | ||
| PCU_DEBUG_ASSERT(f->getScalarType() == Mesh::DOUBLE && | ||
| (f->getValueType() == SCALAR || f->getValueType() == PACKED); | ||
| f->getData()->setNodeComponents(e,node,components); | ||
| } | ||
|
|
||
| void getComponents(Field* f, MeshEntity* e, int node, double* components) | ||
| { | ||
| PCU_DEBUG_ASSERT(f->getScalarType() == Mesh::DOUBLE && | ||
| (f->getValueType() == SCALAR || f->getValueType() == PACKED); | ||
| f->getData()->getNodeComponents(e,node,components); | ||
| } | ||
|
|
||
|
|
@@ -473,7 +484,7 @@ void unfreeze(Field* f) | |
|
|
||
| bool isFrozen(Field* f) | ||
| { | ||
| return f->getData()->isFrozen(); | ||
| return isFrozen(static_cast<FieldBase*>(f)); | ||
| } | ||
|
|
||
| Function::~Function() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| #include "apfMatrix.h" | ||
| #include "apfNew.h" | ||
| #include "apfDynamicArray.h" | ||
| #include "apfComplex.h" | ||
|
|
||
| #include <vector> | ||
| #include <limits> | ||
|
|
@@ -717,9 +718,29 @@ bool isFrozen(Field* f); | |
| \details This function is only defined for fields | ||
| which are using array storage, for which apf::isFrozen | ||
| returns true. | ||
| \note If the underlying field data type is NOT double, | ||
| this will cause an assert fail in all compile modes. | ||
| */ | ||
| double* getArrayData(Field* f); | ||
|
Contributor
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. Do we have a mechanism for depreciation? If so, this should probably be depreciated and replaced with
Collaborator
Author
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. 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). |
||
|
|
||
| /** \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. | ||
| \note If the underlying field data type is NOT int, | ||
| this will cause an assert fail in all compile modes. | ||
| */ | ||
| int* getIntArrayData(Field* f); | ||
|
|
||
| /** \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. | ||
| \note If the underlying field data type is NOT double_complex, | ||
| this will cause an assert fail in all compile modes. | ||
| */ | ||
| double_complex* getComplexArrayData(Field * 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 | ||
|
Collaborator
Author
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); | ||
|
Collaborator
Author
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.
Contributor
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.