Skip to content

Commit

Permalink
Merge pull request #211 from PrincetonUniversity/issue-201
Browse files Browse the repository at this point in the history
Implemented specfem::mesh::control_nodes with template specialization.
  • Loading branch information
lsawade authored Dec 2, 2024
2 parents b5f6350 + 3bd0340 commit edac764
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
12 changes: 8 additions & 4 deletions include/compute/compute_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ struct quadrature {
quadrature() = default;

quadrature(const specfem::quadrature::quadratures &quadratures,
const specfem::mesh::control_nodes &control_nodes)
const specfem::mesh::control_nodes<specfem::dimension::type::dim2>
&control_nodes)
: gll(quadratures, control_nodes.ngnod) {}
};

Expand All @@ -123,8 +124,10 @@ struct control_nodes {
specfem::kokkos::HostMirror3d<type_real> h_coord; ///< (x, z) for every
///< distinct control node

control_nodes(const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::control_nodes &control_nodes);
control_nodes(
const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::control_nodes<specfem::dimension::type::dim2>
&control_nodes);

control_nodes() = default;
};
Expand Down Expand Up @@ -188,7 +191,8 @@ struct mesh {
mesh() = default;

mesh(const specfem::mesh::tags &tags,
const specfem::mesh::control_nodes &control_nodes,
const specfem::mesh::control_nodes<specfem::dimension::type::dim2>
&control_nodes,
const specfem::quadrature::quadratures &quadratures);

specfem::compute::points assemble();
Expand Down
10 changes: 8 additions & 2 deletions include/mesh/control_nodes/control_nodes.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _MESH_CONTROL_NODES_HPP
#define _MESH_CONTROL_NODES_HPP

#include "enumerations/interface.hpp"
#include "kokkos_abstractions.h"
#include "specfem_setup.hpp"

Expand All @@ -11,9 +12,14 @@ namespace mesh {
* @brief Control node information
*
*/
struct control_nodes {
using ViewType = Kokkos::View<type_real **, Kokkos::HostSpace>;
template <specfem::dimension::type DimensionType> struct control_nodes;

template <> struct control_nodes<specfem::dimension::type::dim2> {

// Use 'specfem::dimension::type::dim2' explicitly here
constexpr static auto dimension = specfem::dimension::type::dim2;

using ViewType = Kokkos::View<type_real **, Kokkos::HostSpace>;
int ngnod; ///< Number of control nodes
int nspec; ///< Number of spectral elements
Kokkos::View<int **, Kokkos::HostSpace> knods; ///< Control node indices
Expand Down
7 changes: 5 additions & 2 deletions include/mesh/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "coupled_interfaces/coupled_interfaces.hpp"
#include "elements/axial_elements.hpp"
#include "elements/tangential_elements.hpp"
#include "enumerations/interface.hpp"
#include "materials/materials.hpp"
#include "mesh/tags/tags.hpp"
#include "properties/properties.hpp"
Expand All @@ -24,7 +25,8 @@ struct mesh {
int npgeo; ///< Total number of spectral element control nodes
int nspec; ///< Total number of spectral elements
int nproc; ///< Total number of processors
specfem::mesh::control_nodes control_nodes; ///< Defines control nodes
specfem::mesh::control_nodes<specfem::dimension::type::dim2>
control_nodes; ///< Defines control nodes

specfem::mesh::properties parameters; ///< Struct to store simulation launch
///< parameters (never used)
Expand Down Expand Up @@ -59,7 +61,8 @@ struct mesh {
mesh(){};

mesh(const int npgeo, const int nspec, const int nproc,
const specfem::mesh::control_nodes &control_nodes,
const specfem::mesh::control_nodes<specfem::dimension::type::dim2>
&control_nodes,
const specfem::mesh::properties &parameters,
const specfem::mesh::coupled_interfaces &coupled_interfaces,
const specfem::mesh::boundaries &boundaries,
Expand Down
2 changes: 1 addition & 1 deletion src/IO/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "IO/mesh/impl/fortran/read_material_properties.hpp"
#include "IO/mesh/impl/fortran/read_mesh_database.hpp"
#include "IO/mesh/impl/fortran/read_properties.hpp"
#include "enumerations/specfem_enums.hpp"
#include "enumerations/interface.hpp"
#include "kokkos_abstractions.h"
#include "material/material.hpp"
#include "mesh/tags/tags.hpp"
Expand Down
6 changes: 4 additions & 2 deletions src/compute/compute_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ assign_numbering(specfem::kokkos::HostView4d<double> global_coordinates) {

specfem::compute::control_nodes::control_nodes(
const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::control_nodes &control_nodes)
const specfem::mesh::control_nodes<specfem::dimension::type::dim2>
&control_nodes)
: ngnod(control_nodes.ngnod), nspec(control_nodes.nspec),
index_mapping("specfem::compute::control_nodes::index_mapping",
control_nodes.nspec, control_nodes.ngnod),
Expand Down Expand Up @@ -318,7 +319,8 @@ specfem::compute::mesh_to_compute_mapping::mesh_to_compute_mapping(

specfem::compute::mesh::mesh(
const specfem::mesh::tags &tags,
const specfem::mesh::control_nodes &m_control_nodes,
const specfem::mesh::control_nodes<specfem::dimension::type::dim2>
&m_control_nodes,
const specfem::quadrature::quadratures &m_quadratures) {

this->mapping = specfem::compute::mesh_to_compute_mapping(tags);
Expand Down

0 comments on commit edac764

Please sign in to comment.