Skip to content
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

Implements the tags with dimensions #215

Merged
merged 9 commits into from
Dec 3, 2024
17 changes: 11 additions & 6 deletions include/compute/compute_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ struct mesh_to_compute_mapping {

mesh_to_compute_mapping() = default;

mesh_to_compute_mapping(const specfem::mesh::tags &tags);
mesh_to_compute_mapping(
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags);
};

/**
Expand Down Expand Up @@ -101,7 +102,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 +125,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 @@ -187,8 +191,9 @@ struct mesh {

mesh() = default;

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

specfem::compute::points assemble();
Expand Down
4 changes: 2 additions & 2 deletions include/compute/kernels/impl/material_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _SPECFEM_COMPUTE_KERNELS_IMPL_MATERIAL_KERNELS_HPP_

#include "compute/properties/properties.hpp"
#include "enumerations/medium.hpp"
#include "enumerations/interface.hpp"
#include "kernels_container.hpp"
#include "kokkos_abstractions.h"
#include <Kokkos_Core.hpp>
Expand All @@ -23,7 +23,7 @@ class material_kernels : public kernels_container<type, property> {
material_kernels(
const int nspec, const int n_element, const int ngllz, const int ngllx,
const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::tags &tags,
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags,
const specfem::kokkos::HostView1d<int> property_index_mapping)
: specfem::compute::impl::kernels::kernels_container<value_type,
property_type>(
Expand Down
2 changes: 1 addition & 1 deletion include/compute/kernels/kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct kernels {
*/
kernels(const int nspec, const int ngllz, const int ngllx,
const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::tags &tags);
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags);
///@}

/**
Expand Down
3 changes: 2 additions & 1 deletion include/compute/properties/impl/material_properties.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "compute/compute_mesh.hpp"
#include "enumerations/interface.hpp"
#include "mesh/materials/materials.hpp"
#include "mesh/tags/tags.hpp"
#include "properties_container.hpp"
Expand All @@ -23,7 +24,7 @@ struct material_property
material_property(
const int nspec, const int n_element, const int ngllz, const int ngllx,
const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::tags &tags,
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags,
const specfem::mesh::materials &materials,
const specfem::kokkos::HostView1d<int> property_index_mapping)
: specfem::compute::impl::properties::properties_container<type,
Expand Down
2 changes: 1 addition & 1 deletion include/compute/properties/properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct properties {
*/
properties(const int nspec, const int ngllz, const int ngllx,
const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::tags &tags,
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags,
const specfem::mesh::materials &materials);

