| [3683] | 1 | /*!\file Numericalflux.c
|
|---|
| 2 | * \brief: implementation of the Numericalflux object
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| [5738] | 5 | /*Headers:*/
|
|---|
| [12365] | 6 | /*{{{*/
|
|---|
| [3683] | 7 | #ifdef HAVE_CONFIG_H
|
|---|
| [9320] | 8 | #include <config.h>
|
|---|
| [3683] | 9 | #else
|
|---|
| 10 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
|---|
| 11 | #endif
|
|---|
| 12 |
|
|---|
| [15012] | 13 | #include "shared/shared.h"
|
|---|
| 14 | #include "../classes.h"
|
|---|
| [5738] | 15 | /*}}}*/
|
|---|
| [3683] | 16 |
|
|---|
| [5738] | 17 | /*Load macros*/
|
|---|
| [14763] | 18 | #define NUMVERTICES 2
|
|---|
| 19 | #define NUMNODES_INTERNAL 4
|
|---|
| 20 | #define NUMNODES_BOUNDARY 2
|
|---|
| [3683] | 21 |
|
|---|
| [4248] | 22 | /*Numericalflux constructors and destructor*/
|
|---|
| [12365] | 23 | /*FUNCTION Numericalflux::Numericalflux(){{{*/
|
|---|
| [3683] | 24 | Numericalflux::Numericalflux(){
|
|---|
| [14761] | 25 | this->inputs = NULL;
|
|---|
| 26 | this->parameters = NULL;
|
|---|
| 27 | this->helement = NULL;
|
|---|
| 28 | this->element = NULL;
|
|---|
| 29 | this->hnodes = NULL;
|
|---|
| 30 | this->hvertices = NULL;
|
|---|
| 31 | this->nodes = NULL;
|
|---|
| [3683] | 32 | }
|
|---|
| 33 | /*}}}*/
|
|---|
| [13915] | 34 | /*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/
|
|---|
| [16137] | 35 | Numericalflux::Numericalflux(int numericalflux_id,int i,int index,IoModel* iomodel, int in_analysis_type){
|
|---|
| [3683] | 36 |
|
|---|
| 37 | /* Intermediary */
|
|---|
| 38 | int j;
|
|---|
| [5452] | 39 | int pos1,pos2,pos3,pos4;
|
|---|
| [3683] | 40 | int num_nodes;
|
|---|
| 41 |
|
|---|
| 42 | /*numericalflux constructor data: */
|
|---|
| 43 | int numericalflux_elem_ids[2];
|
|---|
| [14761] | 44 | int numericalflux_vertex_ids[2];
|
|---|
| [3683] | 45 | int numericalflux_node_ids[4];
|
|---|
| 46 | int numericalflux_type;
|
|---|
| 47 |
|
|---|
| [16137] | 48 | /*Get edge*/
|
|---|
| 49 | int i1 = iomodel->faces[4*index+0];
|
|---|
| 50 | int i2 = iomodel->faces[4*index+1];
|
|---|
| 51 | int e1 = iomodel->faces[4*index+2];
|
|---|
| 52 | int e2 = iomodel->faces[4*index+3];
|
|---|
| [9356] | 53 |
|
|---|
| [12574] | 54 | /*First, see wether this is an internal or boundary edge (if e2=-1)*/
|
|---|
| [16137] | 55 | if(e2==-1){
|
|---|
| [3683] | 56 | /* Boundary edge, only one element */
|
|---|
| [16560] | 57 | num_nodes=2;
|
|---|
| [3683] | 58 | numericalflux_type=BoundaryEnum;
|
|---|
| [12574] | 59 | numericalflux_elem_ids[0]=e1;
|
|---|
| [3683] | 60 | }
|
|---|
| 61 | else{
|
|---|
| 62 | /* internal edge: connected to 2 elements */
|
|---|
| [16560] | 63 | num_nodes=4;
|
|---|
| [3683] | 64 | numericalflux_type=InternalEnum;
|
|---|
| [12574] | 65 | numericalflux_elem_ids[0]=e1;
|
|---|
| 66 | numericalflux_elem_ids[1]=e2;
|
|---|
| [3683] | 67 | }
|
|---|
| 68 |
|
|---|
| 69 | /*1: Get vertices ids*/
|
|---|
| [14761] | 70 | numericalflux_vertex_ids[0]=i1;
|
|---|
| 71 | numericalflux_vertex_ids[1]=i2;
|
|---|
| [3683] | 72 |
|
|---|
| [14761] | 73 | /*2: Get node ids*/
|
|---|
| [3683] | 74 | if (numericalflux_type==InternalEnum){
|
|---|
| 75 |
|
|---|
| 76 | /*Now, we must get the nodes of the 4 nodes located on the edge*/
|
|---|
| 77 |
|
|---|
| 78 | /*2: Get the column where these ids are located in the index*/
|
|---|
| [5452] | 79 | pos1=pos2=pos3=pos4=UNDEF;
|
|---|
| [3683] | 80 | for(j=0;j<3;j++){
|
|---|
| [16137] | 81 | if(iomodel->elements[3*(e1-1)+j]==i1) pos1=j+1;
|
|---|
| 82 | if(iomodel->elements[3*(e1-1)+j]==i2) pos2=j+1;
|
|---|
| 83 | if(iomodel->elements[3*(e2-1)+j]==i1) pos3=j+1;
|
|---|
| 84 | if(iomodel->elements[3*(e2-1)+j]==i2) pos4=j+1;
|
|---|
| [3683] | 85 | }
|
|---|
| [6412] | 86 | _assert_(pos1!=UNDEF && pos2!=UNDEF && pos3!=UNDEF && pos4!=UNDEF);
|
|---|
| [3683] | 87 |
|
|---|
| 88 | /*3: We have the id of the elements and the position of the vertices in the index
|
|---|
| 89 | * we can compute their dofs!*/
|
|---|
| [5452] | 90 | numericalflux_node_ids[0]=iomodel->nodecounter+3*(e1-1)+pos1;
|
|---|
| 91 | numericalflux_node_ids[1]=iomodel->nodecounter+3*(e1-1)+pos2;
|
|---|
| 92 | numericalflux_node_ids[2]=iomodel->nodecounter+3*(e2-1)+pos3;
|
|---|
| 93 | numericalflux_node_ids[3]=iomodel->nodecounter+3*(e2-1)+pos4;
|
|---|
| [3683] | 94 | }
|
|---|
| 95 | else{
|
|---|
| 96 |
|
|---|
| 97 | /*2: Get the column where these ids are located in the index*/
|
|---|
| [5452] | 98 | pos1=pos2=UNDEF;
|
|---|
| [3683] | 99 | for(j=0;j<3;j++){
|
|---|
| [16137] | 100 | if(iomodel->elements[3*(e1-1)+j]==i1) pos1=j+1;
|
|---|
| 101 | if(iomodel->elements[3*(e1-1)+j]==i2) pos2=j+1;
|
|---|
| [3683] | 102 | }
|
|---|
| [6412] | 103 | _assert_(pos1!=UNDEF && pos2!=UNDEF);
|
|---|
| [3683] | 104 |
|
|---|
| 105 | /*3: We have the id of the elements and the position of the vertices in the index
|
|---|
| 106 | * we can compute their dofs!*/
|
|---|
| [4456] | 107 | numericalflux_node_ids[0]=iomodel->nodecounter+3*(e1-1)+pos1;
|
|---|
| [5452] | 108 | numericalflux_node_ids[1]=iomodel->nodecounter+3*(e1-1)+pos2;
|
|---|
| [3683] | 109 | }
|
|---|
| 110 |
|
|---|
| 111 | /*Ok, we have everything to build the object: */
|
|---|
| 112 | this->id=numericalflux_id;
|
|---|
| [4007] | 113 | this->analysis_type=in_analysis_type;
|
|---|
| [3683] | 114 |
|
|---|
| 115 | /*Hooks: */
|
|---|
| [14761] | 116 | this->hnodes =new Hook(numericalflux_node_ids,num_nodes);
|
|---|
| [14763] | 117 | this->hvertices =new Hook(&numericalflux_vertex_ids[0],2);
|
|---|
| [14761] | 118 | this->helement =new Hook(numericalflux_elem_ids,1); // take only the first element for now
|
|---|
| [3683] | 119 |
|
|---|
| 120 | //intialize and add as many inputs per element as requested:
|
|---|
| 121 | this->inputs=new Inputs();
|
|---|
| [14688] | 122 | this->inputs->AddInput(new IntInput(NumericalfluxTypeEnum,numericalflux_type));
|
|---|
| [3683] | 123 |
|
|---|
| 124 | //this->parameters: we still can't point to it, it may not even exist. Configure will handle this.
|
|---|
| 125 | this->parameters=NULL;
|
|---|
| [5737] | 126 | this->element=NULL;
|
|---|
| 127 | this->nodes=NULL;
|
|---|
| [3683] | 128 | }
|
|---|
| 129 | /*}}}*/
|
|---|
| [12365] | 130 | /*FUNCTION Numericalflux::~Numericalflux(){{{*/
|
|---|
| [3683] | 131 | Numericalflux::~Numericalflux(){
|
|---|
| 132 | delete inputs;
|
|---|
| 133 | this->parameters=NULL;
|
|---|
| [4433] | 134 | delete helement;
|
|---|
| [4396] | 135 | delete hnodes;
|
|---|
| [14761] | 136 | delete hvertices;
|
|---|
| [3683] | 137 | }
|
|---|
| 138 | /*}}}*/
|
|---|
| 139 |
|
|---|
| [4248] | 140 | /*Object virtual functions definitions:*/
|
|---|
| [12365] | 141 | /*FUNCTION Numericalflux::Echo {{{*/
|
|---|
| [4248] | 142 | void Numericalflux::Echo(void){
|
|---|
| [15104] | 143 | _printf_("Numericalflux:\n");
|
|---|
| [15100] | 144 | _printf_(" id: " << id << "\n");
|
|---|
| 145 | _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");
|
|---|
| [5452] | 146 | hnodes->Echo();
|
|---|
| [14761] | 147 | hvertices->Echo();
|
|---|
| [5452] | 148 | helement->Echo();
|
|---|
| [15100] | 149 | _printf_(" parameters: " << parameters << "\n");
|
|---|
| 150 | _printf_(" inputs: " << inputs << "\n");
|
|---|
| [3683] | 151 | }
|
|---|
| 152 | /*}}}*/
|
|---|
| [12365] | 153 | /*FUNCTION Numericalflux::DeepEcho {{{*/
|
|---|
| [3683] | 154 | void Numericalflux::DeepEcho(void){
|
|---|
| 155 |
|
|---|
| [15104] | 156 | _printf_("Numericalflux:\n");
|
|---|
| [15100] | 157 | _printf_(" id: " << id << "\n");
|
|---|
| 158 | _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");
|
|---|
| [4396] | 159 | hnodes->DeepEcho();
|
|---|
| [14761] | 160 | hvertices->DeepEcho();
|
|---|
| [4433] | 161 | helement->DeepEcho();
|
|---|
| [15104] | 162 | _printf_(" parameters\n");
|
|---|
| [5452] | 163 | if(parameters)
|
|---|
| 164 | parameters->DeepEcho();
|
|---|
| 165 | else
|
|---|
| [15104] | 166 | _printf_(" NULL\n");
|
|---|
| 167 | _printf_(" inputs\n");
|
|---|
| [3683] | 168 | inputs->DeepEcho();
|
|---|
| [13622] | 169 |
|
|---|
| [3683] | 170 | }
|
|---|
| 171 | /*}}}*/
|
|---|
| [12365] | 172 | /*FUNCTION Numericalflux::Id {{{*/
|
|---|
| [4248] | 173 | int Numericalflux::Id(void){
|
|---|
| 174 | return id;
|
|---|
| [3683] | 175 | }
|
|---|
| 176 | /*}}}*/
|
|---|
| [12365] | 177 | /*FUNCTION Numericalflux::ObjectEnum{{{*/
|
|---|
| [9883] | 178 | int Numericalflux::ObjectEnum(void){
|
|---|
| [3683] | 179 |
|
|---|
| [4248] | 180 | return NumericalfluxEnum;
|
|---|
| 181 |
|
|---|
| 182 | }
|
|---|
| 183 | /*}}}*/
|
|---|
| [12365] | 184 | /*FUNCTION Numericalflux::copy {{{*/
|
|---|
| [4248] | 185 | Object* Numericalflux::copy() {
|
|---|
| [13622] | 186 |
|
|---|
| [4248] | 187 | Numericalflux* numericalflux=NULL;
|
|---|
| 188 |
|
|---|
| 189 | numericalflux=new Numericalflux();
|
|---|
| 190 |
|
|---|
| 191 | /*copy fields: */
|
|---|
| 192 | numericalflux->id=this->id;
|
|---|
| 193 | numericalflux->analysis_type=this->analysis_type;
|
|---|
| 194 | if(this->inputs){
|
|---|
| 195 | numericalflux->inputs=(Inputs*)this->inputs->Copy();
|
|---|
| 196 | }
|
|---|
| 197 | else{
|
|---|
| 198 | numericalflux->inputs=new Inputs();
|
|---|
| 199 | }
|
|---|
| 200 | /*point parameters: */
|
|---|
| 201 | numericalflux->parameters=this->parameters;
|
|---|
| 202 |
|
|---|
| 203 | /*now deal with hooks and objects: */
|
|---|
| [14761] | 204 | numericalflux->hnodes = (Hook*)this->hnodes->copy();
|
|---|
| 205 | numericalflux->hvertices = (Hook*)this->hvertices->copy();
|
|---|
| 206 | numericalflux->helement = (Hook*)this->helement->copy();
|
|---|
| [4248] | 207 |
|
|---|
| [5737] | 208 | /*corresponding fields*/
|
|---|
| [14761] | 209 | numericalflux->nodes = (Node**)numericalflux->hnodes->deliverp();
|
|---|
| 210 | numericalflux->vertices = (Vertex**)numericalflux->hvertices->deliverp();
|
|---|
| 211 | numericalflux->element = (Element*)numericalflux->helement->delivers();
|
|---|
| [5737] | 212 |
|
|---|
| [4248] | 213 | return numericalflux;
|
|---|
| 214 | }
|
|---|
| 215 | /*}}}*/
|
|---|
| 216 |
|
|---|
| 217 | /*Load virtual functions definitions:*/
|
|---|
| [12365] | 218 | /*FUNCTION Numericalflux::Configure {{{*/
|
|---|
| [4248] | 219 | void Numericalflux::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
|
|---|
| 220 |
|
|---|
| 221 | /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
|
|---|
| 222 | * datasets, using internal ids and offsets hidden in hooks: */
|
|---|
| [14975] | 223 | hnodes->configure((DataSet*)nodesin);
|
|---|
| 224 | hvertices->configure((DataSet*)verticesin);
|
|---|
| 225 | helement->configure((DataSet*)elementsin);
|
|---|
| [4248] | 226 |
|
|---|
| [5737] | 227 | /*Initialize hooked fields*/
|
|---|
| [14761] | 228 | this->nodes = (Node**)hnodes->deliverp();
|
|---|
| 229 | this->vertices = (Vertex**)hvertices->deliverp();
|
|---|
| 230 | this->element = (Element*)helement->delivers();
|
|---|
| [5737] | 231 |
|
|---|
| [4248] | 232 | /*point parameters to real dataset: */
|
|---|
| 233 | this->parameters=parametersin;
|
|---|
| 234 | }
|
|---|
| 235 | /*}}}*/
|
|---|
| [12365] | 236 | /*FUNCTION Numericalflux::SetCurrentConfiguration {{{*/
|
|---|
| [4575] | 237 | void Numericalflux::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
|
|---|
| 238 |
|
|---|
| 239 | }
|
|---|
| 240 | /*}}}*/
|
|---|
| [12365] | 241 | /*FUNCTION Numericalflux::CreateKMatrix {{{*/
|
|---|
| [13216] | 242 | void Numericalflux::CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){
|
|---|
| [3683] | 243 |
|
|---|
| [6026] | 244 | /*recover some parameters*/
|
|---|
| 245 | ElementMatrix* Ke=NULL;
|
|---|
| [5455] | 246 | int analysis_type;
|
|---|
| 247 | this->parameters->FindParam(&analysis_type,AnalysisTypeEnum);
|
|---|
| [3683] | 248 |
|
|---|
| [5911] | 249 | /*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */
|
|---|
| 250 | switch(analysis_type){
|
|---|
| [16137] | 251 | case MasstransportAnalysisEnum:
|
|---|
| 252 | Ke=CreateKMatrixMasstransport();
|
|---|
| [5911] | 253 | break;
|
|---|
| [8287] | 254 | case BalancethicknessAnalysisEnum:
|
|---|
| 255 | Ke=CreateKMatrixBalancethickness();
|
|---|
| [6026] | 256 | break;
|
|---|
| [8287] | 257 | case AdjointBalancethicknessAnalysisEnum:
|
|---|
| 258 | Ke=CreateKMatrixAdjointBalancethickness();
|
|---|
| [6026] | 259 | break;
|
|---|
| [5911] | 260 | default:
|
|---|
| [13036] | 261 | _error_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
|
|---|
| [3683] | 262 | }
|
|---|
| [5911] | 263 |
|
|---|
| 264 | /*Add to global matrix*/
|
|---|
| 265 | if(Ke){
|
|---|
| [8800] | 266 | Ke->AddToGlobal(Kff,Kfs);
|
|---|
| [5911] | 267 | delete Ke;
|
|---|
| [3683] | 268 | }
|
|---|
| 269 |
|
|---|
| 270 | }
|
|---|
| 271 | /*}}}*/
|
|---|
| [12365] | 272 | /*FUNCTION Numericalflux::CreatePVector {{{*/
|
|---|
| [13216] | 273 | void Numericalflux::CreatePVector(Vector<IssmDouble>* pf){
|
|---|
| [4248] | 274 |
|
|---|
| [6026] | 275 | /*recover some parameters*/
|
|---|
| 276 | ElementVector* pe=NULL;
|
|---|
| [5455] | 277 | int analysis_type;
|
|---|
| 278 | this->parameters->FindParam(&analysis_type,AnalysisTypeEnum);
|
|---|
| [4248] | 279 |
|
|---|
| [5911] | 280 | switch(analysis_type){
|
|---|
| [16137] | 281 | case MasstransportAnalysisEnum:
|
|---|
| 282 | pe=CreatePVectorMasstransport();
|
|---|
| [5911] | 283 | break;
|
|---|
| [8287] | 284 | case BalancethicknessAnalysisEnum:
|
|---|
| 285 | pe=CreatePVectorBalancethickness();
|
|---|
| [6026] | 286 | break;
|
|---|
| [8287] | 287 | case AdjointBalancethicknessAnalysisEnum:
|
|---|
| 288 | pe=CreatePVectorAdjointBalancethickness();
|
|---|
| [6026] | 289 | break;
|
|---|
| [5911] | 290 | default:
|
|---|
| [13036] | 291 | _error_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
|
|---|
| [4248] | 292 | }
|
|---|
| [5911] | 293 |
|
|---|
| 294 | /*Add to global matrix*/
|
|---|
| 295 | if(pe){
|
|---|
| [8800] | 296 | pe->AddToGlobal(pf);
|
|---|
| [5911] | 297 | delete pe;
|
|---|
| [4248] | 298 | }
|
|---|
| 299 |
|
|---|
| 300 | }
|
|---|
| 301 | /*}}}*/
|
|---|
| [13915] | 302 | /*FUNCTION Numericalflux::GetNodesSidList{{{*/
|
|---|
| 303 | void Numericalflux::GetNodesSidList(int* sidlist){
|
|---|
| 304 |
|
|---|
| 305 | int type;
|
|---|
| [14688] | 306 | inputs->GetInputValue(&type,NumericalfluxTypeEnum);
|
|---|
| [13915] | 307 | _assert_(sidlist);
|
|---|
| 308 | _assert_(nodes);
|
|---|
| 309 |
|
|---|
| 310 | switch(type){
|
|---|
| 311 | case InternalEnum:
|
|---|
| [14763] | 312 | for(int i=0;i<NUMNODES_INTERNAL;i++) sidlist[i]=nodes[i]->Sid();
|
|---|
| [13915] | 313 | return;
|
|---|
| 314 | case BoundaryEnum:
|
|---|
| [14763] | 315 | for(int i=0;i<NUMNODES_BOUNDARY;i++) sidlist[i]=nodes[i]->Sid();
|
|---|
| [13915] | 316 | return;
|
|---|
| 317 | default:
|
|---|
| 318 | _error_("Numericalflux type " << EnumToStringx(type) << " not supported yet");
|
|---|
| 319 | }
|
|---|
| 320 | }
|
|---|
| 321 | /*}}}*/
|
|---|
| [16137] | 322 | /*FUNCTION Numericalflux::GetNodesLidList{{{*/
|
|---|
| 323 | void Numericalflux::GetNodesLidList(int* lidlist){
|
|---|
| 324 |
|
|---|
| 325 | int type;
|
|---|
| 326 | inputs->GetInputValue(&type,NumericalfluxTypeEnum);
|
|---|
| 327 | _assert_(lidlist);
|
|---|
| 328 | _assert_(nodes);
|
|---|
| 329 |
|
|---|
| 330 | switch(type){
|
|---|
| 331 | case InternalEnum:
|
|---|
| 332 | for(int i=0;i<NUMNODES_INTERNAL;i++) lidlist[i]=nodes[i]->Lid();
|
|---|
| 333 | return;
|
|---|
| 334 | case BoundaryEnum:
|
|---|
| 335 | for(int i=0;i<NUMNODES_BOUNDARY;i++) lidlist[i]=nodes[i]->Lid();
|
|---|
| 336 | return;
|
|---|
| 337 | default:
|
|---|
| 338 | _error_("Numericalflux type " << EnumToStringx(type) << " not supported yet");
|
|---|
| 339 | }
|
|---|
| 340 | }
|
|---|
| 341 | /*}}}*/
|
|---|
| [13915] | 342 | /*FUNCTION Numericalflux::GetNumberOfNodes{{{*/
|
|---|
| 343 | int Numericalflux::GetNumberOfNodes(void){
|
|---|
| 344 |
|
|---|
| 345 | int type;
|
|---|
| [14688] | 346 | inputs->GetInputValue(&type,NumericalfluxTypeEnum);
|
|---|
| [13915] | 347 |
|
|---|
| 348 | switch(type){
|
|---|
| 349 | case InternalEnum:
|
|---|
| [14763] | 350 | return NUMNODES_INTERNAL;
|
|---|
| [13915] | 351 | case BoundaryEnum:
|
|---|
| [14763] | 352 | return NUMNODES_BOUNDARY;
|
|---|
| [13915] | 353 | default:
|
|---|
| 354 | _error_("Numericalflux type " << EnumToStringx(type) << " not supported yet");
|
|---|
| 355 | }
|
|---|
| 356 |
|
|---|
| 357 | }
|
|---|
| 358 | /*}}}*/
|
|---|
| [13925] | 359 | /*FUNCTION Numericalflux::IsPenalty{{{*/
|
|---|
| 360 | bool Numericalflux::IsPenalty(void){
|
|---|
| 361 | return false;
|
|---|
| 362 | }
|
|---|
| 363 | /*}}}*/
|
|---|
| [12365] | 364 | /*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{*/
|
|---|
| [13216] | 365 | void Numericalflux::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,IssmDouble kmax){
|
|---|
| [4248] | 366 |
|
|---|
| 367 | /*No stiffness loads applied, do nothing: */
|
|---|
| 368 | return;
|
|---|
| 369 |
|
|---|
| 370 | }
|
|---|
| 371 | /*}}}*/
|
|---|
| [12365] | 372 | /*FUNCTION Numericalflux::PenaltyCreatePVector{{{*/
|
|---|
| [13216] | 373 | void Numericalflux::PenaltyCreatePVector(Vector<IssmDouble>* pf,IssmDouble kmax){
|
|---|
| [4248] | 374 |
|
|---|
| 375 | /*No penalty loads applied, do nothing: */
|
|---|
| 376 | return;
|
|---|
| 377 |
|
|---|
| 378 | }
|
|---|
| 379 | /*}}}*/
|
|---|
| [12365] | 380 | /*FUNCTION Numericalflux::InAnalysis{{{*/
|
|---|
| [4248] | 381 | bool Numericalflux::InAnalysis(int in_analysis_type){
|
|---|
| 382 | if (in_analysis_type==this->analysis_type) return true;
|
|---|
| 383 | else return false;
|
|---|
| 384 | }
|
|---|
| 385 | /*}}}*/
|
|---|
| [13915] | 386 | /*FUNCTION Numericalflux::SetwiseNodeConnectivity{{{*/
|
|---|
| [16137] | 387 | void Numericalflux::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){
|
|---|
| [4248] | 388 |
|
|---|
| [13915] | 389 | /*Output */
|
|---|
| 390 | int d_nz = 0;
|
|---|
| 391 | int o_nz = 0;
|
|---|
| 392 |
|
|---|
| 393 | /*Loop over all nodes*/
|
|---|
| 394 | for(int i=0;i<this->GetNumberOfNodes();i++){
|
|---|
| 395 |
|
|---|
| [16137] | 396 | if(!flags[this->nodes[i]->Lid()]){
|
|---|
| [13915] | 397 |
|
|---|
| 398 | /*flag current node so that no other element processes it*/
|
|---|
| [16137] | 399 | flags[this->nodes[i]->Lid()]=true;
|
|---|
| [13915] | 400 |
|
|---|
| [16137] | 401 | int counter=0;
|
|---|
| 402 | while(flagsindices[counter]>=0) counter++;
|
|---|
| 403 | flagsindices[counter]=this->nodes[i]->Lid();
|
|---|
| 404 |
|
|---|
| [13915] | 405 | /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
|
|---|
| 406 | switch(set2_enum){
|
|---|
| 407 | case FsetEnum:
|
|---|
| 408 | if(nodes[i]->indexing.fsize){
|
|---|
| 409 | if(this->nodes[i]->IsClone())
|
|---|
| 410 | o_nz += 1;
|
|---|
| 411 | else
|
|---|
| 412 | d_nz += 1;
|
|---|
| 413 | }
|
|---|
| 414 | break;
|
|---|
| 415 | case GsetEnum:
|
|---|
| 416 | if(nodes[i]->indexing.gsize){
|
|---|
| 417 | if(this->nodes[i]->IsClone())
|
|---|
| 418 | o_nz += 1;
|
|---|
| 419 | else
|
|---|
| 420 | d_nz += 1;
|
|---|
| 421 | }
|
|---|
| 422 | break;
|
|---|
| 423 | case SsetEnum:
|
|---|
| 424 | if(nodes[i]->indexing.ssize){
|
|---|
| 425 | if(this->nodes[i]->IsClone())
|
|---|
| 426 | o_nz += 1;
|
|---|
| 427 | else
|
|---|
| 428 | d_nz += 1;
|
|---|
| 429 | }
|
|---|
| 430 | break;
|
|---|
| 431 | default: _error_("not supported");
|
|---|
| 432 | }
|
|---|
| 433 | }
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | /*Assign output pointers: */
|
|---|
| 437 | *pd_nz=d_nz;
|
|---|
| 438 | *po_nz=o_nz;
|
|---|
| 439 | }
|
|---|
| 440 | /*}}}*/
|
|---|
| 441 |
|
|---|
| [4248] | 442 | /*Numericalflux management*/
|
|---|
| [16137] | 443 | /*FUNCTION Numericalflux::CreateKMatrixMasstransport{{{*/
|
|---|
| 444 | ElementMatrix* Numericalflux::CreateKMatrixMasstransport(void){
|
|---|
| [3683] | 445 |
|
|---|
| [6026] | 446 | int type;
|
|---|
| [14688] | 447 | inputs->GetInputValue(&type,NumericalfluxTypeEnum);
|
|---|
| [6026] | 448 |
|
|---|
| 449 | switch(type){
|
|---|
| 450 | case InternalEnum:
|
|---|
| [16137] | 451 | return CreateKMatrixMasstransportInternal();
|
|---|
| [6026] | 452 | case BoundaryEnum:
|
|---|
| [16137] | 453 | return CreateKMatrixMasstransportBoundary();
|
|---|
| [6026] | 454 | default:
|
|---|
| [13036] | 455 | _error_("type not supported yet");
|
|---|
| [6026] | 456 | }
|
|---|
| 457 | }
|
|---|
| 458 | /*}}}*/
|
|---|
| [16137] | 459 | /*FUNCTION Numericalflux::CreateKMatrixMasstransportInternal {{{*/
|
|---|
| 460 | ElementMatrix* Numericalflux::CreateKMatrixMasstransportInternal(void){
|
|---|
| [6026] | 461 |
|
|---|
| [5738] | 462 | /* constants*/
|
|---|
| [14763] | 463 | const int numdof=NDOF1*NUMNODES_INTERNAL;
|
|---|
| [3683] | 464 |
|
|---|
| [5738] | 465 | /* Intermediaries*/
|
|---|
| [6026] | 466 | int i,j,ig,index1,index2;
|
|---|
| [12472] | 467 | IssmDouble DL1,DL2,Jdet,dt,vx,vy,UdotN;
|
|---|
| [14763] | 468 | IssmDouble xyz_list[NUMVERTICES][3];
|
|---|
| [12472] | 469 | IssmDouble normal[2];
|
|---|
| 470 | IssmDouble B[numdof];
|
|---|
| 471 | IssmDouble Bprime[numdof];
|
|---|
| 472 | IssmDouble Ke_g1[numdof][numdof];
|
|---|
| 473 | IssmDouble Ke_g2[numdof][numdof];
|
|---|
| [5738] | 474 | GaussTria *gauss;
|
|---|
| [3683] | 475 |
|
|---|
| [5911] | 476 | /*Initialize Element matrix and return if necessary*/
|
|---|
| 477 | Tria* tria=(Tria*)element;
|
|---|
| [16137] | 478 | if(tria->NoIceInElement()) return NULL;
|
|---|
| [14763] | 479 | ElementMatrix* Ke=new ElementMatrix(nodes,NUMNODES_INTERNAL,this->parameters);
|
|---|
| [5911] | 480 |
|
|---|
| 481 | /*Retrieve all inputs and parameters*/
|
|---|
| [14763] | 482 | GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
|
|---|
| [9628] | 483 | parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
|---|
| [5738] | 484 | Input* vxaverage_input=tria->inputs->GetInput(VxEnum);
|
|---|
| 485 | Input* vyaverage_input=tria->inputs->GetInput(VyEnum);
|
|---|
| [3683] | 486 | GetNormal(&normal[0],xyz_list);
|
|---|
| [4904] | 487 |
|
|---|
| [3683] | 488 | /* Start looping on the number of gaussian points: */
|
|---|
| [5738] | 489 | index1=tria->GetNodeIndex(nodes[0]);
|
|---|
| 490 | index2=tria->GetNodeIndex(nodes[1]);
|
|---|
| 491 | gauss=new GaussTria(index1,index2,2);
|
|---|
| 492 | for(ig=gauss->begin();ig<gauss->end();ig++){
|
|---|
| [3683] | 493 |
|
|---|
| [5738] | 494 | gauss->GaussPoint(ig);
|
|---|
| [3683] | 495 |
|
|---|
| [5738] | 496 | tria->GetSegmentBFlux(&B[0],gauss,index1,index2);
|
|---|
| 497 | tria->GetSegmentBprimeFlux(&Bprime[0],gauss,index1,index2);
|
|---|
| [3683] | 498 |
|
|---|
| [10135] | 499 | vxaverage_input->GetInputValue(&vx,gauss);
|
|---|
| 500 | vyaverage_input->GetInputValue(&vy,gauss);
|
|---|
| [3683] | 501 | UdotN=vx*normal[0]+vy*normal[1];
|
|---|
| [5738] | 502 | tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss);
|
|---|
| 503 | DL1=gauss->weight*Jdet*dt*UdotN/2;
|
|---|
| 504 | DL2=gauss->weight*Jdet*dt*fabs(UdotN)/2;
|
|---|
| [3683] | 505 |
|
|---|
| 506 | TripleMultiply(&B[0],1,numdof,1,
|
|---|
| 507 | &DL1,1,1,0,
|
|---|
| [5738] | 508 | &Bprime[0],1,numdof,0,
|
|---|
| [5739] | 509 | &Ke_g1[0][0],0);
|
|---|
| [3683] | 510 | TripleMultiply(&B[0],1,numdof,1,
|
|---|
| 511 | &DL2,1,1,0,
|
|---|
| 512 | &B[0],1,numdof,0,
|
|---|
| [5739] | 513 | &Ke_g2[0][0],0);
|
|---|
| [3683] | 514 |
|
|---|
| [5911] | 515 | for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g1[i][j];
|
|---|
| 516 | for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g2[i][j];
|
|---|
| [5738] | 517 | }
|
|---|
| [13622] | 518 |
|
|---|
| [5911] | 519 | /*Clean up and return*/
|
|---|
| [5738] | 520 | delete gauss;
|
|---|
| [5911] | 521 | return Ke;
|
|---|
| [3683] | 522 | }
|
|---|
| 523 | /*}}}*/
|
|---|
| [16137] | 524 | /*FUNCTION Numericalflux::CreateKMatrixMasstransportBoundary {{{*/
|
|---|
| 525 | ElementMatrix* Numericalflux::CreateKMatrixMasstransportBoundary(void){
|
|---|
| [3683] | 526 |
|
|---|
| [5739] | 527 | /* constants*/
|
|---|
| [14763] | 528 | const int numdof=NDOF1*NUMNODES_BOUNDARY;
|
|---|
| [3683] | 529 |
|
|---|
| [5739] | 530 | /* Intermediaries*/
|
|---|
| [6026] | 531 | int i,j,ig,index1,index2;
|
|---|
| [12472] | 532 | IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN;
|
|---|
| [14763] | 533 | IssmDouble xyz_list[NUMVERTICES][3];
|
|---|
| [12472] | 534 | IssmDouble normal[2];
|
|---|
| 535 | IssmDouble L[numdof];
|
|---|
| 536 | IssmDouble Ke_g[numdof][numdof];
|
|---|
| [5739] | 537 | GaussTria *gauss;
|
|---|
| [3683] | 538 |
|
|---|
| [5911] | 539 | /*Initialize Element matrix and return if necessary*/
|
|---|
| [6029] | 540 | ElementMatrix* Ke = NULL;
|
|---|
| [5911] | 541 | Tria* tria=(Tria*)element;
|
|---|
| [16137] | 542 | if(tria->NoIceInElement()) return NULL;
|
|---|
| [5911] | 543 |
|
|---|
| 544 | /*Retrieve all inputs and parameters*/
|
|---|
| [14763] | 545 | GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
|
|---|
| [9628] | 546 | parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
|---|
| [9232] | 547 | Input* vxaverage_input=tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input);
|
|---|
| 548 | Input* vyaverage_input=tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input);
|
|---|
| [3683] | 549 | GetNormal(&normal[0],xyz_list);
|
|---|
| [6026] | 550 |
|
|---|
| 551 | /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/
|
|---|
| 552 | index1=tria->GetNodeIndex(nodes[0]);
|
|---|
| 553 | index2=tria->GetNodeIndex(nodes[1]);
|
|---|
| 554 |
|
|---|
| 555 | gauss=new GaussTria();
|
|---|
| 556 | gauss->GaussEdgeCenter(index1,index2);
|
|---|
| [10135] | 557 | vxaverage_input->GetInputValue(&mean_vx,gauss);
|
|---|
| 558 | vyaverage_input->GetInputValue(&mean_vy,gauss);
|
|---|
| [6026] | 559 | delete gauss;
|
|---|
| 560 |
|
|---|
| 561 | UdotN=mean_vx*normal[0]+mean_vy*normal[1];
|
|---|
| 562 | if (UdotN<=0){
|
|---|
| [6029] | 563 | return NULL; /*(u,n)<0 -> inflow, PenaltyCreatePVector will take care of it*/
|
|---|
| [6026] | 564 | }
|
|---|
| [6029] | 565 | else{
|
|---|
| [14763] | 566 | Ke=new ElementMatrix(nodes,NUMNODES_BOUNDARY,this->parameters);
|
|---|
| [6029] | 567 | }
|
|---|
| [6026] | 568 |
|
|---|
| 569 | /* Start looping on the number of gaussian points: */
|
|---|
| 570 | gauss=new GaussTria(index1,index2,2);
|
|---|
| 571 | for(ig=gauss->begin();ig<gauss->end();ig++){
|
|---|
| 572 |
|
|---|
| 573 | gauss->GaussPoint(ig);
|
|---|
| 574 |
|
|---|
| 575 | tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2);
|
|---|
| 576 |
|
|---|
| [10135] | 577 | vxaverage_input->GetInputValue(&vx,gauss);
|
|---|
| 578 | vyaverage_input->GetInputValue(&vy,gauss);
|
|---|
| [6026] | 579 | UdotN=vx*normal[0]+vy*normal[1];
|
|---|
| 580 | tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss);
|
|---|
| 581 | DL=gauss->weight*Jdet*dt*UdotN;
|
|---|
| 582 |
|
|---|
| 583 | TripleMultiply(&L[0],1,numdof,1,
|
|---|
| 584 | &DL,1,1,0,
|
|---|
| 585 | &L[0],1,numdof,0,
|
|---|
| 586 | &Ke_g[0][0],0);
|
|---|
| 587 |
|
|---|
| 588 | for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g[i][j];
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | /*Clean up and return*/
|
|---|
| 592 | delete gauss;
|
|---|
| 593 | return Ke;
|
|---|
| 594 | }
|
|---|
| 595 | /*}}}*/
|
|---|
| [12365] | 596 | /*FUNCTION Numericalflux::CreateKMatrixBalancethickness{{{*/
|
|---|
| [8287] | 597 | ElementMatrix* Numericalflux::CreateKMatrixBalancethickness(void){
|
|---|
| [6026] | 598 |
|
|---|
| 599 | int type;
|
|---|
| [14688] | 600 | inputs->GetInputValue(&type,NumericalfluxTypeEnum);
|
|---|
| [6026] | 601 |
|
|---|
| 602 | switch(type){
|
|---|
| 603 | case InternalEnum:
|
|---|
| [8287] | 604 | return CreateKMatrixBalancethicknessInternal();
|
|---|
| [6026] | 605 | case BoundaryEnum:
|
|---|
| [8287] | 606 | return CreateKMatrixBalancethicknessBoundary();
|
|---|
| [5739] | 607 | default:
|
|---|
| [13036] | 608 | _error_("type not supported yet");
|
|---|
| [4904] | 609 | }
|
|---|
| [6026] | 610 | }
|
|---|
| 611 | /*}}}*/
|
|---|
| [12365] | 612 | /*FUNCTION Numericalflux::CreateKMatrixBalancethicknessInternal {{{*/
|
|---|
| [8287] | 613 | ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessInternal(void){
|
|---|
| [4904] | 614 |
|
|---|
| [6026] | 615 | /* constants*/
|
|---|
| [14763] | 616 | const int numdof=NDOF1*NUMNODES_INTERNAL;
|
|---|
| [6026] | 617 |
|
|---|
| 618 | /* Intermediaries*/
|
|---|
| 619 | int i,j,ig,index1,index2;
|
|---|
| [12472] | 620 | IssmDouble DL1,DL2,Jdet,vx,vy,UdotN;
|
|---|
| [14763] | 621 | IssmDouble xyz_list[NUMVERTICES][3];
|
|---|
| [12472] | 622 | IssmDouble normal[2];
|
|---|
| 623 | IssmDouble B[numdof];
|
|---|
| 624 | IssmDouble Bprime[numdof];
|
|---|
| 625 | IssmDouble Ke_g1[numdof][numdof];
|
|---|
| 626 | IssmDouble Ke_g2[numdof][numdof];
|
|---|
| [6026] | 627 | GaussTria *gauss;
|
|---|
| 628 |
|
|---|
| 629 | /*Initialize Element matrix and return if necessary*/
|
|---|
| 630 | Tria* tria=(Tria*)element;
|
|---|
| [16137] | 631 | if(tria->NoIceInElement()) return NULL;
|
|---|
| [14763] | 632 | ElementMatrix* Ke=new ElementMatrix(nodes,NUMNODES_INTERNAL,this->parameters);
|
|---|
| [6026] | 633 |
|
|---|
| 634 | /*Retrieve all inputs and parameters*/
|
|---|
| [14763] | 635 | GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
|
|---|
| [6026] | 636 | Input* vxaverage_input=tria->inputs->GetInput(VxEnum);
|
|---|
| 637 | Input* vyaverage_input=tria->inputs->GetInput(VyEnum);
|
|---|
| 638 | GetNormal(&normal[0],xyz_list);
|
|---|
| 639 |
|
|---|
| 640 | /* Start looping on the number of gaussian points: */
|
|---|
| 641 | index1=tria->GetNodeIndex(nodes[0]);
|
|---|
| 642 | index2=tria->GetNodeIndex(nodes[1]);
|
|---|
| 643 | gauss=new GaussTria(index1,index2,2);
|
|---|
| 644 | for(ig=gauss->begin();ig<gauss->end();ig++){
|
|---|
| 645 |
|
|---|
| 646 | gauss->GaussPoint(ig);
|
|---|
| 647 |
|
|---|
| 648 | tria->GetSegmentBFlux(&B[0],gauss,index1,index2);
|
|---|
| 649 | tria->GetSegmentBprimeFlux(&Bprime[0],gauss,index1,index2);
|
|---|
| 650 |
|
|---|
| [10135] | 651 | vxaverage_input->GetInputValue(&vx,gauss);
|
|---|
| 652 | vyaverage_input->GetInputValue(&vy,gauss);
|
|---|
| [6026] | 653 | UdotN=vx*normal[0]+vy*normal[1];
|
|---|
| 654 | tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss);
|
|---|
| 655 | DL1=gauss->weight*Jdet*UdotN/2;
|
|---|
| 656 | DL2=gauss->weight*Jdet*fabs(UdotN)/2;
|
|---|
| 657 |
|
|---|
| 658 | TripleMultiply(&B[0],1,numdof,1,
|
|---|
| 659 | &DL1,1,1,0,
|
|---|
| 660 | &Bprime[0],1,numdof,0,
|
|---|
| 661 | &Ke_g1[0][0],0);
|
|---|
| 662 | TripleMultiply(&B[0],1,numdof,1,
|
|---|
| 663 | &DL2,1,1,0,
|
|---|
| 664 | &B[0],1,numdof,0,
|
|---|
| 665 | &Ke_g2[0][0],0);
|
|---|
| 666 |
|
|---|
| 667 | for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g1[i][j];
|
|---|
| 668 | for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g2[i][j];
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| 671 | /*Clean up and return*/
|
|---|
| 672 | delete gauss;
|
|---|
| 673 | return Ke;
|
|---|
| 674 | }
|
|---|
| 675 | /*}}}*/
|
|---|
| [12365] | 676 | /*FUNCTION Numericalflux::CreateKMatrixBalancethicknessBoundary {{{*/
|
|---|
| [8287] | 677 | ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessBoundary(void){
|
|---|
| [6026] | 678 |
|
|---|
| 679 | /* constants*/
|
|---|
| [14763] | 680 | const int numdof=NDOF1*NUMNODES_BOUNDARY;
|
|---|
| [6026] | 681 |
|
|---|
| 682 | /* Intermediaries*/
|
|---|
| 683 | int i,j,ig,index1,index2;
|
|---|
| [12472] | 684 | IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN;
|
|---|
| [14763] | 685 | IssmDouble xyz_list[NUMVERTICES][3];
|
|---|
| [12472] | 686 | IssmDouble normal[2];
|
|---|
| 687 | IssmDouble L[numdof];
|
|---|
| 688 | IssmDouble Ke_g[numdof][numdof];
|
|---|
| [6026] | 689 | GaussTria *gauss;
|
|---|
| 690 |
|
|---|
| 691 | /*Initialize Element matrix and return if necessary*/
|
|---|
| [6029] | 692 | ElementMatrix* Ke = NULL;
|
|---|
| [6026] | 693 | Tria* tria=(Tria*)element;
|
|---|
| [16137] | 694 | if(tria->NoIceInElement()) return NULL;
|
|---|
| [6026] | 695 |
|
|---|
| 696 | /*Retrieve all inputs and parameters*/
|
|---|
| [14763] | 697 | GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
|
|---|
| [6026] | 698 | Input* vxaverage_input=tria->inputs->GetInput(VxEnum);
|
|---|
| 699 | Input* vyaverage_input=tria->inputs->GetInput(VyEnum);
|
|---|
| 700 | GetNormal(&normal[0],xyz_list);
|
|---|
| 701 |
|
|---|
| [4422] | 702 | /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/
|
|---|
| [5739] | 703 | index1=tria->GetNodeIndex(nodes[0]);
|
|---|
| 704 | index2=tria->GetNodeIndex(nodes[1]);
|
|---|
| 705 |
|
|---|
| 706 | gauss=new GaussTria();
|
|---|
| 707 | gauss->GaussEdgeCenter(index1,index2);
|
|---|
| [10135] | 708 | vxaverage_input->GetInputValue(&mean_vx,gauss);
|
|---|
| 709 | vyaverage_input->GetInputValue(&mean_vy,gauss);
|
|---|
| [5739] | 710 | delete gauss;
|
|---|
| 711 |
|
|---|
| [3683] | 712 | UdotN=mean_vx*normal[0]+mean_vy*normal[1];
|
|---|
| 713 | if (UdotN<=0){
|
|---|
| [6029] | 714 | return NULL; /*(u,n)<0 -> inflow, PenaltyCreatePVector will take care of it*/
|
|---|
| [3683] | 715 | }
|
|---|
| [6029] | 716 | else{
|
|---|
| [14763] | 717 | Ke=new ElementMatrix(nodes,NUMNODES_BOUNDARY,this->parameters);
|
|---|
| [6029] | 718 | }
|
|---|
| [3683] | 719 |
|
|---|
| 720 | /* Start looping on the number of gaussian points: */
|
|---|
| [5739] | 721 | gauss=new GaussTria(index1,index2,2);
|
|---|
| 722 | for(ig=gauss->begin();ig<gauss->end();ig++){
|
|---|
| [3683] | 723 |
|
|---|
| [5739] | 724 | gauss->GaussPoint(ig);
|
|---|
| [3683] | 725 |
|
|---|
| [5739] | 726 | tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2);
|
|---|
| [3683] | 727 |
|
|---|
| [10135] | 728 | vxaverage_input->GetInputValue(&vx,gauss);
|
|---|
| 729 | vyaverage_input->GetInputValue(&vy,gauss);
|
|---|
| [3683] | 730 | UdotN=vx*normal[0]+vy*normal[1];
|
|---|
| [5739] | 731 | tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss);
|
|---|
| [6026] | 732 | DL=gauss->weight*Jdet*UdotN;
|
|---|
| [3683] | 733 |
|
|---|
| 734 | TripleMultiply(&L[0],1,numdof,1,
|
|---|
| 735 | &DL,1,1,0,
|
|---|
| 736 | &L[0],1,numdof,0,
|
|---|
| [5739] | 737 | &Ke_g[0][0],0);
|
|---|
| [3683] | 738 |
|
|---|
| [5911] | 739 | for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g[i][j];
|
|---|
| [5739] | 740 | }
|
|---|
| [3683] | 741 |
|
|---|
| [5911] | 742 | /*Clean up and return*/
|
|---|
| [5739] | 743 | delete gauss;
|
|---|
| [5911] | 744 | return Ke;
|
|---|
| [3683] | 745 | }
|
|---|
| 746 | /*}}}*/
|
|---|
| [12365] | 747 | /*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethickness{{{*/
|
|---|
| [8287] | 748 | ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethickness(void){
|
|---|
| [3683] | 749 |
|
|---|
| [6026] | 750 | int type;
|
|---|
| [14688] | 751 | inputs->GetInputValue(&type,NumericalfluxTypeEnum);
|
|---|
| [6026] | 752 |
|
|---|
| 753 | switch(type){
|
|---|
| 754 | case InternalEnum:
|
|---|
| [8287] | 755 | return CreateKMatrixAdjointBalancethicknessInternal();
|
|---|
| [6026] | 756 | case BoundaryEnum:
|
|---|
| [8287] | 757 | return CreateKMatrixAdjointBalancethicknessBoundary();
|
|---|
| [6026] | 758 | default:
|
|---|
| [13036] | 759 | _error_("type not supported yet");
|
|---|
| [6026] | 760 | }
|
|---|
| 761 | }
|
|---|
| 762 | /*}}}*/
|
|---|
| [12365] | 763 | /*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessInternal {{{*/
|
|---|
| [8287] | 764 | ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessInternal(void){
|
|---|
| [6026] | 765 |
|
|---|
| [8287] | 766 | ElementMatrix* Ke=CreateKMatrixBalancethicknessInternal();
|
|---|
| [6029] | 767 | if (Ke) Ke->Transpose();
|
|---|
| 768 | return Ke;
|
|---|
| [6026] | 769 | }
|
|---|
| 770 | /*}}}*/
|
|---|
| [12365] | 771 | /*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary {{{*/
|
|---|
| [8287] | 772 | ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary(void){
|
|---|
| [6026] | 773 |
|
|---|
| [8287] | 774 | ElementMatrix* Ke=CreateKMatrixBalancethicknessBoundary();
|
|---|
| [6029] | 775 | if(Ke) Ke->Transpose();
|
|---|
| 776 | return Ke;
|
|---|
| [6026] | 777 | }
|
|---|
| 778 | /*}}}*/
|
|---|
| [16137] | 779 | /*FUNCTION Numericalflux::CreatePVectorMasstransport{{{*/
|
|---|
| 780 | ElementVector* Numericalflux::CreatePVectorMasstransport(void){
|
|---|
| [6026] | 781 |
|
|---|
| 782 | int type;
|
|---|
| [14688] | 783 | inputs->GetInputValue(&type,NumericalfluxTypeEnum);
|
|---|
| [6026] | 784 |
|
|---|
| 785 | switch(type){
|
|---|
| 786 | case InternalEnum:
|
|---|
| [16137] | 787 | return CreatePVectorMasstransportInternal();
|
|---|
| [6026] | 788 | case BoundaryEnum:
|
|---|
| [16137] | 789 | return CreatePVectorMasstransportBoundary();
|
|---|
| [6026] | 790 | default:
|
|---|
| [13036] | 791 | _error_("type not supported yet");
|
|---|
| [6026] | 792 | }
|
|---|
| 793 | }
|
|---|
| 794 | /*}}}*/
|
|---|
| [16137] | 795 | /*FUNCTION Numericalflux::CreatePVectorMasstransportInternal{{{*/
|
|---|
| 796 | ElementVector* Numericalflux::CreatePVectorMasstransportInternal(void){
|
|---|
| [6026] | 797 |
|
|---|
| [3683] | 798 | /*Nothing added to PVector*/
|
|---|
| [5911] | 799 | return NULL;
|
|---|
| [3683] | 800 |
|
|---|
| 801 | }
|
|---|
| 802 | /*}}}*/
|
|---|
| [16137] | 803 | /*FUNCTION Numericalflux::CreatePVectorMasstransportBoundary{{{*/
|
|---|
| 804 | ElementVector* Numericalflux::CreatePVectorMasstransportBoundary(void){
|
|---|
| [3683] | 805 |
|
|---|
| [5739] | 806 | /* constants*/
|
|---|
| [14763] | 807 | const int numdof=NDOF1*NUMNODES_BOUNDARY;
|
|---|
| [3683] | 808 |
|
|---|
| [5739] | 809 | /* Intermediaries*/
|
|---|
| [13761] | 810 | int i,ig,index1,index2;
|
|---|
| [12472] | 811 | IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness;
|
|---|
| [14763] | 812 | IssmDouble xyz_list[NUMVERTICES][3];
|
|---|
| [12472] | 813 | IssmDouble normal[2];
|
|---|
| 814 | IssmDouble L[numdof];
|
|---|
| [5739] | 815 | GaussTria *gauss;
|
|---|
| [3683] | 816 |
|
|---|
| [6026] | 817 | /*Initialize Load Vector and return if necessary*/
|
|---|
| [6029] | 818 | ElementVector* pe = NULL;
|
|---|
| [5911] | 819 | Tria* tria=(Tria*)element;
|
|---|
| [16137] | 820 | if(tria->NoIceInElement()) return NULL;
|
|---|
| [5911] | 821 |
|
|---|
| 822 | /*Retrieve all inputs and parameters*/
|
|---|
| [14763] | 823 | GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
|
|---|
| [9628] | 824 | parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
|---|
| [9642] | 825 | Input* vxaverage_input =tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input);
|
|---|
| 826 | Input* vyaverage_input =tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input);
|
|---|
| [16137] | 827 | Input* spcthickness_input=tria->inputs->GetInput(MasstransportSpcthicknessEnum); _assert_(spcthickness_input);
|
|---|
| [6026] | 828 | GetNormal(&normal[0],xyz_list);
|
|---|
| 829 |
|
|---|
| 830 | /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/
|
|---|
| 831 | index1=tria->GetNodeIndex(nodes[0]);
|
|---|
| 832 | index2=tria->GetNodeIndex(nodes[1]);
|
|---|
| 833 |
|
|---|
| 834 | gauss=new GaussTria();
|
|---|
| 835 | gauss->GaussEdgeCenter(index1,index2);
|
|---|
| [10135] | 836 | vxaverage_input->GetInputValue(&mean_vx,gauss);
|
|---|
| 837 | vyaverage_input->GetInputValue(&mean_vy,gauss);
|
|---|
| [6026] | 838 | delete gauss;
|
|---|
| [6029] | 839 |
|
|---|
| [6026] | 840 | UdotN=mean_vx*normal[0]+mean_vy*normal[1];
|
|---|
| 841 | if (UdotN>0){
|
|---|
| [6029] | 842 | return NULL; /*(u,n)>0 -> outflow, PenaltyCreateKMatrix will take care of it*/
|
|---|
| [6026] | 843 | }
|
|---|
| [6029] | 844 | else{
|
|---|
| [14763] | 845 | pe=new ElementVector(nodes,NUMNODES_BOUNDARY,this->parameters);
|
|---|
| [6029] | 846 | }
|
|---|
| [6026] | 847 |
|
|---|
| 848 | /* Start looping on the number of gaussian points: */
|
|---|
| 849 | gauss=new GaussTria(index1,index2,2);
|
|---|
| 850 | for(ig=gauss->begin();ig<gauss->end();ig++){
|
|---|
| 851 |
|
|---|
| 852 | gauss->GaussPoint(ig);
|
|---|
| 853 |
|
|---|
| 854 | tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2);
|
|---|
| 855 |
|
|---|
| [10135] | 856 | vxaverage_input->GetInputValue(&vx,gauss);
|
|---|
| 857 | vyaverage_input->GetInputValue(&vy,gauss);
|
|---|
| 858 | spcthickness_input->GetInputValue(&thickness,gauss);
|
|---|
| [13036] | 859 | if(xIsNan<IssmDouble>(thickness)) _error_("Cannot weakly apply constraint because NaN was provided");
|
|---|
| [9232] | 860 |
|
|---|
| [6026] | 861 | UdotN=vx*normal[0]+vy*normal[1];
|
|---|
| 862 | tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss);
|
|---|
| 863 | DL= - gauss->weight*Jdet*dt*UdotN*thickness;
|
|---|
| 864 |
|
|---|
| 865 | for(i=0;i<numdof;i++) pe->values[i] += DL*L[i];
|
|---|
| 866 | }
|
|---|
| 867 |
|
|---|
| 868 | /*Clean up and return*/
|
|---|
| 869 | delete gauss;
|
|---|
| 870 | return pe;
|
|---|
| 871 | }
|
|---|
| 872 | /*}}}*/
|
|---|
| [12365] | 873 | /*FUNCTION Numericalflux::CreatePVectorBalancethickness{{{*/
|
|---|
| [8287] | 874 | ElementVector* Numericalflux::CreatePVectorBalancethickness(void){
|
|---|
| [6026] | 875 |
|
|---|
| 876 | int type;
|
|---|
| [14688] | 877 | inputs->GetInputValue(&type,NumericalfluxTypeEnum);
|
|---|
| [6026] | 878 |
|
|---|
| 879 | switch(type){
|
|---|
| 880 | case InternalEnum:
|
|---|
| [8287] | 881 | return CreatePVectorBalancethicknessInternal();
|
|---|
| [6026] | 882 | case BoundaryEnum:
|
|---|
| [8287] | 883 | return CreatePVectorBalancethicknessBoundary();
|
|---|
| [6026] | 884 | default:
|
|---|
| [13036] | 885 | _error_("type not supported yet");
|
|---|
| [6026] | 886 | }
|
|---|
| 887 | }
|
|---|
| 888 | /*}}}*/
|
|---|
| [12365] | 889 | /*FUNCTION Numericalflux::CreatePVectorBalancethicknessInternal{{{*/
|
|---|
| [8287] | 890 | ElementVector* Numericalflux::CreatePVectorBalancethicknessInternal(void){
|
|---|
| [6026] | 891 |
|
|---|
| 892 | /*Nothing added to PVector*/
|
|---|
| 893 | return NULL;
|
|---|
| 894 |
|
|---|
| 895 | }
|
|---|
| 896 | /*}}}*/
|
|---|
| [12365] | 897 | /*FUNCTION Numericalflux::CreatePVectorBalancethicknessBoundary{{{*/
|
|---|
| [8287] | 898 | ElementVector* Numericalflux::CreatePVectorBalancethicknessBoundary(void){
|
|---|
| [6026] | 899 |
|
|---|
| 900 | /* constants*/
|
|---|
| [14763] | 901 | const int numdof=NDOF1*NUMNODES_BOUNDARY;
|
|---|
| [6026] | 902 |
|
|---|
| 903 | /* Intermediaries*/
|
|---|
| [13761] | 904 | int i,ig,index1,index2;
|
|---|
| 905 | IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness;
|
|---|
| [14763] | 906 | IssmDouble xyz_list[NUMVERTICES][3];
|
|---|
| [13761] | 907 | IssmDouble normal[2];
|
|---|
| 908 | IssmDouble L[numdof];
|
|---|
| [6026] | 909 | GaussTria *gauss;
|
|---|
| 910 |
|
|---|
| 911 | /*Initialize Load Vector and return if necessary*/
|
|---|
| [6029] | 912 | ElementVector* pe = NULL;
|
|---|
| [6026] | 913 | Tria* tria=(Tria*)element;
|
|---|
| [16137] | 914 | if(tria->NoIceInElement()) return NULL;
|
|---|
| [6026] | 915 |
|
|---|
| 916 | /*Retrieve all inputs and parameters*/
|
|---|
| [14763] | 917 | GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
|
|---|
| [6412] | 918 | Input* vxaverage_input=tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input);
|
|---|
| 919 | Input* vyaverage_input=tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input);
|
|---|
| 920 | Input* thickness_input=tria->inputs->GetInput(ThicknessEnum); _assert_(thickness_input);
|
|---|
| [6026] | 921 | GetNormal(&normal[0],xyz_list);
|
|---|
| [3683] | 922 |
|
|---|
| [6026] | 923 | /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/
|
|---|
| 924 | index1=tria->GetNodeIndex(nodes[0]);
|
|---|
| 925 | index2=tria->GetNodeIndex(nodes[1]);
|
|---|
| 926 |
|
|---|
| 927 | gauss=new GaussTria();
|
|---|
| 928 | gauss->GaussEdgeCenter(index1,index2);
|
|---|
| [10135] | 929 | vxaverage_input->GetInputValue(&mean_vx,gauss);
|
|---|
| 930 | vyaverage_input->GetInputValue(&mean_vy,gauss);
|
|---|
| [6026] | 931 | delete gauss;
|
|---|
| 932 | UdotN=mean_vx*normal[0]+mean_vy*normal[1];
|
|---|
| 933 | if (UdotN>0){
|
|---|
| [6029] | 934 | return NULL; /*(u,n)>0 -> outflow, PenaltyCreateKMatrix will take care of it*/
|
|---|
| [6026] | 935 | }
|
|---|
| [6029] | 936 | else{
|
|---|
| [14763] | 937 | pe=new ElementVector(nodes,NUMNODES_BOUNDARY,this->parameters);
|
|---|
| [6029] | 938 | }
|
|---|
| [6026] | 939 |
|
|---|
| 940 | /* Start looping on the number of gaussian points: */
|
|---|
| 941 | gauss=new GaussTria(index1,index2,2);
|
|---|
| 942 | for(ig=gauss->begin();ig<gauss->end();ig++){
|
|---|
| 943 |
|
|---|
| 944 | gauss->GaussPoint(ig);
|
|---|
| 945 |
|
|---|
| 946 | tria->GetSegmentNodalFunctions(&L[0],gauss,index1,index2);
|
|---|
| 947 |
|
|---|
| [10135] | 948 | vxaverage_input->GetInputValue(&vx,gauss);
|
|---|
| 949 | vyaverage_input->GetInputValue(&vy,gauss);
|
|---|
| 950 | thickness_input->GetInputValue(&thickness,gauss);
|
|---|
| [9232] | 951 |
|
|---|
| [6026] | 952 | UdotN=vx*normal[0]+vy*normal[1];
|
|---|
| 953 | tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss);
|
|---|
| 954 | DL= - gauss->weight*Jdet*UdotN*thickness;
|
|---|
| 955 |
|
|---|
| 956 | for(i=0;i<numdof;i++) pe->values[i] += DL*L[i];
|
|---|
| 957 | }
|
|---|
| 958 |
|
|---|
| 959 | /*Clean up and return*/
|
|---|
| 960 | delete gauss;
|
|---|
| 961 | return pe;
|
|---|
| 962 | }
|
|---|
| 963 | /*}}}*/
|
|---|
| [12365] | 964 | /*FUNCTION Numericalflux::CreatePVectorAdjointBalancethickness{{{*/
|
|---|
| [8287] | 965 | ElementVector* Numericalflux::CreatePVectorAdjointBalancethickness(void){
|
|---|
| [6026] | 966 |
|
|---|
| [6029] | 967 | /*No PVector for the Adjoint*/
|
|---|
| [6026] | 968 | return NULL;
|
|---|
| 969 | }
|
|---|
| 970 | /*}}}*/
|
|---|
| [12365] | 971 | /*FUNCTION Numericalflux::GetNormal {{{*/
|
|---|
| [12472] | 972 | void Numericalflux:: GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){
|
|---|
| [3683] | 973 |
|
|---|
| 974 | /*Build unit outward pointing vector*/
|
|---|
| [12472] | 975 | IssmDouble vector[2];
|
|---|
| 976 | IssmDouble norm;
|
|---|
| [3683] | 977 |
|
|---|
| 978 | vector[0]=xyz_list[1][0] - xyz_list[0][0];
|
|---|
| 979 | vector[1]=xyz_list[1][1] - xyz_list[0][1];
|
|---|
| 980 |
|
|---|
| 981 | norm=sqrt(pow(vector[0],2.0)+pow(vector[1],2.0));
|
|---|
| 982 |
|
|---|
| 983 | normal[0]= + vector[1]/norm;
|
|---|
| 984 | normal[1]= - vector[0]/norm;
|
|---|
| 985 | }
|
|---|
| 986 | /*}}}*/
|
|---|