-
Notifications
You must be signed in to change notification settings - Fork 66
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); | ||
|
||
| 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); | ||
|
||
|
|
||
| /** \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 | ||
|
||
| #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); | ||
|
||
| 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.