Skip to content

Commit

Permalink
Merge pull request #3 from pcarruscag/develop
Browse files Browse the repository at this point in the history
update master
  • Loading branch information
pcarruscag authored Dec 8, 2021
2 parents f098f47 + 750a100 commit d4dfa56
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 36 deletions.
20 changes: 20 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# FADO Authors #

FADO is developed by a community of voluntary contributors who contribute code, bug reports, documentation, support, etc.

## Original Authors ##

```
Pedro Gomes (Imperial College London)
```

## Individual Contributors ##

(extracted using `git shortlog -s --no-merges`, alphabetical order).
Copyright holders might be the individual person or their respective employer. If no real name is available, the Github user name is listed.

```
Pedro Gomes
Tobias Kattmann
```

2 changes: 1 addition & 1 deletion documentation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down
4 changes: 2 additions & 2 deletions drivers/base_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down Expand Up @@ -232,7 +232,7 @@ def setStorageMode(self,keepDesigns=False,dirPrefix="DSN_"):

def setFailureMode(self,mode):
"""
Set the failure behavior, for "HARD" (default) an exeption is throw if function evaluations fail,
Set the failure behavior, for "HARD" (default) an exception is throw if function evaluations fail,
for "SOFT" the driver catches exceptions and uses default function values (if they have them).
The "SOFT" mode is useful if the optimizer does not handle exceptions.
"""
Expand Down
2 changes: 1 addition & 1 deletion drivers/constrained_optim_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down
2 changes: 1 addition & 1 deletion drivers/exterior_penalty.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down
2 changes: 1 addition & 1 deletion drivers/ipopt_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down
4 changes: 2 additions & 2 deletions drivers/parallel_eval_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down Expand Up @@ -187,7 +187,7 @@ def _runAction(self, action):
#end
#end

