19using namespace std::string_literals;
26template <
short_t d,
typename T>
29 static_assert(
d >= 1 &&
d <= 3,
"Spatial dimension must be between 1 and 3");
39 gismo::gsBoundaryConditions<T>
bc_;
46 std::array<gismo::gsFunctionExpr<T>, 2 *
d>
bcFunc_;
49 std::array<gismo::condition_type::type, 2 * d>
bcType_;
64 assembler.options().setInt(
"MaterialLaw", gismo::material_law::hooke);
65 assembler.options().setInt(
"DirichletStrategy", gismo::dirichlet::elimination);
71 typename gismo::gsSparseSolver<T>::CGDiagonal
solver(
assembler.matrix());
85 const std::array<int64_t, d> ncoeffs,
86 const std::array<int64_t, d> npatches,
94 bcType_[
side - 1] = gismo::condition_type::unknownType;
95 bcFunc_[
side - 1] = gismo::give(gismo::gsFunctionExpr<T>(
"0",
"0",
"0", 3));
99 bc_.addCondition(0, gismo::boundary::west, gismo::condition_type::dirichlet,
101 bc_.addCondition(0, gismo::boundary::west, gismo::condition_type::dirichlet,
103 bc_.addCondition(0, gismo::boundary::west, gismo::condition_type::dirichlet,
106 bc_.addCondition(0, gismo::boundary::east, gismo::condition_type::neumann,
121 return "GismoLinearElasticity" + std::to_string(
d) +
"d";
126 return "G+Smo linear elasticity model in " + std::to_string(
d) +
141 "name" : "Displacement",
142 "description" : "Displament magnitude",
144 "name" : "Displacement_x",
145 "description" : "Displacement x-component",
147 "name" : "Displacement_y",
148 "description" : "Displacement x-component",
150 "name" : "Displacement_z",
151 "description" : "Displacement z-component",
163 auto json = nlohmann::json::array();
168 const std::string &name,
const std::string &
label,
169 const std::string &
group,
171 const Value &value) {
178 item[
"value"] = value;
179 item[
"default"] = value;
187 const std::string &name,
const std::string &
label,
197 item[
"value"] = value;
203 add_json(
"YoungModulus",
"Young",
"",
"Young's modulus",
"float",
205 add_json(
"PoissonRatio",
"Poisson",
"",
"Poisson's ratio",
"float",
221 const nlohmann::json &
json)
override {
226 if (!
json.contains(
"data"))
235 if (!
json.contains(
"data"))
254 const nlohmann::json &
json)
const override {
262 return R
"({ INVALID REQUEST })"_json;
273 result[
"degrees"] = nlohmann::json::array();
279 result[
"ncoeffs"] = nlohmann::json::array();
283 for (std::size_t
i = 0;
i <
bspline->parDim(); ++
i)
285 else if (
auto bspline =
dynamic_cast<const gismo::gsTensorBSpline<d, T> *
>(
287 for (std::size_t
i = 0;
i <
bspline->parDim(); ++
i)
290 return R
"({ INVALID REQUEST })"_json;
293 result[
"nknots"] = nlohmann::json::array();
297 for (std::size_t
i = 0;
i <
bspline->parDim(); ++
i)
299 else if (
auto bspline =
dynamic_cast<const gismo::gsTensorBSpline<d, T> *
>(
301 for (std::size_t
i = 0;
i <
bspline->parDim(); ++
i)
304 return R
"({ INVALID REQUEST })"_json;
307 result[
"knots"] = nlohmann::json::array();
311 for (std::size_t
i = 0;
i <
bspline->parDim(); ++
i)
313 else if (
auto bspline =
dynamic_cast<const gismo::gsTensorBSpline<d, T> *
>(
315 for (std::size_t
i = 0;
i <
bspline->parDim(); ++
i)
318 return R
"({ INVALID REQUEST })"_json;
321 gismo::gsMatrix<T> coeffs;
324 }
else if (
component ==
"Displacement_x") {
326 }
else if (
component ==
"Displacement_y") {
328 }
else if (
component ==
"Displacement_z") {
345 if (
json.contains(
"data"))
359 if (
json.contains(
"data")) {
361 num =
json[
"data"][
"num"].get<
int>();
385 if (
json.contains(
"data"))
399 if (
json.contains(
"data")) {
401 num =
json[
"data"][
"num"].get<
int>();
425 if (
json.contains(
"data"))
439 if (
json.contains(
"data")) {
441 num =
json[
"data"][
"num"].get<
int>();
469 throw std::runtime_error(
"Adding patches is not yet implemented in G+Smo");
477 const nlohmann::json &
json =
NULL)
override {
487 if (
json.contains(
"data")) {
virtual void addPatch(const nlohmann::json &json)=0
Adds a patch to a model.
virtual void elevate(const nlohmann::json &json)=0
Elevates the model's degrees, preserves smoothness.
virtual nlohmann::json eval(const std::string &patch, const std::string &component, const nlohmann::json &json) const =0
Evaluates model.
virtual nlohmann::json getOutputs() const =0
Returns the model's outputs.
virtual nlohmann::json getOptions() const =0
Returns the model's options.
virtual nlohmann::json updateAttribute(const std::string &patch, const std::string &component, const std::string &attribute, const nlohmann::json &json)
Updates the attributes of the model.
Definition model.hpp:297
virtual void increase(const nlohmann::json &json)=0
Increases the model's degrees, preserves multiplicity.
virtual void refine(const nlohmann::json &json)=0
Refines model.
virtual void removePatch(const std::string &patch, const nlohmann::json &json)=0
Adds a patch to a model.
gismo::gsMultiPatch< T > geo_
Multi-patch geometry.
Definition GismoGeometryModel.hpp:39
G+Smo Linear elasticity model.
Definition GismoLinearElasticityModel.hpp:27
void refine(const nlohmann::json &json=NULL) override
Refines the model.
Definition GismoLinearElasticityModel.hpp:421
nlohmann::json getParameters() const override
Returns the model's parameters.
Definition GismoLinearElasticityModel.hpp:161
void solve()
Solve the Linear elasticity problem.
Definition GismoLinearElasticityModel.hpp:58
std::array< gismo::condition_type::type, 2 *d > bcType_
Boundary condition type.
Definition GismoLinearElasticityModel.hpp:49
std::array< gismo::gsFunctionExpr< T >, 2 *d > bcFunc_
Boundary condition values.
Definition GismoLinearElasticityModel.hpp:46
gismo::gsFunctionExpr< T > loadFunc_
Definition GismoLinearElasticityModel.hpp:43
GismoLinearElasticityModel(const std::array< short_t, d > degrees, const std::array< int64_t, d > ncoeffs, const std::array< int64_t, d > npatches, const std::array< T, d > dimensions)
Constructor for equidistant knot vectors.
Definition GismoLinearElasticityModel.hpp:84
nlohmann::json updateAttribute(const std::string &patch, const std::string &component, const std::string &attribute, const nlohmann::json &json) override
Updates the attributes of the model.
Definition GismoLinearElasticityModel.hpp:218
std::string getDescription() const override
Returns the model's description.
Definition GismoLinearElasticityModel.hpp:125
gismo::gsBoundaryConditions< T > bc_
Boundary conditions.
Definition GismoLinearElasticityModel.hpp:39
gismo::gsMultiBasis< T > basis_
Multi-patch basis.
Definition GismoLinearElasticityModel.hpp:36
void increase(const nlohmann::json &json=NULL) override
Increases the model's degrees, preserves multiplicity.
Definition GismoLinearElasticityModel.hpp:381
T YoungsModulus_
Young's modulus.
Definition GismoLinearElasticityModel.hpp:52
nlohmann::json getOutputs() const override
Returns the model's outputs.
Definition GismoLinearElasticityModel.hpp:139
nlohmann::json eval(const std::string &patch, const std::string &component, const nlohmann::json &json) const override
Evaluates the model.
Definition GismoLinearElasticityModel.hpp:253
void addPatch(const nlohmann::json &json=NULL) override
Add new patch to the model.
Definition GismoLinearElasticityModel.hpp:461
std::string getName() const override
Returns the model's name.
Definition GismoLinearElasticityModel.hpp:120
T PoissonsRatio_
Poisson's ratio.
Definition GismoLinearElasticityModel.hpp:55
void removePatch(const std::string &patch, const nlohmann::json &json=NULL) override
Remove existing patch from the model.
Definition GismoLinearElasticityModel.hpp:476
nlohmann::json getOptions() const override
Returns the model's options.
Definition GismoLinearElasticityModel.hpp:131
GismoLinearElasticityModel()=delete
Default constructor.
~GismoLinearElasticityModel()
Destructor.
Definition GismoLinearElasticityModel.hpp:117
void elevate(const nlohmann::json &json=NULL) override
Elevates the model's degrees, preserves smoothness.
Definition GismoLinearElasticityModel.hpp:341
gismo::gsFunctionExpr< T > rhsFunc_
Right-hand side function.
Definition GismoLinearElasticityModel.hpp:42
G+Smo PDE model.
Definition GismoPdeModel.hpp:58
gismo::gsMultiPatch< T > solution_
Solution.
Definition GismoPdeModel.hpp:190
auto to_json(const torch::TensorAccessor< T, N > &accessor)
Converts a torch::TensorAccessor object to a JSON object.
Definition serialize.hpp:41
degree
Enumerator for specifying the degree of B-splines.
Definition BSplineModel.hpp:23
Definition boundary.hpp:22
constexpr bool is_SplineType_v
Alias to the value of is_SplineType.
Definition bspline.hpp:3243
side
Identifiers for topological sides.
Definition boundary.hpp:25
InvalidModelAttribute exception.
Definition model.hpp:42