dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #23019
Re: [Question #153448]: Importing mesh and entities
Question #153448 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/153448
B. Emek Abali posted a new comment:
915c915,916
< The Abaqus 6.8 has Node->Element->Elset->Material
---
> The Abaqus format first defines a node block, then there should be a number
> of elements containing these nodes.
928a930,932
> else:
> handler.warn("Invalid parameter syntax on line %d: %s" % (lineno, p))
> continue
938,940c942,943
< elset2eid = {}
< material2elsetnames = {}
< material2eids = {}
---
> eid2elset = {}
> material2elsetids = {}
942d944
< elsets = []
946d947
< re_elset = re.compile(r"(\d+),\s*(\d+),\s*(\d+)")
957d957
< print 'Section: ', sect
960,984c960,968
< if "type" not in params and "elset" not in params:
< handler.warn("Element on line %d doesn't declare TYPE" % (lineno,))
< supported_elem = False
< if "elset" in params:
< elsetname = params["elset"]
< elsets.append(elsetname)
< if re.search("generate", params_str):
< elset_loop=True
< else:
< elset_loop=False
<
< if re.search("internal", params_str):
< elset_internal=True
< else:
< elset_internal=False
< supported_elem = False
< else:
< tp = params["type"]
< if tp not in ("c3d4", "dc3d4"):
< handler.warn("Unsupported element type '%s' on line %d" % (tp, lineno))
< supported_elem = False
< else:
< supported_elem = True
< elsetname = None
<
---
> if "type" not in params:
> handler.error("Element on line %d doesn't declare TYPE" %
> (lineno,))
> tp, elset = params["type"], params.get("elset")
> if tp not in ("c3d4", "dc3d4"):
> handler.warn("Unsupported element type '%s' on line %d" % (tp, lineno))
> supported_elem = False
> else:
> supported_elem = True
993c977
< material2elsetnames.setdefault(matname, []).append(params["elset"])
---
> material2elsetids.setdefault(matname, []).append(params["elset"])
995,1004c979,980
< matname = read_params(params_spec, ["name"], lineno)["name"]
< materials.append(matname)
< elif sect == "elset":
< elsetname = read_params(params_spec, ["elset"], lineno)["elset"]
< elsets.append(elsetname)
< print elsets
< if re.search("generate", params_str):
< elset_loop=True
< else:
< elset_loop=False
---
> name = read_params(params_spec, ["name"], lineno)["name"]
> materials.append(name)
1006,1008c982
< else:
< print 'line ',lineno, ' is ignored start of it:', sect #handler.warn("Unsupported section type '%s' on line %d" % (sect, lineno))
< continue
---
> continue
1026,1046c1000,1001
< if not supported_elem and elset_internal:
< if elset_loop:
< m = re_elset.match(l)
< if m is None:
< handler.warn("Element set is not understood, line %d" % (lineno,))
< continue
< first, last, inc = [int(x) for x in m.groups()]
< if elsetname is None:
< handler.warn("Name of the element set is not known")
< continue
< eids = range(first,last+1,inc)
< if elsetname in elset2eid.keys():
< handler.warn("More than one element set: %s definition" % (elsetname,))
< print 'Element internal set ',elsetname,' has ',len(eids),' elements'
< elset2eid[elsetname] = eids
< else:
< if elsetname is None:
< handler.warn("Name of the element set is not known")
< else:
< handler.warn("Only element sets with generate are supported")
< continue
---
> if not supported_elem:
> continue
1049,1050c1004,1005
< handler.warn("Blank line %d or sth. is bad, ignoring..." % (lineno,))
< continue
---
> handler.error("Node on line %d badly specified (expected 3 "
> "coordinates)" % (lineno,))
1053,1078c1008
< if elsetname is not None:
< if elsetname in elset2eid.keys():
< print 'Adding cell ',idx,' to element set ',elsetname
< elset2eid[elsetname].append(idx)
< else:
< elset2eid[elsetname] = idx
< elif sect == "elset":
< if elset_loop:
< m = re_elset.match(l)
< if m is None:
< handler.warn("Element set is not understood, line %d" % (lineno,))
< continue
< first, last, inc = [int(x) for x in m.groups()]
< if elsetname is None:
< handler.warn("Name of the element set is not known")
< continue
< eids = range(first,last+1,inc)
< if elsetname in elset2eid.keys():
< handler.warn("More than one element set: %s definition" % (elsetname,))
< elset2eid[elsetname] = eids
< print 'Element set ',elsetname,' has ',len(eids),' elements'
< else:
< if elsetname is None:
< handler.warn("Name of the element set is not known")
< else:
< handler.warn("Only element sets with generate are supported")
---
> eid2elset.setdefault(elset, set()).add(idx)
1106c1036,1045
<
---
>
> # Define the material function for the cells
>
> num_entities = 0
> for matname, elsetids in material2elsetids.items():
> if matname not in materials:
> handler.error("Unknown material %s referred to for element sets %s" %
> (matname, ", ".join(elsetids)))
> num_entities += len(elsetids)
> handler.start_meshfunction("material", 3, num_entities)
1108d1046
< num_entities = 1
1110c1048
< try: elsetnames = material2elsetnames[matname]
---
> try: elsetids = material2elsetids[matname]
1112c1050
< # No element sets for this material
---
> # No elements for this material
1115,1133c1053,1061
< material2eids[i] = []
< for j, elsetname in enumerate(elsetnames):
< if elsetname in elsets:
< print 'Element set ',elsetname,' for ',matname,' is found'
< material2eids[i].extend(elset2eid[elsetname])
< else:
< handler.error("Material '%s' is assigned to undefined element set '%s', the known element sets: '%s'" % (matname, elsetname,elset2eid.keys()))
< num_entities +=len(material2eids[i])
< handler.start_meshfunction(matname, 3, len(elems))
< print 'adding ',len(material2eids[i]),' cells into ...',matname,'.xml'
< for eid in material2eids[i]:
< handler.add_entity_meshfunction(elemids.index(eid), i+1)
< handler.end_meshfunction()
<
< handler.start_meshfunction("material", 3, len(elems))
< print 'adding all material defined ',num_entities,' cells into ...-material.xml'
< for i in material2eids.keys():
< for eid in material2eids[i]:
< handler.add_entity_meshfunction(elemids.index(eid), i+1)
---
> elsets = []
> for eid in elsetids:
> try: elsets.append(eid2elset[eid])
> except KeyError:
> handler.error("Material '%s' is assigned to undefined element "
> "set '%s'" % (matname, eid))
> for elset in elsets:
> for elemid in elset:
> handler.add_entity_meshfunction(elemids.index(elemid), i)
1135d1062
< print "Conversion done"
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.
References