convert2d23d
This file converts a two-d coord system bilinear mesh ipnode file into a 3-d coordinate system ipnode file with a known uniform thickness.
#load perl libraries for CMISS
use CmUtils::File::Ipnode use CmUtils::File::Ipdata use CmUtils::Objects::NodeGroup use CmUtils::Objects::Field use CmUtils::Objects::FieldSet use CmUtils::Objects::Node
use CmUtils::Vector
$thickness=0.3; $convertFile="displacements_line_23"; $convertedFile="displacements3d_line_23";
fem def para;r;multiaxes
$group2d = readIpnode($convertFile); $group3d = CmUtils::Objects::NodeGroup->new(); $group3d->name($convertedFile); $numnodes2d = $group2d->numberOfNodes(); $numnodes3d = $numnodes2d*2;
for($i=1;$i<=$numnodes3d;$i++) {
$node3d = CmUtils::Objects::Node->new(); if($i<=$numnodes2d) {
$node2d = $group2d->getNode($i);} else {
$node2d = $group2d->getNode($i-$numnodes2d);} $node2dx = $node2d->value(0); $node2dy = $node2d->value(1);
#$fieldSet2d = $node2d->fieldSet(); #$fieldSet2d->list();
$node3dx = CmUtils::Objects::Component->new(); $node3dx->name("x"); $node3dx->valIndex(0); $node3dy = CmUtils::Objects::Component->new(); $node3dy->name("y"); $node3dy->valIndex(1); $node3dz = CmUtils::Objects::Component->new(); $node3dz->name("z"); $node3dz->valIndex(2);
$field3d = CmUtils::Objects::Field->new(); $field3d->name("coordinates"); $field3d->addComponent($node3dx); $field3d->addComponent($node3dy); $field3d->addComponent($node3dz);
$fieldSet3d = CmUtils::Objects::FieldSet->new(); $fieldSet3d->addField($field3d); $fieldSet3d->numValues(3) $fieldSet3d->list(); $node3d->name($i); $node3d->fieldSet($fieldSet3d); $node3d->value(0,$node2dx); $node3d->value(1,$node2dy); if($i<=$numnodes2d) {
$node3d->value(2,0.3);} else {
$node3d->value(2,0);}
$group3d->addNode($node3d);
} $group3d->listFields(); writeIpnode($convertedFile,$group3d);