Skip to content

Commit

Permalink
Merge pull request #37 from frkasper/2022.1
Browse files Browse the repository at this point in the history
Merging 2022.1 cycle for MacroUtils.
  • Loading branch information
Fabio Kasper authored Feb 23, 2022
2 parents 683e395 + 16c3a0d commit 668a568
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MacroUtils is a collection of high-level APIs in order to make your life easier

## Requires

1. Simcenter STAR-CCM+ v2021.3 libraries;
1. Simcenter STAR-CCM+ v2022.1 libraries;

1. Integrated development environment (IDE) supporting JDK 11 and gradle -- e.g.: NetBeans 11 or later.

Expand Down
4 changes: 2 additions & 2 deletions macroutils/src/macroutils/MacroUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
*
* <b>Requires:</b>
* <ul>
* <li> Simcenter STAR-CCM+ 2021.3 libraries (<u>It may not run in other versions</u>);
* <li> Simcenter STAR-CCM+ 2022.1 libraries (<u>It may not run in other versions</u>);
* </ul>
*
* @since STAR-CCM+ v7.02, May of 2012
* @author Fabio Kasper
* @version 2021.3
* @version 2022.1
*/
public final class MacroUtils {

Expand Down
13 changes: 9 additions & 4 deletions macroutils/src/macroutils/creator/CreatePhysicsContinua.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import star.common.CompositeArrayProfileMethod;
import star.common.EulerianPhase;
import star.common.ExplicitUnsteadyModel;
import star.common.FieldFunction;
import star.common.FunctionScalarProfileMethod;
import star.common.FunctionVectorProfileMethod;
import star.common.ImplicitUnsteadyModel;
Expand Down Expand Up @@ -129,20 +130,24 @@ public FlatVofWave createWave(PhysicsContinuum pc, double[] ptLvl, double[] vert
_ud.unit_kgpm3, "Heavy Fluid Density", true);
//--
//-- Apply Wave Initial Conditions
FieldFunction ffp = _get.objects.fieldFunction("Hydrostatic Pressure.*", true);
FieldFunction ffvfh = _get.objects.fieldFunction("Volume Fraction.*Heavy.*", true);
FieldFunction ffvfl = _get.objects.fieldFunction("Volume Fraction.*Light.*", true);
FieldFunction ffvel = _get.objects.fieldFunction("Velocity of .*Wave.*", true);
InitialPressureProfile ipp = pc.getInitialConditions().get(InitialPressureProfile.class);
ipp.setMethod(FunctionScalarProfileMethod.class);
ipp.getMethod(FunctionScalarProfileMethod.class).setFieldFunction(fvw.getPressureFF());
ipp.getMethod(FunctionScalarProfileMethod.class).setFieldFunction(ffp);
VolumeFractionProfile vfp = pc.getInitialConditions().get(VolumeFractionProfile.class);
vfp.setMethod(CompositeArrayProfileMethod.class);
ScalarProfile sp0 = vfp.getMethod(CompositeArrayProfileMethod.class).getProfile(0);
sp0.setMethod(FunctionScalarProfileMethod.class);
ScalarProfile sp1 = vfp.getMethod(CompositeArrayProfileMethod.class).getProfile(1);
sp1.setMethod(FunctionScalarProfileMethod.class);
sp0.getMethod(FunctionScalarProfileMethod.class).setFieldFunction(fvw.getVofHeavyFF());
sp1.getMethod(FunctionScalarProfileMethod.class).setFieldFunction(fvw.getVofLightFF());
sp0.getMethod(FunctionScalarProfileMethod.class).setFieldFunction(ffvfh);
sp1.getMethod(FunctionScalarProfileMethod.class).setFieldFunction(ffvfl);
VelocityProfile vpp = pc.getInitialConditions().get(VelocityProfile.class);
vpp.setMethod(FunctionVectorProfileMethod.class);
vpp.getMethod(FunctionVectorProfileMethod.class).setFieldFunction(fvw.getVelocityFF());
vpp.getMethod(FunctionVectorProfileMethod.class).setFieldFunction(ffvel);
//--
_io.say.created(fvw, true);
return fvw;
Expand Down
10 changes: 6 additions & 4 deletions macroutils/src/macroutils/setter/SetSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,12 @@ private void _updateURFs_EMP() {
SegregatedMultiPhaseSolver emps = _get.solver.byClass(SegregatedMultiPhaseSolver.class);
MultiPhaseVelocitySolver empv = emps.getVelocitySolver();
MultiPhasePressureSolver empp = emps.getPressureSolver();
empv.setUrf(_ud.urfPhsCplVel);
empp.setUrf(_ud.urfP);
_io.say.value("URF Phase Couple Velocity", empv.getUrf(), true);
_io.say.value("URF Pressure", empp.getUrf(), true);
ScalarPhysicalQuantity urfp = empp.getUrfQuantity();
ScalarPhysicalQuantity urfv = empv.getUrfQuantity();
urfp.setValue(_ud.urfP);
urfv.setValue(_ud.urfPhsCplVel);
_io.say.value("URF Phase Couple Velocity", urfv.getRawValue(), true);
_io.say.value("URF Pressure", urfp.getRawValue(), true);
}

private void _updateURFs_OtherSolvers() {
Expand Down
14 changes: 7 additions & 7 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
attrs==20.3.0
attrs==21.4.0
iniconfig==1.1.1
packaging==20.9
pluggy==0.13.1
py==1.10.0
pyparsing==2.4.7
pytest==6.2.2
toml==0.10.2
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.0.7
pytest==7.0.1
tomli==2.0.1
2 changes: 1 addition & 1 deletion tests/test/test_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def _assert_opacity_bug_14(key, expected):
re_patt = 'Scene -> \w+ -> \w+ -> %s Opacity:\s(.*)\n' % key
re_patt = r'Scene -> \w+ -> \w+ -> %s Opacity:\s(.*)\n' % key
actual = _float(re_patt, _bug_sim(1))
test_utils.assert_value(actual, expected, tolerance=0)

Expand Down
8 changes: 4 additions & 4 deletions tests/test/test_demo05.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_kart_wrap_part_surfaces_count():


def test_cell_count():
test_utils.assert_cell_count(DEMO_ID, 621000, tolerance=0.01)
test_utils.assert_cell_count(DEMO_ID, 610000, tolerance=0.025)


def test_solution():
Expand All @@ -40,12 +40,12 @@ def test_cl_report():


def test_scalar_pressure_kart_min():
test_utils.assert_scene_min(DEMO_ID, 'Pressure Kart', 'Scalar', -2.0,
test_utils.assert_scene_min(DEMO_ID, 'Pressure Kart', 'Scalar', -1.5,
tolerance=0.2, relative=False)


def test_scalar_pressure_kart_max():
test_utils.assert_scene_max(DEMO_ID, 'Pressure Kart', 'Scalar', 5.2,
test_utils.assert_scene_max(DEMO_ID, 'Pressure Kart', 'Scalar', 4.3,
tolerance=0.1, relative=True)


Expand All @@ -55,7 +55,7 @@ def test_scalar_pressure_section_min():


def test_scalar_pressure_section_max():
test_utils.assert_scene_max(DEMO_ID, 'Pressure Section', 'Scalar', 5.3,
test_utils.assert_scene_max(DEMO_ID, 'Pressure Section', 'Scalar', 4.3,
tolerance=0.1, relative=True)


Expand Down
2 changes: 1 addition & 1 deletion tests/test/test_demo11.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_subtract_part_surfaces_count():


def test_cell_count():
test_utils.assert_cell_count(DEMO_ID, 156500, tolerance=0.01)
test_utils.assert_cell_count(DEMO_ID, 165000, tolerance=0.025)


def test_scalar_min():
Expand Down
4 changes: 2 additions & 2 deletions tests/test/test_demo12.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def test_cfl_avg_report():


def test_cfl_max_report():
test_utils.assert_report(DEMO_ID, 'CFL_max', 8.0,
tolerance=0.7, relative=False)
test_utils.assert_report(DEMO_ID, 'CFL_max', 8.5,
tolerance=1.0, relative=False)


def test_time_report():
Expand Down
16 changes: 8 additions & 8 deletions tests/test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def _assert_content_count(key, argument, expected, tolerance, relative):
actual = _float_from_argument('%s Count:\s(.*)\n' % key, argument)
actual = _float_from_argument(r'%s Count:\s(.*)\n' % key, argument)
print('\n[assert %s Count]: ' % key),
assert_value(actual, expected, tolerance, relative)

Expand All @@ -28,14 +28,14 @@ def _assert_exists(filename):


def _assert_report(argument, report_name, expected, tolerance, relative):
re_patt = 'Report -> %s:\s(.*)\n' % report_name
re_patt = r'Report -> %s:\s(.*)\n' % report_name
actual = _float_from_argument(re_patt, argument)
print('\n[assert Report] %s: ' % report_name),
assert_value(actual, expected, tolerance, relative)


def _assert_scene(argument, scene, displayer, expected, tol, relative, key):
re_patt = 'Scene -> %s -> \w+ -> %s %s:\s(.*)\n' % (scene, displayer, key)
re_patt = r'Scene -> %s -> \w+ -> %s %s:\s(.*)\n' % (scene, displayer, key)
actual = _float_from_argument(re_patt, argument)
print('\n[assert Scene] %s -> %s: ' % (scene, displayer)),
assert_value(actual, expected, tol, relative)
Expand Down Expand Up @@ -189,14 +189,14 @@ def assert_pictures_count_in_folder(glob_pattern, expected):

def assert_part_surfaces_count(argument, part_name, expected, tolerance=0,
relative=False):
actual = _float_from_argument('Part -> %s:\s(\d+) Part' % part_name,
actual = _float_from_argument(r'Part -> %s:\s(\d+) Part' % part_name,
argument)
print('\n[assert Part Surfaces Count]: '),
assert_value(actual, expected, tolerance, relative)


def assert_iteration(argument, expected, tolerance=0.0, relative=False):
actual = _int_from_argument('Iteration:\s(\d+)', argument)
actual = _int_from_argument(r'Iteration:\s(\d+)', argument)
assert_value(actual, expected, tolerance, relative)


Expand Down Expand Up @@ -228,7 +228,7 @@ def assert_summary_contents_by_sim_file(filename):


def assert_time(argument, expected, tolerance=0.0001, relative=True):
actual = _float_from_argument('Time:\s(.*)\n', argument)
actual = _float_from_argument(r'Time:\s(.*)\n', argument)
assert_value(actual, expected, tolerance, relative)


Expand Down Expand Up @@ -260,8 +260,8 @@ def assert_vertex_count(argument, expected, tolerance=0.005, relative=True):

def demo_id(filename):
"""Get the demo_number from a test macro"""
b1 = re.match('.*/test_demo\d{2}\.py', filename)
found = re.findall('.*/test_demo(\d{2})\.py', filename)
b1 = re.match(r'.*/test_demo\d{2}\.py', filename)
found = re.findall(r'.*/test_demo(\d{2})\.py', filename)
b2 = len(found) == 1
is_test_file = b1 and b2
assert is_test_file, 'Not a test file: "%s"' % filename
Expand Down

0 comments on commit 668a568

Please sign in to comment.