-
Notifications
You must be signed in to change notification settings - Fork 7
Reduced Quintic Implicit #77
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: main
Are you sure you want to change the base?
Changes from 1 commit
01a16db
5dad2c9
ae07b45
3622fa0
06d337d
01da95c
c5d418b
ee9e7a0
de30493
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 |
|---|---|---|
|
|
@@ -67,11 +67,46 @@ class TriangleIntegration : public EntityIntegration<3> { | |
| } | ||
| virtual int getAccuracy() const { return 2; } | ||
| }; // end N2 | ||
| virtual int countIntegrations() const { return 2; } | ||
| class N6 : public Integration<3> { | ||
| public: | ||
| virtual int countPoints() const { return 12; } | ||
| virtual std::vector<IntegrationPoint<3>> getPoints() const { | ||
| return { | ||
| IntegrationPoint(Vector3{0.873821971, 0.063089014, 0.063089014}, | ||
| 0.0508449063702 / 2.0), | ||
| IntegrationPoint(Vector3{0.063089014, 0.873821971, 0.063089014}, | ||
| 0.0508449063702 / 2.0), | ||
| IntegrationPoint(Vector3{0.063089014, 0.063089014, 0.873821971}, | ||
| 0.0508449063702 / 2.0), | ||
|
|
||
| IntegrationPoint(Vector3{0.501426509, 0.249286745, 0.249286745}, | ||
| 0.1167862757264 / 2.0), | ||
| IntegrationPoint(Vector3{0.249286745, 0.501426509, 0.249286745}, | ||
| 0.1167862757264 / 2.0), | ||
| IntegrationPoint(Vector3{0.249286745, 0.249286745, 0.501426509}, | ||
| 0.1167862757264 / 2.0), | ||
|
|
||
|
||
| IntegrationPoint(Vector3{0.636502499, 0.310352451, 0.053145050}, | ||
| 0.0828510756184 / 2.0), | ||
| IntegrationPoint(Vector3{0.636502499, 0.053145050, 0.310352451}, | ||
| 0.0828510756184 / 2.0), | ||
| IntegrationPoint(Vector3{0.310352451, 0.636502499, 0.053145050}, | ||
| 0.0828510756184 / 2.0), | ||
| IntegrationPoint(Vector3{0.310352451, 0.053145050, 0.636502499}, | ||
| 0.0828510756184 / 2.0), | ||
| IntegrationPoint(Vector3{0.053145050, 0.636502499, 0.310352451}, | ||
| 0.0828510756184 / 2.0), | ||
| IntegrationPoint(Vector3{0.053145050, 0.310352451, 0.636502499}, | ||
| 0.0828510756184 / 2.0)}; | ||
| } | ||
| virtual int getAccuracy() const { return 6; } | ||
| }; // end N6 | ||
| virtual int countIntegrations() const { return 3; } | ||
| virtual Integration<3> const *getIntegration(int i) const { | ||
| static N1 i1; | ||
| static N2 i2; | ||
| static Integration<3> *integrations[2] = {&i1, &i2}; | ||
| static N6 i6; | ||
| static Integration<3> *integrations[3] = {&i1, &i2, &i6}; | ||
| return integrations[i]; | ||
| } | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,80 @@ | ||||||
| #include "KokkosController.hpp" | ||||||
| #include "MeshField.hpp" | ||||||
| #include "Omega_h_build.hpp" | ||||||
| #include "Omega_h_file.hpp" | ||||||
| #include "Omega_h_simplex.hpp" | ||||||
| #include <Kokkos_Core.hpp> | ||||||
| #include <MeshField_Integrate.hpp> | ||||||
| #include <iostream> | ||||||
|
|
||||||
| using ExecutionSpace = Kokkos::DefaultExecutionSpace; | ||||||
|
|
||||||
| template <size_t dim> | ||||||
| Omega_h::Mesh createMesh(Omega_h::Library &lib) { | ||||||
| auto world = lib.world(); | ||||||
| const auto family = OMEGA_H_SIMPLEX; | ||||||
| auto len = 1.0; | ||||||
| return Omega_h::build_box(world, family, len, len, len, | ||||||
| 2, 2, (dim == 3 ? 2 : 0)); | ||||||
|
||||||
| } | ||||||
|
|
||||||
| template <typename FieldElement> | ||||||
| class ReducedQuinticImplicitIntegrator : public MeshField::Integrator { | ||||||
| public: | ||||||
| ReducedQuinticImplicitIntegrator(FieldElement &fes_in) | ||||||
| : MeshField::Integrator(5), fes(fes_in), totalValue(0.0) {} | ||||||
|
|
||||||
| void atPoints(Kokkos::View<MeshField::Real **> p, | ||||||
| Kokkos::View<MeshField::Real *> w, | ||||||
| Kokkos::View<MeshField::Real *> dV) override { | ||||||
| const auto numPts = p.extent(0); | ||||||
| double localSum = 0.0; | ||||||
| Kokkos::parallel_reduce( | ||||||
| "IntegrateReducedQuinticImplicit", numPts, | ||||||
| KOKKOS_LAMBDA(const int i, double &sum) { | ||||||
| const double weight = w(i); | ||||||
| const double jac = dV(i); | ||||||
| const double f = 1.0; // Integrate constant field | ||||||
| sum += f * weight * jac; | ||||||
| }, | ||||||
| localSum); | ||||||
| totalValue += localSum; | ||||||
| } | ||||||
|
|
||||||
| void post() override { | ||||||
| printf("[ReducedQuinticImplicit] Integrated Value = %e\n", totalValue); | ||||||
| } | ||||||
|
|
||||||
| private: | ||||||
| FieldElement &fes; | ||||||
| double totalValue; | ||||||
| }; | ||||||
|
|
||||||
| template <template <typename...> typename Controller, size_t dim> | ||||||
| void runReducedQuinticImplicit(Omega_h::Mesh &mesh, | ||||||
| MeshField::OmegahMeshField<ExecutionSpace, dim, Controller> &omf) { | ||||||
| const auto ShapeOrder = 5; | ||||||
|
|
||||||
| auto field = omf.getCoordField(); | ||||||
|
|
||||||
| const auto [shp, map] = MeshField::Omegah::getReducedQuinticImplicitElement(mesh); | ||||||
| MeshField::FieldElement fes(mesh.nelems(), field, shp, map); | ||||||
|
|
||||||
| ReducedQuinticImplicitIntegrator<FieldElement> integrator(fes); | ||||||
|
||||||
| ReducedQuinticImplicitIntegrator<FieldElement> integrator(fes); | |
| ReducedQuinticImplicitIntegrator integrator(fes); |
Either do not put in template or you have to include the templating of FieldElement. ie MeshField::FieldElement<templating>.
Outdated
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.
Is there an expected result from the integration? I'd much prefer a test that we know the result for.
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.
There is probably some test cases in M3DC1 that I can dig up and share with James.
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.