///@}
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
14 changes: 10 additions & 4 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 All @@ -35,7 +37,10 @@ struct mesh {
specfem::mesh::boundaries boundaries; ///< Struct to store information at the
///< boundaries

specfem::mesh::tags tags; ///< Struct to store tags for every spectral element
specfem::mesh::tags<specfem::dimension::type::dim2> tags; ///< Struct to store
///< tags for every
///< spectral
///< element

specfem::mesh::elements::tangential_elements tangential_nodes; ///< Defines
///< tangential
Expand All @@ -59,11 +64,12 @@ 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,
const specfem::mesh::tags &tags,
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags,
const specfem::mesh::elements::tangential_elements &tangential_nodes,
const specfem::mesh::elements::axial_elements &axial_nodes,
const specfem::mesh::materials &materials)
Expand Down
8 changes: 7 additions & 1 deletion include/mesh/tags/tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ namespace mesh {
* @brief Struct to store tags for every spectral element
*
*/
struct tags {
template <specfem::dimension::type DimensionType> struct tags;

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

constexpr static auto dimension =
specfem::dimension::type::dim2; ///< Dimension

int nspec; ///< Total number of spectral elements
Kokkos::View<specfem::mesh::impl::tags_container *, Kokkos::HostSpace>
tags_container; ///< Tags container
Expand Down
5 changes: 3 additions & 2 deletions 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 Expand Up @@ -208,7 +208,8 @@ specfem::mesh::mesh specfem::IO::read_mesh(const std::string filename,
assert(l_elastic_isotropic.size() + l_acoustic_isotropic.size() ==
mesh.materials.n_materials);

mesh.tags = specfem::mesh::tags(mesh.materials, mesh.boundaries);
mesh.tags = specfem::mesh::tags<specfem::dimension::type::dim2>(
mesh.materials, mesh.boundaries);

return mesh;
}
4 changes: 2 additions & 2 deletions src/compute/compute_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ template class specfem::compute::impl::kernels::material_kernels<
namespace {
void compute_number_of_elements_per_medium(
const int nspec, const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::tags &tags,
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags,
const specfem::kokkos::HostView1d<specfem::element::medium_tag>
&h_element_types,
const specfem::kokkos::HostView1d<specfem::element::property_tag>
Expand Down Expand Up @@ -62,7 +62,7 @@ void compute_number_of_elements_per_medium(
specfem::compute::kernels::kernels(
const int nspec, const int ngllz, const int ngllx,
const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::tags &tags)
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags)
: nspec(nspec), ngllz(ngllz), ngllx(ngllx),
element_types("specfem::compute::properties::element_types", nspec),
h_element_types(Kokkos::create_mirror_view(element_types)),
Expand Down
13 changes: 7 additions & 6 deletions src/compute/compute_mesh.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "compute/interface.hpp"
#include "enumerations/boundary.hpp"
#include "enumerations/medium.hpp"
#include "enumerations/interface.hpp"
#include "jacobian/interface.hpp"
#include "kokkos_abstractions.h"
#include "quadrature/interface.hpp"
Expand Down Expand Up @@ -158,7 +157,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 @@ -222,7 +222,7 @@ specfem::compute::shape_functions::shape_functions(
}

specfem::compute::mesh_to_compute_mapping::mesh_to_compute_mapping(
const specfem::mesh::tags &tags)
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags)
: compute_to_mesh("specfem::compute::mesh_to_compute_mapping", tags.nspec),
mesh_to_compute("specfem::compute::mesh_to_compute_mapping", tags.nspec) {

Expand Down Expand Up @@ -317,8 +317,9 @@ 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::tags<specfem::dimension::type::dim2> &tags,
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
6 changes: 4 additions & 2 deletions src/compute/compute_properties.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "compute/interface.hpp"
#include "enumerations/interface.hpp"
#include "kokkos_abstractions.h"
#include "material/material.hpp"
#include "specfem_setup.hpp"
Expand All @@ -8,7 +9,7 @@
namespace {
void compute_number_of_elements_per_medium(
const int nspec, const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::tags &tags,
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags,
const specfem::kokkos::HostView1d<specfem::element::medium_tag>
&h_element_types,
const specfem::kokkos::HostView1d<specfem::element::property_tag>
Expand Down Expand Up @@ -57,7 +58,8 @@ void compute_number_of_elements_per_medium(
specfem::compute::properties::properties(
const int nspec, const int ngllz, const int ngllx,
const specfem::compute::mesh_to_compute_mapping &mapping,
const specfem::mesh::tags &tags, const specfem::mesh::materials &materials)
const specfem::mesh::tags<specfem::dimension::type::dim2> &tags,
const specfem::mesh::materials &materials)
: nspec(nspec), ngllz(ngllz), ngllx(ngllx),
element_types("specfem::compute::properties::element_types", nspec),
h_element_types(Kokkos::create_mirror_view(element_types)),
Expand Down
6 changes: 4 additions & 2 deletions src/mesh/tags/tags.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "mesh/tags/tags.hpp"
#include "enumerations/dimension.hpp"

specfem::mesh::tags::tags(const specfem::mesh::materials &materials,
const specfem::mesh::boundaries &boundaries) {
specfem::mesh::tags<specfem::dimension::type::dim2>::tags(
const specfem::mesh::materials &materials,
const specfem::mesh::boundaries &boundaries) {

this->nspec = materials.material_index_mapping.extent(0);

Expand Down
Loading