Page MenuHomec4science

test_structural_mechanics_model_fixture.hh
No OneTemporary

File Metadata

Created
Wed, Jun 19, 10:54

test_structural_mechanics_model_fixture.hh

/* -------------------------------------------------------------------------- */
#include "element_class_structural.hh"
#include "structural_mechanics_model.hh"
#include "test_gtest_utils.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <vector>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TEST_STRUCTURAL_MECHANICS_MODEL_FIXTURE_HH__
#define __AKANTU_TEST_STRUCTURAL_MECHANICS_MODEL_FIXTURE_HH__
using namespace akantu;
template <typename type_> class TestStructuralFixture : public ::testing::Test {
public:
static constexpr const ElementType type = type_::value;
static constexpr const size_t spatial_dimension =
ElementClass<type>::getSpatialDimension();
static const UInt ndof = ElementClass<type>::getNbDegreeOfFreedom();
void SetUp() override {
const auto spatial_dimension = this->spatial_dimension;
mesh = std::make_unique<Mesh>(spatial_dimension);
readMesh(makeMeshName());
std::stringstream element_type;
element_type << this->type;
model = std::make_unique<StructuralMechanicsModel>(*mesh, _all_dimensions,
element_type.str());
addMaterials();
model->initFull();
assignMaterials();
setDirichlets();
setNeumanns();
model->solveStep();
}
virtual void readMesh(std::string filename) {
mesh->read(filename, _miot_gmsh_struct);
}
virtual std::string makeMeshName() {
std::stringstream element_type;
element_type << type;
SCOPED_TRACE(element_type.str().c_str());
return element_type.str() + ".msh";
}
void TearDown() override {
model.reset(nullptr);
mesh.reset(nullptr);
}
virtual void addMaterials() = 0;
virtual void assignMaterials() = 0;
virtual void setDirichlets() = 0;
virtual void setNeumanns() = 0;
protected:
std::unique_ptr<Mesh> mesh;
std::unique_ptr<StructuralMechanicsModel> model;
};
template <typename type_>
constexpr ElementType TestStructuralFixture<type_>::type;
template <typename type_>
constexpr size_t TestStructuralFixture<type_>::spatial_dimension;
template <typename type_> const UInt TestStructuralFixture<type_>::ndof;
// using types = gtest_list_t<StructuralTestElementTypes>;
// TYPED_TEST_CASE(TestStructuralFixture, types);
#endif /* __AKANTU_TEST_STRUCTURAL_MECHANICS_MODEL_FIXTURE_HH__ */

Event Timeline