Skip to content

Commit

Permalink
mesh_helper and unstructured_mesh
Browse files Browse the repository at this point in the history
In this commit the mesh_helper and unstructured_mesh header is made common for 2D and 3D case.

The test_3d_unstructured_mesh_reader test case is removed to avoid repetation.
  • Loading branch information
Yashmandaokar committed Apr 18, 2024
1 parent 64a0a75 commit 708710c
Show file tree
Hide file tree
Showing 19 changed files with 503 additions and 136,077 deletions.
335 changes: 335 additions & 0 deletions src/for_2D_build/bodies/mesh_helper.cpp

Large diffs are not rendered by default.

400 changes: 39 additions & 361 deletions src/for_2D_build/bodies/unstructured_mesh.cpp

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef MESHTYPE_H
#define MESHTYPE_H

#include "unstructured_mesh_3d.h"
#include "unstructured_mesh.h"
using namespace std;
namespace SPH
{
Expand All @@ -45,40 +45,39 @@ namespace SPH

static void meshDimension(ifstream& mesh_file, size_t& dimension, string& text_line);
static void numberofNodes(ifstream& mesh_file, size_t& number_of_points, string& text_line);
static void nodeCoordinates(ifstream& mesh_file, size_t& node_index, vector<vector<Real>> & node_coordinates_, string& text_line,
size_t& dimension, vector<vector<Real>>& point_coordinates);
static void nodeCoordinates(ifstream& mesh_file, StdLargeVec<Vecd>& node_coordinates_, string& text_line,size_t& dimension);
static void numberofElements(ifstream& mesh_file, size_t& number_of_elements, string& text_line);
static void dataStruct(vector<vector<vector<size_t>>>& mesh_topology_, vector<vector<size_t>>& elements_nodes_connection_,
size_t number_of_elements, size_t mesh_type, size_t dimension, StdLargeVec<Vecd>& elements_neighbors_connection_);
static void dataStruct(vector<vector<vector<size_t>>>& mesh_topology_, StdLargeVec<StdVec<size_t>>& elements_nodes_connection_,
size_t number_of_elements, size_t mesh_type, size_t dimension);
static size_t findBoundaryType(string& text_line, size_t boundary_type);
static Vecd nodeIndex(string& text_line);
static Vec2d cellIndex(string& text_line);
static void updateElementsNodesConnection(vector<vector<size_t>>& elements_nodes_connection_, Vecd nodes, Vec2d cells,
static void updateElementsNodesConnection(StdLargeVec<StdVec<size_t>>& elements_nodes_connection_, Vecd nodes, Vec2d cells,
bool& check_neighbor_cell1, bool& check_neighbor_cell2);
static void updateCellLists(vector<vector<vector<size_t>>>& mesh_topology_, vector<vector<size_t>>& elements_nodes_connection_, Vecd nodes,
static void updateCellLists(vector<vector<vector<size_t>>>& mesh_topology_, StdLargeVec<StdVec<size_t>>& elements_nodes_connection_, Vecd nodes,
Vec2d cells, bool& check_neighbor_cell1, bool& check_neighbor_cell2, size_t boundary_type);
static void updateBoundaryCellLists(vector<vector<vector<size_t>>>& mesh_topology_, vector<vector<size_t>>& elements_nodes_connection_,
static void updateBoundaryCellLists(vector<vector<vector<size_t>>>& mesh_topology_, StdLargeVec<StdVec<size_t>>& elements_nodes_connection_,
Vecd nodes, Vec2d cells, bool& check_neighbor_cell1, bool& check_neighbor_cell2, size_t boundary_type);
static void cellCenterCoordinates(vector<vector<size_t>>& elements_nodes_connection_, std::vector<std::vector<long unsigned int>>::size_type& element,
vector<vector<Real>>& node_coordinates_, StdLargeVec<Vecd>& elements_center_coordinates_, Vecd& center_coordinate);
static void elementVolume(vector<vector<size_t>>& elements_nodes_connection_, std::vector<std::vector<long unsigned int>>::size_type& element,
vector<vector<Real>>& node_coordinates_, StdLargeVec<Real>& elements_volumes_);
static void minimumdistance(vector<Real>& all_data_of_distance_between_nodes, StdLargeVec<Real>& elements_volumes_, vector<vector<vector<size_t>>>& mesh_topology_,
vector<vector<Real>>& node_coordinates_);
static void cellCenterCoordinates(StdLargeVec<StdVec<size_t>>& elements_nodes_connection_, std::size_t& element,
StdLargeVec<Vecd>& node_coordinates_, StdLargeVec<Vecd>& elements_center_coordinates_, Vecd& center_coordinate);
static void elementVolume(StdLargeVec<StdVec<size_t>>& elements_nodes_connection_, std::size_t& element,
StdLargeVec<Vecd>& node_coordinates_, StdLargeVec<Real>& elements_volumes_);
static void minimumdistance(vector<Real>& all_data_of_distance_between_nodes, StdLargeVec<Real>& elements_volumes_,
vector<vector<vector<size_t>>>& mesh_topology_, StdLargeVec<Vecd>& node_coordinates_);
static void vtuFileHeader(std::ofstream& out_file);
static void vtuFileNodeCoordinates(std::ofstream& out_file, vector<vector<Real>>& nodes_coordinates_,
vector<vector<size_t>>& elements_nodes_connection_, SPHBody& bounds_,Real& rangemax);
static void vtuFileNodeCoordinates(std::ofstream& out_file, StdLargeVec<Vecd>& nodes_coordinates_,
StdLargeVec<StdVec<size_t>>& elements_nodes_connection_, SPHBody& bounds_,Real& rangemax);
static void vtuFileInformationKey(std::ofstream& out_file, Real& rangemax);
static void vtuFileCellConnectivity(std::ofstream& out_file, vector<vector<size_t>>& elements_nodes_connection_, vector<vector<Real>>& node_coordinates_);
static void vtuFileOffsets(std::ofstream& out_file, vector<vector<size_t>>& elements_nodes_connection_);
static void vtuFileTypeOfCell(std::ofstream& out_file, vector<vector<size_t>>& elements_nodes_connection_);
static void vtuFileCellConnectivity(std::ofstream& out_file, StdLargeVec<StdVec<size_t>>& elements_nodes_connection_, StdLargeVec<Vecd>& node_coordinates_);
static void vtuFileOffsets(std::ofstream& out_file, StdLargeVec<StdVec<size_t>>& elements_nodes_connection_);
static void vtuFileTypeOfCell(std::ofstream& out_file, StdLargeVec<StdVec<size_t>>& elements_nodes_connection_);

/*Functions for .msh file from FLUENT*/
static void numberofNodesFluent(ifstream& mesh_file, size_t& number_of_points, string& text_line);
static void numberofElementsFluent(ifstream& mesh_file, size_t& number_of_elements, string& text_line);
static void nodeCoordinatesFluent(ifstream& mesh_file, size_t& node_index, vector<vector<Real>>& node_coordinates_, string& text_line,
size_t& dimension, vector<vector<Real>>& point_coordinates);
static void updateBoundaryCellListsFluent(vector<vector<vector<size_t>>>& mesh_topology_, vector<vector<size_t>>& elements_nodes_connection_,
static void nodeCoordinatesFluent(ifstream& mesh_file, StdLargeVec<Vecd>& node_coordinates_, string& text_line,
size_t& dimension);
static void updateBoundaryCellListsFluent(vector<vector<vector<size_t>>>& mesh_topology_, StdLargeVec<StdVec<size_t>>& elements_nodes_connection_,
Vecd nodes, Vec2d cells, bool& check_neighbor_cell1, bool& check_neighbor_cell2, size_t boundary_type);
};

Expand Down
23 changes: 18 additions & 5 deletions src/shared/bodies/complex_bodies/unstructured_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "compressible_fluid.h"
#include "fluid_body.h"
#include "io_vtk.h"
#include <Eigen/Dense>
using namespace std;
namespace SPH
{
Expand All @@ -57,11 +58,9 @@ class ANSYSMesh
protected:
double min_distance_between_nodes_;

void readNodeCoordinate(const std::string &text_line, StdLargeVec<Vec2d> &node_coordinates);
void readNodeCoordinate(const std::string &text_line, StdLargeVec<Vec3d> &node_coordinates);
void getDataFromMeshFile(const std::string &full_path);
void getElementCenterCoordinates();
void computeMinimumDistanceBetweenNodes();
void getMinimumDistanceBetweenNodes();
};

/**
Expand Down Expand Up @@ -189,9 +188,20 @@ class BodyStatesRecordingInMeshToVtp : public BodyStatesRecording
protected:
virtual void writeWithFileName(const std::string &sequence) override;
StdLargeVec<Vecd> &node_coordinates_;
StdLargeVec<StdVec<size_t>> &elements_nodes_connection_;
StdLargeVec<StdVec<size_t>>&elements_nodes_connection_;
};
class BodyStatesRecordingInMeshToVtu : public BodyStatesRecording
{
public:
BodyStatesRecordingInMeshToVtu(SPHBody& body, ANSYSMesh& ansys_mesh);
virtual ~BodyStatesRecordingInMeshToVtu() {};

protected:
virtual void writeWithFileName(const std::string& sequence) override;
StdLargeVec<Vecd>& node_coordinates_;
StdLargeVec<StdVec<size_t>>& elements_nodes_connection_;
SPHBody& bounds_;
};

//----------------------------------------------------------------------
// BoundaryConditionSetupInFVM
//----------------------------------------------------------------------
Expand All @@ -206,6 +216,9 @@ class BoundaryConditionSetupInFVM : public fluid_dynamics::FluidDataInner
virtual void applyOutletBoundary(size_t ghost_index, size_t index_i){};
virtual void applyTopBoundary(size_t ghost_index, size_t index_i){};
virtual void applyFarFieldBoundary(size_t ghost_index){};
virtual void applyPressureOutletBC(size_t ghost_index, size_t index_i) {};
virtual void applySymmetryBoundary(size_t ghost_index, size_t index_i, Vecd e_ij) {};
virtual void applyVelocityInletFlow(size_t ghost_index, size_t index_i) {};
// Common functionality for resetting boundary conditions
void resetBoundaryConditions();

Expand Down
238 changes: 0 additions & 238 deletions src/shared/bodies/complex_bodies/unstructured_mesh_3d.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "common_weakly_compressible_FVM_classes_3d.h"
#include "common_weakly_compressible_FVM_classes.h"

using namespace std;
namespace SPH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#ifndef COMMON_WEAKLY_COMPRESSIBLE_FVM_CLASSES_3D_H
#define COMMON_WEAKLY_COMPRESSIBLE_FVM_CLASSES_3D_H
#include "unstructured_mesh_3d.h"
#include "unstructured_mesh.h"

namespace SPH
{
Expand Down
Loading

0 comments on commit 708710c

Please sign in to comment.