mGFD 0.9.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mGFD/__init__.py +73 -0
- mGFD/cloud_generator/__init__.py +47 -0
- mGFD/cloud_generator/cli/__init__.py +33 -0
- mGFD/cloud_generator/cli/cli.py +261 -0
- mGFD/cloud_generator/core/__init__.py +33 -0
- mGFD/cloud_generator/core/classification.py +237 -0
- mGFD/cloud_generator/core/generator.py +245 -0
- mGFD/cloud_generator/core/point_generation/__init__.py +73 -0
- mGFD/cloud_generator/core/point_generation/boundary.py +82 -0
- mGFD/cloud_generator/core/point_generation/geometry.py +63 -0
- mGFD/cloud_generator/core/point_generation/poisson_generation.py +379 -0
- mGFD/cloud_generator/core/point_generation/regular_generation.py +313 -0
- mGFD/cloud_generator/core/point_generation/relaxation.py +117 -0
- mGFD/cloud_generator/core/reduction.py +323 -0
- mGFD/cloud_generator/io/__init__.py +33 -0
- mGFD/cloud_generator/io/data_processing.py +128 -0
- mGFD/cloud_generator/io/export.py +128 -0
- mGFD/cloud_generator/utils/__init__.py +33 -0
- mGFD/cloud_generator/utils/utils.py +195 -0
- mGFD/cloud_generator/viz/__init__.py +33 -0
- mGFD/cloud_generator/viz/visualization.py +245 -0
- mGFD/core/__init__.py +33 -0
- mGFD/core/gammas.py +415 -0
- mGFD/core/neighbors.py +325 -0
- mGFD/core/utils.py +207 -0
- mGFD/io/__init__.py +33 -0
- mGFD/io/export_vtk.py +184 -0
- mGFD/io/io.py +93 -0
- mGFD/solvers/__init__.py +33 -0
- mGFD/solvers/stationary.py +126 -0
- mGFD/solvers/time_derivative1.py +157 -0
- mGFD/solvers/time_derivative2.py +178 -0
- mGFD/viz/__init__.py +33 -0
- mGFD/viz/graph.py +413 -0
- mgfd-0.9.1.dist-info/METADATA +250 -0
- mgfd-0.9.1.dist-info/RECORD +40 -0
- mgfd-0.9.1.dist-info/WHEEL +5 -0
- mgfd-0.9.1.dist-info/entry_points.txt +2 -0
- mgfd-0.9.1.dist-info/licenses/LICENSE +21 -0
- mgfd-0.9.1.dist-info/top_level.txt +1 -0
mGFD/__init__.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
mGFD — Meshless Generalized Finite Differences
|
|
3
|
+
|
|
4
|
+
Overview:
|
|
5
|
+
Meshless solvers for 2D stationary and transient PDEs using generalized finite differences (GFD).
|
|
6
|
+
Spatial derivatives are approximated using local reconstructions over a node neighborhood (nvec).
|
|
7
|
+
|
|
8
|
+
Public API:
|
|
9
|
+
Stationary Stationary problems with Dirichlet boundary conditions.
|
|
10
|
+
TimeDerivative1 First-order-in-time problems (heat / advection-diffusion family).
|
|
11
|
+
TimeDerivative2 Second-order-in-time problems (wave family).
|
|
12
|
+
|
|
13
|
+
Data conventions:
|
|
14
|
+
p (m, 3) ndarray
|
|
15
|
+
Point cloud with columns [x, y, flag]. flag = 0 for interior; flag = 1/2 for boundary.
|
|
16
|
+
vec (m, nvec) ndarray[int]
|
|
17
|
+
Neighbor list. Each row contains neighbor indices; unused slots are padded with -1.
|
|
18
|
+
If vec is not provided, it is computed from p using Neighbors.compute_neighbors / Neighbors.compute_upwind_neighbors.
|
|
19
|
+
|
|
20
|
+
Operator conventions:
|
|
21
|
+
operator array-like
|
|
22
|
+
A 6-coefficient vector [D, E, A, B, C, F] (shape (6,) or (6, 1)).
|
|
23
|
+
The spatial stencil is built with L = operator[:5] = [D, E, A, B, C], interpreted as:
|
|
24
|
+
D*u_x + E*u_y + A*u_xx + B*u_xy + C*u_yy
|
|
25
|
+
The reaction term F*u is reserved in the last coefficient, but it is not applied by the
|
|
26
|
+
current implementation. For the Laplacian, use [0, 0, 2, 0, 2, 0].
|
|
27
|
+
When upwind=True, neighbor selection is upwind-biased using velocities (D, E).
|
|
28
|
+
|
|
29
|
+
Notes:
|
|
30
|
+
NumPy is required. SciPy is optional, but implicit schemes require SciPy for sparse linear algebra.
|
|
31
|
+
Transient solvers use a normalized time grid T = linspace(0, 1, t).
|
|
32
|
+
When instability is detected, the solver may retry with expanded neighborhoods (8→12→16→20→30).
|
|
33
|
+
|
|
34
|
+
Credits:
|
|
35
|
+
All the codes presented below were developed by:
|
|
36
|
+
Dr. Gerardo Tinoco-Guerrero
|
|
37
|
+
Dr. Francisco Javier Domínguez-Mota
|
|
38
|
+
Dr. José Alberto Guzmán-Torres
|
|
39
|
+
Universidad Michoacana de San Nicolás de Hidalgo
|
|
40
|
+
gerardo.tinoco@umich.mx
|
|
41
|
+
With the funding of:
|
|
42
|
+
Secretary of Science, Humanities, Technology and Innovation, SECIHTI (Secretaria de Ciencia, Humanidades, Tecnología e Innovación). México.
|
|
43
|
+
Coordination of Scientific Research, CIC-UMSNH (Coordinación de la Investigación Científica de la Universidad Michoacana de San Nicolás de Hidalgo, CIC-UMSNH). México.
|
|
44
|
+
Aula CIMNE-Morelia. México.
|
|
45
|
+
SIIIA-MATH: Soluciones de Ingeniería. México.
|
|
46
|
+
|
|
47
|
+
Based on the theoretical concepts presented in:
|
|
48
|
+
"mGFD: A meshless generalized finite difference method",
|
|
49
|
+
Gerardo Tinoco-Guerrero, Francisco Javier Domínguez-Mota, José Alberto Guzmán-Torres,
|
|
50
|
+
Gabriela Pedraza-Jiménez, José Gerardo Tinoco-Ruiz,
|
|
51
|
+
Computers & Mathematics with Applications, Volume 195 (2025) 396-418.
|
|
52
|
+
https://doi.org/10.1016/j.camwa.2025.07.034
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
Date:
|
|
56
|
+
May, 2024.
|
|
57
|
+
Last Modification:
|
|
58
|
+
August, 2026.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
## Library importation.
|
|
62
|
+
from mGFD.solvers.stationary import Stationary
|
|
63
|
+
from mGFD.solvers.time_derivative1 import TimeDerivative1
|
|
64
|
+
from mGFD.solvers.time_derivative2 import TimeDerivative2
|
|
65
|
+
from mGFD.core.neighbors import compute_neighbors
|
|
66
|
+
from mGFD.core.gammas import compute_sparse_matrix, Cloud
|
|
67
|
+
from mGFD.cloud_generator import generate_cloud_natural, generate_cloud_regular, reduce_points_by_region
|
|
68
|
+
|
|
69
|
+
__all__ = [
|
|
70
|
+
'Stationary', 'TimeDerivative1', 'TimeDerivative2',
|
|
71
|
+
'compute_neighbors', 'compute_sparse_matrix', 'Cloud',
|
|
72
|
+
'generate_cloud_natural', 'generate_cloud_regular', 'reduce_points_by_region'
|
|
73
|
+
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CloudGenerator — Point Cloud Generation System for mGFD
|
|
3
|
+
|
|
4
|
+
Overview:
|
|
5
|
+
This package contains the core modular components for the Cloud Generation system.
|
|
6
|
+
It is organized into specialized modules to separate concerns and improve maintainability.
|
|
7
|
+
|
|
8
|
+
Public API:
|
|
9
|
+
generate_cloud_natural
|
|
10
|
+
generate_cloud_regular
|
|
11
|
+
reduce_points_by_region
|
|
12
|
+
|
|
13
|
+
Credits:
|
|
14
|
+
All the codes presented below were developed by:
|
|
15
|
+
Dr. Gerardo Tinoco-Guerrero
|
|
16
|
+
Dr. Francisco Javier Domínguez-Mota
|
|
17
|
+
Dr. José Alberto Guzmán-Torres
|
|
18
|
+
Universidad Michoacana de San Nicolás de Hidalgo
|
|
19
|
+
gerardo.tinoco@umich.mx
|
|
20
|
+
|
|
21
|
+
With the funding of:
|
|
22
|
+
Secretary of Science, Humanities, Technology and Innovation, SECIHTI (Secretaria de Ciencia, Humanidades, Tecnología e Innovación). México.
|
|
23
|
+
Coordination of Scientific Research, CIC-UMSNH (Coordinación de la Investigación Científica de la Universidad Michoacana de San Nicolás de Hidalgo, CIC-UMSNH). México.
|
|
24
|
+
Aula CIMNE-Morelia. México.
|
|
25
|
+
SIIIA-MATH: Soluciones de Ingeniería. México.
|
|
26
|
+
|
|
27
|
+
Based on the theoretical concepts presented in:
|
|
28
|
+
"mGFD: A meshless generalized finite difference method",
|
|
29
|
+
Gerardo Tinoco-Guerrero, Francisco Javier Domínguez-Mota, José Alberto Guzmán-Torres,
|
|
30
|
+
Gabriela Pedraza-Jiménez, José Gerardo Tinoco-Ruiz,
|
|
31
|
+
Computers & Mathematics with Applications, Volume 195 (2025) 396-418.
|
|
32
|
+
https://doi.org/10.1016/j.camwa.2025.07.034
|
|
33
|
+
|
|
34
|
+
Date:
|
|
35
|
+
March, 2026.
|
|
36
|
+
Last Modification:
|
|
37
|
+
August, 2026.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
from .core.generator import generate_cloud_natural, generate_cloud_regular
|
|
41
|
+
from .core.reduction import reduce_points_by_region
|
|
42
|
+
|
|
43
|
+
__all__ = [
|
|
44
|
+
"generate_cloud_natural",
|
|
45
|
+
"generate_cloud_regular",
|
|
46
|
+
"reduce_points_by_region",
|
|
47
|
+
]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CloudGenerator.cli — Command Line Interface
|
|
3
|
+
|
|
4
|
+
Overview:
|
|
5
|
+
This module provides the Command Line Interface (CLI) for the Cloud Generator,
|
|
6
|
+
allowing users to operate the point cloud generation directly from the terminal.
|
|
7
|
+
|
|
8
|
+
Credits:
|
|
9
|
+
All the codes presented below were developed by:
|
|
10
|
+
Dr. Gerardo Tinoco-Guerrero
|
|
11
|
+
Dr. Francisco Javier Domínguez-Mota
|
|
12
|
+
Dr. José Alberto Guzmán-Torres
|
|
13
|
+
Universidad Michoacana de San Nicolás de Hidalgo
|
|
14
|
+
gerardo.tinoco@umich.mx
|
|
15
|
+
|
|
16
|
+
With the funding of:
|
|
17
|
+
Secretary of Science, Humanities, Technology and Innovation, SECIHTI (Secretaria de Ciencia, Humanidades, Tecnología e Innovación). México.
|
|
18
|
+
Coordination of Scientific Research, CIC-UMSNH (Coordinación de la Investigación Científica de la Universidad Michoacana de San Nicolás de Hidalgo, CIC-UMSNH). México.
|
|
19
|
+
Aula CIMNE-Morelia. México.
|
|
20
|
+
SIIIA-MATH: Soluciones de Ingeniería. México.
|
|
21
|
+
|
|
22
|
+
Based on the theoretical concepts presented in:
|
|
23
|
+
"mGFD: A meshless generalized finite difference method",
|
|
24
|
+
Gerardo Tinoco-Guerrero, Francisco Javier Domínguez-Mota, José Alberto Guzmán-Torres,
|
|
25
|
+
Gabriela Pedraza-Jiménez, José Gerardo Tinoco-Ruiz,
|
|
26
|
+
Computers & Mathematics with Applications, Volume 195 (2025) 396-418.
|
|
27
|
+
https://doi.org/10.1016/j.camwa.2025.07.034
|
|
28
|
+
|
|
29
|
+
Date:
|
|
30
|
+
March, 2026.
|
|
31
|
+
Last Modification:
|
|
32
|
+
August, 2026.
|
|
33
|
+
"""
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CloudGenerator.cli — Command Line Interface
|
|
3
|
+
|
|
4
|
+
Overview:
|
|
5
|
+
This module provides the command line interface (CLI) for the CloudGenerator suite.
|
|
6
|
+
It exposes subcommands for generating new point clouds from contours and reducing
|
|
7
|
+
the density of existing point clouds.
|
|
8
|
+
|
|
9
|
+
Data conventions:
|
|
10
|
+
None.
|
|
11
|
+
|
|
12
|
+
Public API:
|
|
13
|
+
handle_generate Handler for the 'generate' subcommand.
|
|
14
|
+
handle_reduce Handler for the 'reduce' subcommand.
|
|
15
|
+
main Main entry point for the CLI.
|
|
16
|
+
|
|
17
|
+
Credits:
|
|
18
|
+
All the codes presented below were developed by:
|
|
19
|
+
Dr. Gerardo Tinoco-Guerrero
|
|
20
|
+
Dr. Francisco Javier Domínguez-Mota
|
|
21
|
+
Dr. José Alberto Guzmán-Torres
|
|
22
|
+
Universidad Michoacana de San Nicolás de Hidalgo
|
|
23
|
+
gerardo.tinoco@umich.mx
|
|
24
|
+
|
|
25
|
+
With the funding of:
|
|
26
|
+
Secretary of Science, Humanities, Technology and Innovation, SECIHTI (Secretaria de Ciencia, Humanidades, Tecnología e Innovación). México.
|
|
27
|
+
Coordination of Scientific Research, CIC-UMSNH (Coordinación de la Investigación Científica de la Universidad Michoacana de San Nicolás de Hidalgo, CIC-UMSNH). México.
|
|
28
|
+
Aula CIMNE-Morelia. México.
|
|
29
|
+
SIIIA-MATH: Soluciones de Ingeniería. México.
|
|
30
|
+
|
|
31
|
+
Based on the theoretical concepts presented in:
|
|
32
|
+
"mGFD: A meshless generalized finite difference method",
|
|
33
|
+
Gerardo Tinoco-Guerrero, Francisco Javier Domínguez-Mota, José Alberto Guzmán-Torres,
|
|
34
|
+
Gabriela Pedraza-Jiménez, José Gerardo Tinoco-Ruiz,
|
|
35
|
+
Computers & Mathematics with Applications, Volume 195 (2025) 396-418.
|
|
36
|
+
https://doi.org/10.1016/j.camwa.2025.07.034
|
|
37
|
+
|
|
38
|
+
Date:
|
|
39
|
+
March, 2026.
|
|
40
|
+
Last Modification:
|
|
41
|
+
August, 2026.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
## Library importation.
|
|
45
|
+
import os # Operating system interfaces.
|
|
46
|
+
import sys # System-specific parameters and functions.
|
|
47
|
+
import logging # Standard logging module.
|
|
48
|
+
import argparse # Module for parsing command-line arguments.
|
|
49
|
+
import numpy as np # Core numerical operations.
|
|
50
|
+
|
|
51
|
+
from typing import Any # Type hinting.
|
|
52
|
+
|
|
53
|
+
from mGFD.cloud_generator.core.generator import generate_cloud_natural, generate_cloud_regular # Import generation functions.
|
|
54
|
+
from mGFD.cloud_generator.core.reduction import reduce_points_by_region # Import reduction function.
|
|
55
|
+
from mGFD.cloud_generator.viz.visualization import create_visualization # Import visualization creator.
|
|
56
|
+
|
|
57
|
+
logger = logging.getLogger(__name__) # Module level logger.
|
|
58
|
+
|
|
59
|
+
def handle_generate(args: argparse.Namespace) -> None:
|
|
60
|
+
"""
|
|
61
|
+
handle_generate
|
|
62
|
+
Handler for the 'generate' subcommand.
|
|
63
|
+
|
|
64
|
+
Parses the arguments and delegates execution to the appropriate point cloud
|
|
65
|
+
generation algorithm (natural or regular).
|
|
66
|
+
|
|
67
|
+
Input:
|
|
68
|
+
args argparse.Namespace Parsed command line arguments containing input, output, method,
|
|
69
|
+
inside_regions, and density.
|
|
70
|
+
|
|
71
|
+
Output:
|
|
72
|
+
None
|
|
73
|
+
"""
|
|
74
|
+
# 1. Validation
|
|
75
|
+
if not os.path.exists(args.input): # Check if the input file exists.
|
|
76
|
+
logger.error(f"Error: Input file '{args.input}' not found.") # Log an error message.
|
|
77
|
+
sys.exit(1) # Exit with an error code.
|
|
78
|
+
|
|
79
|
+
# 2. Header and info output
|
|
80
|
+
if not args.quiet:
|
|
81
|
+
logger.info("mGFD CloudGenerator - Generate") # Log header text for generation.
|
|
82
|
+
logger.info("==============================") # Log separator line.
|
|
83
|
+
logger.info(f"Input: {args.input}") # Log the input file path.
|
|
84
|
+
logger.info(f"Output: {args.output}") # Log the output file path.
|
|
85
|
+
logger.info(f"Method: {args.method}") # Log the selected method.
|
|
86
|
+
logger.info(f"Density: {args.density}x") # Log the density multiplier.
|
|
87
|
+
logger.info("Generating point cloud, please wait...") # Log wait message.
|
|
88
|
+
|
|
89
|
+
# 3. Cloud generation
|
|
90
|
+
try: # Start generation process inside a try-except block.
|
|
91
|
+
if args.method == "natural": # Check if the selected method is 'natural'.
|
|
92
|
+
result = generate_cloud_natural( # Call the natural generation function.
|
|
93
|
+
csv_file=args.input, # Pass the input CSV file.
|
|
94
|
+
output_file=args.output, # Pass the output CSV file.
|
|
95
|
+
inside_regions=args.inside_regions, # Pass the inside regions flag.
|
|
96
|
+
density_multiplier=args.density # Pass the density multiplier.
|
|
97
|
+
)
|
|
98
|
+
else: # If the method is 'regular' (or anything else).
|
|
99
|
+
result = generate_cloud_regular( # Call the regular generation function.
|
|
100
|
+
csv_file=args.input, # Pass the input CSV file.
|
|
101
|
+
output_file=args.output, # Pass the output CSV file.
|
|
102
|
+
inside_regions=args.inside_regions, # Pass the inside regions flag.
|
|
103
|
+
density_multiplier=args.density # Pass the density multiplier.
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# 4. Success output
|
|
107
|
+
if not args.quiet:
|
|
108
|
+
logger.info("\nSuccess!") # Log success message.
|
|
109
|
+
logger.info(f"Total points generated: {result.get('total_nodes', 'Unknown')}") # Log total generated nodes.
|
|
110
|
+
logger.info(f"Regions generated: {result.get('regions_generated', 'Unknown')}") # Log number of generated regions.
|
|
111
|
+
logger.info(f"Main region points: {result.get('main_region_nodes', 'Unknown')}") # Log points in the main region.
|
|
112
|
+
logger.info(f"Visualizations saved to {result.get('visualization_file', '')} and {result.get('visualization_svg_file', '')}") # Log visualization paths.
|
|
113
|
+
|
|
114
|
+
# 5. Exception handling
|
|
115
|
+
except Exception as e: # Handle general exceptions.
|
|
116
|
+
logger.error(f"\nError generating cloud: {e}") # Log error details.
|
|
117
|
+
sys.exit(1) # Exit with an error code.
|
|
118
|
+
|
|
119
|
+
def handle_reduce(args: argparse.Namespace) -> None:
|
|
120
|
+
"""
|
|
121
|
+
handle_reduce
|
|
122
|
+
Handler for the 'reduce' subcommand.
|
|
123
|
+
|
|
124
|
+
Parses the arguments and delegates execution to the point cloud reduction
|
|
125
|
+
algorithm to decimate an existing point cloud while preserving its boundary.
|
|
126
|
+
|
|
127
|
+
Input:
|
|
128
|
+
args argparse.Namespace Parsed command line arguments containing input, output, and multiplier.
|
|
129
|
+
|
|
130
|
+
Output:
|
|
131
|
+
None
|
|
132
|
+
"""
|
|
133
|
+
# 1. Validation
|
|
134
|
+
if not os.path.exists(args.input): # Check if the input file exists.
|
|
135
|
+
logger.error(f"Error: Input file '{args.input}' not found.") # Log an error message.
|
|
136
|
+
sys.exit(1) # Exit with an error code.
|
|
137
|
+
|
|
138
|
+
# 2. Header and info output
|
|
139
|
+
if not args.quiet:
|
|
140
|
+
logger.info("mGFD CloudGenerator - Reduce") # Log header text for reduction.
|
|
141
|
+
logger.info("============================") # Log separator line.
|
|
142
|
+
logger.info(f"Input: {args.input}") # Log the input file path.
|
|
143
|
+
logger.info(f"Output: {args.output}") # Log the output file path.
|
|
144
|
+
logger.info(f"Multiplier: {args.multiplier}") # Log the reduction multiplier.
|
|
145
|
+
logger.info("Reducing point cloud, please wait...") # Log wait message.
|
|
146
|
+
|
|
147
|
+
# 3. Cloud reduction
|
|
148
|
+
try: # Start reduction process inside a try-except block.
|
|
149
|
+
result = reduce_points_by_region( # Call the point reduction function.
|
|
150
|
+
input_csv=args.input, # Pass the input CSV file.
|
|
151
|
+
output_csv=args.output, # Pass the output CSV file.
|
|
152
|
+
multiplier=args.multiplier # Pass the reduction multiplier.
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# 4. Visualization and output
|
|
156
|
+
if result is not None: # Check if the reduction was successful.
|
|
157
|
+
if not args.quiet:
|
|
158
|
+
logger.info("\nSuccess!") # Log success message.
|
|
159
|
+
logger.info(f"Total points after reduction: {len(result)}") # Log the new total number of points.
|
|
160
|
+
|
|
161
|
+
points = np.array([(row['x'], row['y']) for row in result]) # Extract point coordinates.
|
|
162
|
+
regions_list = [row.get('region', 1) for row in result] # Extract region list.
|
|
163
|
+
classifications = [row.get('classification', 'interior') for row in result] # Extract classifications.
|
|
164
|
+
output_base = os.path.splitext(args.output)[0] # Get output path without extension.
|
|
165
|
+
|
|
166
|
+
create_visualization(points, regions_list, output_base, classifications) # Generate visual plots.
|
|
167
|
+
|
|
168
|
+
if not args.quiet:
|
|
169
|
+
logger.info(f"Visualizations saved to {output_base}.png and {output_base}.svg") # Log saved visual plots.
|
|
170
|
+
else: # If reduction returned None (failed).
|
|
171
|
+
logger.error("\nError: Failed to reduce cloud. Check logs for details.") # Log error message.
|
|
172
|
+
sys.exit(1) # Exit with an error code.
|
|
173
|
+
|
|
174
|
+
# 5. Exception handling
|
|
175
|
+
except Exception as e: # Handle general exceptions.
|
|
176
|
+
logger.error(f"\nError reducing cloud: {e}") # Log error details.
|
|
177
|
+
sys.exit(1) # Exit with an error code.
|
|
178
|
+
|
|
179
|
+
def main() -> None:
|
|
180
|
+
"""
|
|
181
|
+
main
|
|
182
|
+
Main entry point for the CLI.
|
|
183
|
+
|
|
184
|
+
Configures the argument parser, defines the 'generate' and 'reduce'
|
|
185
|
+
subcommands, and dispatches the execution to the corresponding handler.
|
|
186
|
+
|
|
187
|
+
Input:
|
|
188
|
+
None
|
|
189
|
+
|
|
190
|
+
Output:
|
|
191
|
+
None
|
|
192
|
+
"""
|
|
193
|
+
# 1. Global Logging configuration
|
|
194
|
+
logging.basicConfig(level=logging.INFO, format='%(message)s') # Configure logging format for CLI.
|
|
195
|
+
|
|
196
|
+
# 2. Parser initialization
|
|
197
|
+
parser = argparse.ArgumentParser( # Instantiate an ArgumentParser.
|
|
198
|
+
description="mGFD CloudGenerator - Point cloud generation and optimization suite." # Define program description.
|
|
199
|
+
)
|
|
200
|
+
parser.add_argument("-q", "--quiet", action="store_true", help="Suppress non-error console output.") # Add quiet flag globally.
|
|
201
|
+
|
|
202
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands") # Add sub-command parsers.
|
|
203
|
+
subparsers.required = True # Ensure a sub-command is always provided.
|
|
204
|
+
|
|
205
|
+
# 2. Generate command configuration
|
|
206
|
+
parser_gen = subparsers.add_parser("generate", help="Generate a point cloud from boundary contours.") # Create parser for 'generate'.
|
|
207
|
+
parser_gen.add_argument( # Add an argument to 'generate'.
|
|
208
|
+
"-i", "--input", # Flag names for the input file.
|
|
209
|
+
required=True, # Make this argument mandatory.
|
|
210
|
+
help="Input CSV file containing the boundary contours." # Help text for the input argument.
|
|
211
|
+
)
|
|
212
|
+
parser_gen.add_argument( # Add an argument to 'generate'.
|
|
213
|
+
"-o", "--output", # Flag names for the output file.
|
|
214
|
+
required=True, # Make this argument mandatory.
|
|
215
|
+
help="Output CSV file where the point cloud will be saved." # Help text for the output argument.
|
|
216
|
+
)
|
|
217
|
+
parser_gen.add_argument( # Add an argument to 'generate'.
|
|
218
|
+
"-m", "--method", # Flag names for the method.
|
|
219
|
+
choices=["natural", "regular"], # Allow only 'natural' or 'regular'.
|
|
220
|
+
default="natural", # Set default method to 'natural'.
|
|
221
|
+
help="Point generation method: 'natural' (Poisson-Disk) or 'regular' (Grid-based)." # Help text for the method argument.
|
|
222
|
+
)
|
|
223
|
+
parser_gen.add_argument( # Add an argument to 'generate'.
|
|
224
|
+
"--inside-regions", # Flag name for generating inside regions.
|
|
225
|
+
action="store_true", # Store a boolean True if provided.
|
|
226
|
+
help="If specified, generate points inside holes (islands) too." # Help text for inside regions flag.
|
|
227
|
+
)
|
|
228
|
+
parser_gen.add_argument( # Add an argument to 'generate'.
|
|
229
|
+
"-d", "--density", # Flag names for the density.
|
|
230
|
+
type=float, # Require a float value.
|
|
231
|
+
default=1.0, # Set default density to 1.0.
|
|
232
|
+
help="Density multiplier. Higher value = denser cloud." # Help text for the density argument.
|
|
233
|
+
)
|
|
234
|
+
parser_gen.set_defaults(func=handle_generate) # Bind the handler function to 'generate'.
|
|
235
|
+
|
|
236
|
+
# 3. Reduce command configuration
|
|
237
|
+
parser_red = subparsers.add_parser("reduce", help="Reduce an existing point cloud density.") # Create parser for 'reduce'.
|
|
238
|
+
parser_red.add_argument( # Add an argument to 'reduce'.
|
|
239
|
+
"-i", "--input", # Flag names for the input file.
|
|
240
|
+
required=True, # Make this argument mandatory.
|
|
241
|
+
help="Input CSV file containing an existing point cloud." # Help text for the input argument.
|
|
242
|
+
)
|
|
243
|
+
parser_red.add_argument( # Add an argument to 'reduce'.
|
|
244
|
+
"-o", "--output", # Flag names for the output file.
|
|
245
|
+
required=True, # Make this argument mandatory.
|
|
246
|
+
help="Output CSV file where the reduced point cloud will be saved." # Help text for the output argument.
|
|
247
|
+
)
|
|
248
|
+
parser_red.add_argument( # Add an argument to 'reduce'.
|
|
249
|
+
"--multiplier", # Flag name for the reduction multiplier.
|
|
250
|
+
type=int, # Require an integer value.
|
|
251
|
+
default=2, # Set default multiplier to 2.
|
|
252
|
+
help="Reduction multiplier. 1 = ~50% reduction. 2 = ~75% reduction." # Help text for multiplier.
|
|
253
|
+
)
|
|
254
|
+
parser_red.set_defaults(func=handle_reduce) # Bind the handler function to 'reduce'.
|
|
255
|
+
|
|
256
|
+
# 4. Argument parsing and execution
|
|
257
|
+
args = parser.parse_args() # Parse the command-line arguments.
|
|
258
|
+
args.func(args) # Call the assigned function based on parsed arguments.
|
|
259
|
+
|
|
260
|
+
if __name__ == "__main__": # Check if the script is run directly.
|
|
261
|
+
main() # Execute the main function.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CloudGenerator.core — Core Cloud Generation Operations
|
|
3
|
+
|
|
4
|
+
Overview:
|
|
5
|
+
This module contains the core operational logic for the Cloud Generator,
|
|
6
|
+
including point generation, classification, and cloud reduction algorithms.
|
|
7
|
+
|
|
8
|
+
Credits:
|
|
9
|
+
All the codes presented below were developed by:
|
|
10
|
+
Dr. Gerardo Tinoco-Guerrero
|
|
11
|
+
Dr. Francisco Javier Domínguez-Mota
|
|
12
|
+
Dr. José Alberto Guzmán-Torres
|
|
13
|
+
Universidad Michoacana de San Nicolás de Hidalgo
|
|
14
|
+
gerardo.tinoco@umich.mx
|
|
15
|
+
|
|
16
|
+
With the funding of:
|
|
17
|
+
Secretary of Science, Humanities, Technology and Innovation, SECIHTI (Secretaria de Ciencia, Humanidades, Tecnología e Innovación). México.
|
|
18
|
+
Coordination of Scientific Research, CIC-UMSNH (Coordinación de la Investigación Científica de la Universidad Michoacana de San Nicolás de Hidalgo, CIC-UMSNH). México.
|
|
19
|
+
Aula CIMNE-Morelia. México.
|
|
20
|
+
SIIIA-MATH: Soluciones de Ingeniería. México.
|
|
21
|
+
|
|
22
|
+
Based on the theoretical concepts presented in:
|
|
23
|
+
"mGFD: A meshless generalized finite difference method",
|
|
24
|
+
Gerardo Tinoco-Guerrero, Francisco Javier Domínguez-Mota, José Alberto Guzmán-Torres,
|
|
25
|
+
Gabriela Pedraza-Jiménez, José Gerardo Tinoco-Ruiz,
|
|
26
|
+
Computers & Mathematics with Applications, Volume 195 (2025) 396-418.
|
|
27
|
+
https://doi.org/10.1016/j.camwa.2025.07.034
|
|
28
|
+
|
|
29
|
+
Date:
|
|
30
|
+
March, 2026.
|
|
31
|
+
Last Modification:
|
|
32
|
+
August, 2026.
|
|
33
|
+
"""
|