240 enum { UNKNOWN, MIXED, C3D8, C3D8R, C3D20, C3D20R, C3D4, C3D10, C3D6, C3D15, T3D2,
255 v_points, i_points, v_vertices_as_cells;
287 return (*v_grid)(field_name);
308 if(!v_cells_as_vertices)
311 return (*v_cells_as_vertices)(field_name);
320 return (*i_grid)(field_name);
338template<
class Po
intType>
343 if(!i_cell_positions)
345 return i_cell_positions->getData( f );
350 if(!v_cell_positions)
353 return v_cell_positions->getData( f );
369 return SI->nElements();
381 return v_cell_arr->Size();
390 return v_cell_arr->Size();
437 POSTFIX_TRIANGULAR[];
487 void setFieldCreator(
string source_field,
string field_name );
500 void setFieldCreator(
string source_field,
string field_name );
514 void setFieldCreator(
string source_field,
string field_name );
521 bool isC3D8R()
const;
522 bool isC3D20()
const;
523 bool isC3D20R()
const;
524 bool isMixed()
const ;
525 bool isUnknown()
const;
527 bool isC3D10()
const;
529 bool isC3D15()
const;
535 bool isTetra()
const;
536 bool isWedge()
const;
541 return v_cell_positions;
591 res_candidates.
clear();
598 Verbose(0) <<
"FEM::getCellCandidates() no tree!";
602 if( ! v_as_cell_positions )
604 Verbose(0) <<
"FEM::getCellCandidates() vertices as cell array!";
608RefPtr<MemArray<1, FEMIndices_t> > v_as_cell_arr;
609 v_as_cell_arr = v_as_cell_positions->getData();
611 assert( v_as_cell_arr );
613MultiArray<1, FEMIndices_t>& v_cells = *v_as_cell_arr;
617 v_coords_tree->getManhattenRange( center, range, result_vertices );
628 for( res_it = result_vertices.
begin(); res_it != result_vertices.
end(); res_it++ )
630 FEMIndices_t::const_iterator cell_it;
631 for( cell_it = v_cells[res_it->second].begin() ; cell_it != v_cells[res_it->second].end(); cell_it++ )
632 res_candidates.
insert( *cell_it );
639 for( cand_it = res_candidates.
begin(); cand_it != res_candidates.
end(); cand_it++ )
647Eagle::PhysicalSpace::tvector range;
651 getCellCandidates( res_candidates, range, bb.
getCenter() );
658int getLocalCoordinate( Eagle::point3& local, FEMIndex_t& cell,
const Eagle::point3& world )
665Eagle::PhysicalSpace::tvector range;
673 getCellCandidates(cell_candidates, range, world );
675MultiArray<1, Eagle::point3>& crds = *v_coords_arr;
676MultiArray< 2, FEMIndex_t >& cells = *v_cell_arr;
679 for( cand_it = cell_candidates.
begin(); cand_it != cell_candidates.
end(); cand_it++ )
684 MultiIndex<2>
max = v_cell_arr->Size();
686 if(
max[0] == 8 ||
max[0] == 20)
687 cuboidToUnitCube( local, world,
688 crds[ cells[*cand_it][0] ],
689 crds[ cells[*cand_it][4] ],
690 crds[ cells[*cand_it][3] ],
691 crds[ cells[*cand_it][1] ],
692 crds[ cells[*cand_it][6] ] );
695 std::cout <<
"getLocalCoordinate() checking cand: " << *cand_it <<
" : " << local <<
std::endl;
698 if( local[0] >= 0.0 && local[1] >= 0.0 && local[2] >= 0.0 &&
699 local[0] <= 1.0 && local[1] <= 1.0 && local[2] <= 1.0 )
705 local += Eagle::PhysicalSpace::tvector(local) - Eagle::PhysicalSpace::tvector(1.,1.,1.);
709 cell = FEMIndex_t(*cand_it);
735 if( cell > v_coords_arr->Size()[0] )
737 Verbose(0) <<
"getLocalCoordinateNewton() cell out of bounds!";
743typedef Eagle::PhysicalSpace::tvector tvector;
745unsigned iterations = 0;
746point local_iterative, world_iterative;
747tvector dPdU, dPdV, dPdW;
754 local_iterative = { 0.0, 0.0, 0.0 };
756 world_iterative = FEMFunc::getInterpolatedC3D8<point>( local_iterative, *v_cell_arr, cell, *v_coords_arr );
759 while(
norm2(world - world_iterative) > prec*prec )
761 Verbose(0) <<
"iteration: " << iterations;
763 dPdU = tvector( FEMFunc::getInterpolatedC3D8Dn<point, 0> ( local_iterative, *v_cell_arr, cell, *v_coords_arr ) );
764 dPdV = tvector( FEMFunc::getInterpolatedC3D8Dn<point, 1> ( local_iterative, *v_cell_arr, cell, *v_coords_arr ) );
765 dPdW = tvector( FEMFunc::getInterpolatedC3D8Dn<point, 2> ( local_iterative, *v_cell_arr, cell, *v_coords_arr ) );
767 Verbose(60) <<
"dPdU: " << dPdU;
768 Verbose(60) <<
"dPdV: " << dPdV;
769 Verbose(60) <<
"dPdW: " << dPdW;
777 sys = dPdU[0], dPdU[1], dPdU[2],
778 dPdV[0], dPdV[1], dPdV[2],
779 dPdW[0], dPdW[1], dPdW[2];
781 delta_world = world - world_iterative;
783 Verbose(0) <<
"delta world: " << delta_world;
787 ComputeInverse(sys_inv, sys);
791 Verbose(0) <<
"getLocalCoordinateNewton() Degenerated matrix error in inversion!";
799 d_local = sysm_inv * b;
801 tvector d_world = tvector::DomainVector_t(sysm * d_local);
803 local_iterative[0] += d_local[0];
804 local_iterative[1] += d_local[1];
805 local_iterative[2] += d_local[2];
807 world_iterative += d_world;
809 Verbose(51) <<
"getLocalCoordinateNewton() in loop[" << iterations <<
"]: local=" << local_iterative;
811 Verbose(0) <<
"world: " << world;
812 Verbose(0) <<
"world_iterative: " << world_iterative;
813 Verbose(0) <<
"residuum: " <<
norm2(world - world_iterative);
817 if( iterations++ > max_iterations )
819 Verbose(0) <<
"getLocalCoordinateNewton prevented endless loop";
824 local = local_iterative;
827 for(
unsigned i = 0; i < 3; i++ )
829 if( local_iterative[i] < -1 )
831 Verbose(0) <<
"getLocalCoordinateNewton local out of -bounds: " << local_iterative;
835 if( local_iterative[i] > 1. )
837 Verbose(0) <<
"getLocalCoordinateNewton local out of +bounds: " << local_iterative;
844 Verbose(0) <<
"getLocalCoordinateNewton found local: " << local;
857FEMIndex_t cell_nr = 0;
866Eagle::PhysicalSpace::tvector range;
871 getCellCandidates(cell_candidates, range, world_pos );
878 for( cand_it = cell_candidates.
begin(); cand_it != cell_candidates.
end(); cand_it++ )
880 check = getLocalCoordinateNewton( local_pos, *cand_it, world_pos );
881 Verbose(0) <<
"getInterpolatedVertexField() local newtonr: " << local_pos;
883 double greatest_value =
std::max(
std::max( local_pos[0], local_pos[1] ), local_pos[2]);
884 closest[ greatest_value ] = *cand_it;
885 local[*cand_it] = local_pos;
893 Verbose(0) <<
"getInterpolatedVertexField()::getLocalCoordinate() returned 1!";
895 if( closest.
size() == 0 )
898 cell_nr = closest.
begin()->second;
899 local_pos = local[cell_nr];
901 for(
unsigned i = 0; i < 3; i++ )
903 if( local_pos[i] < -1 )
904 local_pos[i] = -0.99;
905 if( local_pos[i] > 1. )
909 RefPtr< MemArray<1, T> > data_arr;
917 data_arr = vertex_data_field.getData();
923Verbose(0) <<
"-------------------------------------------------------------------------------- cell_nr: " << cell_nr;
924Verbose(0) <<
"-------------------------------------------------------------------------------- local_pos: " << local_pos;
926 return std::pair<bool, T>(
true, FEMFunc::getInterpolatedC3D8<T>(local_pos, *v_cell_arr, cell_nr, *data_arr ));
931 std::cout <<
"getInterpolatedVertexField()[" << check <<
"] world: " << world_pos <<
"-->" << local_pos <<
std::endl;
939 RefPtr< MemArray<1, T> > data_arr;
946 data_arr = vertex_data_field.getData();
952return std::pair<bool, T>(
true, FEMFunc::getInterpolatedC3D8<T>( local_pos, *v_cell_arr, cell_nr, *data_arr ));