51 if (formulation ==
"Helmholtz")
52 return std::make_shared<Helmholtz>();
53 else if (formulation ==
"Laplacian")
54 return std::make_shared<Laplacian>();
55 else if (formulation ==
"Bilaplacian")
56 return std::make_shared<BilaplacianMain>();
57 else if (formulation ==
"BilaplacianAux")
58 return std::make_shared<BilaplacianAux>();
60 else if (formulation ==
"LinearElasticity")
61 return std::make_shared<LinearElasticity>();
62 else if (formulation ==
"HookeLinearElasticity")
63 return std::make_shared<HookeLinearElasticity>();
64 else if (formulation ==
"IncompressibleLinearElasticity")
65 return std::make_shared<IncompressibleLinearElasticityDispacement>();
66 else if (formulation ==
"IncompressibleLinearElasticityPressure")
67 return std::make_shared<IncompressibleLinearElasticityPressure>();
69 else if (formulation ==
"SaintVenant")
70 return std::make_shared<SaintVenantElasticity>();
71 else if (formulation ==
"NeoHookean")
72 return std::make_shared<NeoHookeanElasticity>();
73 else if (formulation ==
"MooneyRivlin")
74 return std::make_shared<MooneyRivlinElasticity>();
75 else if (formulation ==
"MooneyRivlin3Param")
76 return std::make_shared<MooneyRivlin3ParamElasticity>();
77 else if (formulation ==
"MooneyRivlin3ParamSymbolic")
78 return std::make_shared<MooneyRivlin3ParamSymbolic>();
79 else if (formulation ==
"MultiModels")
80 return std::make_shared<MultiModel>();
81 else if (formulation ==
"UnconstrainedOgden")
82 return std::make_shared<UnconstrainedOgdenElasticity>();
83 else if (formulation ==
"IncompressibleOgden")
84 return std::make_shared<IncompressibleOgdenElasticity>();
86 else if (formulation ==
"Stokes")
87 return std::make_shared<StokesVelocity>();
88 else if (formulation ==
"StokesPressure")
89 return std::make_shared<StokesPressure>();
90 else if (formulation ==
"NavierStokes")
91 return std::make_shared<NavierStokesVelocity>();
92 else if (formulation ==
"OperatorSplitting")
93 return std::make_shared<OperatorSplitting>();
95 else if (formulation ==
"AMIPS")
96 return std::make_shared<AMIPSEnergy>();
97 else if (formulation ==
"AMIPSAutodiff")
98 return std::make_shared<AMIPSEnergyAutodiff>();
99 else if (formulation ==
"FixedCorotational")
100 return std::make_shared<FixedCorotational>();
118 const int n_bases,
const int n_pressure_bases,
const int problem_dim,
const bool add_average,
122 assert(velocity_stiffness.rows() == velocity_stiffness.cols());
123 assert(velocity_stiffness.rows() == n_bases * problem_dim);
125 assert(mixed_stiffness.size() == 0 || mixed_stiffness.rows() == n_bases * problem_dim);
126 assert(mixed_stiffness.size() == 0 || mixed_stiffness.cols() == n_pressure_bases);
128 assert(pressure_stiffness.size() == 0 || pressure_stiffness.rows() == n_pressure_bases);
129 assert(pressure_stiffness.size() == 0 || pressure_stiffness.cols() == n_pressure_bases);
131 const int avg_offset = add_average ? 1 : 0;
133 std::vector<Eigen::Triplet<double>> blocks;
134 blocks.reserve(velocity_stiffness.nonZeros() + 2 * mixed_stiffness.nonZeros() + pressure_stiffness.nonZeros() + 2 * avg_offset * velocity_stiffness.rows());
136 for (
int k = 0; k < velocity_stiffness.outerSize(); ++k)
138 for (StiffnessMatrix::InnerIterator it(velocity_stiffness, k); it; ++it)
140 blocks.emplace_back(it.row(), it.col(), it.value());
144 for (
int k = 0; k < mixed_stiffness.outerSize(); ++k)
146 for (StiffnessMatrix::InnerIterator it(mixed_stiffness, k); it; ++it)
148 blocks.emplace_back(it.row(), n_bases * problem_dim + it.col(), it.value());
149 blocks.emplace_back(it.col() + n_bases * problem_dim, it.row(), it.value());
153 for (
int k = 0; k < pressure_stiffness.outerSize(); ++k)
155 for (StiffnessMatrix::InnerIterator it(pressure_stiffness, k); it; ++it)
157 blocks.emplace_back(n_bases * problem_dim + it.row(), n_bases * problem_dim + it.col(), it.value());
163 const double val = 1.0 / n_pressure_bases;
164 for (
int i = 0; i < n_pressure_bases; ++i)
166 blocks.emplace_back(n_bases * problem_dim + i, n_bases * problem_dim + n_pressure_bases,
val);
167 blocks.emplace_back(n_bases * problem_dim + n_pressure_bases, n_bases * problem_dim + i,
val);
171 stiffness.resize(n_bases * problem_dim + n_pressure_bases + avg_offset, n_bases * problem_dim + n_pressure_bases + avg_offset);
172 stiffness.setFromTriplets(blocks.begin(), blocks.end());
173 stiffness.makeCompressed();
185 if (assembler ==
"Mass")
189 return std::max(basis_degree * 2, 1);
191 return basis_degree * 2 + 1;
193 else if (assembler ==
"NavierStokes")
196 return std::max((basis_degree - 1) + basis_degree, 1);
198 return std::max(basis_degree * 2, 1);
200 return basis_degree * 2 + 1;
207 return std::max((basis_degree - 1) * 2, 1);
217 return std::max(basis_degree * 2, 1);
220 return (basis_degree - 1) * 2 + 1;
static int quadrature_order(const std::string &assembler, const int basis_degree, const BasisType &b_type, const int dim)
utility for retrieving the needed quadrature order to precisely integrate the given form on the given...
static void merge_mixed_matrices(const int n_bases, const int n_pressure_bases, const int problem_dim, const bool add_average, const StiffnessMatrix &velocity_stiffness, const StiffnessMatrix &mixed_stiffness, const StiffnessMatrix &pressure_stiffness, StiffnessMatrix &stiffness)
utility to merge 3 blocks of mixed matrices, A=velocity_stiffness, B=mixed_stiffness,...