Chi-Tech
fv_00_constrdestr.cc
Go to the documentation of this file.
1#include "FiniteVolume.h"
2
3#include "chi_runtime.h"
5
7{
8
9// ##################################################################
10/**Only constructor for this method.*/
14{
16
17 OrderNodes();
18}
19
20// ##################################################################
21/**Publicly accessible construction handler.*/
22std::shared_ptr<FiniteVolume>
24 const chi_mesh::MeshContinuum& in_grid,
26 in_cs_type /* = chi_math::CoordinateSystemType::CARTESIAN*/)
27{
28 // First try to find an existing spatial discretization that matches the
29 // one requested.
30 for (auto& sdm : Chi::sdm_stack)
31 if (sdm->Type() == SpatialDiscretizationType::FINITE_VOLUME and
32 std::addressof(sdm->Grid()) == std::addressof(in_grid) and
33 sdm->GetCoordinateSystemType() == in_cs_type)
34 {
35 auto sdm_ptr = std::dynamic_pointer_cast<FiniteVolume>(sdm);
36
37 ChiLogicalErrorIf(not sdm_ptr, "Casting failure");
38
39 return sdm_ptr;
40 }
41
42 // If no existing discretization was found then go ahead and make a
43 // new one
44 auto new_sdm =
45 std::shared_ptr<spatial_discretization::FiniteVolume>(
46 new FiniteVolume(in_grid, in_cs_type));
47
48 Chi::sdm_stack.push_back(new_sdm);
49
50 return new_sdm;
51}
52
53} // namespace chi_math::spatial_discretization
#define ChiLogicalErrorIf(condition, message)
static std::vector< chi_math::SpatialDiscretizationPtr > sdm_stack
Definition: chi_runtime.h:97
static std::shared_ptr< FiniteVolume > New(const chi_mesh::MeshContinuum &in_grid, CoordinateSystemType in_cs_type=CoordinateSystemType::CARTESIAN)
FiniteVolume(const chi_mesh::MeshContinuum &grid, CoordinateSystemType cs_type)
SpatialDiscretizationType
Definition: chi_math.h:37
CoordinateSystemType
Definition: chi_math.h:29