Skip to content
Snippets Groups Projects
Commit 7844d0d6 authored by Jean-Baptiste Keck's avatar Jean-Baptiste Keck
Browse files

replaced sh with bash, added can_split to the logs, fixed head_equation example

parent eebb4f95
No related branches found
No related tags found
1 merge request!16MPI operators
Pipeline #19972 failed
...@@ -17,8 +17,8 @@ config:bionic: ...@@ -17,8 +17,8 @@ config:bionic:
image: keckj/hysop:ubuntu_bionic image: keckj/hysop:ubuntu_bionic
stage: configure stage: configure
script: script:
- "sh ci/scripts/config.sh $CI_PROJECT_DIR/build/gcc-7 $CI_PROJECT_DIR/install/gcc-7 gcc-7 g++-7 gfortran-7" - "bash ci/scripts/config.sh $CI_PROJECT_DIR/build/gcc-7 $CI_PROJECT_DIR/install/gcc-7 gcc-7 g++-7 gfortran-7"
- "sh ci/scripts/config.sh $CI_PROJECT_DIR/build/clang-6 $CI_PROJECT_DIR/install/clang-6 clang-6.0 clang++-6.0 gfortran-7" - "bash ci/scripts/config.sh $CI_PROJECT_DIR/build/clang-6 $CI_PROJECT_DIR/install/clang-6 clang-6.0 clang++-6.0 gfortran-7"
dependencies: dependencies:
- env:bionic - env:bionic
artifacts: artifacts:
...@@ -29,8 +29,8 @@ build:bionic: ...@@ -29,8 +29,8 @@ build:bionic:
image: keckj/hysop:ubuntu_bionic image: keckj/hysop:ubuntu_bionic
stage: build stage: build
script: script:
- "sh ci/scripts/build.sh $CI_PROJECT_DIR/build/gcc-7 gcc-7 g++-7 gfortran-7" - "bash ci/scripts/build.sh $CI_PROJECT_DIR/build/gcc-7 gcc-7 g++-7 gfortran-7"
- "sh ci/scripts/build.sh $CI_PROJECT_DIR/build/clang-6 clang-6.0 clang++-6.0 gfortran-7" - "bash ci/scripts/build.sh $CI_PROJECT_DIR/build/clang-6 clang-6.0 clang++-6.0 gfortran-7"
dependencies: dependencies:
- config:bionic - config:bionic
artifacts: artifacts:
...@@ -41,7 +41,7 @@ install:bionic: ...@@ -41,7 +41,7 @@ install:bionic:
image: keckj/hysop:ubuntu_bionic image: keckj/hysop:ubuntu_bionic
stage: install stage: install
script: script:
- "sh ci/scripts/install.sh $CI_PROJECT_DIR/build/gcc-7 $CI_PROJECT_DIR/install/gcc-7" - "bash ci/scripts/install.sh $CI_PROJECT_DIR/build/gcc-7 $CI_PROJECT_DIR/install/gcc-7"
dependencies: dependencies:
- build:bionic - build:bionic
artifacts: artifacts:
...@@ -52,7 +52,7 @@ test:bionic: ...@@ -52,7 +52,7 @@ test:bionic:
image: keckj/hysop:ubuntu_bionic image: keckj/hysop:ubuntu_bionic
stage: test stage: test
script: script:
- "sh ci/scripts/test.sh $CI_PROJECT_DIR/install/gcc-7 $CI_PROJECT_DIR/hysop $CI_PROJECT_DIR/cache" - "bash ci/scripts/test.sh $CI_PROJECT_DIR/install/gcc-7 $CI_PROJECT_DIR/hysop $CI_PROJECT_DIR/cache"
dependencies: dependencies:
- install:bionic - install:bionic
cache: cache:
......
"""Example for fixed point iteration inside Simulation. """
Example for fixed point iteration inside Simulation.
We consider steady state of heat equation with a varying source term. We consider steady state of heat equation with a varying source term.
Each time step, the source terms are computed analytically and then an Each time step, the source terms are computed analytically and then an
...@@ -6,6 +7,7 @@ iterative method is used to compute steady state solution. ...@@ -6,6 +7,7 @@ iterative method is used to compute steady state solution.
""" """
import numpy as np import numpy as np
import sympy as sp
from hysop import Box, Simulation, Problem, Field, MPIParams from hysop import Box, Simulation, Problem, Field, MPIParams
from hysop.constants import Implementation, HYSOP_REAL, Backend, ResidualError from hysop.constants import Implementation, HYSOP_REAL, Backend, ResidualError
...@@ -15,13 +17,12 @@ from hysop.operators import StrangSplitting, DirectionalDiffusion, \ ...@@ -15,13 +17,12 @@ from hysop.operators import StrangSplitting, DirectionalDiffusion, \
from hysop.methods import StrangOrder from hysop.methods import StrangOrder
from hysop.parameters.scalar_parameter import ScalarParameter from hysop.parameters.scalar_parameter import ScalarParameter
from hysop.topology.cartesian_topology import CartesianTopology from hysop.topology.cartesian_topology import CartesianTopology
from hysop.tools.parameters import Discretization from hysop.tools.parameters import CartesianDiscretization
from hysop.iterative_method import PseudoSimulation, IterativeMethod from hysop.iterative_method import PseudoSimulation, IterativeMethod
from hysop.symbolic.relational import Assignment from hysop.symbolic.relational import Assignment
from hysop.symbolic.misc import Select from hysop.symbolic.misc import Select
from hysop.symbolic.tmp import TmpScalar from hysop.symbolic.tmp import TmpScalar
from hysop.simulation import eps from hysop.simulation import eps
import sympy as sp
# Define the domain # Define the domain
...@@ -45,7 +46,7 @@ pseudo_dt = ScalarParameter(name='pseudo_dt', dtype=HYSOP_REAL, min_value=eps, ...@@ -45,7 +46,7 @@ pseudo_dt = ScalarParameter(name='pseudo_dt', dtype=HYSOP_REAL, min_value=eps,
topo_nogh = CartesianTopology( topo_nogh = CartesianTopology(
domain=box, domain=box,
backend=Backend.HOST, backend=Backend.HOST,
discretization=Discretization(npts, ghosts=(0, 0, 0)), discretization=CartesianDiscretization(npts, ghosts=(0, 0, 0), default_boundaries=True),
mpi_params=mpi_params) mpi_params=mpi_params)
# Operator for setting iterative method # Operator for setting iterative method
......
...@@ -230,8 +230,8 @@ enstrophy_op = Enstrophy( ...@@ -230,8 +230,8 @@ enstrophy_op = Enstrophy(
implementation=Implementation.PYTHON, **extra_op_kwds) implementation=Implementation.PYTHON, **extra_op_kwds)
### Adaptive timestep operator ### Adaptive timestep operator
#TODO:move advection to GRAD_U #TODO: move advection to GRAD_U
#TODO:add stretching criteria, based on a gradient #TODO: add stretching criteria, based on a gradient
adapt_dt = AdaptiveTimeStep(dt, equivalent_CFL=True, adapt_dt = AdaptiveTimeStep(dt, equivalent_CFL=True,
start_time=10*dt0) # start adapting timestep at t=10*dt0 start_time=10*dt0) # start adapting timestep at t=10*dt0
dt_cfl = adapt_dt.push_cfl_criteria(cfl=cfl, dt_cfl = adapt_dt.push_cfl_criteria(cfl=cfl,
...@@ -268,8 +268,8 @@ problem.insert( ...@@ -268,8 +268,8 @@ problem.insert(
) )
problem.build() problem.build()
# # Create a simulation ## Create a simulation
# # (do not forget to specify the t and dt parameters here) ## (do not forget to specify the t and dt parameters here)
simu = Simulation(start=0., end=10.0, simu = Simulation(start=0., end=10.0,
dt0=dt0, t=t, dt=dt) dt0=dt0, t=t, dt=dt)
simu.write_parameters(t, dt_cfl, dt_advec, dt, enstrophy, flowrate, simu.write_parameters(t, dt_cfl, dt_advec, dt, enstrophy, flowrate,
......
...@@ -95,9 +95,10 @@ class ComputationalGraph(ComputationalGraphNode): ...@@ -95,9 +95,10 @@ class ComputationalGraph(ComputationalGraphNode):
ghosts = u'{}<=ghosts<{}'.format(min_ghosts, max_ghosts) ghosts = u'{}<=ghosts<{}'.format(min_ghosts, max_ghosts)
can_split=req.can_split.view(npw.int8) can_split=req.can_split.view(npw.int8)
memory_order=u'{}'.format(req.memory_order) if req.memory_order else u'ANY' memory_order=u'{}'.format(req.memory_order) if req.memory_order else u'ANY'
can_split=u'[{}]'.format(u','.join('1' if cs else '0' for cs in req.can_split))
tstates=u'{}'.format(u','.join(str(ts) for ts in req.tstates)) \ tstates=u'{}'.format(u','.join(str(ts) for ts in req.tstates)) \
if req.tstates else 'ANY' if req.tstates else 'ANY'
sin.append( (opname, fname, discr, ghosts, memory_order, tstates) ) sin.append( (opname, fname, discr, ghosts, memory_order, can_split, tstates) )
for field, mreqs in requirements.output_field_requirements.iteritems(): for field, mreqs in requirements.output_field_requirements.iteritems():
for td, reqs in mreqs.requirements.iteritems(): for td, reqs in mreqs.requirements.iteritems():
for req in reqs: for req in reqs:
...@@ -114,19 +115,21 @@ class ComputationalGraph(ComputationalGraphNode): ...@@ -114,19 +115,21 @@ class ComputationalGraph(ComputationalGraphNode):
ghosts = u'{}<=ghosts<{}'.format(min_ghosts, max_ghosts) ghosts = u'{}<=ghosts<{}'.format(min_ghosts, max_ghosts)
can_split=req.can_split.view(npw.int8) can_split=req.can_split.view(npw.int8)
memory_order=u'{}'.format(req.memory_order) if req.memory_order else u'ANY' memory_order=u'{}'.format(req.memory_order) if req.memory_order else u'ANY'
can_split=u'[{}]'.format(u','.join('1' if cs else '0' for cs in req.can_split))
tstates=u'{}'.format(u','.join(str(ts) for ts in req.tstates)) \ tstates=u'{}'.format(u','.join(str(ts) for ts in req.tstates)) \
if req.tstates else u'ANY' if req.tstates else u'ANY'
sout.append( (opname, fname, discr, ghosts, memory_order, tstates) ) sout.append( (opname, fname, discr, ghosts, memory_order, can_split, tstates) )
titles = [[(u'OPERATOR', u'FIELD', u'DISCRETIZATION', u'GHOSTS', u'MEMORY ORDER', u'TSTATES')]] titles = [[(u'OPERATOR', u'FIELD', u'DISCRETIZATION', u'GHOSTS', u'MEMORY ORDER', u'CAN_SPLIT', u'TSTATES')]]
name_size = max(len(s[0]) for ss in sinputs.values()+soutputs.values()+titles for s in ss) name_size = max(len(s[0]) for ss in sinputs.values()+soutputs.values()+titles for s in ss)
field_size = max(len(s[1]) for ss in sinputs.values()+soutputs.values()+titles for s in ss) field_size = max(len(s[1]) for ss in sinputs.values()+soutputs.values()+titles for s in ss)
discr_size = max(len(s[2]) for ss in sinputs.values()+soutputs.values()+titles for s in ss) discr_size = max(len(s[2]) for ss in sinputs.values()+soutputs.values()+titles for s in ss)
ghosts_size = max(len(s[3]) for ss in sinputs.values()+soutputs.values()+titles for s in ss) ghosts_size = max(len(s[3]) for ss in sinputs.values()+soutputs.values()+titles for s in ss)
order_size = max(len(s[4]) for ss in sinputs.values()+soutputs.values()+titles for s in ss) order_size = max(len(s[4]) for ss in sinputs.values()+soutputs.values()+titles for s in ss)
tstates_size = max(len(s[5]) for ss in sinputs.values()+soutputs.values()+titles for s in ss) cansplit_size = max(len(s[5]) for ss in sinputs.values()+soutputs.values()+titles for s in ss)
tstates_size = max(len(s[6]) for ss in sinputs.values()+soutputs.values()+titles for s in ss)
template = u'\n {:<{name_size}} {:^{field_size}} {:^{discr_size}} {:^{ghosts_size}} {:^{order_size}} {:^{tstates_size}}' template = u'\n {:<{name_size}} {:^{field_size}} {:^{discr_size}} {:^{ghosts_size}} {:^{order_size}} {:^{cansplit_size}} {:^{tstates_size}}'
ss= u'>INPUTS:' ss= u'>INPUTS:'
if sinputs: if sinputs:
...@@ -138,13 +141,15 @@ class ComputationalGraph(ComputationalGraphNode): ...@@ -138,13 +141,15 @@ class ComputationalGraph(ComputationalGraphNode):
ss+= template.format(*titles[0][0], ss+= template.format(*titles[0][0],
name_size=name_size, field_size=field_size, name_size=name_size, field_size=field_size,
discr_size=discr_size, ghosts_size=ghosts_size, discr_size=discr_size, ghosts_size=ghosts_size,
order_size=order_size, tstates_size=tstates_size) order_size=order_size, cansplit_size=cansplit_size,
for (opname, fname, discr, ghosts, order, tstates) in sreqs: tstates_size=tstates_size)
for (opname, fname, discr, ghosts, order, can_split, tstates) in sreqs:
ss+=template.format( ss+=template.format(
opname, fname, discr, ghosts, order, tstates, opname, fname, discr, ghosts, order, can_split, tstates,
name_size=name_size, field_size=field_size, name_size=name_size, field_size=field_size,
discr_size=discr_size, ghosts_size=ghosts_size, discr_size=discr_size, ghosts_size=ghosts_size,
order_size=order_size, tstates_size=tstates_size) order_size=order_size, cansplit_size=cansplit_size,
tstates_size=tstates_size)
else: else:
ss+=u' None' ss+=u' None'
ss+= u'\n>OUTPUTS:' ss+= u'\n>OUTPUTS:'
...@@ -157,13 +162,15 @@ class ComputationalGraph(ComputationalGraphNode): ...@@ -157,13 +162,15 @@ class ComputationalGraph(ComputationalGraphNode):
ss+= template.format(*titles[0][0], ss+= template.format(*titles[0][0],
name_size=name_size, field_size=field_size, name_size=name_size, field_size=field_size,
discr_size=discr_size, ghosts_size=ghosts_size, discr_size=discr_size, ghosts_size=ghosts_size,
order_size=order_size, tstates_size=tstates_size) order_size=order_size, cansplit_size=cansplit_size,
for (opname, fname, discr, ghosts, order, tstates) in sreqs: tstates_size=tstates_size)
for (opname, fname, discr, ghosts, order, can_split, tstates) in sreqs:
ss+=template.format( ss+=template.format(
opname, fname, discr, ghosts, order, tstates, opname, fname, discr, ghosts, order, can_split, tstates,
name_size=name_size, field_size=field_size, name_size=name_size, field_size=field_size,
discr_size=discr_size, ghosts_size=ghosts_size, discr_size=discr_size, ghosts_size=ghosts_size,
order_size=order_size, tstates_size=tstates_size) order_size=order_size, cansplit_size=cansplit_size,
tstates_size=tstates_size)
else: else:
ss+=u' None' ss+=u' None'
......
...@@ -63,8 +63,6 @@ class PseudoSimulation(Simulation): ...@@ -63,8 +63,6 @@ class PseudoSimulation(Simulation):
vprint(msg.format(self.current_iteration, crit)) vprint(msg.format(self.current_iteration, crit))
class IterativeMethod(Problem): class IterativeMethod(Problem):
"""Overriding a Problem to enfoce a PseudoSimulation for iterative method loop. """Overriding a Problem to enfoce a PseudoSimulation for iterative method loop.
...@@ -128,3 +126,6 @@ class IterativeMethod(Problem): ...@@ -128,3 +126,6 @@ class IterativeMethod(Problem):
loop.current_iteration, loop.stop_criteria.value)) loop.current_iteration, loop.stop_criteria.value))
self.it_num.value = loop.current_iteration self.it_num.value = loop.current_iteration
loop.finalize() loop.finalize()
def get_preserved_input_fields(self):
return set()
...@@ -126,8 +126,8 @@ class Parameter(TaggedObject, VariableTag): ...@@ -126,8 +126,8 @@ class Parameter(TaggedObject, VariableTag):
value = value._get_value() value = value._get_value()
self._set_value_impl(value) self._set_value_impl(value)
if not self.quiet: if not self.quiet:
if __DEBUG__ or main_rank == 0: if __DEBUG__ or (main_rank == 0):
msg='[{}]>Parameter {} set to {}.'.format( msg='[{}] >Parameter {} set to {}.'.format(
main_rank, self.pretty_name, value) main_rank, self.pretty_name, value)
vprint(msg) vprint(msg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment