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

Last change on this file since 17976 was 17976, checked in by Mathieu Morlighem, 11 years ago

CHG: pushing misfits away from elements

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