How to specify material constants for regions of type facet

46 views
Skip to first unread message

Geoff Wright

unread,
Nov 9, 2015, 6:42:21 PM11/9/15
to sfepy-devel
I just updated sfepy to the latest master (previous version was about 1 year old) and I'm having trouble evaluating an FEM model that was working with the old version.  The full script is pretty long so I will try to summarize here.  It seems that a region of facet type is no longer able to evaluate it's material properties where the material properties were defined on other related regions of cell type.

Robert, do you know off hand of any changes to Region or Material that may have broken this?  Otherwise, I can try to reproduce it in a simpler use case, for debugging.. anyway here is a description of whats happening:

A material is defined as follows:

self.matP = Material('elecProps', kind='stationary', values={'sigma' : {
        'BloodPool' : sigma_blood,
        'Tissue' : sigma_tissue}})

One of the terms is as follows:

probeFlux = Term.new('dw_surface_integrate(elecProps.sigma, s)', self.integral, self.probeSurf, elecProps=self.matP, s=self.s)

where self.probeSurf is defined as follows (it contains no cells, only facets):

self.probeSurf = self.domain.create_region('ProbeSurf', 'r.Probe *f r.Tissue', kind='facet', parent='Tissue')


When I run the full script I get the following backtrace:



/usr/local/lib/python2.7/dist-packages/sfepy/discrete/problem.pyc in solve(self, state0, nls_status, ls_conf, nls_conf, force_values, var_data)
   1012         self.equations.set_data(var_data, ignore_unknown=True)
   1013 
-> 1014         self.update_materials()
   1015         state0.apply_ebc(force_values=force_values)
   1016 

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/problem.pyc in update_materials(self, ts, mode, verbose)
    528             self.update_time_stepper(ts)
    529             self.equations.time_update_materials(self.ts, mode=mode,
--> 530                                                  problem=self, verbose=verbose)
    531 
    532 

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/equations.pyc in time_update_materials(self, ts, mode, problem, verbose)
    318         """
    319         self.materials.time_update(ts, self, mode=mode, problem=problem,
--> 320                                    verbose=verbose)
    321 
    322     def setup_initial_conditions(self, ics, functions=None):

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/materials.pyc in time_update(self, ts, equations, mode, problem, verbose)
     55         for mat in self:
     56             if verbose: output(' ', mat.name)
---> 57             mat.time_update(ts, equations, mode=mode, problem=problem)
     58         if verbose: output('...done in %.2f s' % (time.clock() - tt))
     59 

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/materials.pyc in time_update(self, ts, equations, mode, problem)
    304 
    305         for key, term in self.iter_terms(equations):
--> 306             self.update_data(key, ts, equations, term, problem=problem)
    307 
    308         self.update_special_data(ts, equations, problem=problem)

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/materials.pyc in update_data(self, key, ts, equations, term, problem)
    220         data = self.function(ts, coors, mode='qp',
    221                              equations=equations, term=term, problem=problem,
--> 222                              **self.extra_args)
    223 
    224         self.set_data(key, qps, data)

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/functions.pyc in __call__(self, *args, **kwargs)
     32         _kwargs = dict(kwargs)
     33         _kwargs.update(self.extra_args)
---> 34         return self.function(*args, **_kwargs)
     35 
     36     def set_function(self, function, is_constant=False):

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/functions.pyc in get_constants(ts, coors, mode, term, problem, **kwargs)
    112                         region = problem.domain.regions[rkey]
    113                         rval = nm.array(rval, dtype=nm.float64, ndmin=3)
--> 114                         ii = term.region.get_cell_indices(region.cells)
    115                         matdata[ii] = rval
    116 

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/common/region.pyc in get_cell_indices(self, cells, true_cells_only)
    600         to facets are returned if the region itself contains no cells.
    601         """
--> 602         fcells = self.get_cells(true_cells_only=true_cells_only)
    603 
    604         ii = nm.searchsorted(fcells, cells)

/usr/local/lib/python2.7/dist-packages/sfepy/discrete/common/region.pyc in get_cells(self, true_cells_only)
    579                 msg = 'region %s has not true cells! (has kind: %s)' \
    580                       % (self.name, self.kind)
--> 581                 raise ValueError(msg)
    582 
    583             else:

ValueError: region ProbeSurf has not true cells! (has kind: facet)

Robert Cimrman

unread,
Nov 10, 2015, 6:21:03 AM11/10/15
to sfepy...@googlegroups.com
Hi Geoff,

could you check, if the problem was caused by the commit [1]?

The problem is, that the material definition uses the ConstantFunctionByRegion
class, that seems to require cell regions now. Defining the material by a
function should work without problems, but I guess this is more convenient :).

Then could you try [2]?

r.

[1] a5c1ca55c8fc4b063d44299974f025f905047488
[2] https://github.com/rc/sfepy/commit/8ac7a7924277ef660df92f5f221dc678e4a14d9c

Geoff Wright

unread,
Nov 10, 2015, 10:36:55 AM11/10/15
to sfepy...@googlegroups.com
Hi Robert,

It was a little hard to test these commits specifically because there were errors about igs not existing for many of the commits on this branch.  But I did narrow it down to the 'no-ig' branch which was merged on 2015-04-07 in a792ae4db5867f5db669c17157e9ba7f24d5b766

Prior to the 'no-ig' branch, revision 2e9eb78341f9072ad07424221a64306c95c5ebd1 is working fine.

Is this a capability you can restore or should I start defining materials with functions?

Thanks,
Geoff


--
You received this message because you are subscribed to a topic in the Google Groups "sfepy-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sfepy-devel/BjAN0HrJkWU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sfepy-devel...@googlegroups.com.
To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sfepy-devel.
Reply all
Reply to author
Forward
0 new messages