-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoundaryCondition.cs
49 lines (46 loc) · 1.7 KB
/
BoundaryCondition.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Diffusion2D_Library
{
public class BoundaryCondition
{
public enum ABoundaryCondition { dirichlet, neumann };
// =======================================================================
// Private methods
// =======================================================================
/// <summary>
/// Converts the enumerated boundary condition to a string
/// </summary>
/// <param name="bc">variable of type BoundaryCondition</param>
/// <returns></returns>
public static string ConvertEnumBCToString(ABoundaryCondition bc)
{
string result = bc switch
{
ABoundaryCondition.dirichlet => "Dirichlet",
ABoundaryCondition.neumann => "Neumann",
_ => "Dirichlet",
};
return result;
}
/// <summary>
/// Method to convert a string value to one of the enumerated boundary conditions
/// </summary>
/// <param name="value">string variable to be converted to the boundary condition enum</param>
/// <returns></returns>
public static ABoundaryCondition ConvertStringToEnumBC(string value)
{
ABoundaryCondition bc = value.ToLower() switch
{
"dirichlet" => ABoundaryCondition.dirichlet,
"neumann" => ABoundaryCondition.neumann,
_ => ABoundaryCondition.dirichlet,
};
return bc;
}
// =======================================================================
}
}