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

Use make_shared; use blockvectors

parent 18d76394
No related branches found
No related tags found
No related merge requests found
......@@ -19,9 +19,9 @@ template <int dim, class OuterFunctionType>
class GlobalLaursenNonlinearity : public GlobalNonlinearity<dim> {
public:
GlobalLaursenNonlinearity(
shared_ptr<std::vector<double> const> mu,
shared_ptr<std::vector<double> const> normalStress,
shared_ptr<std::vector<FieldVector<double, 1>> const> nodalIntegrals)
shared_ptr<BlockVector<FieldVector<double, 1>> const> mu,
shared_ptr<BlockVector<FieldVector<double, 1>> const> normalStress,
shared_ptr<BlockVector<FieldVector<double, 1>> const> nodalIntegrals)
: mu(mu), normalStress(normalStress), nodalIntegrals(nodalIntegrals) {}
/*
......@@ -43,18 +43,16 @@ class GlobalLaursenNonlinearity : public GlobalNonlinearity<dim> {
coefficient *= (*normalStress)[i];
coefficient *= 1 + (*mu)[i];
shared_ptr<NiceFunction const> const func(
new OuterFunctionType(coefficient));
return shared_ptr<LocalNonlinearity<dim> const>(
new LocalNonlinearity<dim>(func));
return make_shared<LocalNonlinearity<dim> const>(
make_shared<OuterFunctionType const>(coefficient));
}
private:
// TODO: If we're clever, we only store one vector with the precomputed
// results
shared_ptr<std::vector<double> const> mu;
shared_ptr<std::vector<double> const> normalStress;
shared_ptr<std::vector<FieldVector<double, 1>> const> nodalIntegrals;
shared_ptr<BlockVector<FieldVector<double, 1>> const> mu;
shared_ptr<BlockVector<FieldVector<double, 1>> const> normalStress;
shared_ptr<BlockVector<FieldVector<double, 1>> const> nodalIntegrals;
};
}
#endif
......@@ -19,11 +19,11 @@ template <int dim>
class GlobalRuinaNonlinearity : public GlobalNonlinearity<dim> {
public:
GlobalRuinaNonlinearity(
shared_ptr<std::vector<FieldVector<double, 1>> const> nodalIntegrals,
shared_ptr<std::vector<double> const> a,
shared_ptr<std::vector<double> const> mu,
shared_ptr<std::vector<double> const> eta,
shared_ptr<std::vector<double> const> normalStress)
shared_ptr<BlockVector<FieldVector<double, 1>> const> nodalIntegrals,
shared_ptr<BlockVector<FieldVector<double, 1>> const> a,
shared_ptr<BlockVector<FieldVector<double, 1>> const> mu,
shared_ptr<BlockVector<FieldVector<double, 1>> const> eta,
shared_ptr<BlockVector<FieldVector<double, 1>> const> normalStress)
: nodalIntegrals(nodalIntegrals),
a(a),
mu(mu),
......@@ -40,19 +40,19 @@ class GlobalRuinaNonlinearity : public GlobalNonlinearity<dim> {
return trivialNonlinearity;
shared_ptr<NiceFunction const> const func(
new RuinaFunction((*nodalIntegrals)[i][0], (*a)[i], (*mu)[i], (*eta)[i],
(*normalStress)[i]));
new RuinaFunction((*nodalIntegrals)[i][0], (*a)[i][0], (*mu)[i][0],
(*eta)[i][0], (*normalStress)[i][0]));
return shared_ptr<LocalNonlinearity<dim>>(new LocalNonlinearity<dim>(func));
}
private:
shared_ptr<LocalNonlinearity<dim> const> const trivialNonlinearity;
shared_ptr<std::vector<FieldVector<double, 1>> const> nodalIntegrals;
shared_ptr<std::vector<double> const> a;
shared_ptr<std::vector<double> const> mu;
shared_ptr<std::vector<double> const> eta;
shared_ptr<std::vector<double> const> normalStress;
shared_ptr<BlockVector<FieldVector<double, 1>> const> nodalIntegrals;
shared_ptr<BlockVector<FieldVector<double, 1>> const> a;
shared_ptr<BlockVector<FieldVector<double, 1>> const> mu;
shared_ptr<BlockVector<FieldVector<double, 1>> const> eta;
shared_ptr<BlockVector<FieldVector<double, 1>> const> normalStress;
};
}
#endif
......@@ -121,7 +121,7 @@ template <class GridType, class GridView, class LocalVectorType, class FEBasis>
void assemble_frictional(
GridView const &gridView, FEBasis const &feBasis,
Dune::BitSetVector<1> const &frictionalNodes,
std::vector<Dune::FieldVector<double, 1>> &nodalIntegrals) {
Dune::BlockVector<Dune::FieldVector<double, 1>> &nodalIntegrals) {
BoundaryPatch<GridView> frictionalBoundary(gridView, frictionalNodes);
ConstantFunction<LocalVectorType, Dune::FieldVector<double, 1>>
constantOneFunction(1);
......@@ -138,42 +138,36 @@ void assemble_frictional(
void assemble_nonlinearity(
int size, Dune::ParameterTree const &parset,
Dune::shared_ptr<Dune::GlobalNonlinearity<dim> const> &myGlobalNonlinearity,
Dune::shared_ptr<std::vector<Dune::FieldVector<double, 1>>>
Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>>
nodalIntegrals) {
// {{{ Assemble terms for the nonlinearity
auto mu = Dune::shared_ptr<std::vector<double>>(new std::vector<double>());
mu->resize(size);
std::fill(mu->begin(), mu->end(), parset.get<double>("boundary.friction.mu"));
auto mu =
Dune::make_shared<Dune::BlockVector<Dune::FieldVector<double, 1>>>(size);
*mu = parset.get<double>("boundary.friction.mu");
auto normalStress =
Dune::shared_ptr<std::vector<double>>(new std::vector<double>());
normalStress->resize(size);
std::fill(normalStress->begin(), normalStress->end(),
parset.get<double>("boundary.friction.normalstress"));
Dune::make_shared<Dune::BlockVector<Dune::FieldVector<double, 1>>>(size);
*normalStress = parset.get<double>("boundary.friction.normalstress");
std::string const friction_model =
parset.get<std::string>("boundary.friction.model");
if (friction_model == std::string("Ruina")) {
auto a = Dune::shared_ptr<std::vector<double>>(new std::vector<double>());
a->resize(size);
std::fill(a->begin(), a->end(),
parset.get<double>("boundary.friction.ruina.a"));
auto eta = Dune::shared_ptr<std::vector<double>>(new std::vector<double>());
eta->resize(size);
std::fill(eta->begin(), eta->end(),
parset.get<double>("boundary.friction.eta"));
auto const tmp = new Dune::GlobalRuinaNonlinearity<dim>(
nodalIntegrals, a, mu, eta, normalStress);
auto a = Dune::make_shared<Dune::BlockVector<Dune::FieldVector<double, 1>>>(
size);
*a = parset.get<double>("boundary.friction.ruina.a");
auto eta =
Dune::make_shared<Dune::BlockVector<Dune::FieldVector<double, 1>>>(
size);
*eta = parset.get<double>("boundary.friction.eta");
myGlobalNonlinearity =
Dune::shared_ptr<Dune::GlobalNonlinearity<dim> const>(tmp);
Dune::make_shared<Dune::GlobalRuinaNonlinearity<dim> const>(
nodalIntegrals, a, mu, eta, normalStress);
} else if (friction_model == std::string("Laursen")) {
auto const tmp =
new Dune::GlobalLaursenNonlinearity<dim, Dune::LinearFunction>(
mu, normalStress, nodalIntegrals);
myGlobalNonlinearity =
Dune::shared_ptr<Dune::GlobalNonlinearity<dim> const>(tmp);
myGlobalNonlinearity = Dune::make_shared<
Dune::GlobalLaursenNonlinearity<dim, Dune::LinearFunction> const>(
mu, normalStress, nodalIntegrals);
} else {
assert(false);
}
......@@ -263,8 +257,7 @@ int main(int argc, char *argv[]) {
VectorType b3;
auto nodalIntegrals =
Dune::shared_ptr<std::vector<Dune::FieldVector<double, 1>>>(
new std::vector<Dune::FieldVector<double, 1>>);
Dune::make_shared<Dune::BlockVector<Dune::FieldVector<double, 1>>>();
assemble_frictional<GridType, GridView, SmallVector, P1Basis>(
leafView, p1Basis, frictionalNodes, *nodalIntegrals);
......@@ -310,12 +303,13 @@ int main(int argc, char *argv[]) {
Dune::VTKWriter<GridView> writer(leafView);
std::string filename((boost::format("obs%d") % run).str());
Dune::shared_ptr<VTKBasisGridFunction<P1Basis, VectorType>>
displacement_ptr(new VTKBasisGridFunction<P1Basis, VectorType>(
p1Basis, u1, "displacement"));
Dune::shared_ptr<VTKBasisGridFunction<P0Basis, CellVectorType>>
vonmises_ptr(new VTKBasisGridFunction<P0Basis, CellVectorType>(
p0Basis, vonMisesStress, "stress"));
auto displacement_ptr =
Dune::make_shared<VTKBasisGridFunction<P1Basis, VectorType>>(
p1Basis, u1, "displacement");
auto vonmises_ptr =
Dune::make_shared<VTKBasisGridFunction<P0Basis, CellVectorType>>(
p0Basis, vonMisesStress, "stress");
writer.addVertexData(displacement_ptr);
writer.addCellData(vonmises_ptr);
writer.write(filename.c_str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment