Skip to content
Snippets Groups Projects

Folder structure and naming methods

Merged Ponsuganth Ilangovan Ponkumar Ilango requested to merge ponsuganth/folder-structure into main
1 unresolved thread
Viewing commit 50e6324d
Prev
Show latest version
2 files
+ 106
20
Preferences
Compare changes
Files
2
+ 34
10
@@ -71,13 +71,16 @@ def unfold_toml_dict(toml_dict):
@@ -71,13 +71,16 @@ def unfold_toml_dict(toml_dict):
)
)
operators_unfolded.append(operator_cleared)
operators_unfolded.append(operator_cleared)
elif "components-trial" in operator or "components-test" in operator:
elif "components-trial" in operator or "components-test" in operator:
comp_str = "components-trial" if "components-trial" in operator else "components-test"
comp_str = (
 
"components-trial"
 
if "components-trial" in operator
 
else "components-test"
 
)
for comp in operator[comp_str]:
for comp in operator[comp_str]:
operator_cleared = operator.copy()
operator_cleared = operator.copy()
operator_cleared.pop(comp_str)
operator_cleared.pop(comp_str)
operator_cleared.update({comp_str.replace('s-', '_'): comp})
operator_cleared.update({comp_str.replace("s-", "_"): comp})
operators_unfolded.append(operator_cleared)
operators_unfolded.append(operator_cleared)
print(operators_unfolded)
else:
else:
operators_unfolded.append(operator)
operators_unfolded.append(operator)
toml_dict_unfolded[form_str] = operators_unfolded
toml_dict_unfolded[form_str] = operators_unfolded
@@ -313,7 +316,9 @@ def generate_operator(
@@ -313,7 +316,9 @@ def generate_operator(
trial_space = fe_spaces[spec["trial-space"]]
trial_space = fe_spaces[spec["trial-space"]]
test_space = fe_spaces[spec["test-space"]]
test_space = fe_spaces[spec["test-space"]]
name = elementwise_operator_name(form_str, spec) # Will use operator-name from spec if provided
name = elementwise_operator_name(
 
form_str, spec
 
) # Will use operator-name from spec if provided
optimizations = {
optimizations = {
operator_generation.optimizer.opts_arg_mapping[opt.upper()]
operator_generation.optimizer.opts_arg_mapping[opt.upper()]
for opt in spec["optimizations"]
for opt in spec["optimizations"]
@@ -350,12 +355,24 @@ def generate_operator(
@@ -350,12 +355,24 @@ def generate_operator(
== spec["form-args"]["component_trial"]
== spec["form-args"]["component_trial"]
)
)
if "component_test" in spec and "component_trial" not in spec:
if "form-args" in spec:
 
if (
 
"component_test" in spec["form-args"]
 
and "component_trial" in spec["form-args"]
 
):
 
test_space = function_space.TensorialVectorFunctionSpace(
 
test_space, single_component=spec["form-args"]["component_test"]
 
)
 
trial_space = function_space.TensorialVectorFunctionSpace(
 
trial_space, single_component=spec["form-args"]["component_trial"]
 
)
 
 
elif "component_test" in spec:
test_space = function_space.TensorialVectorFunctionSpace(
test_space = function_space.TensorialVectorFunctionSpace(
test_space, single_component=spec["component_test"]
test_space, single_component=spec["component_test"]
)
)
if "component_trial" in spec and "component_test" not in spec:
elif "component_trial" in spec:
trial_space = function_space.TensorialVectorFunctionSpace(
trial_space = function_space.TensorialVectorFunctionSpace(
trial_space, single_component=spec["component_trial"]
trial_space, single_component=spec["component_trial"]
)
)
@@ -415,7 +432,10 @@ def generate_operator(
@@ -415,7 +432,10 @@ def generate_operator(
optimizations=optimizations,
optimizations=optimizations,
)
)
dir_path = os.path.join(args.output, spec["folder-name"] if "folder-name" in spec.keys() else form_str)
dir_path = os.path.join(
 
args.output,
 
spec["folder-name"] if "folder-name" in spec.keys() else form_str,
 
)
operator.generate_class_code(
operator.generate_class_code(
dir_path,
dir_path,
class_files=operator_generation.operators.CppClassFiles.HEADER_IMPL_AND_VARIANTS,
class_files=operator_generation.operators.CppClassFiles.HEADER_IMPL_AND_VARIANTS,
@@ -437,7 +457,11 @@ def generate_operator(
@@ -437,7 +457,11 @@ def generate_operator(
def elementwise_operator_name(form_str: str, spec: Dict[str, Any]) -> str:
def elementwise_operator_name(form_str: str, spec: Dict[str, Any]) -> str:
operator_name = spec["operator-name"] if "operator-name" in spec else form_str.title().replace("_", "")
operator_name = (
 
spec["operator-name"]
 
if "operator-name" in spec
 
else form_str.title().replace("_", "")
 
)
if spec["trial-space"] == spec["test-space"]:
if spec["trial-space"] == spec["test-space"]:
space_mapping = spec["trial-space"]
space_mapping = spec["trial-space"]
@@ -455,10 +479,10 @@ def elementwise_operator_name(form_str: str, spec: Dict[str, Any]) -> str:
@@ -455,10 +479,10 @@ def elementwise_operator_name(form_str: str, spec: Dict[str, Any]) -> str:
# I do not like this, but should do the trick until we have actual vector function spaces in the HOG.
# I do not like this, but should do the trick until we have actual vector function spaces in the HOG.
if "component_test" in spec and "component_trial" not in spec:
if "component_test" in spec and "component_trial" not in spec:
component = f"_{spec['component_test']}_0"
component = f"_{spec['component_test']}_0"
if "component_trial" in spec and "component_test" not in spec:
if "component_trial" in spec and "component_test" not in spec:
component = f"_0_{spec['component_trial']}"
component = f"_0_{spec['component_trial']}"
blending = ""
blending = ""
if spec.get("blending", "IdentityMap") != "IdentityMap":
if spec.get("blending", "IdentityMap") != "IdentityMap":
blending = spec["blending"]
blending = spec["blending"]