source: issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp@ 25446

Last change on this file since 25446 was 25446, checked in by Mathieu Morlighem, 5 years ago

CHG: removing loop on gauss points

File size: 2.2 KB
RevLine 
[5286]1/*!\file ThicknessAbsMisfitx
2 * \brief: compute misfit between observations and model
3 */
4
5#include "./ThicknessAbsMisfitx.h"
6
7#include "../../shared/shared.h"
8#include "../../toolkits/toolkits.h"
[25379]9#include "../../classes/Inputs/DatasetInput.h"
[5286]10
[16314]11void ThicknessAbsMisfitx( IssmDouble* pJ, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters){
[5286]12
13 /*output: */
[17976]14 IssmDouble J=0.;
[13073]15 IssmDouble J_sum;
[5286]16
17 /*Compute Misfit: */
[17976]18 for(int i=0;i<elements->Size();i++){
[18521]19 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
[17976]20 J+=ThicknessAbsMisfit(element);
[5286]21 }
22
23 /*Sum all J from all cpus of the cluster:*/
[15838]24 ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
25 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
[5286]26 J=J_sum;
27
28 /*Assign output pointers: */
29 *pJ=J;
30}
[17976]31
32IssmDouble ThicknessAbsMisfit(Element* element){
33
34 IssmDouble thickness,thicknessobs,weight;
35 IssmDouble Jelem=0.;
36 IssmDouble misfit,Jdet;
37 IssmDouble* xyz_list = NULL;
38
39 /*If on water, return 0: */
40 if(!element->IsIceInElement()) return 0.;
41
42 /* Get node coordinates*/
43 element->GetVerticesCoordinates(&xyz_list);
44
45 /*Retrieve all inputs we will be needing: */
[25379]46 DatasetInput* weights_input =element->GetDatasetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input);
47 Input* thickness_input =element->GetInput(ThicknessEnum); _assert_(thickness_input);
48 Input* thicknessobs_input=element->GetInput(InversionThicknessObsEnum); _assert_(thicknessobs_input);
[17976]49
50 /* Start looping on the number of gaussian points: */
51 Gauss* gauss=element->NewGauss(2);
[25446]52 while(gauss->next()){
[17976]53
54 /* Get Jacobian determinant: */
55 element->JacobianDeterminant(&Jdet,xyz_list,gauss);
56
57 /*Get all parameters at gaussian point*/
58 weights_input->GetInputValue(&weight,gauss,ThicknessAbsMisfitEnum);
59 thickness_input->GetInputValue(&thickness,gauss);
60 thicknessobs_input->GetInputValue(&thicknessobs,gauss);
61
62 /*Compute ThicknessAbsMisfitEnum*/
63 Jelem+=0.5*(thickness-thicknessobs)*(thickness-thicknessobs)*weight*Jdet*gauss->weight;
64 }
65
66 /*clean up and Return: */
67 xDelete<IssmDouble>(xyz_list);
68 delete gauss;
69 return Jelem;
70}
Note: See TracBrowser for help on using the repository browser.