Skip to content
Snippets Groups Projects
Commit c7725ec6 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Populate restrictions: on demand -> construction

parent 64b2b29a
No related branches found
No related tags found
No related merge requests found
...@@ -26,55 +26,30 @@ class GlobalRuinaNonlinearity ...@@ -26,55 +26,30 @@ class GlobalRuinaNonlinearity
GlobalRuinaNonlinearity(dataptr nodalIntegrals, dataptr a, dataptr mu, GlobalRuinaNonlinearity(dataptr nodalIntegrals, dataptr a, dataptr mu,
dataptr eta, dataptr normalStress, dataptr b, dataptr eta, dataptr normalStress, dataptr b,
dataptr state, dataptr L, double h) dataptr state, dataptr L, double h)
: nodalIntegrals(nodalIntegrals), // TODO: can we get the size from another place?
a(a), : restrictions(nodalIntegrals->size()) {
mu(mu), auto trivialNonlinearity = make_shared<LocalNonlinearity<dim> const>(
eta(eta), make_shared<TrivialFunction const>());
normalStress(normalStress), for (size_t i = 0; i < restrictions.size(); ++i) {
b(b), restrictions[i] =
state(state), (*nodalIntegrals)[i] == 0
L(L), ? trivialNonlinearity
h(h), : make_shared<LocalNonlinearity<dim> const>(
trivialNonlinearity( make_shared<RuinaFunction const>(
new LocalNonlinearity<dim>(make_shared<TrivialFunction const>())), (*nodalIntegrals)[i], (*a)[i], (*mu)[i], (*eta)[i],
restrictions(nodalIntegrals->size()) // TODO: can we get the size from (*normalStress)[i], (*b)[i], (*state)[i], (*L)[i], h));
// another place? }
{
for (auto &x : restrictions)
x = shared_ptr<LocalNonlinearity<dim> const>();
} }
/* /*
Return a restriction of the outer function to the i'th node. Return a restriction of the outer function to the i'th node.
*/ */
virtual shared_ptr<LocalNonlinearity<dim> const> restriction(int i) const { virtual shared_ptr<LocalNonlinearity<dim> const> restriction(int i) const {
if ((*nodalIntegrals)[i] == 0)
return trivialNonlinearity;
if (restrictions[i] != nullptr)
return restrictions[i];
auto const func = make_shared<RuinaFunction const>(
(*nodalIntegrals)[i], (*a)[i], (*mu)[i], (*eta)[i], (*normalStress)[i],
(*b)[i], (*state)[i], (*L)[i], h);
restrictions[i] = make_shared<LocalNonlinearity<dim> const>(func);
return restrictions[i]; return restrictions[i];
} }
private: private:
dataptr nodalIntegrals; std::vector<shared_ptr<LocalNonlinearity<dim> const>> restrictions;
dataptr a;
dataptr mu;
dataptr eta;
dataptr normalStress;
dataptr b;
dataptr state;
dataptr L;
double const h;
shared_ptr<LocalNonlinearity<dim> const> const trivialNonlinearity;
std::vector<shared_ptr<LocalNonlinearity<dim> const>> mutable restrictions;
}; };
} }
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment