Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7bdb39

Browse files
committed
Support of JSON format at configuration file.
Incorporation mesh file name into configuration file.
1 parent 1c62851 commit b7bdb39

13 files changed

Lines changed: 392 additions & 43 deletions

File tree

README.md

Lines changed: 132 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DGFEM for Acoustic Wave Propagation
22

3-
[![version](https://img.shields.io/badge/version-1.3.5-red)](https://github.com/skhelladi/DGFEM-CAA/releases/tag/v1.3.5)
4-
[![compilers](https://img.shields.io/badge/c++-17%20|%2020-27ae60.svg)](https://github.com/skhelladi/DGFEM-CAA/releases/tag/v1.3.5)
3+
[![version](https://img.shields.io/badge/version-1.3.6-red)](https://github.com/skhelladi/DGFEM-CAA/releases/tag/v1.3.6)
4+
[![compilers](https://img.shields.io/badge/c++-17%20|%2020-27ae60.svg)](https://github.com/skhelladi/DGFEM-CAA/releases/tag/v1.3.6)
55

66
This repository implements a discontinuous Galerkin finite element method (DGFEM) applied to the linearized Euler equations and the acoustic
77
perturbation equations.
@@ -11,6 +11,7 @@ The solver is based on [GMSH](http://gmsh.info/) library and supports a wide ran
1111
- 4-th order Runge-Kutta
1212
- High order elements
1313
- Absorbing and reflecting boundaries
14+
- Support 'json' format configartion file
1415
- Multiple sources support: monopoles, dipoles, quadrupoles, user defined analytical formulation sources and external data (csv and sound 'wave' file supported)
1516
- Complex geometry and unstructured grid (only triangles (2D) and tetrahedrons (3D) elements are supported)
1617
- VTK post-processing (use [Paraview](https://www.paraview.org/))
@@ -58,7 +59,13 @@ Once the sources sucessfully build, you can start using with the solver. It requ
5859

5960
```
6061
cd bin
61-
./dgalerkin mymesh.msh myconfig.conf
62+
./dgalerkin myconfig.conf
63+
```
64+
or
65+
66+
```
67+
cd bin
68+
./dgalerkin myconfig.json
6269
```
6370

6471
### Minimal working example
@@ -67,7 +74,13 @@ cd bin
6774

6875
```
6976
cd build/bin
70-
./dgalerkin ../../doc/2d/square.msh ../../doc/config/config.conf
77+
./dgalerkin ../../doc/config/Square.conf
78+
```
79+
or
80+
81+
```
82+
cd build/bin
83+
./dgalerkin ../../doc/config/Square.json
7184
```
7285

7386
or configure run_caa batch file with the right mesh and configurations files.
@@ -76,8 +89,12 @@ or configure run_caa batch file with the right mesh and configurations files.
7689
sh run_caa
7790
```
7891
## Configuration file example
92+
### Text format file
7993
<!-- python style text highlight -->
8094
```python
95+
96+
meshFileName = doc/2d/square2.msh
97+
8198
# Initial, final time and time step(t>0)
8299
timeStart=0
83100
timeEnd=0.05
@@ -144,9 +161,118 @@ source4 = file,"data/data.wav", 0.0,0.0,0.0, 0.1
144161
observer1 = 2.11792,0.00340081,0.0,0.1
145162
observer2 = -2.11792,0.00340081,0.0,0.1
146163

147-
148164
```
149-
165+
### Json format file
166+
<!-- python style text highlight -->
167+
```json
168+
{
169+
"mesh": {
170+
"File": "doc/2d/square2.msh",
171+
"BC": {
172+
"number": 2,
173+
"boundary1": {
174+
"name": "Abs",
175+
"type": "Absorbing"
176+
},
177+
"boundary2": {
178+
"name": "Ref",
179+
"type": "Reflecting"
180+
}
181+
}
182+
},
183+
"solver": {
184+
"time": {
185+
"start": 0.0,
186+
"end": 0.05,
187+
"step": 5e-05,
188+
"rate": 0.001
189+
},
190+
"elementType": "Lagrange",
191+
"timeIntMethod": "Runge-Kutta",
192+
"numThreads": 12
193+
},
194+
"initialization": {
195+
"meanFlow": {
196+
"vx": 30.0,
197+
"vy": 0.0,
198+
"vz": 0.0,
199+
"rho": 1.225,
200+
"c": 100.0
201+
},
202+
"number": 2,
203+
"initialCondition1": {
204+
"type": "gaussian",
205+
"x": 0.2,
206+
"y": 0.0,
207+
"z": 0.0,
208+
"size": 1.0,
209+
"amplitude": 1.0
210+
},
211+
"initialCondition2": {
212+
"type": "gaussian",
213+
"x": -0.2,
214+
"y": 0.0,
215+
"z": 0.0,
216+
"size": 1.0,
217+
"amplitude": 1.0
218+
}
219+
},
220+
"observers": {
221+
"number": 2,
222+
"observer1": {
223+
"x": 2.11792,
224+
"y": 0.00340081,
225+
"z": 0.0,
226+
"size": 0.1
227+
},
228+
"observer2": {
229+
"x": -2.11792,
230+
"y": 0.00340081,
231+
"z": 0.0,
232+
"size": 0.1
233+
}
234+
},
235+
"sources": {
236+
"number": 3,
237+
"source1": {
238+
"type": "formula",
239+
"fct": "0.1 * sin(2 * pi * 50 * t)",
240+
"x": 0.0,
241+
"y": 0.0,
242+
"z": 0.0,
243+
"size": 0.1,
244+
"amplitude": 0.0,
245+
"frequency": 0.0,
246+
"phase": 0.0,
247+
"duration": 0.05
248+
},
249+
"source2": {
250+
"type": "file",
251+
"fct": "data/data2.wav",
252+
"x": 0.0,
253+
"y": 0.0,
254+
"z": 0.0,
255+
"size": 0.1,
256+
"amplitude": 0.0,
257+
"frequency": 0.0,
258+
"phase": 0.0,
259+
"duration": 0.05
260+
},
261+
"source3": {
262+
"type": "monopole",
263+
"fct": "",
264+
"x": 0.0,
265+
"y": 0.0,
266+
"z": 0.0,
267+
"size": 0.1,
268+
"amplitude": 0.1,
269+
"frequency": 50.0,
270+
"phase": 0.0,
271+
"duration": 0.05
272+
}
273+
}
274+
}
275+
```
150276
## Author
151277
* Sofiane Khelladi
152278

build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ else
9797
echo "libfftw3-dev installed.";
9898
fi
9999

100+
dpkg -s nlohmann-json3-dev > /dev/null 2>&1;
101+
if [ $? -eq 0 ]; then
102+
echo "nlohmann-json3-dev found.";
103+
else
104+
echo "nlohmann-json3-dev not found, installing...";
105+
sudo apt-get -y install nlohmann-json3-dev;
106+
echo "nlohmann-json3-dev installed.";
107+
fi
108+
100109
if [ ! -d "3rdParty/gmsh" ]; then
101110
echo "Gmsh not found, installing...";
102111
wget http://gmsh.info/bin/Linux/gmsh-4.10.5-Linux64-sdk.tgz

doc/config/Amphi_Pulse_3D.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# 1) Compile the DGalerkin sources (cmake && make)
55
# 2) ./DGalerkin mymesh.msh myconfig.conf
66
# -> First args = mesh file, Second arg = config file
7-
7+
meshFileName = file.msh
88
# Initial, final time and time step(t>0)
99
timeStart=0
1010
timeEnd=0.2

doc/config/Cube.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# 2) ./DGalerkin mymesh.msh myconfig.conf
66
# -> First args = mesh file, Second arg = config file
77

8+
meshFileName = doc/3d/cube.msh
9+
810
# Initial, final time and time step(t>0)
911
timeStart=0
1012
timeEnd=0.005

doc/config/Square.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
# 2) ./DGalerkin mymesh.msh myconfig.conf
66
# -> First args = mesh file, Second arg = config file
77

8+
meshFileName = doc/2d/square2.msh
9+
810
# Initial, final time and time step(t>0)
911
timeStart=0
10-
timeEnd=0.5
12+
timeEnd=0.1
1113
timeStep=0.00005
1214

1315
# Saving rate:
@@ -19,13 +21,11 @@ elementType=Lagrange
1921

2022
# Time integration method:
2123
# ["Euler1", "Euler2", "Runge-Kutta"...]
22-
timeIntMethod=Euler1
24+
timeIntMethod=Runge-Kutta
2325

2426
# Boundary condition:
2527
# /!\ The physical group name must match the Gmsh name (case sensitive)
26-
Reflecting = Reflecting
27-
Absorbing = Absorbing
28-
MyPhysicalName = Absorbing
28+
Abs = Absorbing
2929

3030
# Number of thread
3131
numThreads=12

doc/config/config.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# 1) Compile the DGalerkin sources (cmake && make)
55
# 2) ./DGalerkin mymesh.msh myconfig.conf
66
# -> First args = mesh file, Second arg = config file
7-
7+
meshFileName = file.msh
88
# Initial, final time and time step(t>0)
99
timeStart=0
1010
timeEnd=0.05

doc/config/land.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# 1) Compile the DGalerkin sources (cmake && make)
55
# 2) ./DGalerkin mymesh.msh myconfig.conf
66
# -> First args = mesh file, Second arg = config file
7-
7+
meshFileName = doc/3d/land.msh
88
# Initial, final time and time step(t>0)
99
timeStart=0
1010
timeEnd=5.0

include/Mesh.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Mesh
3939
{
4040

4141
public:
42-
Mesh(std::string name, Config config);
42+
Mesh(Config config);
4343

4444
/**
4545
* List of getters used for vector access and to improve readability.
@@ -217,7 +217,6 @@ class Mesh
217217
void writePVD(std::string filename);
218218

219219
private:
220-
std::string name; // Associated mesh file string
221220
Config config; // Configuration object
222221

223222
int fc = 1; // Numerical flux coefficient

include/configParser.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
#include <map>
44
#include <string>
55

6+
#include <nlohmann/json.hpp>
7+
8+
69
#ifndef DGALERKIN_CONFIG_H
710
#define DGALERKIN_CONFIG_H
811

12+
using json = nlohmann::json;
13+
using ordered_json=nlohmann::ordered_json;
14+
15+
916
//! ////////////////////////////////////////////////////////////////
1017
class Sources
1118
{
@@ -61,6 +68,10 @@ class Sources
6168

6269
struct Config
6370
{
71+
ordered_json jsonData;
72+
73+
std::string meshFileName;
74+
6475
// Initial, final time and time step(t>0)
6576
double timeStart = 0;
6677
double timeEnd = 1;
@@ -106,6 +117,7 @@ struct Config
106117
namespace config
107118
{
108119
Config parseConfig(std::string name);
120+
Config parseJSON(std::string name);
109121
}
110122

111123
#endif

run_caa

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/sh
2-
#export GMSHLIBS=gmsh-4.9.5-Linux64-sdk/lib
3-
#export LD_LIBRARY_PATH=$GMSHLIBS:$LD_LIBRARY_PATH
4-
# build/bin/dgalerkin $1 $2
52

6-
build/bin/dgalerkin doc/2d/square.msh doc/config/Square.conf
7-
# build/bin/dgalerkin doc/3d/cube.msh doc/config/Cube.conf
8-
# build/bin/dgalerkin doc/3d/sphere.msh doc/config/Sphere.conf
9-
# build/bin/dgalerkin doc/3d/Urban_3D.msh doc/config/Urban_3D.conf
10-
# build/bin/dgalerkin doc/3d/land.msh doc/config/land.conf
3+
# build/bin/dgalerkin doc/config/Cube.conf
4+
# build/bin/dgalerkin doc/config/Sphere.conf
5+
# build/bin/dgalerkin doc/config/Urban_3D.conf
6+
# build/bin/dgalerkin doc/config/land.conf
7+
8+
# build/bin/dgalerkin doc/config/Square.conf
9+
10+
build/bin/dgalerkin doc/config/Square.json

0 commit comments

Comments
 (0)