Skip to content

Commit

Permalink
Fixed bug with pvd file output by adding virtual destructor to module…
Browse files Browse the repository at this point in the history
… system
  • Loading branch information
dbeurle committed Sep 28, 2017
1 parent 7e9fb85 commit 23b3af0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/SimulationControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void SimulationControl::build_simulation_tree()
std::cout << std::string(4, ' ') << "Simulation \"" << name << "\" is continued by:\n";
for (auto const& item : queue)
{
std::cout << "\t\"" << item["Name"].asString() << "\"" << std::endl;
std::cout << std::string(4, ' ') << "\"" << item["Name"].asString() << "\"" << std::endl;
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/assembler/diffusion/femDynamicMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ femDynamicMatrix::femDynamicMatrix(femMesh& fem_mesh, Json::Value const& simulat
d = 250.0 * Vector::Ones(fem_mesh.active_dofs());
}

femDynamicMatrix::~femDynamicMatrix() { std::cout << "Dtor femdynamicmatrix" << std::endl; }

void femDynamicMatrix::solve()
{
// Perform time dependent solution
Expand Down
2 changes: 0 additions & 2 deletions src/assembler/diffusion/femDynamicMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class femDynamicMatrix : public femStaticMatrix
public:
explicit femDynamicMatrix(femMesh& fem_mesh, Json::Value const& simulation_data);

~femDynamicMatrix();

void solve() override final;

protected:
Expand Down
20 changes: 5 additions & 15 deletions src/io/FileIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace neon
FileIO::FileIO(std::string file_name, Json::Value const& visualisation_data)
: file_name(file_name), unstructured_mesh(vtkSmartPointer<vtkUnstructuredGrid>::New())
{
std::cout << "Parent ctor" << std::endl;

if (visualisation_data.isMember("WriteEvery"))
{
write_every = visualisation_data["WriteEvery"].asInt();
Expand All @@ -44,7 +42,7 @@ FileIO::FileIO(std::string file_name, Json::Value const& visualisation_data)

pvd_file << "<?xml version=\"1.0\"?>\n";
pvd_file << "<VTKFile type=\"Collection\" version=\"0.1\">\n";
pvd_file << std::string(2, ' ') << "<Collection>" << std::endl;
pvd_file << std::string(2, ' ') << "<Collection>\n";

unstructured_mesh->Allocate();

Expand All @@ -59,11 +57,9 @@ FileIO::FileIO(std::string file_name, Json::Value const& visualisation_data)

FileIO::~FileIO()
{
std::cout << "Calling parent dtor" << std::endl;

// Close off the last of the file for the timestepping
pvd_file << std::string(2, ' ') << "</Collection>\n"
<< "</VTKFile>" << std::endl;
<< "</VTKFile>\n";
pvd_file.close();
}

Expand All @@ -85,8 +81,7 @@ void FileIO::write_to_file(int const time_step, double const total_time)

// Update the pvd file for timestep mapping
pvd_file << std::string(4, ' ') << "<DataSet timestep = \"" << std::to_string(total_time)
<< "\" file = \"" << file_name << "_" << std::to_string(time_step) << ".vtu\" />"
<< std::endl;
<< "\" file = \"" << file_name << "_" << std::to_string(time_step) << ".vtu\" />\n";
}

void FileIO::add_field(std::string const& name, Vector const& field, int const components)
Expand Down Expand Up @@ -214,7 +209,6 @@ namespace diffusion
FileIO::FileIO(std::string file_name, Json::Value const& visualisation_data, femMesh const& fem_mesh)
: neon::FileIO(file_name, visualisation_data), fem_mesh(fem_mesh)
{
std::cout << "ctor diffusion" << std::endl;
// Check the output set against the known values for this module
for (auto const& output : output_set)
{
Expand All @@ -227,18 +221,14 @@ FileIO::FileIO(std::string file_name, Json::Value const& visualisation_data, fem
add_mesh();
}

void FileIO::write(int const time_step, double const total_time, Vector const& temperature)
void FileIO::write(int const time_step, double const total_time, Vector const& scalars)
{
if (time_step % write_every != 0) return;

// Write out the required fields
for (auto const& name : output_set)
{
if (name == primary_field)
{
std::cout << "Writing out " << primary_field << std::endl;
add_field(primary_field, temperature, 1);
}
if (name == primary_field) add_field(primary_field, scalars, 1);
}
write_to_file(time_step, total_time);
}
Expand Down
2 changes: 2 additions & 0 deletions src/modules/AbstractModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class AbstractModule
public:
virtual void perform_simulation() = 0;

virtual ~AbstractModule() = default;

protected:
std::map<std::string, std::vector<Json::Value>> multistep_simulations;
};
Expand Down
10 changes: 6 additions & 4 deletions src/modules/LinearDiffusionModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ template <typename femMatrix_Tp>
class LinearDiffusionModule : public AbstractModule
{
public:
LinearDiffusionModule(BasicMesh const& mesh,
Json::Value const& material,
Json::Value const& simulation)
explicit LinearDiffusionModule(BasicMesh const& mesh,
Json::Value const& material,
Json::Value const& simulation)
: fem_mesh(mesh, material, simulation["Mesh"][0]), fem_matrix(fem_mesh, simulation)
{
}

virtual void perform_simulation() override final { fem_matrix.solve(); }
virtual ~LinearDiffusionModule() = default;

void perform_simulation() override final { fem_matrix.solve(); }

protected:
diffusion::femMesh fem_mesh;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/SolidMechanicsModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SolidMechanicsModule : public AbstractModule
Json::Value const& material,
Json::Value const& simulation);

~SolidMechanicsModule() = default;
virtual ~SolidMechanicsModule() = default;

SolidMechanicsModule(SolidMechanicsModule const&) = delete;

Expand Down

0 comments on commit 23b3af0

Please sign in to comment.