Chi-Tech
lagD_00_constrdestr.cc
Go to the documentation of this file.
2
4
5#include "chi_runtime.h"
6#include "chi_log.h"
7
8#include "utils/chi_timer.h"
9
11{
12
13// ###################################################################
14/**Constructor.*/
16 const chi_mesh::MeshContinuum& grid,
20 grid, q_order, SDMType::LAGRANGE_DISCONTINUOUS, cs_type)
21{
23
24 OrderNodes();
25}
26
27// ###################################################################
28/**Construct a shared object using the protected constructor.*/
29std::shared_ptr<LagrangeDiscontinuous> LagrangeDiscontinuous::New(
30 const chi_mesh::MeshContinuum& grid,
31 QuadratureOrder q_order /*=QuadratureOrder::SECOND*/,
32 CoordinateSystemType cs_type /*=CoordinateSystemType::CARTESIAN*/)
33
34{
36 // First try to find an existing spatial discretization that matches the
37 // one requested.
38 for (auto& sdm : Chi::sdm_stack)
39 if (sdm->Type() == LagrangeD and
40 std::addressof(sdm->Grid()) == std::addressof(grid) and
41 sdm->GetCoordinateSystemType() == cs_type)
42 {
43 auto fe_ptr = std::dynamic_pointer_cast<FiniteElementBase>(sdm);
44
45 ChiLogicalErrorIf(not fe_ptr, "Casting failure to FE");
46
47 if (fe_ptr->GetQuadratureOrder() != q_order) break;
48
49 auto sdm_ptr =
50 std::dynamic_pointer_cast<LagrangeDiscontinuous>(fe_ptr);
51
52 ChiLogicalErrorIf(not sdm_ptr, "Casting failure");
53
54 return sdm_ptr;
55 }
56
57 auto new_sdm = std::shared_ptr<LagrangeDiscontinuous>(
58 new LagrangeDiscontinuous(grid, q_order, cs_type));
59
60 Chi::sdm_stack.push_back(new_sdm);
61
62 return new_sdm;
63}
64
65} // namespace chi_math::spatial_discretization
#define ChiLogicalErrorIf(condition, message)
static std::vector< chi_math::SpatialDiscretizationPtr > sdm_stack
Definition: chi_runtime.h:97
LagrangeDiscontinuous(const chi_mesh::MeshContinuum &grid, QuadratureOrder q_order, CoordinateSystemType cs_type)
static std::shared_ptr< LagrangeDiscontinuous > New(const chi_mesh::MeshContinuum &grid, QuadratureOrder q_order=QuadratureOrder::SECOND, CoordinateSystemType cs_type=CoordinateSystemType::CARTESIAN)
QuadratureOrder
Definition: quadrature.h:12
SpatialDiscretizationType
Definition: chi_math.h:37
CoordinateSystemType
Definition: chi_math.h:29