Chi-Tech
pwlc_00_constrdestr.cc
Go to the documentation of this file.
2
3#include "chi_runtime.h"
4#include "chi_log.h"
5
6#include "utils/chi_timer.h"
7
9{
10
11// ###################################################################
12/**Constructor.*/
14 const chi_mesh::MeshContinuum& grid,
17 : spatial_discretization::PieceWiseLinearBase(
18 grid, q_order, SDMType::PIECEWISE_LINEAR_CONTINUOUS, cs_type)
19{
21
22 OrderNodes();
23}
24
25// ###################################################################
26/**Construct a shared object using the protected constructor.*/
27std::shared_ptr<PieceWiseLinearContinuous> PieceWiseLinearContinuous::New(
28 const chi_mesh::MeshContinuum& grid,
29 QuadratureOrder q_order /*=QuadratureOrder::SECOND*/,
30 CoordinateSystemType cs_type /*=CoordinateSystemType::CARTESIAN*/)
31
32{
34 // First try to find an existing spatial discretization that matches the
35 // one requested.
36 for (auto& sdm : Chi::sdm_stack)
37 if (sdm->Type() == PWLC and
38 std::addressof(sdm->Grid()) == std::addressof(grid) and
39 sdm->GetCoordinateSystemType() == cs_type)
40 {
41 auto fe_ptr = std::dynamic_pointer_cast<FiniteElementBase>(sdm);
42
43 ChiLogicalErrorIf(not fe_ptr, "Casting failure to FE");
44
45 if (fe_ptr->GetQuadratureOrder() != q_order) break;
46
47 auto sdm_ptr =
48 std::dynamic_pointer_cast<PieceWiseLinearContinuous>(fe_ptr);
49
50 ChiLogicalErrorIf(not sdm_ptr, "Casting failure");
51
52 return sdm_ptr;
53 }
54
55 auto new_sdm = std::shared_ptr<PieceWiseLinearContinuous>(
56 new PieceWiseLinearContinuous(grid, q_order, cs_type));
57
58 Chi::sdm_stack.push_back(new_sdm);
59
60 return new_sdm;
61}
62
63} // 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< PieceWiseLinearContinuous > New(const chi_mesh::MeshContinuum &grid, QuadratureOrder q_order=QuadratureOrder::SECOND, CoordinateSystemType cs_type=CoordinateSystemType::CARTESIAN)
PieceWiseLinearContinuous(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