-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from PrincetonUniversity/issue-343
Property reader / writer
- Loading branch information
Showing
70 changed files
with
1,718 additions
and
597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include "compute/interface.hpp" | ||
#include "enumerations/interface.hpp" | ||
#include "IO/reader.hpp" | ||
|
||
namespace specfem { | ||
namespace IO { | ||
/** | ||
* @brief Read model property | ||
* | ||
* @tparam InputLibrary Library to use for output (HDF5, ASCII, etc.) | ||
*/ | ||
template <typename InputLibrary> class property_reader : public reader { | ||
public: | ||
/** | ||
* @name Constructors | ||
* | ||
*/ | ||
///@{ | ||
/** | ||
* @brief Construct a reader object | ||
* | ||
* @param output_folder Path to input location (will be an .h5 file if using | ||
* HDF5, and a folder if using ASCII) | ||
*/ | ||
property_reader(const std::string input_folder); | ||
|
||
/** | ||
* @brief read the property from disk | ||
* | ||
* @param assembly SPECFEM++ assembly | ||
* | ||
*/ | ||
void read(specfem::compute::assembly &assembly) override; | ||
|
||
private: | ||
std::string input_folder; ///< Path to output folder | ||
specfem::compute::properties properties; ///< Properties object | ||
}; | ||
} // namespace IO | ||
} // namespace specfem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#pragma once | ||
|
||
#include "compute/assembly/assembly.hpp" | ||
#include "enumerations/dimension.hpp" | ||
#include "enumerations/medium.hpp" | ||
#include "kokkos_abstractions.h" | ||
#include "point/properties.hpp" | ||
#include "IO/property/reader.hpp" | ||
#include <Kokkos_Core.hpp> | ||
|
||
template <typename InputLibrary> | ||
specfem::IO::property_reader<InputLibrary>::property_reader(const std::string input_folder): input_folder(input_folder) {} | ||
|
||
template <typename InputLibrary> | ||
void specfem::IO::property_reader<InputLibrary>::read(specfem::compute::assembly &assembly) { | ||
auto &properties = assembly.properties; | ||
|
||
using DomainView = | ||
Kokkos::View<type_real ***, Kokkos::LayoutLeft, Kokkos::HostSpace>; | ||
|
||
typename InputLibrary::File file(input_folder + "/Properties"); | ||
|
||
{ | ||
typename InputLibrary::Group elastic = file.openGroup("/ElasticIsotropic"); | ||
|
||
elastic.openDataset("rho", properties.elastic_isotropic.h_rho).read(); | ||
elastic.openDataset("mu", properties.elastic_isotropic.h_mu).read(); | ||
elastic.openDataset("lambdaplus2mu", properties.elastic_isotropic.h_lambdaplus2mu).read(); | ||
} | ||
|
||
{ | ||
typename InputLibrary::Group elastic = file.openGroup("/ElasticAnisotropic"); | ||
|
||
elastic.openDataset("rho", properties.elastic_anisotropic.h_rho).read(); | ||
elastic.openDataset("c11", properties.elastic_anisotropic.h_c11).read(); | ||
elastic.openDataset("c13", properties.elastic_anisotropic.h_c13).read(); | ||
elastic.openDataset("c15", properties.elastic_anisotropic.h_c15).read(); | ||
elastic.openDataset("c33", properties.elastic_anisotropic.h_c33).read(); | ||
elastic.openDataset("c35", properties.elastic_anisotropic.h_c35).read(); | ||
elastic.openDataset("c55", properties.elastic_anisotropic.h_c55).read(); | ||
elastic.openDataset("c12", properties.elastic_anisotropic.h_c12).read(); | ||
elastic.openDataset("c23", properties.elastic_anisotropic.h_c23).read(); | ||
elastic.openDataset("c25", properties.elastic_anisotropic.h_c25).read(); | ||
} | ||
|
||
{ | ||
typename InputLibrary::Group acoustic = file.openGroup("/Acoustic"); | ||
|
||
acoustic.openDataset("rho_inverse", properties.acoustic_isotropic.h_rho_inverse).read(); | ||
acoustic.openDataset("kappa", properties.acoustic_isotropic.h_kappa).read(); | ||
} | ||
|
||
std::cout << "Properties read from " << input_folder << "/Properties" | ||
<< std::endl; | ||
|
||
properties.copy_to_device(); | ||
} |
Oops, something went wrong.