Skip to content
Snippets Groups Projects
Commit 7ba32158 authored by Matteo Cicuttin's avatar Matteo Cicuttin
Browse files

Don't generate mesh if input is .msh.

parent 11f22e71
Branches
No related tags found
No related merge requests found
......@@ -183,11 +183,8 @@ public:
model(const char *, int, int);
~model();
void build(void);
void build(double);
void build();
void generate_mesh(void);
void generate_mesh(double);
void partition_mesh(int);
void populate_from_gmsh(void);
......
......@@ -11,4 +11,10 @@ Cylinder(3) = {0, 0, -d/2-t, 0, 0, t, R};
Sphere(4) = {0, 0, 0, 2*R, -Pi/2, Pi/2, 2*Pi};
Coherence;
Physical Volume(1000) = {1, 3};
Physical Volume(1001) = {2};
Physical Volume(1002) = {4};
Physical Surface(2000) = {1};
MeshSize{ PointsOf{ Volume{2}; } } = 0.0003;
sim.name = "capacitor" -- simulation name
sim.dt = 1e-14 -- timestep size
sim.timesteps = 1001 -- num of iterations
sim.gmsh_model = "capacitor.geo" -- gmsh model filename
sim.gmsh_model = "capacitor.msh" -- gmsh model filename
sim.use_gpu = 0 -- 0: cpu, 1: gpu
sim.approx_order = 1 -- approximation order
sim.time_integrator = "leapfrog" -- time integration method
......
......@@ -790,36 +790,10 @@ model::populate_from_gmsh()
void
model::build()
{
generate_mesh();
make_boundary_to_faces_map();
populate_from_gmsh_rank0();
}
void
model::build(double sf)
{
generate_mesh(sf);
make_boundary_to_faces_map();
//make_boundary_to_faces_map();
populate_from_gmsh_rank0();
}
void
model::generate_mesh()
{
gmm::generate( DIMENSION(3) );
}
void
model::generate_mesh(double sf)
{
gmm::generate( DIMENSION(3) );
std::vector<double> tr = {sf, 0, 0, 0,
0, sf, 0, 0,
0, 0, sf, 0 };
gmm::affineTransform(tr);
}
#ifdef USE_MPI
void
model::partition_mesh(int parts)
......
#include <regex>
#ifdef DONT_USE_STD_FILESYSTEM
#include <sys/stat.h>
#include <sys/types.h>
......@@ -397,26 +399,36 @@ int main(int argc, char *argv[])
gmsh::initialize();
gmsh::option::setNumber("General.Terminal", 0);
gmsh::open( mpl.sim_gmshmodel() );
bool generate = std::regex_match(mpl.sim_gmshmodel(), std::regex(".*\\.geo$") );
if (generate)
{
std::cout << "Generating mesh..." << std::flush;
gmm::generate( DIMENSION(3) );
std::cout << "done" << std::endl;
}
auto [scaled, sf] = mpl.mesh_scalefactor();
if (scaled)
{
std::vector<double> tr = {sf, 0, 0, 0,
0, sf, 0, 0,
0, 0, sf, 0 };
gmm::affineTransform(tr);
}
#ifdef USE_MPI
}
#endif /* USE_MPI */
model mod( mpl.sim_geomorder(), mpl.sim_approxorder() );
auto [scaled, sf] = mpl.mesh_scalefactor();
#ifdef USE_MPI
if (comm_rank == 0)
{
std::cout << "Generating mesh..." << std::flush;
if (scaled)
mod.generate_mesh(sf);
else
mod.generate_mesh();
if (comm_size > 1)
mod.partition_mesh(comm_size);
std::cout << "done" << std::endl;
std::cout << "Distributing mesh partitions..." << std::flush;
mod.populate_from_gmsh();
std::cout << "done" << std::endl;
......@@ -426,12 +438,7 @@ int main(int argc, char *argv[])
mod.populate_from_gmsh();
}
#else /* USE_MPI */
std::cout << "Generating mesh..." << std::flush;
if (scaled)
mod.build(sf);
else
mod.build();
std::cout << "done" << std::endl;
mod.populate_from_gmsh();
#endif /* USE_MPI */
......
......@@ -39,6 +39,7 @@ int
test_basics(int geometric_order, int approximation_order)
{
make_geometry(0, 0.1);
gmm::generate( DIMENSION(3) );
model mod(geometric_order, approximation_order);
mod.build();
......@@ -163,6 +164,8 @@ int
test_normals(int geometric_order, int approximation_order)
{
make_geometry(0, 0.1);
gmm::generate( DIMENSION(3) );
model mod(geometric_order, approximation_order);
mod.build();
......@@ -247,6 +250,8 @@ int
test_normals_2()
{
make_geometry(0, 0.1);
gmm::generate( DIMENSION(3) );
model mod(1, 1);
mod.build();
......
......@@ -69,6 +69,8 @@ int test_differentiation_convergence(int geometric_order, int approximation_orde
{
double h = sizes[i];
make_geometry(0,h);
gmm::generate( DIMENSION(3) );
model mod(geometric_order, approximation_order);
mod.build();
......
......@@ -70,6 +70,8 @@ int test_differentiation_convergence(int geometric_order, int approximation_orde
{
double h = sizes[i];
make_geometry(0,h);
gmm::generate( DIMENSION(3) );
model mod(geometric_order, approximation_order);
mod.build();
......
......@@ -81,6 +81,8 @@ int test_lifting(int geometric_order, int approximation_order)
{
double h = sizes[sz];
make_geometry(0,h);
gmm::generate( DIMENSION(3) );
model mod(geometric_order, approximation_order);
mod.build();
......
......@@ -82,8 +82,9 @@ int test_lifting(int geometric_order, int approximation_order)
{
double h = sizes[sz];
make_geometry(0,h);
gmm::generate( DIMENSION(3) );
model mod(geometric_order, approximation_order);
mod.build();
mod.populate_from_gmsh();
#ifdef WRITE_TEST_OUTPUTS
std::stringstream ss;
......
......@@ -39,6 +39,8 @@ int test_mass_convergence(int geometric_order, int approximation_order)
{
double h = sizes[i];
make_geometry(0,h);
gmm::generate( DIMENSION(3) );
model mod(geometric_order, approximation_order);
mod.build();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment