Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
tarun-mitruka committed Oct 10, 2024
1 parent 2b803be commit 3cbc683
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/src/testnonlineareas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using namespace Ikarus;
using Dune::TestSuite;

template <typename MAT>
auto cantileverBeamTest(const MAT& mat) {
auto cantileverBeamTest(const MAT& reducedMat) {
TestSuite t("Cantilever Beam for Nonlinear EAS element (Q1E4)");
constexpr int gridDim = 2;
using Grid = Dune::YaspGrid<gridDim>;
Expand All @@ -53,9 +53,8 @@ auto cantileverBeamTest(const MAT& mat) {
using namespace Dune::Functions::BasisFactory;
auto basis = Ikarus::makeBasis(gridView, power<2>(lagrange<1>(), FlatInterleaved()));

auto reducedMat = planeStress(mat, 1e-8);
auto sk = skills(nonLinearElastic(reducedMat), eas(4));
using FEType = decltype(makeFE(basis, sk));
auto sk = skills(nonLinearElastic(reducedMat), eas(4));
using FEType = decltype(makeFE(basis, sk));
std::vector<FEType> fes;

for (auto&& ge : elements(gridView)) {
Expand Down Expand Up @@ -88,22 +87,25 @@ auto cantileverBeamTest(const MAT& mat) {
Dune::FieldVector<double, gridDim> topRightPos{L, h};
const auto globalIndices = utils::globalIndexFromGlobalPosition(basis.flat(), topRightPos);
auto pointLoad = [&](const auto&, const auto& par, auto, auto, Eigen::VectorXd& vec) -> void {
auto loadFactor = par.parameter();
auto loadFactor = par.parameter();
vec[globalIndices[1]] -= loadFactor * 1.0;
};
sparseAssemblerAM->bind(pointLoad);

auto linSolver = LinearSolver(SolverTypeTag::sd_UmfPackLU);

AffordanceCollection elastoStaticsNoScalar(VectorAffordance::forces, MatrixAffordance::stiffness);

auto nonOp = NonLinearOperatorFactory::op(sparseAssemblerAM, elastoStaticsNoScalar, sparseAssemblerAM->dBCOption());

auto nrConfig = Ikarus::NewtonRaphsonConfig<decltype(linSolver)>{.linearSolver = linSolver};
auto nonLinearSolverObserver = std::make_shared<NonLinearSolverLogger>();
auto pathFollowingObserver = std::make_shared<ControlLogger>();
auto vtkWriter =
std::make_shared<ControlSubsamplingVertexVTKWriter<std::remove_cvref_t<decltype(basis.flat())>>>(basis.flat(), d);
vtkWriter->setFileNamePrefix("CantileverNonlinearEAS");
vtkWriter->setFieldInfo("Displacement", Dune::VTK::FieldInfo::Type::vector, 2);
NonlinearSolverFactory nrFactory(nrConfig);
auto nr = nrFactory.create(sparseAssemblerAM);
auto nr = createNonlinearSolver(nrConfig, nonOp);
auto lc = LoadControl(nr, 10, {0, 1});
nr->subscribeAll(nonLinearSolverObserver);
lc.subscribeAll({pathFollowingObserver, vtkWriter});
Expand Down Expand Up @@ -143,6 +145,6 @@ int main(int argc, char** argv) {
auto reducedMat = planeStress(matSVK);
easAutoDiffTest<2>(t, reducedMat);
easAutoDiffTest<3>(t, matSVK);
t.subTest(cantileverBeamTest(matSVK));
t.subTest(cantileverBeamTest(reducedMat));
return t.exit();
}

0 comments on commit 3cbc683

Please sign in to comment.