Chi-Tech
lagC_00_constrdestr.cc
Go to the documentation of this file.
2
4
6{
7
9 QuadratureOrder q_order,
12 grid, q_order, SpatialDiscretizationType::LAGRANGE_CONTINUOUS, cs_type)
13{
14 OrderNodes();
15}
16
17// ###################################################################
18/**Construct a shared object using the protected constructor.*/
19std::shared_ptr<LagrangeContinuous> LagrangeContinuous::New(
20 const chi_mesh::MeshContinuum& grid,
21 QuadratureOrder q_order /*=QuadratureOrder::SECOND*/,
22 CoordinateSystemType cs_type /*=CoordinateSystemType::CARTESIAN*/)
23
24{
26 // First try to find an existing spatial discretization that matches the
27 // one requested.
28 for (auto& sdm : Chi::sdm_stack)
29 if (sdm->Type() == LagrangeC and
30 std::addressof(sdm->Grid()) == std::addressof(grid) and
31 sdm->GetCoordinateSystemType() == cs_type)
32 {
33 auto fe_ptr = std::dynamic_pointer_cast<FiniteElementBase>(sdm);
34
35 ChiLogicalErrorIf(not fe_ptr, "Casting failure to FE");
36
37 if (fe_ptr->GetQuadratureOrder() != q_order) break;
38
39 auto sdm_ptr =
40 std::dynamic_pointer_cast<LagrangeContinuous>(fe_ptr);
41
42 ChiLogicalErrorIf(not sdm_ptr, "Casting failure");
43
44 return sdm_ptr;
45 }
46
47 auto new_sdm = std::shared_ptr<LagrangeContinuous>(
48 new LagrangeContinuous(grid, q_order, cs_type));
49
50 Chi::sdm_stack.push_back(new_sdm);
51
52 return new_sdm;
53}
54
55} // 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< LagrangeContinuous > New(const chi_mesh::MeshContinuum &grid, QuadratureOrder q_order=QuadratureOrder::SECOND, CoordinateSystemType cs_type=CoordinateSystemType::CARTESIAN)
LagrangeContinuous(const chi_mesh::MeshContinuum &grid, QuadratureOrder q_order, CoordinateSystemType cs_type)
QuadratureOrder
Definition: quadrature.h:12
SpatialDiscretizationType
Definition: chi_math.h:37
CoordinateSystemType
Definition: chi_math.h:29