Page MenuHomec4science

test_computeTemp.cc
No OneTemporary

File Metadata

Created
Sat, Nov 9, 15:44

test_computeTemp.cc

#include "my_types.hh"
#include "fft.hh"
#include "material_point.hh"
#include "compute_temperature.hh"
#include <gtest/gtest.h>
/*****************************************************************/
// Fixture class
class material : public ::testing::Test {
protected:
void SetUp() override {
std::vector<MaterialPoint> points;
for(int i = 0; i < size*size; i++) {
MaterialPoint p;
Vector position;
position[0] = (i % size) * (2.0 / size);
position[1] = int(i / size) * (2.0 / size);
position[2] = 0;
p.getPosition() = position;
p.getTemperature() = 0.0;
p.getHeatRate() = 0.0;
points.push_back(p);
}
for (auto& p : points) {
system.addParticle(std::make_shared<MaterialPoint>(p));
}
computeTemp = std::make_shared<ComputeTemperature>();
}
int size = 10;
System system;
std::shared_ptr<ComputeTemperature> computeTemp;
};
/*****************************************************************/
TEST_F(material, uniformInit) {
computeTemp->compute(system);
for (int i = 0; i < size * size; i++) {
auto& p = static_cast<MaterialPoint&>(system.getParticle(i));
ASSERT_NEAR(p.getTemperature(), 0.0, 1e-15);
}
}

Event Timeline