# Evaluate all functions (objectives and constraints), imediately
# Evaluate all functions (objectives and constraints), immediately
# retrieves and stores the results after shifting and scaling.
def _evaluateFunctions(self, x):
self._handleVariableChange(x)
Expand Down
2 changes: 1 addition & 1 deletion drivers/scipy_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down
22 changes: 14 additions & 8 deletions evaluation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down Expand Up @@ -34,6 +34,7 @@ class ExternalRun:
"""
def __init__(self,dir,command,useSymLinks=False):
self._dataFiles = []
self._dataFilesDestination = []
self._confFiles = []
self._expectedFiles = []
self._workDir = dir
Expand All @@ -54,17 +55,22 @@ def _addAbsoluteFile(self,file,flist):
raise ValueError("File '"+file+"' not found.")
flist.append(file)

def addData(self,file,location="auto"):
def addData(self,file,location="auto",destination=None):
"""
Adds a "data" file to the run, an immutable dependency of the process.
Parameters
----------
file : Path to the file.
location : Type of path, "relative" (to the parent of "dir"), "absolute" (the path
is immediately converted to an absolute path, the file must exist),
or "auto" (tries "absolute" first, reverts to "relative").
file : Path to the file.
location : Type of path, "relative" (to the parent of "dir"), "absolute" (the path
is immediately converted to an absolute path, the file must exist),
or "auto" (tries "absolute" first, falls back to "relative").
destination : Filename to be set at the destination. Discards any additional file path.
The default destination is the regular filename (i.e. "file").
"""
if destination is None: destination = file
self._dataFilesDestination.append(os.path.basename(destination))

if location == "relative":
self._dataFiles.append(file)
else:
Expand Down Expand Up @@ -119,8 +125,8 @@ def initialize(self):

try:
os.mkdir(self._workDir)
for file in self._dataFiles:
target = os.path.join(self._workDir,os.path.basename(file))
for file, destination in zip(self._dataFiles, self._dataFilesDestination):
target = os.path.join(self._workDir,destination)
(shutil.copy,os.symlink)[self._symLinks](os.path.abspath(file),target)

for file in self._confFiles:
Expand Down
16 changes: 6 additions & 10 deletions examples/example3_SU2/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
# two load cases
load_horizontal = Parameter(["1.0, 0.0"],LabelReplacer("__LOAD_DIR__"))
load_vertical = Parameter(["0.0, -1.0"],LabelReplacer("__LOAD_DIR__"))
# for deformation the input mesh is different
mesh_deform = Parameter(["MESH_FILENAME= mesh_ffd.su2"],\
LabelReplacer("MESH_FILENAME= mesh_def.su2"))
# this is a meta-parameter, for SU2_GEO the FFD variables are the FD step sizes
vars_geometry = Parameter(["DV_VALUE=0.001"+",0.001"*(ffd.getSize()-1)],\
LabelReplacer("DV_VALUE= 0"+",0"*(ffd.getSize()-1)))
Expand All @@ -37,7 +34,6 @@
deform = ExternalRun("DEFORM","SU2_DEF settings.cfg",True)
deform.addConfig("settings.cfg")
deform.addData("mesh_ffd.su2")
deform.addParameter(mesh_deform)
# these parameters are not relevant but are needed to make a valid config
deform.addParameter(load_vertical)
deform.addParameter(filter_type)
Expand All @@ -47,7 +43,7 @@
# geometric properties
geometry = ExternalRun("GEOMETRY","SU2_GEO settings.cfg",True)
geometry.addConfig("settings.cfg")
geometry.addData("DEFORM/mesh_def.su2")
geometry.addData("DEFORM/mesh_def.su2",destination="mesh_ffd.su2")
geometry.addParameter(vars_geometry)
# these parameters are not relevant but are needed to make a valid config
geometry.addParameter(load_vertical)
Expand All @@ -59,7 +55,7 @@
hload_dir = ExternalRun("HLOAD","SU2_CFD -t 2 settings.cfg",True)
hload_dir.addConfig("settings.cfg")
hload_dir.addConfig("element_properties.dat")
hload_dir.addData("DEFORM/mesh_def.su2")
hload_dir.addData("DEFORM/mesh_def.su2",destination="mesh_ffd.su2")
hload_dir.addParameter(load_horizontal)
hload_dir.addParameter(filter_type)
hload_dir.addParameter(filter_radius)
Expand All @@ -69,7 +65,7 @@
vload_dir = ExternalRun("VLOAD","SU2_CFD -t 2 settings.cfg",True)
vload_dir.addConfig("settings.cfg")
vload_dir.addConfig("element_properties.dat")
vload_dir.addData("DEFORM/mesh_def.su2")
vload_dir.addData("DEFORM/mesh_def.su2",destination="mesh_ffd.su2")
vload_dir.addParameter(load_vertical)
vload_dir.addParameter(filter_type)
vload_dir.addParameter(filter_radius)
Expand All @@ -83,7 +79,7 @@
volume = ExternalRun("VOLUME",adj_command.replace("FUN","volfrac"),True)
volume.addConfig("settings.cfg")
volume.addConfig("element_properties.dat")
volume.addData("DEFORM/mesh_def.su2")
volume.addData("DEFORM/mesh_def.su2",destination="mesh_ffd.su2")
volume.addData("direct.dat") # dummy solution file
volume.addParameter(func_constraint)
volume.addParameter(iter_constraint)
Expand All @@ -97,7 +93,7 @@
hload_adj = ExternalRun("HLOAD_ADJ",adj_command.replace("FUN","refnode"),True)
hload_adj.addConfig("settings.cfg")
hload_adj.addConfig("element_properties.dat")
hload_adj.addData("DEFORM/mesh_def.su2")
hload_adj.addData("DEFORM/mesh_def.su2",destination="mesh_ffd.su2")
hload_adj.addData("HLOAD/direct.dat")
hload_adj.addParameter(load_horizontal)
hload_adj.addParameter(filter_type)
Expand All @@ -108,7 +104,7 @@
vload_adj = ExternalRun("VLOAD_ADJ",adj_command.replace("FUN","refnode"),True)
vload_adj.addConfig("settings.cfg")
vload_adj.addConfig("element_properties.dat")
vload_adj.addData("DEFORM/mesh_def.su2")
vload_adj.addData("DEFORM/mesh_def.su2",destination="mesh_ffd.su2")
vload_adj.addData("VLOAD/direct.dat")
vload_adj.addParameter(load_vertical)
vload_adj.addParameter(filter_type)
Expand Down
2 changes: 1 addition & 1 deletion examples/example3_SU2/settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ DISCADJ_LIN_SOLVER= CONJUGATE_GRADIENT
DISCADJ_LIN_PREC= ILU
%
% In/Out
MESH_FILENAME= mesh_def.su2
MESH_FILENAME= mesh_ffd.su2
MESH_OUT_FILENAME= mesh_def.su2
MESH_FORMAT= SU2
SOLUTION_FILENAME= direct.dat
Expand Down
4 changes: 2 additions & 2 deletions function.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand All @@ -20,7 +20,7 @@


class FunctionBase(abc.ABC):
"""Abstract base class to define the essencial interface of Function objects."""
"""Abstract base class to define the essential interface of Function objects."""
def __init__(self,name):
self._name = name
# inputs
Expand Down
2 changes: 1 addition & 1 deletion optimizers/fletcher_reeves.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down
2 changes: 1 addition & 1 deletion optimizers/line_searches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down
4 changes: 2 additions & 2 deletions tools/file_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down Expand Up @@ -85,7 +85,7 @@ class PreStringHandler:
Read or write "delim"-separated values in front of a label (prefix-string),
which must start the line. Both label and delimiter are passed to __init__.
When reading the class can only handle the first occurrence of the label,
when writing every occurence will be handled.
when writing every occurrence will be handled.
Example
-------
Expand Down
2 changes: 1 addition & 1 deletion tools/variable_transformation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down
2 changes: 1 addition & 1 deletion variable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2020, Pedro Gomes.
# Copyright 2019-2020, FADO Contributors (cf. AUTHORS.md)
#
# This file is part of FADO.
#
Expand Down

0 comments on commit d4dfa56

Please sign in to comment.