Nalu
Nalu: a generalized unstructured massively parallel low Mach flow code designed to support a variety of energy applications of interest (most notably Wind ECP) built on the Sierra Toolkit and Trilinos solver Tpetra/Epetra stack. The open source BSD, clause 3 license model has been chosen for the code base. See LICENSE for more information. http://NaluCFD.org
UnitTestAlgorithm.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2014 National Renewable Energy Laboratory. */
3 /* This software is released under the license detailed */
4 /* in the file, LICENSE, which is located in the top-level Nalu */
5 /* directory structure */
6 /*------------------------------------------------------------------------*/
7 
8 #ifndef UNITTESTALGORITHM_H
9 #define UNITTESTALGORITHM_H
10 
11 #include <gtest/gtest.h>
12 #include "UnitTestRealm.h"
13 #include "UnitTestUtils.h"
14 #include "UnitTestFieldUtils.h"
15 
16 #include <memory>
17 #include <cassert>
18 
19 #ifndef KOKKOS_HAVE_CUDA
20 
21 class TestAlgorithm: public ::testing::Test
22 {
23 public:
25  : comm_(MPI_COMM_WORLD)
26  {
28  naluObj_.reset(new unit_test_utils::NaluTest(doc));
29  }
30 
31  virtual ~TestAlgorithm() {}
32 
34  const YAML::Node& realm_node,
35  const std::string realm_type = "multi_physics")
36  {
37  realm_ = &naluObj_->create_realm(realm_node, realm_type);
38  return *realm_;
39  }
40 
42  const std::string realm_type = "multi_physics")
43  {
45  realm_ = &naluObj_->create_realm(realm_node, realm_type);
46  return *realm_;
47  }
48 
49  void fill_mesh(const std::string mesh_spec="generated:10x10x10");
50 
51  virtual void declare_fields() = 0;
52 
53  inline sierra::nalu::Realm& realm() const
54  {
55  assert(realm_ != nullptr);
56  return *realm_;
57  }
58 
59  inline stk::mesh::MetaData& meta() const
60  {
61  return realm().meta_data();
62  }
63 
64  inline stk::mesh::BulkData& bulk() const
65  {
66  return realm().bulk_data();
67  }
68 
69  double field_norm(const ScalarFieldType & field, stk::mesh::Selector* selector = nullptr);
70 
72  std::unique_ptr<unit_test_utils::NaluTest> naluObj_;
73 
76 
77  stk::mesh::Part* meshPart_{nullptr};
78  const VectorFieldType* coordinates_{nullptr};
79  stk::ParallelMachine comm_;
80 };
81 
83 {
84 public:
86  : TestAlgorithm()
87  {}
88 
90 
91  virtual void declare_fields();
92 
93  virtual void fill_mesh_and_init_fields(
94  const std::string mesh_spec="generated:10x10x10");
95 
96  ScalarFieldType* density_{nullptr};
97  ScalarFieldType* viscosity_{nullptr};
98  ScalarFieldType* tke_{nullptr};
99  ScalarFieldType* sdr_{nullptr};
100  ScalarFieldType* minDistance_{nullptr};
101  GenericFieldType* dudx_{nullptr};
102  ScalarFieldType* tvisc_{nullptr};
103  ScalarFieldType* maxLengthScale_{nullptr};
104  ScalarFieldType* fOneBlend_{nullptr};
105  ScalarFieldType* evisc_{nullptr};
106  ScalarFieldType* dualNodalVolume_{nullptr};
107  VectorFieldType* dkdx_{nullptr};
108  VectorFieldType* dwdx_{nullptr};
109  VectorFieldType* dhdx_{nullptr};
110  ScalarFieldType* specificHeat_{nullptr};
111 };
112 
113 #endif /* KOKKOS_HAVE_CUDA */
114 
115 #endif /* UNITTESTALGORITHM_H */
stk::mesh::Part * meshPart_
Definition: UnitTestAlgorithm.h:77
Definition: UnitTestAlgorithm.h:21
stk::mesh::MetaData & meta_data()
Definition: Realm.C:4746
stk::mesh::Field< double > ScalarFieldType
Definition: PromotedElementIO.h:38
stk::mesh::BulkData & bulk_data()
Definition: Realm.C:4737
sierra::nalu::Realm & realm() const
Definition: UnitTestAlgorithm.h:53
std::unique_ptr< unit_test_utils::NaluTest > naluObj_
Reference to test Nalu instance used to hold Simulation and Realm.
Definition: UnitTestAlgorithm.h:72
Definition: UnitTestAlgorithm.h:82
TestTurbulenceAlgorithm()
Definition: UnitTestAlgorithm.h:85
YAML::Node get_realm_default_node()
Definition: UnitTestRealm.C:101
sierra::nalu::Realm & create_realm(const std::string realm_type="multi_physics")
Definition: UnitTestAlgorithm.h:41
TestAlgorithm()
Definition: UnitTestAlgorithm.h:24
stk::mesh::BulkData & bulk() const
Definition: UnitTestAlgorithm.h:64
stk::mesh::Field< double, stk::mesh::Cartesian > VectorFieldType
Definition: PromotedElementIO.h:40
sierra::nalu::Realm * realm_
Reference to realm instance.
Definition: UnitTestAlgorithm.h:75
const VectorFieldType * coordinates_
Definition: UnitTestAlgorithm.h:78
stk::mesh::Field< double, stk::mesh::SimpleArrayTag > GenericFieldType
Definition: PromotedElementIO.h:39
void fill_mesh(const std::string mesh_spec="generated:10x10x10")
Definition: UnitTestAlgorithm.C:16
Tpetra::Map< LocalOrdinal, GlobalOrdinal >::node_type Node
Definition: LinearSolver.h:32
Definition: UnitTestRealm.h:25
sierra::nalu::Realm & create_realm(const YAML::Node &realm_node, const std::string realm_type="multi_physics")
Definition: UnitTestAlgorithm.h:33
YAML::Node get_default_inputs()
Definition: UnitTestRealm.C:95
virtual ~TestTurbulenceAlgorithm()
Definition: UnitTestAlgorithm.h:89
Definition: Realm.h:82
virtual ~TestAlgorithm()
Definition: UnitTestAlgorithm.h:31
stk::mesh::MetaData & meta() const
Definition: UnitTestAlgorithm.h:59
stk::ParallelMachine comm_
Definition: UnitTestAlgorithm.h:79
double field_norm(const ScalarFieldType &field, stk::mesh::Selector *selector=nullptr)
Definition: UnitTestAlgorithm.C:27
virtual void declare_fields()=0