9 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
14 #include "../classes.h"
15 #include "../Inputs2/ElementInput2.h"
16 #include "../../shared/shared.h"
76 for(i=0;i<nanalyses;i++){
90 else tetra->
hnodes[i] = NULL;
100 tetra->
id = this->
id;
110 unsigned int num_nodes = 4;
111 tetra->
nodes = xNew<Node*>(num_nodes);
112 for(i=0;i<num_nodes;i++)
if(this->
nodes[i]) tetra->
nodes[i]=this->
nodes[i];
else tetra->
nodes[i] = NULL;
120 void Tetra::Marshall(
char** pmarshalled_data,
int* pmarshalled_data_size,
int marshall_direction){
139 int analysis_counter;
155 else this->
nodes=NULL;
172 xmin=xyz_list[0][0]; xmax=xyz_list[0][0];
173 ymin=xyz_list[0][1]; ymax=xyz_list[0][1];
174 zmin=xyz_list[0][2]; zmax=xyz_list[0][2];
177 if(xyz_list[i][0]<xmin) xmin=xyz_list[i][0];
178 if(xyz_list[i][0]>xmax) xmax=xyz_list[i][0];
179 if(xyz_list[i][1]<ymin) ymin=xyz_list[i][1];
180 if(xyz_list[i][1]>ymax) ymax=xyz_list[i][1];
181 if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
182 if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
193 int indices[4][3] = {{0,1,2},{0,3,1},{1,3,2},{0,2,3}};
198 for(
int i=0;i<4;i++){
199 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1. && values[indices[i][2]] == 1.){
200 *pindex1 = indices[i][0];
201 *pindex2 = indices[i][1];
202 *pindex3 = indices[i][2];
207 _error_(
"Could not find 3 vertices on bed");
213 int indices[4][3] = {{0,1,2},{0,3,1},{1,3,2},{0,2,3}};
218 for(
int i=0;i<4;i++){
219 if(values[indices[i][0]] == 0. && values[indices[i][1]] == 0. && values[indices[i][2]] == 0.){
220 *pindex1 = indices[i][0];
221 *pindex2 = indices[i][1];
222 *pindex3 = indices[i][2];
227 _error_(
"Could not find 3 vertices on bed");
233 int indices[4][3] = {{0,1,2},{0,3,1},{1,3,2},{0,2,3}};
238 for(
int i=0;i<4;i++){
239 if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1. && values[indices[i][2]] == 1.){
240 *pindex1 = indices[i][0];
241 *pindex2 = indices[i][1];
242 *pindex3 = indices[i][2];
247 _error_(
"Could not find 3 vertices on bed");
260 _error_(
"not implemented yet");
263 _error_(
"not implemented yet");
279 for(
int iv=0;iv<
NUMVERTICES;iv++) pvalue[iv] = default_value;
295 for(
int iv=0;iv<numnodes;iv++){
301 for(
int iv=0;iv<numnodes;iv++) pvalue[iv] = default_value;
334 IssmDouble* xyz_list_edge = xNew<IssmDouble>(3*3);
336 for(
int i=0;i<3;i++)
for(
int j=0;j<3;j++) xyz_list_edge[i*3+j]=xyz_list[indices[i]][j];
339 *pxyz_list = xyz_list_edge;
351 IssmDouble* xyz_list_edge = xNew<IssmDouble>(3*3);
353 for(
int i=0;i<3;i++)
for(
int j=0;j<3;j++) xyz_list_edge[i*3+j]=xyz_list[indices[i]][j];
356 *pxyz_list = xyz_list_edge;
366 sum = values[0]+values[1]+values[2]+values[3];
368 _assert_(sum==0. || sum==1. || sum==2. || sum==3.);
385 sum = values[0]+values[1]+values[2]+values[3];
387 _assert_(sum==0. || sum==1. || sum==2. || sum==3.);
407 bool control_analysis;
408 char** controls = NULL;
409 int num_control_type,num_responses;
413 iomodel->
FindConstant(&control_analysis,
"md.inversion.iscontrol");
414 if(control_analysis) iomodel->
FindConstant(&num_control_type,
"md.inversion.num_control_parameters");
415 if(control_analysis) iomodel->
FindConstant(&num_responses,
"md.inversion.num_cost_functions");
434 IssmDouble* values = xNew<IssmDouble>(numnodes);
437 for(
int i=0;i<numnodes;i++){
438 values[i]=solution[doflist[i]];
439 if(xIsNan<IssmDouble>(values[i]))
_error_(
"NaN found in solution vector");
440 if(xIsInf<IssmDouble>(values[i]))
_error_(
"Inf found in solution vector");
447 xDelete<IssmDouble>(values);
448 xDelete<int>(doflist);
460 for(
int i=0;i<
NUMVERTICES;i++)
if(ls[i]<0.) nrice++;
461 if(nrice==1)
return true;
505 return new GaussTetra(indices[0],indices[1],indices[2],
max(order_horiz,order_vert));
512 return new GaussTetra(indices[0],indices[1],indices[2],order);
519 return new GaussTetra(indices[0],indices[1],indices[2],order);
570 for(
int i=0;i<3;i++){
571 v13[i]=xyz_list[0*3+i]-xyz_list[2*3+i];
572 v23[i]=xyz_list[1*3+i]-xyz_list[2*3+i];
575 normal[0]=v13[1]*v23[2]-v13[2]*v23[1];
576 normal[1]=v13[2]*v23[0]-v13[0]*v23[2];
577 normal[2]=v13[0]*v23[1]-v13[1]*v23[0];
578 normal_norm=sqrt(normal[0]*normal[0]+ normal[1]*normal[1]+ normal[2]*normal[2]);
581 bed_normal[0]=-normal[0]/normal_norm;
582 bed_normal[1]=-normal[1]/normal_norm;
583 bed_normal[2]=-normal[2]/normal_norm;
595 AB[0]=xyz_list[1*3+0] - xyz_list[0*3+0];
596 AB[1]=xyz_list[1*3+1] - xyz_list[0*3+1];
597 AB[2]=xyz_list[1*3+2] - xyz_list[0*3+2];
598 AC[0]=xyz_list[2*3+0] - xyz_list[0*3+0];
599 AC[1]=xyz_list[2*3+1] - xyz_list[0*3+1];
600 AC[2]=xyz_list[2*3+2] - xyz_list[0*3+2];
603 norm=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]);
605 for(
int i=0;i<3;i++) normal[i]=normal[i]/norm;
614 for(
int i=0;i<3;i++){
615 v13[i]=xyz_list[0*3+i]-xyz_list[2*3+i];
616 v23[i]=xyz_list[1*3+i]-xyz_list[2*3+i];
619 normal[0]=v13[1]*v23[2]-v13[2]*v23[1];
620 normal[1]=v13[2]*v23[0]-v13[0]*v23[2];
621 normal[2]=v13[0]*v23[1]-v13[1]*v23[0];
622 normal_norm=sqrt(normal[0]*normal[0]+ normal[1]*normal[1]+ normal[2]*normal[2]);
624 top_normal[0]=normal[0]/normal_norm;
625 top_normal[1]=normal[1]/normal_norm;
626 top_normal[2]=normal[2]/normal_norm;
651 int indices[3]={12,13,14};
658 int* indices=xNew<int>(size);
659 for(
int i=0;i<size;i++) indices[i] = offset+i;
661 xDelete<int>(indices);
667 int indices[3]={12,13,14};
674 int* indices=xNew<int>(size);
675 for(
int i=0;i<size;i++) indices[i] = offset+i;
677 xDelete<int>(indices);
700 vertexonbase = xNew<IssmDouble>(numnodes);
707 if(vertexonbase[i]==1){
712 groundedicelevelset_input->
GetInputValue(&groundedice,gauss);
715 xz_plane[0]=1.; xz_plane[3]=-slopex;
716 xz_plane[1]=0.; xz_plane[4]=-slopey;
717 xz_plane[2]=slopex; xz_plane[5]=1.;
737 xDelete<IssmDouble>(vertexonbase);
759 int analysis_counter;
767 else this->
nodes=NULL;
775 int index1,index2,index3;
783 int index1,index2,index3;
789 int analysis_counter;
799 this->
SpawnTriaHook(xDynamicCast<ElementHook*>(tria),index1,index2,index3);
820 int tetra_vertex_ids[6];
823 bool dakota_analysis;
826 int* tetra_node_ids = NULL;
830 iomodel->
FindConstant(&dakota_analysis,
"md.qmu.isdakota");
841 for(i=0;i<4;i++) tetra_vertex_ids[i]=iomodel->
elements[4*index+i];
844 switch(finiteelement_type){
847 tetra_node_ids = xNew<int>(numnodes);
848 tetra_node_ids[0]=iomodel->
elements[4*index+0];
849 tetra_node_ids[1]=iomodel->
elements[4*index+1];
850 tetra_node_ids[2]=iomodel->
elements[4*index+2];
851 tetra_node_ids[3]=iomodel->
elements[4*index+3];
855 tetra_node_ids = xNew<int>(numnodes);
856 tetra_node_ids[0]=iomodel->
elements[4*index+0];
857 tetra_node_ids[1]=iomodel->
elements[4*index+1];
858 tetra_node_ids[2]=iomodel->
elements[4*index+2];
859 tetra_node_ids[3]=iomodel->
elements[4*index+3];
864 tetra_node_ids = xNew<int>(numnodes);
865 tetra_node_ids[0]=iomodel->
elements[4*index+0];
866 tetra_node_ids[1]=iomodel->
elements[4*index+1];
867 tetra_node_ids[2]=iomodel->
elements[4*index+2];
868 tetra_node_ids[3]=iomodel->
elements[4*index+3];
878 tetra_node_ids = xNew<int>(numnodes);
879 tetra_node_ids[0]=iomodel->
elements[4*index+0];
880 tetra_node_ids[1]=iomodel->
elements[4*index+1];
881 tetra_node_ids[2]=iomodel->
elements[4*index+2];
882 tetra_node_ids[3]=iomodel->
elements[4*index+3];
893 tetra_node_ids = xNew<int>(numnodes);
894 tetra_node_ids[0]=iomodel->
elements[4*index+0];
895 tetra_node_ids[1]=iomodel->
elements[4*index+1];
896 tetra_node_ids[2]=iomodel->
elements[4*index+2];
897 tetra_node_ids[3]=iomodel->
elements[4*index+3];
912 tetra_node_ids = xNew<int>(numnodes);
913 tetra_node_ids[0]=iomodel->
elements[4*index+0];
914 tetra_node_ids[1]=iomodel->
elements[4*index+1];
915 tetra_node_ids[2]=iomodel->
elements[4*index+2];
916 tetra_node_ids[3]=iomodel->
elements[4*index+3];
930 xDelete<int>(tetra_node_ids);
954 GetPhi(&phi,&epsilon[0],viscosity);