Chi-Tech
SphereLogicalVolume.cc
Go to the documentation of this file.
2
3#include "ChiObjectFactory.h"
4
5namespace chi_mesh
6{
7
9
11{
13
14 params.SetDocGroup("LuaLogicVolumes");
15
16 params.AddOptionalParameter("r", 1.0, "Radius of the sphere.");
17 params.AddOptionalParameter("x", 0.0, "X-location of the volume.");
18 params.AddOptionalParameter("y", 0.0, "Y-location of the volume.");
19 params.AddOptionalParameter("z", 0.0, "Z-location of the volume.");
20
21 using namespace chi_data_types;
23 "r", AllowableRangeLowLimit::New(0.0, /*low_closed=*/false));
24
25 return params;
26}
27
29 const chi::InputParameters& params)
30 : LogicalVolume(params),
31 r_(params.GetParamValue<double>("r")),
32 x0_(params.GetParamValue<double>("x")),
33 y0_(params.GetParamValue<double>("y")),
34 z0_(params.GetParamValue<double>("z"))
35{
36}
37
39{
40 double dx = point.x - x0_;
41 double dy = point.y - y0_;
42 double dz = point.z - z0_;
43
44 double R2 = dx * dx + dy * dy + dz * dz;
45
46 if (R2 <= (r_ * r_)) return true;
47 else
48 return false;
49}
50
51} // namespace chi_mesh
static chi::InputParameters GetInputParameters()
Definition: ChiObject.cc:4
void SetDocGroup(const std::string &doc_group)
void ConstrainParameterRange(const std::string &param_name, AllowableRangePtr allowable_range)
void AddOptionalParameter(const std::string &name, T value, const std::string &doc_string)
static chi::InputParameters GetInputParameters()
bool Inside(const chi_mesh::Vector3 &point) const override
SphereLogicalVolume(const chi::InputParameters &params)
RegisterChiObject(chi_mesh, BooleanLogicalVolume)
double x
Element-0.
double y
Element-1.
double z
Element-2.