Start computation with arbitrary field data (not functiondefined)
Hello,
I am working on the solution of coupled systems of equations through external coupling of partial systems by the boundary conditions (specifically, CHT coupling for aerothermics). This is typically performed at Onera with the solvers /elsA /for aerodynamics and Zset for thermics, coupled through DirichletRobin, NeumannRobin or similar boundary conditions on temperature and flux at the solid boundaries.
For (possibly athome) research purposes I am trying to create a simpler system, based on SfePy and Gmsh.
The solution by SfePy of the thermal problem on the solid domain works very well (NACA C3X turbine vane), as for the aerodynamics (in laminar flow in a periodic channel at low Reynolds number to reduce computational costs).
I am currently tackling the solution of the aerothermal problem in incompressible flow; again, the solution of the global problem (1:dynamics & 2:thermics combined in 1 system) by SfePy works very well.
I then proceeded to the separation of systems 1 & 2, which are uncoupled for incompressible flow and may be solved successively.
Again, I managedto chain initial computations on the two sets of equations, starting from constant or functiondefined boundary conditions.
For CHT coupling, I will need to (re)start computations from initial fields:
 velocity u
 pressure p
 temperature T
As a check,, I tried to solve the global set of all equations (1+2) from the previous (u, p, T) fields. This would also allow me to output a single file with all the fields for plotting.
I didn't find a way toset the initial fields through initial conditions, because apparently the icsdefinition is used bydiscrete.variables.FieldVariable.setup_initial_conditions()(see code below).
I also tried (last code snippet) using state.set_parts(), with init_fields=False, to no avail.
Please tell, what am I missing ? How can I initialise a field with arbitrary fieldtyped data:
 not defined by a function of the coordinates
 not read from a file
?
Best regards, Marc Lazareff
In my script:
# 1) solve the stationary incompressible dynamics state_dynamics = problem1.solve() ... # 2) solve the stationary thermics (decoupled heat advection) state_thermics = problem2.solve() ... # 3) gather all data u_part = state_dynamics.get_parts()['u’] p_part = state_dynamics.get_parts()['p'] T_part = state_thermics.get_parts()['T']
# initial conditions from fields: *bad, only uses 1 value from each field
ics = { 'icU' : ('Omega', u_part), 'icP' : ('Omega', p_part), 'icT' : ('Omega', T_part), } problem3 = Problem.from_conf(conf, init_equations=False) # , init_fields=False) problem3.setup_default_output() equations3 = {spam:equations0[spam] for spam in ['balance', 'incompressibility', 'neumannP', 'energy']} problem3.set_equations(equations3) variables3 = problem3.get_variables() # (re)solve "coupled" problem state_all = problem3.solve() problem3.save_state(problem3.get_output_name(suffix='all'), state_all)
In SfePy: def setup_initial_conditions(self, ics, di, functions, warn=True): # ML warn=False): """ Setup of initial conditions. """ ics.canonize_dof_names(self.dofs) ics.sort() print(f"setup_initial_conditions: ics = {ics}")
self.initial_condition = nm.zeros((di.n_dof[self.name],), dtype=self.dtype) for ic in ics: region = ic.region dofs, val = ic.dofs print(f"setup_initial_conditions: val = {val}”) # !! only gathers a single value ...
# also tried: state = problem3.create_state() # not OK @ dictionary comprehension, using explicit loop for var in ('u', 'p', 'T'): state.set_parts({var: eval(f"{var}_part")})
Hello Marc,
On 07/02/2022 11:53, Marc Lazareff wrote:
Hello,
I am working on the solution of coupled systems of equations through external coupling of partial systems by the boundary conditions (specifically, CHT coupling for aerothermics). This is typically performed at Onera with the solvers /elsA /for aerodynamics and Zset for thermics, coupled through DirichletRobin, NeumannRobin or similar boundary conditions on temperature and flux at the solid boundaries.
For (possibly athome) research purposes I am trying to create a simpler system, based on SfePy and Gmsh.
The solution by SfePy of the thermal problem on the solid domain works very well (NACA C3X turbine vane), as for the aerodynamics (in laminar flow in a periodic channel at low Reynolds number to reduce computational costs).
I am currently tackling the solution of the aerothermal problem in incompressible flow; again, the solution of the global problem (1:dynamics & 2:thermics combined in 1 system) by SfePy works very well.
I then proceeded to the separation of systems 1 & 2, which are uncoupled for incompressible flow and may be solved successively.
Again, I managedto chain initial computations on the two sets of equations, starting from constant or functiondefined boundary conditions.
For CHT coupling, I will need to (re)start computations from initial fields:
 velocity u
 pressure p
 temperature T
As a check,, I tried to solve the global set of all equations (1+2) from the previous (u, p, T) fields. This would also allow me to output a single file with all the fields for plotting.
I didn't find a way toset the initial fields through initial conditions, because apparently the ics definition is used by discrete.variables.FieldVariable.setup_initial_conditions()(see code below).
You would need to specify the initial conditions by a function. For the nodal basis (the default), the coordinates correspond to the FE nodes and should be in the correct order, so the function could just return the initial DOF vectors.
I also tried (last code snippet) using state.set_parts(), with init_fields=False, to no avail.
Please tell, what am I missing ? How can I initialise a field with arbitrary fieldtyped data:
 not defined by a function of the coordinates
For the nodal basis this should just work, see above. But it's not a very clean solution, I agree.
 not read from a file
<snip> > # also tried: > state = problem3.create_state() > # not OK @ dictionary comprehension, using explicit loop > for var in ('u', 'p', 'T'): > state.set_parts({var: eval(f"{var}_part")})
Here I am guessing that you then call problem.solve() which applies the initial conditions and so replaces the desired values?
I am guessing without having a runable example, but I have some suggestions:
 Have a look at [1]  sfepy can automatically solve equations blockbyblock
(see the 'block_solve' : True in the options).
 Have a look at [2], where a parameter variable is used. (Note that in the git
version of sfepy, .set_data() should/could not be used with state variables, where the new .set_state_parts() should be used, see [3]  do not hesitate to ask.)
If the above does not help, try sending a minimal example that I could run to see the problem.
Best regards, r.
[1] https://sfepy.org/docdevel/examples/multi_physicsthermo_elasticity_ess.htm... [2] https://sfepy.org/docdevel/examples/multi_physicsthermal_electric.html [3] https://github.com/sfepy/sfepy/pull/764#issuecomment1011149413
participants (2)

Marc Lazareff

Robert Cimrman